• 0 Posts
  • 35 Comments
Joined 1 year ago
cake
Cake day: June 16th, 2023

help-circle
rss

  • To do quick and simple explanations:

    var test int = 0
    

    assign an int, var = let in rust land

    := 
    

    This is basically an inferred assignment e.g.

    a := "hello world"
    

    The compiler will know this is a string without me explicitly saying

    func (u User) hi() {}
    

    To return to rust land this is a function that implements User. In OOP land we would say that this function belongs to the user class. In Go, just like in rust we don’t say if a function returns void so this function is for User objects and doesn’t return anything:

    func (u User) hi(s string) string {}
    

    If it took in a string and returned a string it would look like this.

    map[string] int {}
    

    I will give you that this syntax is a bit odd but this is just a hashmap/dictionary where the key is a string and the value is an int




  • It looks like it’s 3x faster than the previous cpython wasm compilation. Recall that most of the performance improvements in python have been done in the last ~2 releases.

    My distro is debian based so it’s still on 3.10 which I would guess this new wasm implementation is much closer to in performance.

    Compiling to wasm also means that you can distribute a binary rather than needing people to have python installed.







  • I remember watching a video of someone writing C code and making the same thing in unsafe rust. While the C code worked just fine the rust code had UB in it and was compiled to a different set of instructions.

    Unsafe rust expects you to uphold the same guarantees that normal rust does and so the compiler will make all the same optimisations it would if the code wasn’t unsafe and this caused UB in the example rust code when optimised for performance. It worked just fine on the debug build, but that’s UB for you.





  • I’m not sure if the rules are different with macros, I’ve never written one but this lint is generally caused because you set a var to a value and then overwrite that value before you use it. e.g.

    let mut a = 1; a = 2; println!(“{}”, a);

    This will throw the same warning because 1 is never used, this could’ve just been:

    let a = 2; println!(“{}”, a);

    So first I’d double check that I NEED last at all. Maybe try:

    cargo clippy

    See if it can tell you how to fix it.

    If that doesn’t work, it’s sometimes necessary to skip certain lints. E.g. if you make a library, most of the code will be flagged as dead code because it isn’t used and you can use an #[allow(dead_code)] to stop the linter warning. You might be able to use #[allow(this_linting_rule)].

    Hope something here helps.




  • It’s already been said a couple times but if your more experienced team members are saying, “that’s a really weird task” the issue is probably the task not you.

    Having daily meetings with a senior because you’re having a lot of trouble progressing isn’t necessarily a bad thing. Everyone has jobs that are absolute ordeals and sometimes it’s better to break them down even further and just go one step at a time.

    Also, are you involved in your team sprint planning? Who says “this ticket is a 1 day job” that should be your teammates, or at least a subset of them? Why did they decide this was an easy task? What did they, or you, miss in the execution?