9 comments

  • QuadmasterXLII11 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)<p><pre><code> (defun fibreverse (i ret acc) (if acc (if (&gt; 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))) </code></pre> 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.
  • foltik2 hours ago
    &gt; which produces primes.cpp, containing your program translated to idiomatic, readable C++ code:<p>As a C++ enjoyer I can confirm this is some excellent idiomatic, readable C++ code.
  • anitil5 hours ago
    &gt; 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.<p>Finally, I can get some primes on my laptop!
  • dnmc10 hours ago
    Is this the Stephen Dolan of &quot;mov is Turing Complete&quot; fame?
    • dolmen3 hours ago
      Is this the Stephen Dolan creator of jq?<p><a href="https:&#x2F;&#x2F;jqlang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;jqlang.org&#x2F;</a>
      • LeonidasXIV2 hours ago
        Yes, its exactly that Stephen Dolan.
    • loeg8 hours ago
      I believe so.
  • zorobo9 hours ago
    This made <i>my day</i>, thank you!
  • ajbt2001285 hours ago
    Wow Stephen Dolan never fails to impress
  • Caum6 hours ago
    [flagged]
    • tux34 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&#x27;re going to spam.
    • fayash4 hours ago
      Might have missed the joke here. This isn&#x27;t a traditional C++ backend; it&#x27;s a C++ Template Metaprogramming backend. The code isn&#x27;t meant to be run—it’s meant to be compiled. The &quot;output&quot; you see is actually just a compiler error message because the program forces the compiler to calculate primes during type checking. The &quot;runtime performance&quot; the author mentioned is actually just how long g++ takes to crash your ram.
    • kristjansson5 hours ago
      Per TFA C++ is a purely functional, interpreted language. Should be trivial to embed into?
  • hudsonhs10 hours ago
    She (Jane Street) is not gonna notice you, bro
    • shorsher8 hours ago
      I believe they already work for Jane Street.
      • binarycrusader8 hours ago
        Indeed: <a href="https:&#x2F;&#x2F;blog.janestreet.com&#x2F;author&#x2F;sdolan&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.janestreet.com&#x2F;author&#x2F;sdolan&#x2F;</a><p><a href="https:&#x2F;&#x2F;signalsandthreads.com&#x2F;memory-management&#x2F;#:~:text=Stephen%20Dolan%20works%20on%20Jane%20Street%E2%80%99s%20Tools%20and%20Compilers%20team%20where%20he%20focuses%20on%20the%20OCaml%20compiler." rel="nofollow">https:&#x2F;&#x2F;signalsandthreads.com&#x2F;memory-management&#x2F;#:~:text=Ste...</a>