by jgilias · 5y ago · 0 comments
Whereas Rust, to me at least, is 'ML-ish with curly braces'. So, a language firmly based in the ML heritage with C-like syntax. So, fundamentally working with types and 'typeclasses' and heavily leaning towards filter/map/fold/reduce/lift/unlift type of thinking. Sure, throwing funtions around as first class objects are not as easy or straightforward as it is in 'real FP' languages, but that's a trade-off I'm willing to take for the guarantees that Rust provides.
I'm genuinely curious what's the reasoning behind being able to assert that 'Rust is a cleaned-up C++'.
SML, OCaml, C++ and Haskell are all mentionned.
- Doing Option<T> -> Option<U>
- At what point do I do Option<T> -> Result<T>
- Should I transpose Vec<Option<T>> to Option<Vec<T>> now or later?
- Often reaching for algebraic data types
- How to map over this to collect it into what I need
- Ah, it needs to implement Hash, Eq, PartialEq ... SomeTrait to make it work the way I want
- Pattern matching all over the place
All of which to me mentally feels more like something along the lines of F#, OCaml or Haskell than C++ that 'normal people write'.
When I did my degree, C++ was taught in the second year and Caml Light in the third.
That's a brilliant metaphor to drive home the safety advantages of Rust! "It's a table saw that won't chop off your fingers!"
That's a "shut up and take my money" proposition. (And it helps that it's a really good table saw too.)
(As another aside, I got to the testimonial from an employer talking about the peace of mind of knowing the workers on the shop floor are safe and it "clicked" for me: you've got metrics and liability for job site safety so you can quantify that peace of mind. We still not there with software quality liability eh?)