Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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:

http://pragprog.com/book/tpdsl/language-implementation-patterns

share|improve this question

closed as too broad by Telastyn, MichaelT, gnat, Corbin March, GlenH7 Aug 31 '13 at 17:52

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

    
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. –  GlenH7 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 Answer 1

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

share|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 –  jozefg 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
    
@James, a language is defined by semantics. Semantics should be derived naturally from the problem domain formal representation. Only this way a language will be useful and will fit its problem domain nicely. There is no place for a syntax in this chain. Syntax is always pretty arbitrary, and may even be omitted altogether. It can be added later, when your language compiler is ready. –  SK-logic Sep 1 '13 at 16:21

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