News for hackers. Stuff that matters.
Re:How to Stop Functional Programming by amluto on Sunday September 21, 2025 @12:30PM (#45324191)
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.

Re:How to Stop Functional Programming by calebh on Sunday September 21, 2025 @01:56PM (#45325079)
In my experience the main benefit of functional programming is function purity. I am completely fine with mutation inside of a function since the all of the mutation logic is self-contained in a single small block of text.

I think everyone should take a shot at writing a non-trivial functional program to see the benefit. Once you understand what makes it great, you can apply what you've learned to the majority of OOP/impure languages.

Re:How to Stop Functional Programming by brabel on Sunday September 21, 2025 @03:21PM (#45325801)
Flix has "regions", which are a way to allow mutation locally while keeping the language purely functional otherwise: See Region-based Local Mutation in https://flix.dev/
Re:How to Stop Functional Programming by Philpax on Sunday September 21, 2025 @01:14PM (#45324672)
Does Rust not meet that description?
Re:How to Stop Functional Programming by amluto on Sunday September 21, 2025 @01:20PM (#45324721)
Rust is very good at making things immutable. But that doesn't mean it's particularly fun to, for example, append or prepend something to a list and retain a reference to both the old and the new list.

Compare to most "functional" languages, in which prepending an item to a list and ending up with immutable references to the old and new lists is almost the defining feature of the language.

Re:How to Stop Functional Programming by Mond_ on Sunday September 21, 2025 @01:43PM (#45324964)
Considering the performance implications of a full commitment to immutable data structures, I think Rust does a pretty good job here.

Dynamic arrays / vectors / slices or whatever you want to call them are probably the most important or fundamental non-plain-old-data data structure, and in a purely immutable environment these are essentially impossible (or have awful performance characteristics).

Re:How to Stop Functional Programming by IshKebab on Sunday September 21, 2025 @01:36PM (#45324882)
Yeah although I find FP languages' obsession with singly linked lists to be a real flaw because they have such awful performance characteristics. And also pretty bad ergonomics often. The number of times stuff comes out backwards...
Re:How to Stop Functional Programming by delta_p_delta_x on Sunday September 21, 2025 @12:46PM (#45324384)
> I wish there was a mainstream, high performance language that made both styles equally ergonomic.

Unironically, C++.

Re:How to Stop Functional Programming by Mond_ on Sunday September 21, 2025 @01:39PM (#45324916)
> > I wish there was a mainstream, high performance language that made both styles equally ergonomic.

> Unironically, C++.

At best C++ falls under "equally unergonomic".

Re:How to Stop Functional Programming by ndriscoll on Sunday September 21, 2025 @12:56PM (#45324485)
Or depending on what "high performance" means (e.g. if Java or Go would be considered acceptable), Scala.