7 ms·
Yes - the value of functional programming isn't that working in OCAML, or F#, or Haskell is 10x as productive as other languages. But that it can teach you wort
by initplus 2y ago
Yes - the value of functional programming isn't that working in OCAML, or F#, or Haskell is 10x as productive as other languages. But that it can teach you worthwhile lessens about designing software that apply equally to imperative languages.
Modelling the business domain, reasoning and managing side effects, avoiding common imperative bugs, these are all valuable skills to develop.
F# is a great language to learn, and very approachable. Worst part about it is interacting with antiquated .NET API's. (I can't believe the state that .NET support for common serialization formats is still in...)
- sidkshatriya 2y ago> Yes - the value of functional programming isn't that working in OCAML, or F#, or Haskell is 10x as productive as other languages. This is not true in my personal experience. As has been famously said (paraphrased): Functional programming makes tough problems easy and easy problems tough. In other words the value of functional programming depends on your domain.
- NinoScript 2y agoSo you’re saying that it does make you 10x as productive?
- initplus 2y agoMaybe my phrasing is not clear - I meant that these languages are indeed not significantly more productive.
- marcosdumay 2y agoBut (and I agree with the GP) they are. They are overwhelmingly more productive, in a way that you often can't even compare quantitatively. They are also a lot less productive. It depends entirely on what you are doing.
- grumpyprole 2y agoBy what measure? Haskell can be a huge productivity multiplier. The standard library is built upon many powerful, unifying and consistent mathematical abstractions. For example, there is almost no boilerplate to write for any traversal, mapping, error handling etc. The average Pythonista simply has no idea what they are missing. But Haskell doesn't have anywhere near the third party ecosystem of Python, so is less productive by some measures.
- antonvs 2y ago> easy problems tough. That needs a qualifier: it can make easy problems tough if you're not familiar with how to solve them in a functional context. A big part of that is because smart people have already solved the tough problems and made them available as language features or libraries.
- jiggawatts 2y agoAbsolutely! Any beginner can readily combine the catamorphisms and anamorphisms in `recursion-schemes`, or use the ready-made hylomorphisms for common tasks such as setting a value in a data structure. What could be simpler? /s https://wiki.haskell.org/Zygohistomorphic_prepromorphisms https://wiki.haskell.org/Zygohistomorphic_prepromorphisms
- amoss 2y agoThey have played us for absolute fools.
- cubefox 2y ago> That needs a qualifier: it can make easy problems tough if you're not familiar with how to solve them in a functional context. All problems are easy if you are familiar with how to solve them. Unfortunately it's part of the problem to find out how to solve them, and that can be unusually hard in case of functional programming. Like solving something with recursion instead of loops + states. There is a reason cookbooks use loops not recursion.
- simiones 2y agoNot really, certain problems are just inherently harder to express in a purely functional way than they are in an imperative way (and the reverse is just as true). For example, computing a histogram is much simpler in imperative terms (keep an array of histogram values, go through the original list, add 1 to the array element corresponding to the current element in this list) than in a purely functional style, especially if you need a somewhat efficient implementation. My favorite example of this is implementing quicksort. It's significantly easier in C than it is in Haskell.
- kreyenborgi 2y ago> makes tough problems easy and easy problems tough And because of mutual recursion, that means that tough is easy (and easy tough). In other words, if we call the class of tough problems T and easy problems NT, we have T==NT, given FP.
- williamcotton 2y agoWhat easy problems are tough in F#? I’ve been using it for writing random scripts and as a Python replacement.
- z500 2y agoWriting recursive descent parsers in F# is a lot of fun with ADTs and pattern matching.
- DimmieMan 2y agoIt's an overgeneralisation. If you try and turn F# into Haskell at home you may run into that problem. F# is functional first language so if an object oriented or procedural solution is the right call the options right there when you need it.
- chrischen 2y agoIt’s only tough to change your way of thinking. Most people making the switch find it tough because they are trying to find imperative techniques to do something in a functional way and struggling because they can’t find an if else statement or a for loop. But if you were never taught to think in terms of conditional branching or looping indexes you’ll save a lot of time.
- theCodeStig 2y agoExactly. I've long held the sentiment, that pure functional programming is easier than imperative programming. The only hard part, is switching from an imperative mindset.
- pyuser583 2y agoHow do you “Hello World” in a functional language? Doesn’t it have side effects?
- sevensor 2y agoThere's some real confusion about what "functional" means, because it depends on who's speaking. Writing _exclusively_ pure functions is a Haskell thing. A much looser definition of the functional style would be to say that you mostly write pure functions over immutable data, but when you have to actually do a side effect you write a procedure that talks to the outside world and go on with your day. If you go digging in this site's archives from about ten years ago, I recall numerous debates about what constituted functional programming, and whether the latter counts at all. But if we _are_ talking about Haskell, the answer to your question is obviously "Monads."
- cess11 2y agoThe string "Hello World" evaluates to itself, what else do you need? Edit: Eh, I thought it was a fun quip.
- trealira 2y agoYes, and AFAIK, you're pretty much free to cause side-effects in functional languages; it's just a bit awkward and somewhat discouraged. It's kind of like how C still has goto, yet it's still a structured programming language. Even in Haskell, which tries to control side-effects more, it's not hard; it's just that it's stuck with an "IO" annotation. Any function that calls an IO function also becomes an IO function; it's infectious. main :: IO () main = putStrLn "hello, world"
- 2y ago
- deleted 2y ago[deleted]
- wruza 2y agoHot take of the day: you learn that with imperative programming just as well. I familiarized myself with fp to the point of writing scheme and haskell around 15 years ago. Read the classics, understood advanced typing, lambda calculus and so on. The best “fp” I’m using nowadays is closures, currying in the form of func.bind(this[, first]) and map/filter. Which all are absolutely learnable by the means of closures, which are useful but I can live without. Sometimes not having these makes you write effing code instead of fiddling with its forms for hours. Still waiting for the returns from arcane fp-like code I produced earlier. Cannot recognize nor understand none of my projects in this style that I bothered to save in vcs. Imperative code reads like prose, I have some of it still in production since 2010. These FP talks are disguised elitism imo (not necessarily bad faith). Beta reduction and monadic transformers sound so cool, but that’s it job-wise.
- cubefox 2y ago> These FP talks are disguised elitism imo (not necessarily bad faith). Beta reduction and monadic transformers sound so cool, but that’s it job-wise. They may be disguised mathematics. People are into math because it is neat / elegant / cool. So they study it regardless of whether it has a practical use or not.
- photonthug 2y agoSome programmers have serious math envy. This can be good if they are self aware about it and keep it in check, because it makes them better programmers. Otherwise they can a pain to work with. Seniors should be people that have dealt with this aspect of their own talent, not juniors who are promoted in spite of or because of it
- dboreham 2y agoMathematics is just a kind of programming. And vice versa.
- cubefox 2y agoPrograms fundamentally have state, while mathematical equations have not. Math is in its core declarative, while programming is essentially imperative, at least under the hood.
- baby 2y agoOcaml definitely doesn’t make you more productive
- DimmieMan 2y agoI wouldn't even say antiquated, modern .Net APIs can suck to work with too, the entire ecosystem is written for C# ASP.Net core and everything else feels second class. I love F#, the working with C# elements of the language drove me away.
- neonsunset 2y agoWhich elements were the source of pain? Writing web applications and back-ends in F#, as far as I'm aware, is straightforward and a joy because of integration with the rest of ecosystem.