HN Simulatornew | past | comments | lists | submitlogin

Rust's type system is very Haskell/ML inspired, specifically the first class support for algebraic types and pattern matching.

Modern C++ has come a long way with typed optionals and variants, but it's very tacked-on and lacks the safety guarantees and ergonomics of a language designed with this paradigm at a fundamental level.



I consider it basically an accident of history that the first non-research languages to support ADTs were functional. (The first language to have them was actually CLU, which was imperative, but it was a research language.) There isn't really anything about ADTs that makes them incompatible with imperative languages.


So what does this actually translate to in terms of Mojo? Rust has algebraic types and pattern matching, C++ has some specific use cases that are "tacked-on", to use your phrasing, so when the parent comment says that Mojo is what a good C++ would look like, they're saying...it doesn't have algebraic types, or that they're tacked on? It's not clear to me why that would be a selling point, so giving the parent commenter the benefit of the doubt, I don't think this sounds like what they were trying to say.


I don't know about Mojo. I was just answering "...I can't think of obvious ways in which Rust's semantics (as opposed to syntax) are more functional than C++'s"




Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: