What Are Some Good Starting Points to Learn What I Need to Write My Own Toy Language?
Chad Windham

Chad Windham @vitalcog

About: I'm a web/app developer with way too many opinions and way too little experience. I also like people a lot more than I like computers.

Joined:
Jun 5, 2018

What Are Some Good Starting Points to Learn What I Need to Write My Own Toy Language?

Publish Date: Aug 10 '18
26 12

image of scratch code in action
So, I asked this question in the comments section of somebody else's post. Then I realized, if I turn my question into a post it may reach a larger number of people! So below I have shamelessly copy pasted the question verbatim. LEND ME YOUR BOTTOMLESS WISDOM DEV.TO COMMUNITY!

So I'm pretty new to the development world. But ever since I started I've wanted to make a toy language of sort as a side project/learning experience. Do you have any advice on how to get started with that? I'm pretty limited on the computer science side of things. I'm an active web developer with experience of only high level languages (both interpreted and compiled). I plan on getting an Arduino simply to play with some Assembly code. I've read the book Code: the hidden language of computer hardware and software and more or less understood the information it presented. (Sometimes much closer to the less side of things...). I became a web developer via a boot camp. And while it was great and did give me the chance to acquire the skillset to jump directly into the workforce. There is SO MUCH MORE I WANT TO DO AND LEARN! The two primary things I want to accomplish in the near future are:

  1. - Write a toy language
  2. - Use relays to create a 4-bit adding machine called "The Nybbler" (get it?)

Learning how to do stuff Rick and Morty style

I'm not somebody who sits around with a bunch of pipe dreams. When I want to do something I go and I try to do it. So if anybody has some good starting point advice on making a toy language. It would be very, very appreciated.

Here is the article that inspired the question BTW...

Comments 12 total

  • Dávid Szabó
    Dávid SzabóAug 10, 2018

    Good. You are on the right path mate. I have my own toy language too: github.com/david-szabo97/DevLang
    You might take a look at it how it works.
    You can find comments,tests and examples in the Main.java

    You get started by doing some Google searches. Keywords: interpeter, compiler, parser, lexer, opcode, virtual machine.

    I used to read a blog series to put together my own language.
    Maybe this one: aosabook.org/en/500L/a-python-inte...
    But I am not sure anymore. It was 2 year ago :)

    Good luck!

    • Dávid Szabó
      Dávid SzabóAug 10, 2018

      I also have some special feature in my toy lanuage: (I have no idea how I did it, my lang contains some secrets.)


      for (i = 0; i < 5; for (j = 0; j < 5; j = j+1) {print('j')} i=i+1) {print('i')}

      Yes, that's a for in a for.

    • Chad Windham
      Chad WindhamAug 11, 2018

      Thanks! The link to the python interpreter is great actually! Also appreciate the keywords list

  • Graham Lyons
    Graham LyonsAug 11, 2018

    This isn't necessarily your own language but it might be good to get you started: buildyourownlisp.com/

    It'll certainly be a good introduction to all the required parts and doubtless you could adapt and extend it once you've got a handle on it. Plus, Lisps are super cool.

    • Chad Windham
      Chad WindhamAug 11, 2018

      WOW! That looks borderline perfect actually! Thankyou

  • Kamal Mustafa
    Kamal MustafaAug 11, 2018

    I collected some links here metak4ml.blogspot.com/2017/06/how-...

    • Chad Windham
      Chad WindhamAug 11, 2018

      That is a really useful collection! Will take some time to read through but looks super helpful for what I need. I appreciate it!

  • Chad Windham
    Chad WindhamAug 11, 2018

    I'm really impressed with how helpful everyone has been on this. I went from not knowing where to start to having almost too much good info to sort through just from 3 responses! Thank you everyone for you help!

  • Liana Felt (she/her)
    Liana Felt (she/her)Aug 11, 2018

    It really should ping @mortoray right when the post is embedded. If only someone would have written that feature. 🤔

  • edA‑qa mort‑ora‑y
    edA‑qa mort‑ora‑yAug 11, 2018

    Maybe I should write up my experiences with various languages, the ones that built to Leaf. Get some final value out of that project of mine.

    • Chad Windham
      Chad WindhamAug 12, 2018

      Seems legit. I for one would appreciate it. And I'm sure a ton of other up and coming devs would too.

  • Casey Brooks
    Casey BrooksAug 14, 2018

    I just started down this road myself! There's some great links and advice here already, I'll definitely be following along for more!

    I've started my journey in writing compilers by first understanding how to write a good parser. I'm writing it all in Kotlin as a combinatorial Recursive Descent Parser (inspired by Haskell's Parsec, and some work I did in college), and have the parser and base functionality of evaluating an AST complete. My next step is parsing complex expressions, and then putting it all together into a toy language.

    copper-leaf / kudzu

    A monadic (I think...) recursive-descent parser written in Kotlin

    Kudzu


    A monadic (I think...) recursive-descent parser written in Kotlin

    Build Status Codacy Project Grade Code Coverage

    Kudzu is a recursive-descent parser written in Kotlin, with the goal of immutability and simplicity. It is mostly an exercise for me to learn more about parsing algorithms, but should work reasonably-well enough to be used for small non-trivial parsers.

    Why did I write it?

    I've got several projects which require custom parsing, and after looking around at the various options available in Java and Kotlin, I've decided that I would just rather write my own. Most of the ones I found either require Java 8 (a deal-breaker if I want to use it on Android), or I found them to be very complex to use, being intended for writing full-blown, high-performance compilers. I needed something simple, and I also wanted to learn how parsers work, so I decided to make my own.

    This library is a parser combinator like…

Add comment