Git Product home page Git Product logo

compiler-book's Introduction

So, I'm writing a compiler book. Inspiration comes from this HN comment. Kudos also to Matthew Walton for thinking it'd be a good idea. ☺

These plans will most likely converge with bootstrapping 007 Alma, and successively building out the language and the compiler can be interwoven with explaining and building optimizations. The different compiler steps can even be used as realistic benchmarking targets.

The plan that falls out of that idea is something like this:

  • Variables and assignments
    • Constant folding
    • Constant propagation
    • Common subexpression elimination
    • Dead code elimination
  • Integers and strings
  • Control flow: if, while, and for
    • Basic blocks
    • SSA
    • Live variables analysis
    • Define-use chain analysis
    • Strength reduction
  • Subroutines
    • Inlining
    • Closures
    • Escape analysis
    • Lowering to local variables
    • Built-in functions
  • Register allocation
    • A naive allocator
    • Graph coloring
    • A linear allocator
  • Modules
  • Operators
    • Precedence and associativity
    • Built-in operators
    • Parsing user-defined operators
  • Classes and objects
    • Dynamic dispatch
    • Lowering to primitives
    • Scalar replacement
    • First-class subroutines
    • Garbage collection
    • Built-in classes
  • Meta-object protocol
    • Object and Type
    • Bootstrapping everything
  • Type declarations
    • Typed variables and parameters
    • Type inference
    • Interfaces
    • Generic types
  • Macros
  • JIT
  • ...
  • IDE errors and warnings (using the IntelliJ stack)

Material

I expect to delve deeply into the Dragon book, SICP, and Modern Compiler Design in order to learn more of the theory and practice of writing compilers. It'll be both a learning experience and a teaching experience. ☺

vendethiel suggested I have a look at this set of AST-based compiler optimizations. Looks very cool. Apparently there's a tool to see exactly what an optimization did.

This post about compiling a small example language to C is just incredibly clear and inspiring.

Here's a nice collection of links.

I found T3X, a nice small self-hosting language/compiler.

This book looks worth pursuing. So does this one.

compiler-book's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.