I Rewrote the Same App in C, Rust, Python, and JS!



I rewrote the exact same raytracer in C, Rust, Python, and JavaScript — same scene, same rules, zero external libraries.
Four languages. One identical scene (camera + 138 spheres + materials). Only the pure render loop was timed. No shortcuts.
Results:
• Python → 55 seconds
• JavaScript → 0.74 seconds
• Rust → 0.25 seconds
• C → 0.19 seconds
C won. Rust came in just 7% behind. JavaScript crushed Python by 74×. The gap between slowest and fastest: 187×.
This is what happens when you force every language to play by the same strict rules and measure only the math that actually matters.

All source code + the live comparison page are linked below.
Go break it, prove me wrong, or tell me which language I should torture next.
🔗 Code & live comparison:
🔔 Subscribe for more painful language experiments.
#programming #rust #c #python #javascript #raytracing #benchmark #coding

source

28 Comments

  1. Your description makes no sense:
    "• Rust → 0.19 seconds

    • C → 0.25 seconds

    C won. Rust came in just 7% behind"
    Why are you saying C won when Rust was quicker??

  2. bro run c with -O2 flag insted of -O3 and didn't us all optimizing flags, gcc insted of clang, use strust with evryfing insted of union + enume, didn't use PGO. the same with rust. cargo in release gives you terrible optimization options and you have to override them (e.g. if you have a loop with a vector for 10000 objects, rust checks 10000 times if you haven't gone beyond the index – you can disable it with a flag (or use unsafe)) or as default you have disabled the jamp table for switch, which slows down the program enormously if you use them constantly in eg switch

  3. If you want to show naive transfer of OOP logic "head-on" without optimization for the runtime architecture, its nice comparition but between python and JS.
    In C you wrote flat structures with switches , in JS you've created a bunch of dynamic objects, causing constant heap allocations, garbage collection pressure, and CPU cache misses. You cant compare it like this.

  4. Rule #3 brings an unfair disadvantage and exist only to favor C. One of the biggest reasons of using a language with with an extensive ecosystem is the ecosystem. Be honest and use full features of each language. You'll be surprised.

  5. How long did Rust take to compile? How much memory and CPU did it take?

    What JavaScript did you run? Was it in a browser or was it some other implementation?

    Was python cpython or mypy or something?

    These details seemed to have been skipped.

    Also counting rust as the winner for a near miss for unrelated details to the test doesn't work. I hardly ever run into lost pointers in the first place and it's much more readable imo than rust is. Spending extra time waiting for compiling and letting it blow out my ram doesn't count as a win for me.

Leave a Reply

Your email address will not be published. Required fields are marked *

You might like

© 2026 Cantinho do Vídeo - WordPress Video Theme by WPEnjoy