An open API service indexing awesome lists of open source software.

https://github.com/cristianoliveira/javascript.js

Build your own simple Javascript interpreter in Javascript
https://github.com/cristianoliveira/javascript.js

Last synced: 7 months ago
JSON representation

Build your own simple Javascript interpreter in Javascript

Awesome Lists containing this project

README

          

# javascript.js

We will build a simple Javascript interpreter in pure Javascript. This was inspired
by two posts that I read recently that are [Let build a Pascal interpreter](https://ruslanspivak.com/lsbasi-part1/)
and [Build your own Lisp](http://www.buildyourownlisp.com/contents). The Ruslan's posts are really good I totally recommend it.
I will try to be as didactic as him in this repo. This tutorial will be based
on his. I hope he don't mind :)

You may have been asking why should I implement my own Javascript Interpreter. So
Steve Yegge can answer it:

>"If you don’t know how compilers work, then you don’t know how computers work.
> If you’re not 100% sure whether you know how compilers work, then you don’t know how they work."

if that phrase isn't enough to convince you to so let me tell why I recommend everyone
to try creating your own toy language or make an interpreter version of your favorite language.

1) You learn a lot about data structures and algorithms.
2) Demystifying things in software development is something that should be mandatory for any developers.
No one should use something that it at least knows a little how it works behind the scenes.
3) It's a nice side project. Did you know that Ruby started as a toy language by Yukihiro Matsumoto?
4) You understand how some of the design decisions of a language are made and probably why.
5) It's fun and you have all the freedom to decide how the language will look like.
There are a lot of languages with fun syntaxes out there. :)

This project doesn't intend to be a full featured Javascript Interpreter cause
it would take a life time in order to do it. I will try though implement some of the ES6 features just for fun.
By following this series of post you will understand more about how this things are implemented:

- [ ] Lexers and Parser.
- [ ] Integer declaration.
- [ ] String declarations.
- [ ] Syntax validation.
- [ ] Eval expression.
- [ ] Comparison.
- [ ] Variable Declaration.
- [ ] Conditional block.
- [ ] Loop blocks.
- [ ] Function Declaration.
- [ ] Global and function scope.
- [ ] Closures.
- [ ] First class functions.
- [ ] High order functions. (map, reduce)
- [ ] Array declaration.
- [ ] [Turing Complete](https://en.wikipedia.org/wiki/Turing_completeness)

Plus:
- [ ] How a language interact with the system.
- [ ] How a REPL works.
- [ ] Tests in Javascript.

[Let's getting started](https://github.com/cristianoliveira/javascript.js/wiki)