Anders Hejlsberg - Compiler Construction The Modern Way |
Written by Mike James | |||
Sunday, 15 May 2016 | |||
What you are taught as the theory of compiler construction in computer science is simply out of date. See what Anders Hejlsberg has to say on theory versus practice. If you have done a course in compiler construction, or just taken an interest in how it is done, you probably have read a classic book or two. Anders Hejlsberg was classically trained too, but he went on to actually write compilers and now thinks that what you are being taught in school is at best out of touch with modern practice. He claims that: "there is a huge gap between the way compilers are taught in school and the way compilers are implemented nowadays." The way compilers are taught today hasn't changed much in 30 years, mostly because of the dominance of a particular book - Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi and Ullman. To most students and teachers it is simply known as the Dragon Book. (The one in the video is the first edition and usually referred to as the Red Dragon Book.)
What Anders explains is that the monolithic design of the compiler has had to give way to a more flexible approach that allows the user to interact with the code even if it is incorrect. Instead of having a compiler do the job of converting the code to abstract syntax trees, and on to binary and dying at the first error, the compiler is broken down into components that can be used to provide information within the IDE about errors, statement completion and so on. The trick seems to be to keep everything "live" and only build the syntax tree for the code in the file that the user is working on. What is the core of this approach - in a word "functional programming". To build systems that are lazy and reuse results you seem to need a functional approach. The big example is, of course, the Rosyln compiler for C#, but the TypeScript compiler is also mentioned. And if you remember Turbo Pascal, another Anders compiler, then you will like the reference to the entire compiler (including an editor) fitted into 32K.
One sound bite of choice: "Compilers for tooling not compilers for code generation" If you watch to the end you might well think that it all sounds much messier than the traditional approach. The standard approach to compilers is so much more "academic" and pure than the style that Anders described. So is it time to dump the dragon book? Only if Anders, or someone with as much experience, writes a replacement that can be taught in an academic environment without the teachers having to have spent a life writing real world compilers. For now, read the dragon and study Roslyn.
More InformationRelated ArticlesMicrosoft Team Explains Language Stagnation TypeScript Fully Accepted into Visual Studio Getting Started With TypeScript
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, Facebook, Google+ or Linkedin.
Comments
or email your comment to: comments@i-programmer.info <ASIN:0321486811> <ASIN:1292024348> <ASIN:B00IZ0FXX6> |
|||
Last Updated ( Sunday, 15 May 2016 ) |