AI summary by TwinMind

JS At The Speed Of C

Theo - t3․gg

27m 54s

JavaScript Performance Limitations

  • JavaScript isn't fastest language by quite a bit
  • Performance issues in:
    • Processing lots of requests (non-serverless)
    • Video encoding
    • Game development
    • Complex animations
    • Crypto hashing/Bitcoin mining

Static Hermes Overview

  • Next version of Hermes JavaScript engine developed by Meta
  • Code-named "static Hermes" - open on GitHub since day one
  • Main innovation: optional ahead-of-time compilation of JavaScript to native code
  • Goal: combine predictability/high performance of C with JavaScript usability
  • Partnership with Amazon for TypeScript support (Meta uses Flow internally)

Technical Architecture

  • Not for entire app compilation - selective optimization
    • Choose specific parts needing maximum performance
    • Rest continues using Hermes bytecode
  • Relies on sound types for native performance
  • Modifies some JavaScript semantics to enable efficient sound typing
  • Runtime types guaranteed to match type annotations
  • Completely safe by default - no native crashes

Performance Benchmarks

  • nbody JS benchmark results:
    • Initial: 550ms (same as Hermes)
    • Static Hermes: 10x faster performance
    • Potential for 20x faster than Hermes
  • Before: dozens of instructions per loop line via interpreter
  • After: 6 assembler instructions for first two loop lines
  • Most calculations performed in parallel by single instruction
  • Performance close to C code

Demo Implementation

  • JavaScript code calling C++ game library (Dear ImGui) and 3D backend (Sokol)
  • Imperative game UI library rendering meshes
  • 100% compiled native code JavaScript
  • Entire UI state recreated every frame
  • Performance comparison:
    • 120 Hz on MacBook
    • 60 Hz on old Motorola G5 phone
  • C++ and JavaScript versions run with same performance
  • ~1000 lines of JavaScript code with static Hermes built-ins

Current Status & Limitations

  • Work in progress - not suitable for general use
  • Only for extreme hackers/enthusiasts currently
  • Not easy to use, many things broken
  • Encouraging results but still experimental
  • Team actively working on improvements
  • Community feedback desired

Technical Implementation Details

  • Uses type information to generate efficient native code
  • Dynamic code (number or string) vs static optimizations
  • Sound types prevent runtime type mismatches
  • Foreign Function Interface (FFI) for native library access
  • Portable across all platforms
  • ARM64 assembler output with minimal instructions

Comparison with Other Solutions

  • Similar to Go's Arenas feature for specific memory management
  • Selective performance optimization vs rewriting everything
  • Flash List library example for React Native performance improvements
  • Shopify's shop.app performance achievements using React Native

TwinMind

Get summaries like this for your own meetings

TwinMind takes notes in the background during meetings, lectures, and calls, then writes the summary for you.

Free plan to get started

No bot joins your calls

Phone, desktop & Chrome apps

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome

Your next meeting, summarized like this

TwinMind listens in the background and turns meetings, lectures, and calls into searchable notes you can chat with. Start free.

Available on phone, desktop & Chrome