frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

How to Stop Functional Programming

https://brianmckenna.org/blog/howtostopfp
48•thunderbong•2h ago

Comments

skybrian•1h ago
Apparently, someone doesn’t really get what makes functional programming hard to understand? It’s not writing the occasional pure function.

Code review or pair programming might help here, to learn the team’s common idioms.

IshKebab•1h ago
Yeah this 100%. FP isn't hard because of FP - it's all the other things that popular FP languages come with that makes them hard to understand. Arguably most of them are not related to FP; they're just style choices:

1. Global type inference.

2. Implicit syntax (no brackets for function calls, commas to separate arguments, semicolons to end statements/expressions, etc.)

3. Currying & point free style.

4. Tendency to have very deep nested expressions. The gap between `let foo =` and it's actual value can often be hundreds of lines.

I'm sure you can write FP code that avoids these issues and is easy to follow but it doesn't seem like people do that in practice.

Rust avoided all of these issues fortunately.

(Oh I forgot about monads.)

amluto•25m ago
Also: avoidance of mutable state, even locally. A lot of functions can be more straightforwardly expressed using mutable variables and data structures, and most functional languages can handle local mutable state, but a lot of code in functional languages avoids it.

Conversely, a lot of code written in imperative languages would be clearer and/or less bug-prone if it avoided mutable state and used persistent data structures.

I wish there was a mainstream, high performance language that made both styles equally ergonomic.

walleeee•12m ago
C# isn't bad in this regard, with LINQ and some discipline with immutability. Dunno if it counts as high performance
delta_p_delta_x•9m ago
> I wish there was a mainstream, high performance language that made both styles equally ergonomic.

Unironically, C++.

jen20•18m ago
Also the unwillingness of so many enterprise developers to learn anything that wasn't commonplace in 2001, regardless of whether they were in the workforce by then.
jazzypants•52m ago
This is written by the same guy who made a big stink about how JS promises weren't pure monads and somehow that was a problem-- a zealot, in other words.
macintux•1h ago
(2016)
seanhunter•1h ago
By the looks of the code snippets he should have explained that he’s not doing functional programming, he’s just writing unnecessarily non-idiomatic python code. I’m sure his manager would have understood.
ndriscoll•1h ago
The code snippets are Scala. The first snippet is idiomatic. I can't imagine a team adopting Scala and complaining about functional programming though.
tengbretson•45m ago
I thought "idiomatic Scala" was an oxymoron.
mrkeen•44m ago
I've been there. One of the more functionally-minded devs wrote something to do with putting Keys and Values into some kind of json store, and a less functionally-minded dev complained about all the type variables - Ks and Vs I guess.
flohofwoe•1h ago
When did method chaining become 'functional programming'?

It's not 'functional programming' that makes the code unreadable, but overly long chains of array-processing functions. Sometimes a simple for-loop which puts all operations that need to happen on an array item into the loop-body is indeed much more readable.

jolux•1h ago
> When did method chaining become 'functional programming'?

It's very similar to applicative style in FP. Conceptually, method chaining is equivalent to nested function application, it just comes with syntax sugar for specifying the `self` parameter.

mrkeen•37m ago
> When did method chaining become 'functional programming'?

As soon as you stop calling it "method chaining" and start calling it "function composition".

If you chain together a bunch of methods ('.' operator) in an OO setting, that's called a "fluent interface". It's a sign of good design and is to be commended.

If you compose a bunch of functions ('.' operator) in an FP setting, it's an unreadable mess, and you will receive requests to break it into separate assignment statements and create named variables for all the intermediate states.

busterarm•1h ago
There's only one universal lesson that I've learned over my 25+ year career so far and it's that software engineering types are fragile creatures whose egos must be tended to. Delicately.

This is becoming increasingly true as the years pass and the number of times I've had to drop whole mature architectures and reimplement something worse because some engineer's feefees got hurt can no longer be counted on my fingers & toes.

imtringued•1h ago
Using Scala and then complaining about unnecessary complexity is a bit much. Like, if you made the technologically brave decision to use a niche language like Scala that isn't just a slightly better Java like Kotlin then you'd better expect to accommodate the inexperienced developers by training them, possibly via pair programming, instead of constricting the experienced developers.
tsss•55m ago
If this code is too complicated for you then you should reconsider your career.
elevation•25m ago
TFA is indignantly reacting to the least charitable interpretation of what his employer has asked him to do. I'd like to know the honest shape of the code his manager rejected before judging the employer over this.
astrobe_•47m ago
Beyond the satire, one is supposed to write code which is readable, and like often with written works, one has to think about the "audience", the readers. When you write technical documentation, you have to decide ahead of time the expected skill level of the reader - often that decision is written too in the intro as "prerequisite(s)".

When writing code you have the motto "don't make me think" in mind, but how to know what's the maximum level of trickiness for readers? There are familiar techniques and idioms when it is your main programming language, but they are not for someone using this language on the side.

In any case, neither code nor comments should be tutorials. To a reasonable extent, it is up to the reviewer to do their homework or just ask. Then based on that interaction you can add a comment or a parenthesis, or uncompress a bit the code. But not to the point that it means to "dumb down" things, because it is a downward spiral.

dimal•21m ago
> When writing code you have the motto "don't make me think" in mind

I disagree with this phrasing. We’re engineering after all. The entire job is thinking. If someone doesn’t want to think, then they shouldn’t be a programmer.

Readability matters, though. I try to have a narrative structure in my code, so it leads the reader along. Formatting matters. And documentation helps. If you want to introduce an unfamiliar idiom that might be more functional, good, but document it. Share it with the team and talk about it. I know that writing and reading documentation is usually seen as a waste of time unless you’re doing it for AI, but I’ve seen it work well in multiple teams. In my experience, the teams with poor docs have the worst code.

_aleph2c_•42m ago
The manager solved the wrong problem. People should be sharing their tricks with each other. This was a perfect time to set up some peer-to-peer training.
jen20•17m ago
Or in the age of AI, "have you asked Claude to explain what the code does so you can learn something?"
jmmv•24m ago
Missed chance to do something like:

  class User:
    def calculateCoworkers() = {
      this.coworkers.clear()
      for { d <- this.departments }
        this.coworkers ++ d.employees
    }
and then, somewhere else...

  user.calculateCoworkers()
  ... many lines after ...
  for { c <- user.coworkers }
    ... do something ...
Yes, I've seen code like this many, many, many times where class members are used as "global variables" to pass state across functions. And I've noticed AI likes to generate code like this too (possibly because of the former (large presence of this "pattern" in the training data), which means I'm encountering this now in pull requests...
cies•22m ago
FP code is often easier to read (the article provides a case to that point).

What gave FP a bad rep is, i guess, Haskell (and the "pure functional approach w/ monad transformer stacks").

Every shop I worked at the devs were already at a level that they'd appreciate FP code: easier to read, refactor and test.

The tendency is also towards FP: see the features in recent Java/C# version. Or languages that gain popularity recently (Kotlin, Rust) are more FP'ish than their predecessors (respectively Java and C++).

Seattle, Tech Boomtown, Grapples with a Future of Fewer Tech Jobs

https://www.wsj.com/tech/seattle-tech-amazon-microsoft-jobs-95f2db27
1•carabiner•2m ago•0 comments

How the Golden Gate Bridge Works [video]

https://www.youtube.com/watch?v=RjbJwnUd3Pw
1•lisper•4m ago•0 comments

AIs built a working Deleuzian engine and the verification script to prove it

1•renshijian•4m ago•1 comments

OpenAI admits AI hallucinations are mathematically inevitable

https://www.computerworld.com/article/4059383/openai-admits-ai-hallucinations-are-mathematically-...
1•_tk_•5m ago•0 comments

UK recognises Palestine as an independent state

https://www.theguardian.com/uk-news/2025/sep/21/uk-recognises-palestine-as-an-independent-state
3•artninja1988•7m ago•0 comments

Alan Turing on Embodied Intelligence

https://rodneybrooks.com/alan-turing-on-embodied-intelligence/
1•chmaynard•8m ago•0 comments

The Link Between Trauma, Drug Use, and Our Search to Feel Better

https://lithub.com/the-link-between-trauma-drug-use-and-our-search-to-feel-better/
1•PaulHoule•11m ago•0 comments

A String Library Beat OpenCV at Image Processing by 4x

https://ashvardanian.com/posts/image-processing-with-strings/
3•ternaus•11m ago•0 comments

President Trump Signs Technology Prosperity Deal with United Kingdom

https://www.whitehouse.gov/articles/2025/09/president-trump-signs-technology-prosperity-deal-with...
2•donutloop•11m ago•0 comments

Liberté, égalité, Radioactivité

https://worksinprogress.co/issue/liberte-egalite-radioactivite/
1•paulpauper•12m ago•0 comments

Sj.h: A tiny little JSON parsing library in ~150 lines of C99

https://github.com/rxi/sj.h
11•simonpure•12m ago•0 comments

Google/timesketch: Collaborative forensic timeline analysis

https://github.com/google/timesketch
3•apachepig•12m ago•0 comments

Ask HN: Local hostnames without root/admin

3•terry_hc•14m ago•0 comments

I Analyzed Over 500 Y Combinator AI Startups [video]

https://www.youtube.com/watch?v=gPWD7YytjmM
2•sc90•14m ago•0 comments

Arm's Chief Architect on the History of the Arm Architecture

https://thechipletter.substack.com/p/arms-chief-architect-on-the-history
2•zdw•15m ago•0 comments

Chezetc: Extending chezmoi to manage files under /etc. and other root-owned dirs

https://github.com/SilverRainZ/chezetc
1•SilverRainZ•17m ago•1 comments

Trump says Murdochs are potential TikTok deal partners

https://www.cnbc.com/2025/09/21/trump-tiktok-murdoch-fox-bytedance.html
1•rntn•18m ago•1 comments

Pragmasevka Font: Pragmata Pro doppelgänger made of Iosevka SS08

https://github.com/shytikov/pragmasevka
1•hggh•19m ago•0 comments

The Aging Democracy (2023)

https://www.cambridge.org/core/journals/perspectives-on-politics/article/aging-democracy-demograp...
1•imankulov•19m ago•0 comments

EA as Antichrist: Understanding Peter Thiel

https://forum.effectivealtruism.org/posts/hGwAohPbwCrDT5ynY/ea-as-antichrist-understanding-peter-...
1•felineflock•21m ago•1 comments

Social contagion is powerful: how researchers suggest we can build resistance

https://www.psypost.org/social-contagion-is-powerful-heres-how-researchers-suggest-we-can-build-r...
2•1659447091•22m ago•0 comments

MutativeJS v1.3.0 is out with performance gains

https://github.com/unadlib/mutative/releases/tag/v1.3.0
1•unadlib•22m ago•0 comments

I spent $8k to get back to US after fears over Trump visa deadline

https://www.bbc.com/news/articles/cn4wwwz2p1po
3•vinni2•23m ago•0 comments

Ts-ignore is almost always the worst option

https://evanhahn.com/ts-ignore-is-almost-always-the-worst-option/
3•Bogdanp•24m ago•0 comments

Show HN: Mimir Crypto – AI crypto news aggregator and analysis

https://mimircrypto.com
1•gitmagic•25m ago•0 comments

Benefits of different active learning methods to conceptual physics learning

https://arxiv.org/abs/2505.04577
1•sebg•30m ago•0 comments

Exploiting the GPU and the 90s crypto wars to crack the APT code signing keys

https://reverse.put.as/2025/08/24/rc4bruteforce/
2•notmine1337•31m ago•0 comments

Layoffs Cast a Long Shadow

https://www.glassdoor.com/blog/layoffs-cast-a-long-shadow/
2•hunglee2•31m ago•0 comments

European airports race to fix check-in glitch after hacking disruption

https://www.cnn.com/2025/09/21/europe/europe-airports-hack-operations-intl
2•Bender•31m ago•0 comments

California bans masks meant to hide law enforcement officers' identities

https://www.npr.org/2025/09/20/nx-s1-5548532/newsom-trump-masked-ice-agents
22•1659447091•32m ago•10 comments