4 ms·
Is there a good reason to say that Rust is an OCaml dialect?
by placeybordeaux 11y ago
Is there a good reason to say that Rust is an OCaml dialect?
- sampo 11y ago> Is there a good reason to say that Rust is an OCaml dialect? There is, maybe, grounds to say that all languages with S-expressions, first class functions and garbage collection are just a type of lisp. But I would not say that all languages with strong static typing, some form of type inference, algebraic data types, patterns matching and functional programming features, are a dialect or OCaml, or ML.
- dkarapetyan 11y agoNo more than saying Erlang is a lisp dialect.
- fermigier 11y agoOr Python (http://norvig.com/python-lisp.html http://norvig.com/python-lisp.html).
- jk4930 11y agoI'd describe it more as uglyfied Haskell, but anyway: http://science.raphael.poss.name/rust-for-functional-programmers.html http://science.raphael.poss.name/rust-for-functional-program...
- bsummer4 11y agoIt really doesn't have that much in common with Haskell either. It's designed by people who are not oblivious about PL stuff, but it's still pretty thoroughly in the C/C++ world in terms of both syntax and semantics. It's not a bad thing, but Rust has very little in common with Haskell/Ocaml; aside from stealing a couple of good ideas.
- FreeFull 11y agoI would say Rust's type system has a lot more in common with Haskell/Ocaml than with C++, at least, although it's not quite as flexible as what Haskell offers (a lack of HKT is painful sometimes).
- bsummer4 11y agoI think the similarities are mostly superficial. I mean it has (local) type inference, ADTs, and traits (which are sooooorta like type classes). But, as a Haskell programmer, the Rust type system feels very foreign. No typeclasses (and associated goodness), GADTs, HKTs, Monadic IO, first class functions, generic deriving, higher rank types, existential type, etc. These are bread-and-butter features in day-to-day Haskell work. Rust's type system isn't powerful enough to build the vast majority of the tools that Haskell programmers use every day. I don't mean this as a criticism; The Rust design seems solid. But different priorities lead to different trade-offs, and the end result is a very different type system.
- dbaupp 11y agoTraits do a lot of what one can do with typeclasses (they're mostly just different names for the same thing), what differences are you thinking of? Also, traits objects are existential types, and closures & functions are as first class as they are in Haskell (main difference is a bit more verbosity).
- zem 11y agowaiting for the "rust is an acceptable ml" blogposts!
- iopq 11y agoIt has algebraic data types, type inference, closures, pattern matching. Haskell has these too, but it has more stuff like more emphasis on immutability and purity unlike Rust and OCaml. Also, the first Rust compiler was written in OCaml.