Live data from Hacker News

Why Isn't Functional Programming the Norm? [video]

youtube.com

271–280 of 417 posts

Re: Why Isn't Functional Programming the Norm? [video]

#271
post #266
post #259

Earlier quoted context omitted.

>My personal belief? We just don't teach it.[...] Grads come out with a 4 year headstart on a non-FP paradigm, I don't agree the lack of proactive education is the reason FP isn't the norm. Your conclusion doesn't take into account the counterfactuals : - C Language took off in popularity despite BASIC/Pascal being the language more often taught in schools - languages like PHP/Javascript/Python/Java all became popula…

> Why does functional programming need to be taught in schools but all the other various programming topics did not? Because I think it is harder for people who have programmed with other paradigms - following an inverse law, most things should get easier to learn with experience, not harder. It's foreign, it's weird, it's back to front. It doesn't have an immediately obvious benefit to what people are used to, and t…

Exactly. As just an anecdote, my intro do FP class in university was taught by a professor who tended to rant about different levels of purity and elegance between his favorite and least favorite languages. Of course, the favorite was his pet project and we had to spend most of the class using it. I also know that Emacs is partly written in Lisp because it was the only editor he would touch.

FP can't even sell itself well in school as a language where useful things can be done, when the student is stuck in a deep valley of ___morphisms and other alien concepts with claims of aesthetic elegance as the only motivation. I recall the math nerds loved it as relief over C that the rest of the department used, but with me being rather mediocre in math, the weirdness and cult-like vibe from the prof and TA left a really bad taste. The impression was so deep that I have no issues recalling this class a decade later. I've never touched any FP since, unless you count borrowing clever lambda snippets.

Re: Why Isn't Functional Programming the Norm? [video]

#272

Earlier quoted context omitted.

That's utter rubbish. My team has been working with Clojure for close to a decade now. We regularly hire coop students from university, and none of them have ever had problems learning functional programming. It typically takes around a couple of weeks for a student to become productive and start writing useful code. The only people I've ever met who say that FP doesn't map to the way our brains work are people who'r…

I think you can do better than calling something you disagree with “rubbish” because your team didn’t have problems with it. Here’s an example of people finding functional programming unnatural, maybe you can leverage your experience to explain why he is wrong: Functional Programming Is Not Popular Because It Is Weird https://probablydance.com/2016/02/27/functional-programming-...

It's not just my team, there are many of people working with Clojure and other functional languages out there, and there are plenty of FP projects in productions in pretty much every domain.

Functional programming is weird in the same way Japanese is weird to an Anglophone. A person who learned Japanese as their mother tongue will find English equally weird. The comments in the link you posted already address the points the author tries to make, which all boil down to FP being different from what they're used to.

Re: Why Isn't Functional Programming the Norm? [video]

#273
post #190

Earlier quoted context omitted.

Programming is has grown so much as a field that generalizations like this rarely capture the truth. It's true that in many domains, people care much less about performance than they used to. At the same time, other people care a lot more about performance. Programming is just big and diverse. The end of single score scaling is one big reason it's more important than ever. Another reason is simply that a lot more peo…

The point here is that for many domains performance is not the top consideration. And it's also worth noting that it's perfectly possible to tune applications written in FP languages to get very good performance. It's also possible to identify the parts of the code that are performance critical and implement those using imperative style. This is especially easy to do with Clojure where you have direct access to Java.…

Sure I get that, but I'm saying your statement about "the overall historical trend" is wrong, or at least fails to capture a large part of the truth.

At some point in history, people stopped worrying about not understanding compilers

This part is misleading too -- I would say there is a renaissance in compiler technology now. For the first 10 years of my career I heard little about compilers, but in the last 10, JS Engines like v8 and Spidermonkey, and AOT compiler tech like LLVM and MLIR have changed that.

The overall historical trend is that computing is getting used a lot more. So you have growth on both ends: more people using high level languages, and more people caring about performance.

It's not either/or -- that's a misleading way of thinking about it. The trend is more "spread", not everyone going "up" the stack. There will always be more people up the stack because lower layers inherently provide leverage, but that doesn't mean the lower layers don't exist or aren't relevant.

And lots of people migrate "down" the stack during their careers -- generally people who are trying to build something novel "up stack" and can't do it with what exists "down there".

Re: Why Isn't Functional Programming the Norm? [video]

#274
post #254

EDIT: I wrote this comment before watching the video. I stand by this comment, but the video is very good and I wholeheartedly agree with its conclusions. As someone who writes pure FP for a living at a rather large and well known org, these threads physically hurt me. They're consistently full of bad takes from people who don't like FP, or haven't written a lick of it. Subsequently, you get judgements that are chock…

Personally, I get frustrated that there seems to be a belief that you can only use FP or OOP, when the reality is both models can be used in conjunction, and there may be reasons to choose one over the other dependent on what you are doing. Not to mention there are other models such as Protocol Oriented Programming. You see this in languages like Swift.

Re: Why Isn't Functional Programming the Norm? [video]

#275

Earlier quoted context omitted.

That's utter rubbish. My team has been working with Clojure for close to a decade now. We regularly hire coop students from university, and none of them have ever had problems learning functional programming. It typically takes around a couple of weeks for a student to become productive and start writing useful code. The only people I've ever met who say that FP doesn't map to the way our brains work are people who'r…

I think you can do better than calling something you disagree with “rubbish” because your team didn’t have problems with it. Here’s an example of people finding functional programming unnatural, maybe you can leverage your experience to explain why he is wrong: Functional Programming Is Not Popular Because It Is Weird https://probablydance.com/2016/02/27/functional-programming-...

I would venture a guess to say that what makes FP or declarative style programming/thinking feel weird is not any great context like the nature of the human brain but rather the lesser one that usually people try to learn it after already having had learned imperative style stuff.

The functionally written recipe from https://probablydance.com/2016/02/27/functional-programming-... may be less helpful if I need to know exactly what steps to take to bake a cake, but it will actually be much more helpful if I want to know what a baked cake is. It isn't quite a fair example because it leverages how humans already know what a baked cake is, what a preheated oven is, etc and the clunkiness of the FP-style recipe is likely more due to that than anything fundamental to FP.

Let's try a different example that better maps to real world application logic. The task is to build a scootybooty.

Imperatively, a scootybooty program is:

- Acquire four wheels and two axels.

- Chop down a tree.

- Plane wood from tree into curved flat shape.

- Attach axels to convex side of planed wood shape.

- Attach wheels to axel.

Declaratively it is:

- A scootybooty is a planed plank of wood with two trucks.

- A planed plank of wood is a flat board.

- A truck is an axel with two wheels.

Now imagine your boss asks you wtf this scootybooty thing is and what it can do. Which program more quickly allows you to answer these questions? My favorite thing about the FP/declarative paradigm is that the mental model first-classes the abstract thing you are implementing above how you implement it. Imperative style encourages you to think about the steps it takes to do something moreso than the thing itself which IMO can lead to cart-before-horse type mistakes in planning. Declarative programming: "the forest is made of many trees", imperative programming: "tree, tree, tree, tree, tree, tree..."

Re: Why Isn't Functional Programming the Norm? [video]

#276

Earlier quoted context omitted.

Here's a talk on making real world commercial games with Clojure on top of Unity. https://www.youtube.com/watch?v=LbS45w_aSCU

come on, the "games" showcased here have the complexity level of a 2003-like game and they barely achieve 200 fps on modern hardware. When I look at similar trivial things ran with no vsync on my machine, it's >10000 fps

That's just moving goalposts. The games showcased are the same complexity as plenty real world commercial games that are making good money in 2019. If you're doing triple-A game development, maybe you need to get down to the metal, but for tons of games you'll be perfectly fine with FP.

Also worth noting that the idea is to use FP around stuff like the actual game logic, and then handle rendering details imperatively.

Re: Why Isn't Functional Programming the Norm? [video]

#277
post #271
post #266

Earlier quoted context omitted.

> Why does functional programming need to be taught in schools but all the other various programming topics did not? Because I think it is harder for people who have programmed with other paradigms - following an inverse law, most things should get easier to learn with experience, not harder. It's foreign, it's weird, it's back to front. It doesn't have an immediately obvious benefit to what people are used to, and t…

Exactly. As just an anecdote, my intro do FP class in university was taught by a professor who tended to rant about different levels of purity and elegance between his favorite and least favorite languages. Of course, the favorite was his pet project and we had to spend most of the class using it. I also know that Emacs is partly written in Lisp because it was the only editor he would touch. FP can't even sell itself…

The sad part is that this is a common experience - universities have done a bad job at teaching FP. I think there are good pieces of FP education, particularly Learn You a Haskell and https://github.com/data61/fp-course - friends have gone through these have questioned "why wasn't I taught like this the first time around".

> I've never touched any FP since, unless you count borrowing clever lambda snippets.

I'd urge you to give it another shot if you have spare time. Even in spite of all the dogshit things associated with it, it's a paradigm I've bet my career on.

Re: Why Isn't Functional Programming the Norm? [video]

#278
post #277
post #271

Earlier quoted context omitted.

Exactly. As just an anecdote, my intro do FP class in university was taught by a professor who tended to rant about different levels of purity and elegance between his favorite and least favorite languages. Of course, the favorite was his pet project and we had to spend most of the class using it. I also know that Emacs is partly written in Lisp because it was the only editor he would touch. FP can't even sell itself…

The sad part is that this is a common experience - universities have done a bad job at teaching FP. I think there are good pieces of FP education, particularly Learn You a Haskell and https://github.com/data61/fp-course - friends have gone through these have questioned "why wasn't I taught like this the first time around". > I've never touched any FP since, unless you count borrowing clever lambda snippets. I'd urge…

Noted--thank you!

Re: Why Isn't Functional Programming the Norm? [video]

#279
post #254

EDIT: I wrote this comment before watching the video. I stand by this comment, but the video is very good and I wholeheartedly agree with its conclusions. As someone who writes pure FP for a living at a rather large and well known org, these threads physically hurt me. They're consistently full of bad takes from people who don't like FP, or haven't written a lick of it. Subsequently, you get judgements that are chock…

Personally, I get frustrated that there seems to be a belief that you can only use FP or OOP, when the reality is both models can be used in conjunction, and there may be reasons to choose one over the other dependent on what you are doing. Not to mention there are other models such as Protocol Oriented Programming. You see this in languages like Swift.

The issues is that you get benefits for sticking to one paradigm, because then everything is made of the same stuff.

If everything is an object, then you can use all your tooling that works with objects, which is everything. If everything is pure, you get easy parallelism. If everything is an actor, you get easy distributability. If everything is a monad or function, you get easy compositionality. The list goes on. Smalltalk, Erlang and Haskell are languages with very dedicated fan bases, which I theorise is because they went all in on their chosen paradigm.

Re: Why Isn't Functional Programming the Norm? [video]

#280

Earlier quoted context omitted.

Are you suggesting that oop allows programmers to understand the assembly output? Did you watch the video? The most popular language is JavaScript, which is only not functional but a quirk of history. The video makes an argument for marketing being the reason.

JS isn't really a functional language, it's an imperative, prototype-based language with partial functional support that allows multiple coding styles, like most of the popular scripting languages.

Yes. Which is why I said it's not functional. Because of a marketing choice.
Post reply on HN