A new C++ back end for ocamlc
glittershark
146 points
10 comments
April 01, 2026
Related Discussions
Found 5 related stories in 52.0ms across 3,471 title embeddings via pgvector HNSW
- A CSS Engine in OCaml p4bl0 · 23 pts · April 03, 2026 · 53% similar
- A preview of Coalton 0.2, a statically-typed Lisp fanf2 · 21 pts · March 15, 2026 · 46% similar
- Notes on Project Oberon surprisetalk · 23 pts · March 04, 2026 · 45% similar
- Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3) thecloudlet · 66 pts · March 12, 2026 · 45% similar
- Common Lisp Development Tooling 0bytematt · 72 pts · March 21, 2026 · 44% similar
Discussion Highlights (7 comments)
QuadmasterXLII
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) (defun fibreverse (i ret acc) (if acc (if (> i 0) (progn (setv call1 (fibreverse (- i 1) (cons (head acc) ret) (tail acc))) (setv ret1 (head call1)) (setv acc1 (head (tail call1))) (if acc1 (fibreverse (- i 2) (cons (head acc1) ret1) (tail acc1)) (pair ret1 acc1))) (pair ret acc)) (pair ret acc))) (defun reverse (list) (head (fibreverse 30 nil list))) 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.
CBLT
> idiomatic, readable C++ code I disagree with this characterization of the generated primes.cpp shown here.
dnmc
Is this the Stephen Dolan of "mov is Turing Complete" fame?
hudsonhs
She (Jane Street) is not gonna notice you, bro
zorobo
This made my day , thank you!
Caum
This is a really interesting direction for OCaml. A formal C++ backend could significantly simplify embedding OCaml into existing C++ codebases, especially where linking against the standard OCaml runtime might be tricky. I wonder how the performance compares to the existing native backend in long-running processes.
anitil
> 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. Finally, I can get some primes on my laptop!