A new C++ back end for ocamlc
183 points by glittershark 11 hours ago | 15 comments
QuadmasterXLII 11 hours ago
Brilliant stuff. A tip for writing long-running C++: bizzarely, the C++ interpreter completely lacks tail call optimization. As a result, most idiomatic C++ code implements and uses reverse, map, range, filter etc, which don’t blow the stack if you implement them like (forgive the pseudo-code)
Whoever has to maintain your code after you are gone will apprrciate that you used the idiomatic, portable approach instrad of relying on command line flags.
replyfoltik 2 hours ago
> which produces primes.cpp, containing your program translated to idiomatic, readable C++ code:
replyAs a C++ enjoyer I can confirm this is some excellent idiomatic, readable C++ code.
anitil 6 hours ago
> Using these more sophisticated data structures, g++ is able to compute the prime numbers below 10000 in only 8 seconds, using a modest 3.1 GiB of memory.
replyFinally, I can get some primes on my laptop!
dnmc 10 hours ago
Is this the Stephen Dolan of "mov is Turing Complete" fame?
replyCaum 7 hours ago
[flagged]
replytux3 4 hours ago
This account is low-effort spam, the LLM generated comment seems to only look at the title. They should at least feed the contents of the page to the AI if they're going to spam.
replyfayash 5 hours ago
Might have missed the joke here. This isn't a traditional C++ backend; it's a C++ Template Metaprogramming backend. The code isn't meant to be run—it’s meant to be compiled. The "output" you see is actually just a compiler error message because the program forces the compiler to calculate primes during type checking. The "runtime performance" the author mentioned is actually just how long g++ takes to crash your ram.
replykristjansson 5 hours ago
Per TFA C++ is a purely functional, interpreted language. Should be trivial to embed into?
reply