Search code examples
parsingprogramming-languageslexer

Understanding the inner workings of a programming language


Where would be a good place to start learning the inner workings of a programming language like C?
Would it be learning how a parser/lexer works?


Solution

  • No, not really. Parsing is only a small part of the complexity of a language, and not the most interesting part. Typing (for C, not such a big part either), optimization, code generation: those are the bulk of the compiler.

    The first step is to know the language well. Get a book such as The C Programming Language by Brian Kernighan and Dennis Ritchie (“K&R”). Do the exercises.

    Then you may find it interesting to learn how a compiler works.

    A good way of measuring your understanding of C is to read the standard. (This is not a tutorial!) See how much you understand. See if you understand why the standard does things the way it does.