3 ms·
IMO it's short term enablement versus long term. You will feel productive early on in Go, but it plateaus. Rust has a lot more CS concepts and I think will be
by anotherhue 4y ago
IMO it's short term enablement versus long term.
You will feel productive early on in Go, but it plateaus. Rust has a lot more CS concepts and I think will be the more fruitful learning experience.
Also, Rust can lead you to WASM, which might work well with your web background.
- stop50 4y agoGo has also wasm output.
- makeworld 4y agoGo can also compile to WASM.
- mejutoco 4y agoAFAIK since Go is garbage-collected, the WASM it generates probably needs to include a runtime, right? While in Rust since the ownership is verified at compile-time there is no need for GC. Please correct me if I am wrong. EDIT: s/runtime/compile-time
- LecroJS 4y agoCan you say a little about what it means that since Rust has provable ownership at runtime, there is no need for GC? I’m familiar with Rust ownership on the surface, but lack the knowledge to see how it eliminates the need for GC. Is it just Rust’s way of guaranteeing that a program is memory safe, or is there more to it?
- mejutoco 4y ago(A bit simplified)My understanding is that reference counting is one of the easiest way to deal with memory assignments and it needs GC. If the ownership rules determine at compile time that your memory assignments are fine (no double free, etc.), you can avoid using reference counting (and the associated GC).
- kaba0 4y agoGarbage collection deals with removing allocated objects that are no longer used. Non-managed languages without a garbage-collected runtime will have to issue the corresponding “free” command for each heap-allocated memory at the necessary place. This is a hard thing to do, because freeing it before the time can result in use-after-frees that are huge vulnerabilities, and not freeing it is a memory leak. Reference counting is a form of GC, but in itself it is not sufficient (it will leak circular references as those will always reference each other). Due to its simplicity, in a sufficiently expressive language one can create this abstraction (see shared_ptr in c++, RC, ARC in Rust) and with the necessary caveats of not using circular structures with it, you get an ergonomic semi-GC without runtime support. Compile time/runtime issue is slightly different - in case of many allocations one can know where you will have to free it even at compile time. C++ has a concept called RAII, which is basically “put a free at the end of the scope”. This works surprisingly well for most use cases and Rust sort of mandates this semantics by the compiler in the general case. But an object’s lifetime can’t be known in advance (think of a User object for a logged in user. Is it still needed or had it expired?) in the general case, that’s why runtime GC is needed like refcounting or tracing GC in managed languages.
- LecroJS 4y agoThese give me some good context to go off of. Are there any resources you’d recommend on an intro to garbage collection for devs without the low level cs background? I’ll read a textbook if I have to, I just don’t know where to start with that sort of thing in terms of biting off comprehend-able amounts of info
- kaba0 4y agoUnfortunately, I am not aware of too much intro-level texts on the topic (I would be happy to get some from other commenters). One well-regarded book is Crafting Interpreters, though it covers a wider topic. Didn’t check this section, but perhaps its GC chapter is a good introduction: https://craftinginterpreters.com/garbage-collection.html https://craftinginterpreters.com/garbage-collection.html
- LecroJS 4y agoThis feels like something I needed to hear. Everything I do in life I try to maximize for long term gains, so this tells me that Rust is very likely for me even if it means I’ll make less flashy stuff at first. Also I am definitely interested in wasm and have been hearing about it for a long while but still admittedly can’t put my finger on what it’d really do for me. I generally find my front end performance to not be limited by js thanks to Cloudflare/web workers, but then again I haven’t done anything I’d consider truly heavyweight just yet. I’d be curious if you knew of any interesting rust/wasm use cases, or if you have any thoughts on where that space is headed and why it’d be good to invest in learning it. Thanks for the insightful reply :)
- anotherhue 4y agoWASM is still fairly niche, some immediate/near term use cases might be: advanced animation (beyond CSS), 3D/VR, low-latency / low level work e.g. webUSB. MAYBE some very forward looking web-apps/hybrid apps. There's no disputing that v8 has come a long way, so likely it's not going to be that much of a perf gain, more interesting to me is bringing more advanced languages (such as Rust) into play, great and all as TypeScript is.