newsfilter.io
Interview, Fireside Chat

Language Design with Leo White

  • Leo White, a compiler team member at Jane Street, entered programming language design after reading Benjamin Pierce's Types and Programming Languages, which shifted his focus from source-to-source compilation to language features.
  • White's entry into OCaml development began accidentally during his PhD; he added a custom language feature to OCaml to facilitate his C compiler work, a move that led to his recruitment by Anil Madhavapedi at OCaml Labs.
  • White notes that while language design is often driven by compiler writers, this does not inherently bias features against practical use, though OCaml is specifically optimized for writing compilers.
  • Programming language design is characterized as an intersection of pure mathematics (specifically type theory) and aesthetic design rather than a purely scientific enterprise driven by controlled experiments.
  • Controlled social science experiments to measure language effectiveness are deemed impractical due to the high cost and complexity of running long-term studies with professional developers on large projects.
  • OCaml is defined by three core characteristics: predictable performance, a strong static type system that shapes programmer habits, and a rigorous approach to modularity via interfaces and functors.
  • OCaml's modularity system enforces strict separation between implementation and interface files, forcing designers to consider abstraction and compositionality before adding new features.
  • White contrasts OCaml's modular approach with Haskell's type classes, noting that type classes are "anti-modular" because they allow ad hoc polymorphism definitions that can conflict at link time, breaking program compositionality.
  • To address the modularity flaws in type classes, White developed "modular implicits," a feature that allows ad hoc polymorphism to work across modules by removing the global uniqueness constraint on implementations.
  • Mathematical simplicity in language design is valued for reducing "sharp corners" and ensuring feature composability, a principle White argues has led to the unexpected utility of features like GADTs in non-compiler contexts like performance optimization.
  • Language evolution is often more challenging and rewarding than creating new languages because it involves overcoming technical debt, backward compatibility constraints, and the need for features to compose with existing ones.
  • OCaml has historically adopted features late but robustly, such as type inference and algebraic data types, waiting for other communities to validate concepts before integrating them.
  • Major mainstream languages like Go lack algebraic data types (variant types), a feature White considers fundamental and obvious, whereas languages like Rust and Swift now include them.
  • Backward compatibility creates significant friction in language evolution, exemplified by the 15-year struggle of the Python 2 to Python 3 transition.
  • Jane Street's goal for OCaml is to make it competitive with Rust and C++ for low-level, hand-tuned systems programming by improving control over memory layout.
  • Current OCaml limitations in systems programming include a rigid memory layout where every record element takes a full machine word (64 bits), even for small booleans or characters.
  • OCaml lacks native support for stack allocation with safe pointer passing, a feature required for high-performance zero-copy idioms common in C and Rust.
  • The OCaml type system currently lacks dependent types, which would allow properties like list length to be encoded directly in types, reducing the need for brittle type-level encodings used to model permissions (e.g., read-only vs. write-only file handles).
  • Jane Street operates as a major but non-controlling contributor to the open-source OCaml community, prioritizing collaboration and upstream review over forking the language.
  • OCaml's contribution process has modernized from patch-based bug trackers to a GitHub-based system with an RFC (Request for Comments) repository to facilitate early design collaboration.
  • Jane Street increasingly utilizes internal forks to experiment with risky features without compromising the stability of the main branch, though managing these forks against upstream changes remains technically demanding.
  • White identifies "Scheme-style extensibility" in typed languages as a "holy grail," currently limited by the difficulty of proving type soundness for external language extensions.
  • Macros in OCaml (inspired by Racket) enable compile-time code generation, transforming high-level data-driven descriptions into efficient, single-loop runtime code to avoid intermediate list allocations.
  • Algebraic effects are proposed as a mathematically simple, powerful abstraction to replace ad-hoc concurrency and control-flow features, effectively unifying async/await, generators, and coroutines.
  • Modular implicits and algebraic effects introduce implicitness into OCaml; however, White argues the design minimizes this by using a simple, file-scope search algorithm that errors on ambiguity rather than applying complex heuristic resolution rules like Scala.
  • White cautions that while powerful implicit features can be useful, their success depends heavily on library design discipline to prevent the system from becoming too difficult to reason about.