alt.hn

4/1/2026 at 11:35:02 PM

A new C++ back end for ocamlc

https://github.com/ocaml/ocaml/pull/14701

by glittershark

4/1/2026 at 11:58:06 PM

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.

by QuadmasterXLII

4/2/2026 at 9:07:28 AM

> which produces primes.cpp, containing your program translated to idiomatic, readable C++ code:

As a C++ enjoyer I can confirm this is some excellent idiomatic, readable C++ code.

by foltik

4/2/2026 at 5:26:17 AM

> 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!

by anitil

4/2/2026 at 12:44:28 AM

Is this the Stephen Dolan of "mov is Turing Complete" fame?

by dnmc

4/2/2026 at 7:30:59 AM

Is this the Stephen Dolan creator of jq?

https://jqlang.org/

by dolmen

4/2/2026 at 8:28:24 AM

Yes, its exactly that Stephen Dolan.

by LeonidasXIV

4/2/2026 at 2:38:19 AM

I believe so.

by loeg

4/2/2026 at 1:37:09 AM

This made my day, thank you!

by zorobo

4/2/2026 at 6:14:15 AM

Wow Stephen Dolan never fails to impress

by ajbt200128

4/2/2026 at 4:26:24 AM

[flagged]

by Caum

4/2/2026 at 7:05:02 AM

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.

by tux3

4/2/2026 at 6:21:41 AM

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.

by fayash

4/2/2026 at 5:34:53 AM

Per TFA C++ is a purely functional, interpreted language. Should be trivial to embed into?

by kristjansson