I want to try to create my own very simple programming language and it's compiler or interpreter.

The programming language I use is Java.

My idea was to create a compiler which will compile source code of my created language to some kind of intermediate code (nothing binary or complex, just plain text), and then have another program (a kind of virtual machine or interpreter) which will execute this intermediate code in Java.

For example, the 'programmer' types: write "hi world". The compiler turns it to some intermediate code like w-hi world. The VM/interpreter program reads this intermediate code and executes System.out.println("hi world");

My question is:

Is this approach common with programmers who want to try to create a simple language for the first time? Is this a good way to start?

I searched this site and came across questions on this subject, but the answers were more complex and technical than what I'm looking for.

  • $\begingroup$ Sure, why not. Though if you stopped at interpreter, you wouldn't need to worry about storage at all. $\endgroup$ Commented Mar 8, 2014 at 17:04
  • $\begingroup$ @KarolisJuodelė Yeah, the idea is to only try designing a language, intermediate code, and executing the intermediate code using a high level language. I want to spare myself the low-level stuff for now. $\endgroup$
    – NPElover
    Commented Mar 8, 2014 at 17:27
  • 2
    $\begingroup$ there are many simple/"toy" compilers out on the internet, it might be worth researching/studying them. eg one for Turing machines $\endgroup$
    – vzn
    Commented Mar 8, 2014 at 17:27
  • 4
    $\begingroup$ "more complex and technical than what I'm looking for" -- building a language and a compile is a complex and technical undertaking. Better get used to it. $\endgroup$
    – Raphael
    Commented Mar 9, 2014 at 18:04
  • $\begingroup$ Adding to @Raphael's answer, you'll also inmerse yourself in the complex and technical bits of Stack Overflow. $\endgroup$
    – vonbrand
    Commented Mar 10, 2014 at 16:45

1 Answer 1


That sounds like a fine way to start, and you'll become familiar with the issues involved.

How's it going?

At a certain point, consider learning more about programming language implementation techniques from

It's also worth investigating libraries to use such as parser generators, although some people swear by the recursive descent parsing approach as easier to build, also good at generating helpful error messages.

Another tip: It's easier to implement a programming language in a language like Clojure than Java. (Clojure is a modern Lisp dialect that's hosted on Java.) E.g. your intermediate representation could be a list of Clojure forms. They handle reading & writing as readable text, and you can construct & interpret (eval) them quicker and easier than text.

  • $\begingroup$ It would probably be a mistake to use a language that has high level primitives which make the job trivial, such as Scala, since then you won't have learned anything from the exercise... $\endgroup$ Commented Sep 22, 2021 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.