Re:Why study functional programming? (2012)
by cassepipe on Tuesday August 02, 2022 @06:34PM
(#32325138)
I think this is the idea behind Richard Feldman's Roc programming language
https://www.roc-lang.org/
Re:Why study functional programming? (2012)
by riwsky on Tuesday August 02, 2022 @07:32PM
(#32325666)
And just like that, you’ve invented Rust!
Re:Why study functional programming? (2012)
by frostwarrior on Tuesday August 02, 2022 @07:59PM
(#32325911)
AFAIK this is the idea behind ImmutableJS: https://immutable-js.com/
In Scala you can add a "@tailrec" annotation to recursive functions. The annotation means that the function is guaranteed to recurse efficiently (without growing the stack) OR that the compiler will give an error telling you why it can't be guaranteed. I could imagine a similar annotation like "@withmutation" for functions where you want to guarantee efficient in-place mutation at runtime. As it is, when I run into performance pain points in Scala I redo the critical bits with (manually written) while-loops and imperative mutation.
[1] Unless you later attach a debugger and expect to be able to observe V1 and V2 simultaneously. But I presume this sort of issue already comes up and is somehow dealt with regarding other compiler optimizations.