TechnicalDiscussion

Should programmers learn how to code in assembly? | Lex Fridman Podcast

Lex Clips

Experts from the FFmpeg/VideoLAN community discuss the value of learning assembly language programming, critiquing traditional teaching methods and advocating for problem-focused learning. They also debate Rust's merits and limitations, particularly in the context of existing high-performance codebases. Notable assembly wizards Henrik Gramner and Martin Storsjö are highlighted as exemplars of the craft.

Summary

The conversation opens with Kieran criticizing how assembly is traditionally taught — through grammar-focused instruction covering every instruction — rather than through practical, problem-solving approaches. He draws an analogy to learning a spoken language, arguing you learn by communicating, not by studying sentence structure. He describes assembly as a 'dying art' passed down person-to-person like blacksmithing, which doesn't scale, and explains his ASM-lessons project aimed at teaching assembly in the FFmpeg style, focused on vector operations and real problems, requiring only high school math and knowledge of C pointers.

The discussion touches on LLMs and their limitations in helping with assembly, noting there isn't enough assembly corpus online for models to train on effectively, leading to hallucinations and incorrect optimizations. One speaker shares his background doing assembly for the Itanium processor, which had extreme computational power but a memory bus bottleneck — a challenge no high-level language could address — illustrating why deep assembly knowledge matters.

The x86inc framework by Laurent is mentioned as enabling broader contributions, including from students who submitted patches to X264 after studying the lessons. The speakers argue that understanding assembly helps programmers understand memory architecture (registers, L1/L2/L3 cache, RAM, SSD), making them better programmers overall.

The conversation shifts to Rust, where the speakers have divergent but nuanced views. One finds value in Rust's memory safety model and considers it a better C++ for new projects, particularly for parsing and networking. However, both agree Rust is poorly suited for integrating into existing complex codebases, and the 'rewrite everything in Rust' mentality is criticized. A key technical point is raised: even if C code is rewritten in Rust for security, handwritten assembly (necessary for performance) breaks the security model entirely since assembly can jump anywhere in memory. A proposed solution is compile-time instrumented 'secure assembly.'

The transcript closes with praise for two assembly wizards: Henrik Gramner, who knows Intel x86 SIMD instruction cycles across CPU generations so well that Intel engineers defer to him, and Martin Storsjö, an ARM assembly expert who reportedly writes assembly on his phone while watching his kids at the playground. The speakers note that x86 assembly, due to out-of-order execution, is more forgiving across variants, while ARM requires understanding many distinct processor generations and Apple-specific variants, making it a more complex target.

Key Insights

  • Kieran argues that assembly is traditionally taught the wrong way — grammar and instruction-first — analogous to learning a language by studying sentence structure rather than by solving real communication problems, which is why his ASM-lessons project takes a problem-focused, vector-operations approach instead.
  • One speaker argues that even if C code in a project like H.264 is rewritten in Rust for memory safety, the security model is entirely broken the moment handwritten assembly is introduced, because assembly can jump anywhere in memory — suggesting 'secure assembly' with compile-time checks is the real solution needed.
  • Kieran characterizes Rust with a 'very big Esperanto vibe' — too utopian and self-important, reminiscent of the Sinclair C5 electric car, arguing that to get adoption it needs to be as good as or better than existing solutions, not just promise a safer utopia, and that it isn't at that stage yet.
  • One speaker explains that it is an order of magnitude easier to write code than to read code, which is why developers arriving at complex codebases instinctively want to rewrite rather than understand — and this phenomenon is visible even in LLMs, which can generate code more easily than they can analyze it.
  • Henrik Gramner is described as knowing Intel x86 SIMD instruction cycle counts across nearly every CPU generation so thoroughly that Intel engineers themselves direct questioners to him rather than answering, and Martin Storsjö is said to write ARM assembly on a virtual phone keyboard while watching his kids play at the playground.

Topics

Assembly language learning and teaching methodologyASM-lessons project and FFmpeg assembly optimizationRust programming language merits and limitationsLLMs and assembly code generationARM vs x86 assembly complexity

Full transcript available for MurmurCast members

Sign Up to Access

Get AI summaries like this delivered to your inbox daily

Get AI summaries delivered to your inbox

MurmurCast summarizes your YouTube channels, podcasts, and newsletters into one daily email digest.