Here is an open secret in web development that most people are afraid to say out loud:
You donβt need a 300KB physics library to simulate gravity. You donβt need a 1.2MB 3D engine to render a rotating torus knot. You just need high school vector math and a Float32Array.
When Yusuf and I set out to build the sandboxes on this site, the temptation was obvious: npm install three matter-js tone. That is what every modern tutorial tells you to do.
We said: absolutely not.
The Cost of Abstraction
Every layer of abstraction in the browser comes with a tax:
- Garbage Collection Spikes: High-level libraries allocate new objects on every frame (
new Vector(x, y)). The JavaScript engineβs garbage collector pauses execution for 16 milliseconds to clean up memory, causing noticeable frame drops and jank. - Bundle Bloat: A single 3D scene shouldnβt require your mobile phone on a 4G connection to download 2 megabytes of JavaScript before anything renders.
- Black Box Bugs: When something goes wrong in a massive framework, you spend 3 hours digging through minified source code instead of fixing your equations.
The TypedArray & Raw WebAudio Superpower
Look at how our Eulerian Fluid Dynamics simulation runs:
// Pure contiguous Float32Array memory layout
const size = (N + 2) * (N + 2);
const u = new Float32Array(size); // Velocity X
const v = new Float32Array(size); // Velocity Y
const dens = new Float32Array(size); // Dye density
Because the memory is allocated once at startup as contiguous typed arrays:
- Zero GC allocations per frame.
- Direct cache-friendly memory access.
- 60 FPS guaranteed on almost any laptop or phone.
The same rule applies to our 8-Bit Chiptune Tracker and Optical Theremin. We talk directly to the browserβs native AudioContext, routing oscillators to biquad filter nodes and delay lines with microsecond timing precision.
The Joy of Raw Craftsmanship
Writing raw code gives you a level of intimacy with the platform that frameworks will never provide. You actually understand why the double pendulum diverges, how Jos Stam solved fluid pressure Poisson equations, and why 16-QAM constellation points scatter under line noise.
Next time you build something on the web, try skipping the heavy npm install. Write the math. Respect the userβs CPU. Zero jank is the ultimate luxury.