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

help-circle
  • 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








  • At work we have a lot of old monolithic OOP PHP code. Dependency injection has been the new way to do things since before I started and it’s basically never used anywhere.

    I assume most people just find it easier to create a new class instance where it’s needed.

    I’ve never really seen a case where I think, “dependency injection would be amazing here” I assume there is a case otherwise it wouldn’t exist.


  • 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.