Re:Why Isn't Functional Programming the Norm? [video]
by classified on Thursday October 17, 2019 @08:54AM
(#21281490)
I regularly read the assembly output of the OCaml compiler I'm using and there are very few surprises. The mapping from source to generated assembly is quite straightforward. You couldn't say the same for Haskell, though. So it depends on which FP language you're using.
[ Parent
| on HN ]
Re:Why Isn't Functional Programming the Norm? [video]
by skohan on Thursday October 17, 2019 @11:58AM
(#21283379)
Does OCaml give you enough tools to optimize around things like CPU-cache and memory management costs? It's one thing to know what kind of assembly is going to be produced by a block of code, but it's another thing to be able to get the machine to do exactly what you want.
Re:Why Isn't Functional Programming the Norm? [video]
by pjmlp on Friday October 18, 2019 @04:09AM
(#21289518)
You can analyze Assembly code just like in any other AOT compiled language.
Have a go at in Godbolt, https://godbolt.org/
OCaml also integrates with perf on Linux,
https://ocaml.org/learn/tutorials/performance_and_profiling....
Some performance tips from an old partially archived page.
https://hackerfall.com/story/writing-performance-sensitive-o...
And if you are feeling fancy, doing some pointer style programming
Re:Why Isn't Functional Programming the Norm? [video]
by classified on Thursday October 17, 2019 @12:25PM
(#21283653)
If “to get the machine to do exactly what you want” is an important goal, I'd recommend C or C++. Those are well known tools for those purposes. FP languages are rather about getting more ideas from math into how you structure your code.
Re:Why Isn't Functional Programming the Norm? [video]
by OskarS on Thursday October 17, 2019 @12:46PM
(#21283864)
I don’t think you need to go that low level. I find it much easier to optimize around things like memory layout, allocation patterns and cache effects even in Java and C# compared to (essentially) any functional language.
I think this is just a feature of imperative languages over functional ones. Functional languages are excellent for many things, but not for this stuff.
Re:Why Isn't Functional Programming the Norm? [video]
by Bjartr on Thursday October 17, 2019 @05:49PM
(#21286665)
Where should I look to learn about doing those things in Java? Last time I tried looking for guidance I mostly found people saying it's not worth the effort since the JVM JIT will do better.
Re:Why Isn't Functional Programming the Norm? [video]
by lonelappde on Friday October 18, 2019 @03:32PM
(#21294411)
This thread is for people who are smarter than compilers. Java is not different from C in that regard.
Re:Why Isn't Functional Programming the Norm? [video]
by ummonk on Thursday October 17, 2019 @09:04PM
(#21287774)
Rust on the other hand is zero-cost abstraction but pushes you to write functional code.
Re:Why Isn't Functional Programming the Norm? [video]
by chowells on Thursday October 17, 2019 @11:46AM
(#21283281)
I absolutely can say that about Haskell. You have to actually learn the language, but it doesn't do anything unpredictable.
Re:Why Isn't Functional Programming the Norm? [video]
by carterschonwald on Thursday October 17, 2019 @09:12AM
(#21281635)
Actually I’ve found it pretty easy to track / reason about. But I guess I do have a decent mental model for how the compiler works
Re:Why Isn't Functional Programming the Norm? [video]
by lonelappde on Friday October 18, 2019 @03:31PM
(#21294398)
Wrong metric. It's not the mapping that matters, it's the assembly that matters.