In this episode we looked at the three main phases each compiler implements - lexical analysis, syntax analysis, and code generation. For further reading you can follow the links:
welcome to the programming podcast. Here you can learn about computers in the brief and accessible way I'm your host. I mean could get hello. Everyone in and this is the first episode of the PODCAST. Old wants to talk about compilers. I picked specifically topic for first episodes. Not only because I think in that understanding how compilers work is essential for us as software engineers but also because I have so special history with them. In my computer percents -education I had two moments in which perceivable impossible tasks became possible. The first one of course was implementing my first pro. I was thirteen or fourteen year old. I entered my first class an informatics. That's how we Has In eastern Europe and I had to implement a program which sums to numbers provided by the user. Of course. This doesn't seem like a industry greats problem to solve but for me it was fascinating because I didn't believe that more tools like me are able to implement programs and sent instructions to the computer. The second point I had was in college. I had data structures class where we had amazing very sharp. Teaching assistant isn't in one of the exercises for trees. He said that's to help us understand the data structure better. We are going to implement an interpreter. Now here I'm seeing an interpreter. Not a compiler but compilers and interpreters they share a lot of counties so if you understand how an interpreter mature works. You'll be able to probably understand how a compiler works as well so the next exercise we were supposed to implement our first interpreter her. I couldn't wait. I really wanted to see how I can do that. I thought its compilers. They're viewed by only some special people in companies. Police like Google and IBM and nobody else will be capable of implementing Quan well. I went about thirty four minutes before my class I started waiting for a teaching assistant for my devastation. He'd either short. I was really frustrated and really disappointed. And and for my even further shock. He'll show up again in any of the classes until the end of the semester. Of course I he had his own personal reasons for that so I don't blame him but that was really disappointing for me. I started looking at different websites which had tutorials and lessons lessons of how to implement our own compiler finally after weeks of reading. I implemented my own interpreter in Johor. Its name was not long because it was on education language a language of the US to educate myself you can still find Jahnke gap at gathered dot com slash. Em Get jeff flush along now. Let us see how compilers can make us better. Software engineer first and foremost by understanding how our programs are being transformed and executed. We are going to become better. Software engineers will be able to write more efficient and better software second of although sometimes we have to implement tasks which share a lot of logic with some of the faces of compilers. There are a lot of examples for that. For instance a couple of years ago I was working on a startup brownie points which we ended suspending since Egypt. Find Market in Brownie points. I had to translate a bunch of mathematical formulas to html it was supposed to be a simplified filed version of tax so I didn't want to reuse their entire ecosystem. It was supposed to be something much lightweight. Of course. When I sold this problem I decided to use regular expressions and at this moment I already had two problems regular expressions? They don't work. Obviously so I went to implementing my own compiler our compiling these mathematical formulas to html. I spent a couple of hours till I find a Grammar Orleans. Talk about drummers just a little bit after I use an abstract syntax tree for going to discuss this in a bit as well and finally translated this abstract syntax tree to html html everything worked perfectly another very common example is when you have to enforce common style and Coding Practices Within Your Organization. I had to do that multiple times. We usually achieve this by using cold for matters or winters. Well call for mattress in linter.
We can either replace samples one two as part of the butte process or we can delay this and let the final user execute while Soi which is going to be redundant right they are never going to get a different result other than to so it might be more efficient to just replace samples twenty two and perform this process of partial arshile evaluation this source code optimization is part of the so called middle and now we have a front content which is responsible for reading Howard program and turning it into a tree we have a middle end just responsible for optimizing this program and finally of course we have eh back end on the back of the compiler rigging to perform a bunch of source code generation this just reversal of the tree and generation of serse colts which could be bite called some machines tractions or translation of the ast to a higher level language and that is how compilers work we made a very high level overview of the executions faces in compilers since we only scratched the surface. If you're interested in knowing more you could take a look at the list of references associated with this episode. Thank you see you next time. Learn learned about the episode's he can pull them to at Ham. Get you the list of horses and recordings is available at podcast dot M. dot com. Thanks for listening.