There is a lot of variety when it comes to the different types of programmers. In general, is beneficial for a programmer to learn how to build a compiler? In what cases would compiler programming be, or not be, needed?
Studying compilers enables you to design and implement your own domain-specific language. Compilers benefit tremendously from careful analysis of a problem, and from tools for performing that analysis.
In theory, a programming language can have both a compiler and an interpreter. In practice, programming languages tend to be associated with just one (a compiler or an interpreter).
Compilers analyze and convert source code written in languages such as Java, C++, C# or Swift. They're commonly used to generate machine code or bytecode that can be executed by the target host system. Interpreters do not generate IR code or save generated machine code.
I settled for learning things like Data structures, Algorithms and Programming techniques. But, cracking this book was a "goal" I have had in mind. Then, someone told about "Dragon book" (1986 edition) and my conviction that Compiler Construction is a difficult topic strengthened very much.
Compiler programming is an interesting topic and there is some great value to it. At the college I went to it was an elective, Language Design and Implementation. I'm personally grateful to have taken it. We learned the various ways to implement lexers, parsers, and bytecode emitters.
The real value that I've seen is that it illuminated the black box that I depend on to get my program up and running. It gave me a better insight into how the compiler works, and helped me better understand compiler errors.
The process of compiling source into code is actually in a general way what most programs do, take some input, perform some process, and output the result. A compiler has some very well-defined ideas on how this should best be done.
I think in all it was beneficial to me, and currently I work on Java based web apps.
I am in the process of reading through The Dragon Book (Compilers) and during the beginning of the book you are greeted with the following:
Although few people are likely to build or even maintain a compiler for a major programming language, the reader can profitably apply the ideas and techniques discussed in this book for general software design. For example, the string matching techniques for building lexical analysers have also been used in text editors, information retrieval systems, and pattern recognition programs. Context-free grammars and syntax-directed definitions have been used to build many little languages such as the typesetting and figure drawing systems that produced this book. The techniques of code optimisation have been used in program verifiers, and in programs that produce "structured" programs from unstructured code.
In short, you won't just be learning how to build a compiler. You'll be learning many different lower-level techniques along the way to assist you in everyday programming. Although some say it is a dated book I still enjoy it and I would recommend it, even though the reading can get a bit heavy. If you do get it leave a good amount of time to read it and understand it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With