DEV Community

Siddharth
Siddharth

Posted on • Edited on

27 6

Let's build a compiler!

Discontinued!

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!

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (2)

Collapse
 
freakcdev297 profile image
FreakCdev

Wow, just wow, this is so helpful!

Collapse
 
javacode7 profile image
JavaCode7

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

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay