25 ms·
My theory is two-fold: 1. Until now most functional programming languages have had abysmal syntax. I'm sure I will get downvoted for this but have you seen Lis
by IshKebab 2y ago
My theory is two-fold:
1. Until now most functional programming languages have had abysmal syntax. I'm sure I will get downvoted for this but have you seen Lisp? I do not want to program in raw AST. ML is also pretty bad. Honestly the hardest thing learning OCaml was figuring out where to put the brackets and semicolons. I am 100% serious. (Well, that and fighting OPAM bugs.)
Rust is functional but the syntax is 10 times easier to read and write. I think other languages will follow.
2. Functional programming has been synonymous with pure functional programming due to Haskell. Honestly I didn't even realise there were impure functional languages until relatively recently. I thought to be "functional" a language had to be pure.
Again Rust is functional and impure.
So I think it's really that most "practical" or "engineering" languages just happened to be not functional until now because the idea of functional programming was hidden in weird and difficult to read academic languages.
There's clearly nothing intrinsic to the functional paradigm that would mean it can't be used in the real world (otherwise Rust wouldn't be so popular).
- Ancapistani 2y ago> I'm sure I will get downvoted for this but have you seen Lisp? How much time have you spent writing in lisps? I'm definitely an OOP person, but I spent a couple of years writing Clojure. After a few hours of working in it, the syntax just... disappears. I installed two tools in vim to help: one colored parentheses to match corresponding pairs, and the other inferred parentheses from indentation. After a week, I removed the first because I realized I literally never looked at them. Ever. The reason I didn't fall in love with lisps is because it's just hard for me to work in them. Yes, I'm _very_ productive once I get into flow state - but it took about a half hour each session before I got there. There were many days where I never got into that state for more than a few minutes here and there. It was a terrible experience as a result. With Python - and other OO languages - I can look at some code and almost immediately know what it does. It's just not like that for me in lisp.
- kazinator 2y agoWhat did you install in Vim for inferring parens from indentation? I use an adaptation of parinfer I found in github. It required a bit of tweaking , including adding a keybinding to turn it off, because sometimes it fights what you are trying to do. Its opposite mode (indentation from parens) does not work at all. > hour each session before I got there That could just be the Clojure, doing everything with immutable sequences. If the obvious way (at least to you, if not generally) to express something is OOP with mutable classes, then you have to solve a puzzle before things start to flow.
- Ancapistani 2y ago> What did you install in Vim for inferring parens from indentation? It's been years now, but I believe it was "parinfer". This specific plugin might not be it, but it looks very similar at least: https://github.com/gpanders/nvim-parinfer https://github.com/gpanders/nvim-parinfer
- trealira 2y agoI 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.