The evolution of Figma’s mobile engine: Compiling away our custom programming language
Figma migrated its prototype viewer's mobile engine from Skew, an in-house compile-to-JavaScript language, to TypeScript using a custom Skew-to-TypeScript transpiler and a three-phase rollout (write/build Skew, write Skew/build TypeScript, write/build TypeScript) that never paused development. The move became viable once mobile WebAssembly support let hot paths move to the C++ engine, removing the need for Skew's optimizing compiler. Transpiler pitfalls included slow JavaScript array destructuring (direct indexing improved per-frame latency by up to 25%), behavior differences from Skew's devirtualization that broke Smart Animate on null receivers, and TypeScript's initialization-order rules. Source maps were maintained so developers could keep debugging throughout.
Related posts
- Migrating a Large Flow Monorepo to TypeScript
Yelp Engineering mediumAdeptYelp migrated 1.4 million lines of Flow-typed JavaScript in a Lerna monorepo to TypeScript over three and a half years, converting one package at a time without ever bulk-disabling typechecking. Packages were converted bottom-up with flowts (later Stripe's flow-to-typescript-codemod), and flowgen turned the generated .d.ts files back into Flow headers so unconverted Flow code still typechecked against them. A dependency-graph importance score, Graphviz visualizations, auto-filed Jira tickets and quarterly deadlines kept the long tail moving. The result was 96.44% type coverage versus 83.15% under Flow, about 6,000 @ts-expect-error directives, and 82% of surveyed engineers reporting higher productivity. Early-2023 LLMs and cron-driven auto-conversion did not prove reliable enough to use.
- Figma rendering: Powered by WebGPU
Figma mediumAdept
Figma migrated its C++ renderer from WebGL to WebGPU while keeping WebGL as a fallback, first refactoring its graphics interface to pass draw-call state explicitly and to batch uniform uploads into a single buffer per submit to avoid performance regressions. Legacy WebGL 1 GLSL shaders are kept and automatically translated to WGSL via a custom shader processor plus naga, and Dawn is used for both the Emscripten/Wasm build and native server-side builds. Because WebGPU only supports asynchronous readback and can fail mid-session on Windows, Figma built a dynamic fallback that swaps backends to WebGL at runtime and blocklists devices by fallback rate. Benchmarks across Windows, Mac and ChromeOS showed gains on some device classes and neutral results elsewhere with no regressions, and compute shaders, MSAA and RenderBundles are next.
- Keeping Figma fast
Figma mediumAdept
Figma replaced its single-MacBook performance testing setup with two systems sharing one CI scheduler. The first runs end-to-end tests in headless Chromium on GPU-enabled cloud VMs for every pull request, finishes within 10 minutes through parallel runs, and uses a 20% pass margin to catch large regressions despite VM noise. The second is a small fleet of older real laptops for on-demand runs such as bisecting subtle regressions and benchmarking hot-path optimizations. Instruction counting and a full device farm were rejected because Figma's WASM/WebGL workload is bound variously by CPU, GPU and I/O. Case studies show the setup validating rendering time-slicing that prioritizes local edits over remote multiplayer changes, improving perceived frame rate on slow devices.
- How Figma draws inspiration from the gaming world
Figma easyNovice
Figma's architecture resembles a game engine more than a typical web stack: a C++ canvas compiled to WebAssembly for 2D rendering, a React/TypeScript UI layer, and a Rust multiplayer server, plus layered systems for multiplayer, animation, collisions, chat and plugins. Because these systems are interdependent, bugs cross boundaries; a layout change from six months earlier made FigJam connectors oscillate between clients, flooding multiplayer messages and overloading autosave. Making FigJam tables collaborative without locking required resolving concurrent edits and adding an animation system so observers can follow row and column moves.
- We Have to Start Over: From Atom to Zed
Zed easyNoviceZed's co-founders explain why they abandoned Atom's Electron/JavaScript stack and rebuilt a code editor in Rust: JavaScript's pointer-chasing arrays, uncontrollable GC pauses, and the costly JS/C++ boundary for multithreading made performance work feel like fighting the platform. Rust's ownership model pushed them toward a copy-on-write B-tree (SumTree) rope built on Arc, letting snapshots move to background threads in O(1), and high-level Rust code cut a find-all-matches operation from 1s to 4ms. GPU rendering with custom shaders and signed distance fields came out of necessity after Pathfinder proved too slow. Owning the stack (Tree-sitter, GPUI) lets them change anything, such as adding WASM language extensions, at the cost of building more themselves.