Why write your own language?

I recently wrote own little lisp implementation. Sometimes when I mention that, I get question “why did you do such a thing?” as a reply. My standard reply is “because some radio amateurs build their own radios”. I think the explanation sums up my reasons particularly well (probably much better than I initially thought even).

Getting the interpreter up and going was relatively simple and took only a couple evenings in the weekend. Even with such a short project, I learned a ton of things: how string is read and tokenized and eventually formed into a syntax tree, how that tree is then executed in a given environment, possibly resulting a new environment, how eval and apply relate to each other and so on. All these things that are behind pretty much every programming language and that I have been taking for granted for all these years.

It’s certainly true that apocrita isn’t anything special. There are tons of good lisp implementations out there that I could have chosen from. It doesn’t add any fancy features (although I have some ideas that I would like to try out in the future, just to better learn the mechanics behind them) either. But it did give me insight on what’s going on uneder the hood and satisfied a little of certain curiosity (I’m sure plenty of people like me liked taking things apart as kid to see what’s inside).

And it’s just exhilarating too write something completely new to myself, wrestle with the details a bit and then get it working. Programming certainly isn’t magic, but sometimes it certainly looks like it.

Advertisements

2 thoughts on “Why write your own language?

  1. Eight years ago, I wrote a tutorial on how to make your own programmer language. In part one, Motivations, I mentioned three reasons: because it’s fun, instructional, and potentially useful. Because you’re not just giving commands, but teaching the computer how to understand them in the first place. Because that gives you a better understanding of the big, serious programming languages you use day-to-day — too many programmers think compilers are magical, and that’s a terrible mentality. And last but not least, because small languages are everywhere, even in things we normally label as data, and understanding that can help us consciously design your own when needed.

    I never wrote a sequel, to my regret. But I did write other interpreters and compilers, learning more all the time. And I discovered surprising truths about things we take for granted in software development.

    • I read through your blog postings about scratch and played a bit with the online interpreter. That’s a really nice idea, because I could read about how the language was implemented and test out things at the same time. I agree with you that by writing an interpreter or compiler, one gets really intimate with computers and learns quite a deal of new things about them and software development.

      For me the biggest thing I learned was how relatively simple writing a language is (at least when you don’t have to design it). It doesn’t take much to get it to the point where one can start writing new things with it, wrap them into nice boxes and give meaningful names to them. And then repeat that again and again in order to build more complex thing. And all that rises from a simple core.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s