3 ms·
I currently write a SaaS website in Go after doing quite some Rust. I do prefer Rust as a language - it's more expresive and I greatly prefer Result<> over erro
by KingOfCoders 4y ago
I currently write a SaaS website in Go after doing quite some Rust. I do prefer Rust as a language - it's more expresive and I greatly prefer Result<> over error, but it has two major downsides for me compared to Go. First compilation is much slower and Go feels like a non-compiled language because of the compilation speed (my last startup I've used Scala with horrendous compilation speeds, the main reason not to use it) The second is the borrow checker. It's excellent mostly (love explicit mut) but fails for me for structs with sub-structs coming from different owners. Very fast you have Arc<> noise everywhere. The Go GC just works. A simple GC as a -gc=on with auto-arc for variables without lifetime annotations for people that don't need Rust for embedded applications would be a dream come true.
I do love 'import "embed"' in Go to embed web files (templates) inside a binary and then deploy/manage that one binary with systemd with zero downtime updates with systemd port activation. Slick.
- TrustPatches 4y agoNot sure if it’s an exact parallel, but you can also embed files into rust binaries with “include_bytes!” and “include_str!”.
- 5e92cb50239222b 4y agoIt's a bit more advanced than what Rust macros provided last time I checked. You can shove whole directories in there and then traverse them or serve as static resources with pretty much one line of code. Random blog post with a few examples: https://blog.carlmjohnson.net/post/2021/how-to-use-go-embed/ https://blog.carlmjohnson.net/post/2021/how-to-use-go-embed/
- TrustPatches 4y agoVery cool, I guess one the the advantages of rust macros is that you could write your own to do something more advanced in theory
- super_flanker 4y agoYou can do the same in Rust with include_dir[1] 1: https://docs.rs/include_dir/latest/include_dir/ https://docs.rs/include_dir/latest/include_dir/
- scruple 4y agoI've gone as far as embedding a ReactJS app inside of Go's embedFS. It's pretty damn powerful.
- surajrmal 4y agoYou can avoid Arc in rust the same way you avoid mutexes in go - use channels instead. I find programming rust with channels between tasks feels quite ergonomic. Also, at least to me, it seems like it's a no brainier to pick a language with a GC if your target runtime environment allows for it.
- Casperin 4y agoMine does. Still picked Rust, and so happy I did. The type system alone does it for me.