Create a programming language for the JVM: getting started to welcome the Turin programming language

Because you know, in the end everyone wants to create his own programming language.

I have been interested in parsers and languages for a while. I worked with Xtext, Jetbrains MPS, created a few DSLs etc. etc. I also wrote my PhD thesis on this topic but so far I did not get started creating a complete programming language from scratch.

Why creating a new language?

Well, there are many wrong answers to this question. Mine is divided in two parts: first, I think it can be a great experience to learn a few things more, and second, a programming language is for me a tool to look at reality, describe it and reason about it to understand it better. Laugh if you wish, but for me it is mainly a tool for thinking. Often it is a clunky tool because I get distracted by technical workarounds or details which are hardly relevent or important for what I am trying to do. For example I am getting tired of clicking here and there to generate equals and hashCode methods (yes, I know about Lombok and some other tricks).

Ok kid… but to make a language usable you need a lot of stuff

I think now the barriers to create a programming language and make it usable by sane persons are significantly lower than they used to be. I think that a language needs a great syntax & semantics, sure, but also a large amount of libraries and decent tool support.

To get libraries just make it run on the JVM. Really. If it runs on the JVM you can reuse a gazzillion of libraries. Your programming language get batteries included. Consider also deployment: I am fascinated by many languages but every time I try to deploy something outside the JVM I end up regretting it. Ask my co-maintainer of WorldEngine (a python program) how much fun is to support libraries on Linux, Mac, Windows, across Python versions. A lot of fun.

Of course you need also tool support: it means to me mainly a nice editor and good integration with the platform of reference. I have an advantage here because I have experience developing IDE plugins and I just ended writing a type solver for Java. In addition to that I contribute to JavaParser. So I know a thing or two about tools that I could use down the road for the integration with Java.

In practice I plan to:

  1. Create a plugin for IntelliJ which is aware of references to file in my language and to Java files. The nice thing is that basically I wrote the libraries for doing that already.
  2. Create a Maven plugin because Maven is awful, but life without Maven is even more awful
  3. Write a parser with ANTLR (that’s the easy part)
  4. Write a bytecode generator with ASM (what a great library!)

Ok tell me more about this language

I just started working on it but… I have a basic compiler working and supporting a few constructs.

The language is named Turin like my hometown and it is available on GitHub:

It is a static language with type inference and this is an example of a piece of valid code that can be already compiled and run:

So I have a plan, I have something working already and I am having a lot of fun.
Could be idiotic, perhaps, to write yet another language but damn… it is so much fun!


  1. Because you know, in the end everyone wants to create his own programming language.
    That’s what I was thinking when I read the post title!! 😀

    it is mainly a tool for thinking.
    I agree with you. Although I don’t use DSLs, I think that’s the point behind them; to express thoughts more clearly right?

    It’s good you mentioned the points about Intellij and Maven because I have this question on my head: does it my work with the tools I already use? For me that would be Intellij and Maven.
    If a language doesn’t have good tool support, then it’s a deal breaker for many of us. It’s good that you appreciate that since the beginning.

    The language is named Turin like my hometown
    Well, you could have chosen the Italian name for it 🙂

    we define this property in generale: a name is a String with property String : name
    Hmm, interesting idea! Were you inspired by an existing language for that?

    It is a static language with type inference
    OK, I have a question: what would be the main programming paradigm in it?

    You mentioned the symbol solver:
    I suppose you are going to blog about it. I had a quick look at it and I must say that the benefits of it are not clear to me.


  2. Thanks Jeshan, very interesting comment!

    Yes, I think we need to be practical and I am already started working on the IntelliJ plugin (basic highlighting and error recognition) and the maven plugin (mvn compile & mvn exec:java and you have an application up and running).

    About the Italian name I was not sure, anyway Italian names seem to hard to pronunciate for non native speakers and Turin remembers Turing.

    About having properties as “first class citizen” I was thinking about duck typing and about ontologies. In duck typing you basically says that if an object has a method named “quack” then it is a duck. The problem is that the same name can have more meanings in different context, so I think we should be more explicit. I was thinking that we can have very general definitions and then we could define operations on everyone having those properties. Simple example: I create the property name and then I use it in several types. Later I could create the method toString for all types having name something like:

    property String name

    T.toString = “My name is #{name}”

    I was also inspired by ontology languages (like the ones used for DBPedia, the computer readable version of Wikipedia) which uses very general definition, such as “a name is a String”.

    The main paradigm will be Object oriented programming, but I would definitely want to support passing functions around things like currying (partial applications of functions).

    The symbol solver is useful when analyzing java code because it permits you to find who is using a certain method or the type of an expression. Example:

    class A {
    void foo(Object o);
    void foo(String s);

    A a = new A();; // what method is this? Depends on the type of b

    by calculating types I can find which methods are call where and I can analyze those calls or I can perform refactoring. In this example if I wanted to rename the first method foo I would now if I need to change or not.

    Definitely I type solver is not that useful per se but it is fundamental for building other tools, like mine effectivejava (

    This discussion will merit 2 or 3 posts 😀

    Very nice questions, feel free to write again!

  3. Pingback: Turin Programming Language for the JVM: building advanced lexers with ANTLR | Federico Tomassetti – A Software Engineer's blog

  4. Pingback: Turin Programming Language for the JVM: Building Advanced Lexers With ANTLR -

Leave a Reply

Your email address will not be published. Required fields are marked *