DEV Community


Posted on • Updated on

Let's build a compiler!


Sorry, but I made too many mistakes while teaching this tutorial and so I have decided to discontinue this series

Let's build a super simple compiler!

In this series, I am going to show you how to build a compiler. This post is going to contain all the metadata for this series, and the next post onwards will explain all the concepts and stuff.

Why should I care?

  • There are tons of compilers around you, and many important concepts can be taken from them. What I cannot create, I do not understand
  • It's a fun side project (my reason)
  • You might create a simple language which is faster to code in than javascript and save some time!

But they seem scary!

According to the super tiny compiler

Yes, they are. But that's our fault (the people who write compilers), we've taken something that is reasonably straightforward and made it so scary that most think of it as this totally unapproachable thing that only the nerdiest of the nerds are able to understand.

Ok Ok, I'm in, what exactly are we building?

We are going to build a compiler (basically a function which takes a string as input). The compiler compiles english like syntax into javascript. So if we:

Had to... We would...
Declare a variable let the variable variableName be 12.

This may seem like nothing, but it is enough to show how a compiler works and its major parts. Edit: I *will* stop on this compiler after showing you the first part because I got an idea for another compiler

That's all for now, see you in the next part!

Top comments (2)

freakcdev297 profile image

Wow, just wow, this is so helpful!

javacode7 profile image

I can't wait for the next in the series.