In recent years we have seen explosion of languages which run on Java Virtual Machine. We also have seen existing languages getting their implementations being rewritten to JVM. With all of the above we have seen rapid development of tools like parsers, bytecode generators and such, even inside JVM we saw initiatives like Da Vinci Machine Project, which led to invoke dynamic in JDK 7 and recent development of Graal and Truffle projects.
Is it really hard to write new programming language running on JVM? Even if you are not going to write your own I think it is worth to understand how your favorite language runs undercover, how early decisions can impact language extensibility and performance, what JVM itself and JVM ecosystem has to offer to language implementors.
During session I will try to get you familiar with options you have when choosing parsers and byte code manipulation libraries. which language implementation to consider, how to test and tune your "new baby". Will you be able after this session to develop new and shiny language, packed with killer features language? No. But for sure you will understand difference between lexers and parsers, how bytecode works, why invoke dynamic and Graal and Truffle are so important to the future of JVM platform. Will we have time to write simple, compiled language?
Yes, we will, just to show you that even person who didn't studied computer science, compilers theory, and for majority of his life didn't know what AST is, can do it :)
1. The following presentation is provided under DHMB license
(Do Not Hurt My Brain).
Lecturer is not responsible for the financial and moral
damages resulting from taking too seriously the content of
the presentation.
Including permanent damage to neurons, reduction of
neurotransmitter activity at the molecular level and group
dismissal.
37. public class Literal implements ExpressionNode {
public final LuaType value;
public Literal(LuaType value) {
super();
this.value = value;
}
@Override
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
}
38. public class VariableName extends Var {
public final String name;
public VariableName(String name) {
this.name = name;
}
@Override
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
}
39. public class Assignment implements StatementNode {
public final Varlist varlist;
public final Explist explist;
public Assignment(Varlist varlist, Explist explist) {
super();
this.varlist = varlist;
this.explist = explist;
}
@Override
public void accept(StatementVisitor visitor) {
visitor.visit(this);
}
}
41. public void visit(Literal literal) {
result = literal.value;
}
public void visit(VariableName variableName) {
result = context.resolveVariable(variableName.name);
}
public void visit(Varlist varlist) {
List<VariableRef> refs = new ArrayList<>();
for (Var var : varlist.vars) {
var.accept(this);
refs.add((VariableRef) result());
}
result = refs;
}