4 ms·
I upvoted you because I don't think Hacker News should become an echo chamber of the same few opinions, but I disagree with what you say here. I wouldn't call
by trealira 2y ago
I upvoted you because I don't think Hacker News should become an echo chamber of the same few opinions, but I disagree with what you say here.
I wouldn't call Rust "functional and impure." It has pattern matching (like in ML), and it has traits (which are reminiscent of Haskell's typeclasses) instead of object-oriented classes (like C++), but most programming in it is very much centered around mutable state and pointers and memory, like a higher-level C; hence, it's impure and imperative, not functional.
A functional and impure language would be more like OCaml, Standard ML, or Scheme. Those all give you unrestricted access to exceptions and mutable cells of memory without restricting it behind a layer of monads, like in Haskell. They just don't really encourage it.
> Rust is functional but the syntax is 10 times easier to read and write. I think other languages will follow.
People complain all the time about Rust syntax looking cryptic and difficult to read.
Also, I'm familiar with both Haskell and Rust syntax, and although many would disagree with what I'm saying here, I don't think Haskell syntax is any harder to read than Rust's. And Standard ML even has much simpler syntax than Rust (although it's much less alive than OCaml, whose syntax is a bit more complicated). I really think it's a matter of what you're used to.
- IshKebab 2y agoI think you're making the pure=functional mistake like I was. Rust is almost identical to OCaml in terms of functional style. Which is no big surprise given that it was heavily inspired by it (and the first compiler was implemented in it). I think the only major difference is the lack of currying.(which IMO is an elegant-looking anti-feature). > People complain all the time about Rust syntax looking cryptic and difficult to read. They're talking about all the borrowing, lifetime and generics syntax. Not the basic blocks and semicolons.
- trealira 2y agoI think we just define functional programming differently. How do you define it? Also, I just noticed this part again: > Honestly the hardest thing learning OCaml was figuring out where to put the brackets and semicolons. I am 100% serious. Unironically, I'd recommend Haskell, or another programming language with similar whitespace-sensitive syntax. I'm more familiar with Haskell than OCaml (though inexperienced in both), and the semicolons and other delimiters actually got me as well. > They're talking about all the borrowing, lifetime and generics syntax. Not the basic blocks and semicolons. That's half the syntax to get confused about. But, ignoring that, people also get confused by the implicit returns at the ends of blocks.