DEV Community

Cover image for 🤯 Wait... You’re building a code simulator?!
William McGonagle
William McGonagle

Posted on

🤯 Wait... You’re building a code simulator?!

If you’ve been following me on Dev.to for the last few months, your probably asking yourself- where have you been? Well, I’ve been busy running a non-profit and so haven’t had the time to write. Sorry!

But, we’ve been working on some cool stuff and through the next couple of days we are going to be sharing it- so stay posted.

What’s the code simulator?
We’ve been working on a system similar to Repl.it but we came upon a realization: we need to run the code that people write with our tool. So, how do you run code?

Most companies that do REPL (Read Eval Print Loop), just use code execution engines in the cloud. These engines are just monolithic computers with tons of programming languages installed on them. Whenever a language needs to be run, it just uses the language’s CLI on the machine. But, this requires an internet connection.

A large number of the people using our application won’t have an internet connection, and so we have to build the system to work for these people too. We could put an entire code execution engine onto their computers, but that would take up way too much disk space. So, the alternative is simulating the behaviors of each programming language.

The simulation is actually quite simple, we are just translating all of the code into a common Abstract Syntax Tree (a tree based way to store information about a program), and from there, we just interpret the Abstract Syntax Tree like it’s any other language.

Help if you can!
This sounds really simple in practice, but it’s not. And so, if you have any experience working with flutter, dart, or programming languages, we could really use some help. Feel free to check out the project and contribute!

Github URL
Irishman on Pub.get

Top comments (1)

Collapse
 
williammcgonagle profile image
William McGonagle

Feel free to drop a comment if you have any questions!