I went to a job interview last week, I was asked why would I design my own compiler. On anwsering this question, I was a bit perplexed myself. Why would I do that? When I answered, I replied that the main idea is to learn compiler specific skills. There are some skills that are applied to specific problem. When trying to explain what those skills were, I was on a loss of words.
So after pondering a bit, I decided that it was neat to read something that would explain why building a compiler would be useful for me. After some time, this text provided by our teacher seems to nail it in the head. Let's dive into it.
The first skill I've ALREADY learned is the way of the Regex Master. Using Regex for separating different kinds of tokens is really Important to use. You can build small transpilers for languages using the find and replace section in different text editors. Nevertheless, It is one skill I’m eager to learn and exploit in the way of compiler design. In the article we get the examples of making a LaTex transpiler to HTML, which also adds the novelty of validating the syntax of a particular language to transpile.
Going one step further, natural language processing could be another way of using compilers tools to generate computer instructions, so it is interesting to notice that even trivial stuff like natural language processing can be learned from learning how to do compilers.
Last, but not least, we can see some different uses in having code generation as part of our toolchain, Imagine a situation where we have to generate a meta-compiler which allows you to generate code from code. A good way to do it is to generate an AST, and then trasverse it backwards, but you can only know that when learning compilers. I encourage you all to try it out sometime now.
[1] Debray, Samuya. Making Compiler Design Relevant for Students who will (Most Likely) Never Design a Compiler“. Retrieved from http://webcem01.cem.itesm.mx:8005/s201811/tc3048/making_compiler_design_relevant_for_students.pdf