3 ms·
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 t
by skohan 7y ago
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.
- classified 7y agoIf “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.
- OskarS 7y agoI 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.
- Bjartr 7y agoWhere 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.
- lonelappde 7y agoThis thread is for people who are smarter than compilers. Java is not different from C in that regard.
- ummonk 7y agoRust on the other hand is zero-cost abstraction but pushes you to write functional code.
- pjmlp 7y agoYou can analyze Assembly code just like in any other AOT compiled language. Have a go at in Godbolt, https://godbolt.org/ https://godbolt.org/ OCaml also integrates with perf on Linux, https://ocaml.org/learn/tutorials/performance_and_profiling.html https://ocaml.org/learn/tutorials/performance_and_profiling.... Some performance tips from an old partially archived page. https://hackerfall.com/story/writing-performance-sensitive-ocaml-code-1 https://hackerfall.com/story/writing-performance-sensitive-o... And if you are feeling fancy, doing some pointer style programming https://ocaml.org/learn/tutorials/pointers.html https://ocaml.org/learn/tutorials/pointers.html