DEV Community

Cover image for I'm building a programming language
Syed Faraaz Ahmad
Syed Faraaz Ahmad

Posted on • Edited on

I'm building a programming language

A lot of people that talk about building their own programming language, have a lot of lofty goals for them. They want them to have this feature, that feature, to conquer the world and back.

Me? not so much. I'm building one just to learn how to do it "for real". Sure, I have some opinions about what features I would like more. I would use them as goals for the whole project, not just as design goals for the language.

So what are my goals, well...

  1. I want to build it using Rust: I've been trying to learn Rust for a long time now, and while I've learnt a lot, built a few side projects here and there, there's still a lot I don't know. So I thought, "Why not just go for it and throw myself in the deep end", and that's what I'll be doing. Using Rust to build the language and learn Rust as I move along.

  2. Truly experience how to build a compiler: Sure I've learnt how to do so at university, wrote some code for building automata etc. But nothing beats the experience of actually building it all on your own.

  3. Have a Lisp like syntax: This is really not a big deal. I've recently been diving into Lisp dialects and I like some concepts and some syntax in it, so I'll try adding some of those in my language.

  4. Be fast and support multiple platforms: I don't think there's much benefit building a programming language that's painfully slow to use. To make it fast I want it to be a compiled language (as opposed to an interpreted one), Rust also helps in this area as it is pretty fast. Since it's also going to be multi-platform, I will be using LLVM because I don't want to be dealing with any assembly code and optimisations yet.

  5. Be usable at every step of development: I will be gradually adding features, but I want every feature made to be able to show me some visible output.

Building an MVP

Like the image above, I want each step in the development process be able to take me from source code to program in some way or another. Instead of building perfect separate components like the perfect parser and perfect lexer that on their own cannot (obviously) get me from source to program. I want to build a lexer than kinda works and a parser that kinda works (and so on) which combined can get me from source code to executable program.

I hope I come out the other side, having a lot more knowledge in this area than I do now (which is really tiny).

see you around

See you around!

Top comments (17)

Collapse
 
jcubic profile image
Jakub T. Jankiewicz

My LIPS language project was also something simple at first (that's from where its name came from), it started as Codepen demo, after making it working, I wanted something more, so now my aim is to make it fully working R7RS Scheme, with mine extensions on top.

I hope your project will be usable (I would like to play with it), good luck on making it working. Don't forget to share the link if you will have something working.

Collapse
 
faraazahmad profile image
Syed Faraaz Ahmad

Wow! LIPS is so cool!! I didn't know you could put lisp in a browser like that. Thanks for sharing! And yeah i will sharing more articles as I progress with my project

Collapse
 
faraazahmad profile image
Syed Faraaz Ahmad

I have a working example here now: github.com/faraazahmad/tisp

Collapse
 
610yesnolovely profile image
Harvey Thompson

Lisp is an excellent choice for learning about building programming languages. LLVM is another excellent choice for doing a lot of the tricky backend stuff for free so you can concentrate on other things. Lisp also is much easier to follow the lower path in that diagram. Welcome to the land of designing and building programming languages!

One challenge for you with your Lisp - how few data types and functions in the Lisp language you're building can you get away with and still have something useful? Technically speaking I think the answer is one (see lambda calculus), but practically I think somewhere in the range 10 to 15. Another one is how small can you make the first program? I think somewhere around 100 to 200 lines?

A gem of a book, not well know, that you may be interested in:

amazon.ca/Programming-Languages-Sa...

Although this discusses how to build interpreters, it was the book that inspired me to get into this field as a hobby/side-project ... well... a long time ago.

Collapse
 
faraazahmad profile image
Syed Faraaz Ahmad

This is amazing! Thanks a bunch!

Collapse
 
davidedelpapa profile image
Davide Del Papa • Edited

Hi! Maybe as reference you could take a look at this good article by Ben Lovy and the C book it refers to.

dev.to/deciduously/rust-your-own-l...

I remember reading this when it came out, and thinking "maybe i could give it a shot"... But then I never found occasion. Take a look and see if it might help you!

Keep us updated if you want to share with us where this journey takes you to!

Collapse
 
faraazahmad profile image
Syed Faraaz Ahmad • Edited

That's amazing! I didn't know that existed. I'll definitely be stealing some ideas from there haha.

I'm working on the next article and I'll post it very soon

Collapse
 
braydentw profile image
Brayden W ⚡️

It might be too early, but any name ideas ;)

Collapse
 
faraazahmad profile image
Syed Faraaz Ahmad

I'm thinking Typed Lisp, aka Tisp

Collapse
 
braydentw profile image
Brayden W ⚡️

Cool!

Collapse
 
hilariocunha profile image
Hilário Cunha

Hi.
I'm more or less on the same journey, of learning more about programming languages construction.
Started implementing some mini-languages to implement parts of code used in some clients projects.
Now i am exploring language-oriented programming using language workbenches (en.wikipedia.org/wiki/Language_wor...).
I'm starting with mps of jetbrains (jetbrains.com/mps/).
Depending on your goals can be a path worth exploring.

Collapse
 
faraazahmad profile image
Syed Faraaz Ahmad

Wow that's really interesting! Thanks for sharing. Also, all the best!!

Collapse
 
tvinko profile image
Tomaž Vinko

nice, would like to play around with your language

Collapse
 
faraazahmad profile image
Syed Faraaz Ahmad • Edited

I have a working example here now: github.com/faraazahmad/tisp

Collapse
 
faraazahmad profile image
Syed Faraaz Ahmad

Hopefully I can get a working demo up and running soon

Collapse
 
seanolad profile image
Sean

nice dude 😎

Collapse
 
faraazahmad profile image
Syed Faraaz Ahmad

Thanks!!