4 ms·
I like rust, but wouldn't recommend it in my enterprise shop. I don't know what language you are used to, so I will suggest some things that you might enjoy lea
by BlackFly 4y ago
I like rust, but wouldn't recommend it in my enterprise shop. I don't know what language you are used to, so I will suggest some things that you might enjoy learning about.
In languages without spread operators (like java), immutable objects are quite clumsy to work with: I want this same object but these two fields changed (like the replace method on python's named tuples, but those are also annoying...). But with mutable objects, everyone can mutate: chaos. Rust gives you the mut keyword, structs are immutable by default.
Ever wanted to implement a method on a class in another library that just used the public API? Just make your own Trait in rust.
Ever wanted to make sure that someone would call `close()` on your implementation? Ever wanted to make sure that no one would use the object afterwards? That's garbage collection of a resource that isn't memory, most GC languages won't manage that for you, but the borrow checker will.
Pattern matching, algebraic data types, expressions and statements distinctions, an excellent build system, procedural macros, no null, no exception handling, good type inference; none of these are new or unique to rust, but lots of languages lack a few to many of them.
But yeah, some times I don't want to decide between monomorphisation via generics, or heap allocating for dynamic dispatch. Some times I just want a JIT and a garbage collector to take care of that for me. But that is another thing rust might give you: a newfound appreciation for what you have.
- kaba0 4y agoJust a heads up, something like that spread operator is actually coming sooner or later to java: https://github.com/openjdk/amber-docs/blob/master/eg-drafts/reconstruction-records-and-classes.md https://github.com/openjdk/amber-docs/blob/master/eg-drafts/... Pattern matching (for records) is already a preview feature.