▲ | amluto 12 hours 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. | |||||||||||||||||||||||
▲ | calebh 11 hours ago | parent | next [-] | ||||||||||||||||||||||
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. | |||||||||||||||||||||||
▲ | brabel 10 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
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/ | |||||||||||||||||||||||
▲ | Philpax 12 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
Does Rust not meet that description? | |||||||||||||||||||||||
| |||||||||||||||||||||||
▲ | 12 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
[deleted] | |||||||||||||||||||||||
▲ | delta_p_delta_x 12 hours ago | parent | prev [-] | ||||||||||||||||||||||
> I wish there was a mainstream, high performance language that made both styles equally ergonomic. Unironically, C++. | |||||||||||||||||||||||
|