5 ms·
> Single exit, though, means no "break", or "continue" for loops, and no early returns from functions. Sounds like pretty standard functional programming a la
by Munksgaard 3y ago
> Single exit, though, means no "break", or "continue" for loops, and no early returns from functions.
Sounds like pretty standard functional programming a la Standard ML or Haskell, or am I missing something?
- amiga386 3y ago> a rather convoluted style It may be standard for them, but it's why functional languages are niche while C, C++, C#, Java, JavaScript and Python dominate.
- Munksgaard 3y agoThat's a bold claim, do you have any evidence to back that up with? To be clear, I agree that it could be a reason, along with a multitude of others. I think that discerning which is the most substantial reason (if any such exist) is hard if not impossible.
- amiga386 3y agoI don't, I just have the feelings and impressions of various programmers, which is anecdata. I think the pattern that emerges is that the popular languages I listed are multi-discipline, they can be adapted to whichever paradigm you prefer, even if it's a little cumbersome, and over time they adopt the key features of other languages, while retaining their existing benefits. In other words... you can get the best features of Haskell in Python, but you can't get the best features of Python in Haskell?
- nyssos 3y ago> you can get the best features of Haskell in Python Haskell's best features relative to more mainstream languages are HM-style type inference, higher-kinded types, and typeclasses - none of which are possible in a language without real static types.
- odyssey7 3y agoTo add to the anecdata of programmer impressions: Haskell can be extremely performant compared to Python. In terms of developer experience, it almost causes me physical pain to use some of the poorly designed Python libraries out there.
- neonsunset 3y agoRust is a quite functional language, C# has been incorporating (aka stealing from F# :)) functional features for years starting with LINQ and ending with advanced forms like pattern matching on sequences (list patterns). I believe all kinds of Python frameworks too like to incorporate FP into their APIs, and of course, there are list comprehensions.
- louthy 3y agoLINQ is arguably stolen from Haskell, not F#. It is closer to ‘do’ notation than Computation Expressions (which has more features). The fact that Eric Meijer was very active in the Haskell community, I think, pretty much confirms that.
- bmicraft 3y agoGuard clauses are considered good practice in many languages, as opposed to nested if's. I'm not saying either approach is generally the right one, but I think it's interesting that best practice can be the polar opposite of his "single exit" recommendation
- drivers99 3y agoDijkstra came up with "guard". Well, "guarded command" as a formal part of the logic of correct programs: https://en.wikipedia.org/wiki/Guarded_Command_Language https://en.wikipedia.org/wiki/Guarded_Command_Language > The guard is a proposition, which must be true before the statement is executed. At the start of that statement's execution, one may assume the guard to be true. Also, if the guard is false, the statement will not be executed. The use of guarded commands makes it easier to prove the program meets the specification. The statement is often another guarded command.