5 ms·
Haskell also changed the way I think about programming. But I wonder if it would have as much of an impact on someone coming from a language like Rust or even m
by adastra22 2y ago
Haskell also changed the way I think about programming. But I wonder if it would have as much of an impact on someone coming from a language like Rust or even modern C++ which has adopted many of haskell’s features?
- mmoll 2y agoTrue. I often think of Rust as a best-of compilation of Haskell and C++ (although I read somewhere that OCaml had a greater influence on it, but I don’t know that language well enough) In real life, I find that Haskell suffers from trying too hard to use the most general concept that‘s applicable (no pun intended). Haskell programs happily use “Either Err Val” and “Left x” where other languages would use the more expressive but less general “Result Err Val” and “Error x”. Also, I don’t want to mentally parse nested liftM2s or learn the 5th effect system ;-)
- hollerith 2y ago>I read somewhere that OCaml had a greater influence on it Whoever wrote that is wrong.
- deleted 2y ago[deleted]
- randomdata 2y agoIf we could wave a magic wand and remove Haskell's influence on Rust, Rust would still exist in some kind of partial form. If we waved the same wand and removed OCaml's influence, Rust would no longer exist at all. You are the one who is wrong, I'm afraid.
- lkitching 2y agoWhich OCaml features exist in Rust but not Haskell? The trait system looks very similar to Haskell typeclasses, but I'm not aware of any novel OCaml influence on the language.
- randomdata 2y ago> Which OCaml features exist in Rust but not Haskell? Rust's most important feature! The bootstrapped implementation.
- lkitching 2y agoI'm not convinced the implementation language of the compiler counts as a feature of the Rust language. If the argument is that Rust wouldn't have been invented without the original author wanting a 'systems OCaml' then fine. But it's possible Rust would still look similar to how it does now in a counterfactual world where the original inspiration was Haskell rather than OCaml, but removing the Haskell influence from Rust as it is now would result in something quite different.
- randomdata 2y agoRust isn't just a language, though. Additionally, unlike some languages that are formally specified before turning to implementation, Rust has subscribed to design-by-implementation. The implementation is the language.
- lkitching 2y agoThat just means the semantics of the language are defined by whatever the default implementation does. It's a big stretch to conclude that means Rust 'was' OCaml in some sense when the compiler was written with it. Especially now the Rust compiler is written in Rust itself.
- randomdata 2y agoYou're overthinking again. Read what is said, not what you want it to say in some fairytale land.
- TwentyPosts 2y agoThe original rust compiler was written in OCaml. That's not evidence it "had an influence", but it's highly striking considering how many other languages Greydon could've used.
- hollerith 2y agoYes: if a person knows nothing else about Rust and the languages that might have influenced it, then the fact that the original Rust compiler was written in OCaml should make that person conclude tentatively that OCaml was the language that influenced the design of Rust the most. I'm not one to hold that one shouldn't form tentative conclusions until one "has all the fact". Also, I'm not one to hold that readers should trust the opinion of an internet comment writer they know nothing about. I could write a long explanation to support my opinion, but I'm probably not going to.
- dimitrios1 2y agoIt's like trying to say Elixir wasn't influenced the most by Erlang
- hollerith 2y agoWas any Elixir interpreter or compiler every written in Erlang? If not, what is the relevance of your comment?
- jolux 2y agoElixir’s implementation still has significant parts written in Erlang. I don’t know if it’s a majority but it’s a lot. e.g.: https://github.com/elixir-lang/elixir/blob/aef7e4eab521dfba9e81708b0f5d28bfe428babe/lib/elixir/src/elixir_erl_for.erl https://github.com/elixir-lang/elixir/blob/aef7e4eab521dfba9...
- itishappy 2y agoRust was bootsrapped in OCaml. https://github.com/mozilla/rust/tree/ef75860a0a72f79f97216f8aaa5b388d98da6480/src/boot https://github.com/mozilla/rust/tree/ef75860a0a72f79f97216f8...
- deleted 2y ago[deleted]
- liveranga 2y agohttps://doc.rust-lang.org/reference/influences.html https://doc.rust-lang.org/reference/influences.html
- samatman 2y ago> SML, OCaml: algebraic data types, pattern matching, type inference, semicolon statement separation > Haskell (GHC): typeclasses, type families https://doc.rust-lang.org/reference/influences.html https://doc.rust-lang.org/reference/influences.html
- hollerith 2y agoHaskell has algebraic data types, pattern matching and type inference, too, and has had them since Haskell first appeared in 1990. Although SML is older (1983), OCaml is younger than Haskell.
- setopt 2y agoI think it does, actually. Python also has many of Haskell's features (list comprehensions, map/filter/reduce, itertools, functools, etc.). But I only started reaching for those features after learning about them in Haskell. In Python, it's very easy to just write out a for-loops to do these things, and you don't necessarily go looking for alternative ways to do these things unless you know the functional equivalents already. But in Haskell you're forced to do things this way since there is no for-loop available. But after learning that way of thinking, the result is then more compact code with arguably less risk of bugs.
- z500 2y agoIf anything, Python encourages you to use loops because the backwards arrangement of the arguments to map and filter makes it painful to chain them.
- sgarland 2y agomap(function, iterable) That seems very logical to me, but then, I’m not a functional programmer, I just like map. It’s elegant, compact, and isn’t hard to understand. Not that list comps are hard to understand either, but they can sometimes get overly verbose. filter has also lost ground in favor of list comps, partially because Guido hates FP [0], and probably due to that, there has been a lot of effort towards optimizing list comps over the years, and they’re now generally faster than filter (or map, sometimes). [0]: https://www.artima.com/weblogs/viewpost.jsp?thread=98196 https://www.artima.com/weblogs/viewpost.jsp?thread=98196
- BeetleB 2y agoYes, but how do you chain them? map(func4, map(func3, map(func2, map(func1, iter)))) vs iter.map(f1).map(f2).map(f3).map(f4) I made up the syntax for the last one, but most functional languages have a nice syntax for it. Here's F#: iter |> f1 |> f2 |> f3 |> f4 Or plain shell: command | f1 | f2 | f3 | f4
- 2y ago
- odyssey7 2y agoCheck out Swift, too!
- adastra22 2y agoWhy would I use swift when more cross-platform solutions exist?
- TylerE 2y agoHeck, even coming from Python (2) it felt very underwhelming and hugely oversold. (Edit: To be fair, I'd done a bit of Ocaml years earlier so algebraic data types weren't some huge revelation). Laziness is mostly an anti-pattern.
- deleted 2y ago[deleted]