I am curious about how to create a programming language based on JVM so I have tried to get some info online, but the information I got are quite fragmented. What I found are mostly information related to single technologies like ASM, Eclipse JDT, JFlex, etc, but what I would like to know are the main steps that need to be implemented and suggested technologies for these steps.

Any idea?

Well this question sounds quite broad but I started to think that is not like that. I kept looking up information online and you can get (relative easily) a basic customized language just using ANTLR (or alternative like JavaCC) used by Groovy mixing it with ASM (alternative BCEL or same Javac compiler). The first helps you to build the necessary grammar/parsing/AST and the second to generate the final bytecode once you got a successful parsing.

BTW from the same author of ANTLR I found this book that more and less is what I was looking for:


  • I don't think the question is too broad. It's actually an interesting question. It's not asking what tools to use etc, just the general process to create your language based on the jvm. An answer summarizing the code -> jvm bytecode -> jvm hotspot would be interesting, at least to me. – Florian Margaine Aug 31 '13 at 11:41
  • 1
    I think there is a good question here, but it needs to be scoped down. Voting to close as too broad because of "good answers would be too long for this format." Randomize, please share what research you have already done in this area and perhaps layout a framework of how you plan on approaching this. Those changes may help narrow the scope of your question. – user53019 Aug 31 '13 at 17:51
  • 1
    Are you referring to domain-specific languages? en.wikipedia.org/wiki/Domain-specific_language – CodeART Aug 31 '13 at 19:59
  • well I am referring to both, generic language and more specific as DSL. Anyway for DSL languages I know there is already Xtext that helps you to build your own dsl-language. – Randomize Aug 31 '13 at 20:07

1) specify a grammar for your language

2) write or generate code that parses to that grammar

3) build an abstract syntax tree

4) perform optimisations (optional)

5) compile to JVM bytecode. The JVM spec is here

| improve this answer | |
  • Join the jvm-languages summit (openjdk.java.net/projects/mlvm/jvmlangsummit) each year and make sure you talk to Charlie Nutter of JRuby fame or Ola Bini - they probably know the most about doing this. – Martijn Verburg Aug 31 '13 at 11:53
  • Note that everything up to step for is target agnostic and instead of generating JVM bytecode you could generate a high level language that compiles to bytecode (Java, Clojure, Groovy, whatever) and then just use the existing compiler for that language to get bytecode – Daniel Gratzer Aug 31 '13 at 16:33
  • 4
    Please, please never start designing a language with its grammar. Syntax is a least important part of a language. – SK-logic Aug 31 '13 at 21:56
  • @SK-logic you're going to have to expand on that – James Sep 1 '13 at 9:20
  • 1
    @James: If you design a syntax before you figure out what concepts the language will need to represent, you will likely find that it would be difficult to represent some things without creating ambiguity. If a language designer starts by figuring out what will need to be represented before assigning representations, the designer will be far less likely to get boxed into a corner. – supercat Jun 26 '14 at 1:34

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