Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Functional programming has "design patterns" but few of them, and those design patterns make so much sense that you stop thinking of them as such and just think of them as the way to solve problems. Referentially transparent functions and immutable records for data are design patterns in the non-pejorative sense, but they simplify code rather than complicating it. These are the two design patterns of functional programming: Noun and Verb. For mutable state (monad vs. ref cells vs. message passing) and for the Adjective problem (type classes vs. inheritance vs. functors) there is less of a consensus.

Functional programming isn't always the solution, but it's amazing how often it is the right way of doing things. I just wrote some neural network code, because I'm developing AI for a card game, and I used mutable state because back-propogation feels "inherently mutable" and because mutable Arrays are fast (whereas Scala's Vector might not be). I regret doing so. If nothing else, I should have started with the immutable solution and only moved to the mutable one if there was a measured performance benefit. So many bugs are invited in when you start using mutable state.

My problem with Java-the-culture is that it seems to come from a hatred of mathematics and the reality of what programming actually is: solving computational problems, and using abstractions when they simplify solutions. Large-project methodologies with the weird design patterns seem tailored to make the programming process easier for people who failed Calc 2 to manage. To make it something that non-technical higher-ups can understand and commoditize: "We have 38 Java developers, 302 kLoC, 1973 Factories, and 714 Visitors, and we're going to double all these numbers in the next 6 months." (Never mind whether any actual problems are being solved.)



I didn't even mention functional programming. Functional Programming is not always an option.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: