SlideShare a Scribd company logo
.com
How do you create a
programming language for the
JVM?
Federico Tomassetti
Hi, I am Federico
!Got a PhD in Language Engineering
!Lived here and there
!Now for a living I:
Ora sono un
Language En
Progetto e co
! Parser
! Interpr
! Compi
! Editor
strumenta.com
• Create languages
• Write parsers
• Transform code
• Build compilers
Why creating languages?
The language or notation we are using
to express or record our thoughts, are
the major factors determining what we
can think or express at all!
Edsger W. Dijkstra
The Humble Programmer
strumenta.com
Motivation
strumenta.com
Build Domain Specific Languages
To support domain experts or to support working on a very specific
kind of applications
Build your very own programming language
When you want to program differently, because you can think you can
do things better or just because having your own language is a lot of
fun and something to be proud of
Why targeting the JVM?
strumenta.com
•Performance: the JVM can perform optimisations
through dynamic analysis and even outperform native
code

•Libraries availability: whatever you want to do, there
is a library for it 

•Platforms supported: the JVM runs in a ton of places
State Machine
Turned off Turned on
Low speed High speed
EmergencyStop
IncreaseSpeed
IncreaseSpeed
LowerSpeed
LowerSpeed
off
on
strumenta.com
System
State Machine
strumenta.com
Write the logic controlling
the machinery
Write the infrastructure
code in Java/Kotlin
Mechanical
Engineers
Software
Developers
Class files Class files
An example of State Machine
strumenta.com
statemachine mySm
input lowSpeedThroughtput: Int
input highSpeedThroughtput: Int
var totalProduction = 0
event turnOff
…
event emergencyStop
start state turnedOff {
on turnOn -> turnedOn
}
state turnedOn {
on turnOff -> turnedOff
on speedUp -> lowSpeed
}
state lowSpeed {
on entry {
totalProduction = totalProduction
+ lowSpeedThroughtput
print("Producing " + lowSpeedThroughtput
+ " elements (total
"+totalProduction+")")
}
on speedDown -> turnedOn
on speedUp -> highSpeed
on doNothing -> lowSpeed
}
General picture
Code Class files
strumenta.com
JVM
01010101
General picture
Model
Code
strumenta.com
Class files
JVM
01010101
Parsing: from code to model
strumenta.com
statemachine mySm
input lowSpeedThroughtput: Int
input highSpeedThroughtput: Int
var totalProduction = 0
event turnOff
…
event emergencyStop
start state turnedOff {
on turnOn -> turnedOn
}
state turnedOn {
on turnOff -> turnedOff
on speedUp -> lowSpeed
}
state lowSpeed {
on entry {
totalProduction = totalProduction
+ lowSpeedThroughtput
print("Producing " + lowSpeedThroughtput
+ " elements (total
"+totalProduction+")")
}
on speedDown -> turnedOn
on speedUp -> highSpeed
on doNothing -> lowSpeed
}
Parsing: from code to model
strumenta.com
statemachine mySm
input lowSpeedThroughtput: Int
input highSpeedThroughtput: Int
var totalProduction = 0
event turnOff
…
event emergencyStop
start state turnedOff {
on turnOn -> turnedOn
}
state turnedOn {
on turnOff -> turnedOff
on speedUp -> lowSpeed
}
state lowSpeed {
on entry {
totalProduction = totalProduction
+ lowSpeedThroughtput
print("Producing " + lowSpeedThroughtput
+ " elements (total
"+totalProduction+")")
}
on speedDown -> turnedOn
on speedUp -> highSpeed
on doNothing -> lowSpeed
}
Parsing: from code to model
strumenta.com
statemachine mySm
input lowSpeedThroughtput: Int
input highSpeedThroughtput: Int
var totalProduction = 0
event turnOff
…
event emergencyStop
start state turnedOff {
on turnOn -> turnedOn
}
state turnedOn {
on turnOff -> turnedOff
on speedUp -> lowSpeed
}
state lowSpeed {
on entry {
totalProduction = totalProduction
+ lowSpeedThroughtput
print("Producing " + lowSpeedThroughtput
+ " elements (total
"+totalProduction+")")
}
on speedDown -> turnedOn
on speedUp -> highSpeed
on doNothing -> lowSpeed
}
Parsing: from code to model
strumenta.com
statemachine mySm
input lowSpeedThroughtput: Int
input highSpeedThroughtput: Int
var totalProduction = 0
event turnOff
…
event emergencyStop
start state turnedOff {
on turnOn -> turnedOn
}
state turnedOn {
on turnOff -> turnedOff
on speedUp -> lowSpeed
}
state lowSpeed {
on entry {
totalProduction = totalProduction
+ lowSpeedThroughtput
print("Producing " + lowSpeedThroughtput
+ " elements (total
"+totalProduction+")")
}
on speedDown -> turnedOn
on speedUp -> highSpeed
on doNothing -> lowSpeed
}
Parsing: from code to model
strumenta.com
Model
Validation
strumenta.com
ModelCodefun StateMachine.validate() : List<Error> {
val errors = LinkedList<Error>()
// check a symbol or input is not duplicated
val valuesByName = HashMap<String, Int>()
this.specificProcess(ValueDeclaration::class.java) {
checkForDuplicate(valuesByName, errors, it)
}
// check references
this.specificProcess(ValueReference::class.java) {
if (!it.symbol.tryToResolve(this.variables) && !it.symbol.tryToResolve(this.inputs))
{
errors.add(Error("A reference to symbol '${it.symbol.name}' cannot be resolved",
it.position!!))
}
}
// check the initial value is compatible with the explicitly declared type
this.specificProcess(VarDeclaration::class.java) {
val valueType = it.value.type()
if (it.explicitType != null && valueType != null && !
it.explicitType.isAssignableBy(valueType)) {
errors.add(Error("Cannot assign ${it.explicitType!!} to variable of type $
{it.value.type()}", it.position!!))
}
}
…
return errors
}
How the JVM works: classes
strumenta.com
// class version 52.0 (52)
// access flags 0x21
public class Person {
// access flags 0x2
private Ljava/lang/String; name
// access flags 0x2
private I age
…
// Here we have the table, etc
…
}
class file
public class Person {
private String name;
private int age;
}
How the JVM works: math operations
strumenta.com
public static sum(II)I
L0
LINENUMBER 4 L0
ILOAD 0
ILOAD 1
IADD
IRETURN
L1
LOCALVARIABLE a I L0 L1 0
LOCALVARIABLE b I L0 L1 1
MAXSTACK = 2
MAXLOCALS = 2
public static int sum(int a, int b) {
return a + b;
}
Bytecode
How the JVM works: math operations
strumenta.com
public static sum(II)I
L0
LINENUMBER 4 L0
ILOAD 0
ILOAD 1
IADD
IRETURN
L1
LOCALVARIABLE a I L0 L1 0
LOCALVARIABLE b I L0 L1 1
MAXSTACK = 2
MAXLOCALS = 2
public static int sum(int a, int b) {
return a + b;
}
Bytecode
Stack
Index Variable
0 a
1 b
How the JVM works: math operations
strumenta.com
public static sum(II)I
L0
LINENUMBER 4 L0
ILOAD 0
ILOAD 1
IADD
IRETURN
L1
LOCALVARIABLE a I L0 L1 0
LOCALVARIABLE b I L0 L1 1
MAXSTACK = 2
MAXLOCALS = 2
public static int sum(int a, int b) {
return a + b;
}
Bytecode
Stack
a
Index Variable
0 a
1 b
How the JVM works: math operations
strumenta.com
public static sum(II)I
L0
LINENUMBER 4 L0
ILOAD 0
ILOAD 1
IADD
IRETURN
L1
LOCALVARIABLE a I L0 L1 0
LOCALVARIABLE b I L0 L1 1
MAXSTACK = 2
MAXLOCALS = 2
public static int sum(int a, int b) {
return a + b;
}
Bytecode
Stack
a
b
Index Variable
0 a
1 b
How the JVM works: math operations
strumenta.com
public static sum(II)I
L0
LINENUMBER 4 L0
ILOAD 0
ILOAD 1
IADD
IRETURN
L1
LOCALVARIABLE a I L0 L1 0
LOCALVARIABLE b I L0 L1 1
MAXSTACK = 2
MAXLOCALS = 2
public static int sum(int a, int b) {
return a + b;
}
Bytecode
Stack
a + b
Index Variable
0 a
1 b
How the JVM works: math operations
strumenta.com
public static sum(II)I
L0
LINENUMBER 4 L0
ILOAD 0
ILOAD 1
IADD
IRETURN
L1
LOCALVARIABLE a I L0 L1 0
LOCALVARIABLE b I L0 L1 1
MAXSTACK = 2
MAXLOCALS = 2
public static int sum(int a, int b) {
return a + b;
}
Bytecode
Stack
a + b
Index Variable
0 a
1 b
How the JVM works: math operations
strumenta.com
public static sum(FF)F
L0
LINENUMBER 8 L0
FLOAD 0
FLOAD 1
FADD
FRETURN
public static float sum(float a,
float b) {
return a + b;
}
Bytecode
How the JVM works: math operations
strumenta.com
public static tripleSum(III)I
L0
LINENUMBER 8 L0
ILOAD 0
ILOAD 1
IADD
ILOAD 2
IADD
IRETURN
public static int tripleSum(int a,
int b, int c) {
return a + b + c;
}
Bytecode
How the JVM works: math operations
strumenta.com
public static tripleSum(III)I
L0
LINENUMBER 8 L0
ILOAD 0
ILOAD 1
IADD
ILOAD 2
IADD
IRETURN
public static int tripleSum(int a,
int b, int c) {
return a + b + c;
}
Bytecode
Stack
Index Variable
0 a
1 b
2 c
How the JVM works: math operations
strumenta.com
public static tripleSum(III)I
L0
LINENUMBER 8 L0
ILOAD 0
ILOAD 1
IADD
ILOAD 2
IADD
IRETURN
public static int tripleSum(int a,
int b, int c) {
return a + b + c;
}
Bytecode
Stack
a
Index Variable
0 a
1 b
2 c
How the JVM works: math operations
strumenta.com
public static tripleSum(III)I
L0
LINENUMBER 8 L0
ILOAD 0
ILOAD 1
IADD
ILOAD 2
IADD
IRETURN
public static int tripleSum(int a,
int b, int c) {
return a + b + c;
}
Bytecode
Stack
a
b
Index Variable
0 a
1 b
2 c
How the JVM works: math operations
strumenta.com
public static tripleSum(III)I
L0
LINENUMBER 8 L0
ILOAD 0
ILOAD 1
IADD
ILOAD 2
IADD
IRETURN
public static int tripleSum(int a,
int b, int c) {
return a + b + c;
}
Bytecode
Stack
a + b
Index Variable
0 a
1 b
2 c
How the JVM works: math operations
strumenta.com
public static tripleSum(III)I
L0
LINENUMBER 8 L0
ILOAD 0
ILOAD 1
IADD
ILOAD 2
IADD
IRETURN
public static int tripleSum(int a,
int b, int c) {
return a + b + c;
}
Bytecode
Stack
a + b
c
Index Variable
0 a
1 b
2 c
How the JVM works: math operations
strumenta.com
public static tripleSum(III)I
L0
LINENUMBER 8 L0
ILOAD 0
ILOAD 1
IADD
ILOAD 2
IADD
IRETURN
public static int tripleSum(int a,
int b, int c) {
return a + b + c;
}
Bytecode
Stack
a + b + c
Index Variable
0 a
1 b
2 c
How the JVM works: math operations
strumenta.com
public static tripleSum(III)I
L0
LINENUMBER 8 L0
ILOAD 0
ILOAD 1
IADD
ILOAD 2
IADD
IRETURN
public static int tripleSum(int a,
int b, int c) {
return a + b + c;
}
Bytecode
Stack
a + b + c
Index Variable
0 a
1 b
2 c
How the JVM works: math operations
strumenta.com
public static
calculateMax(II)I
L0
LINENUMBER 8 L0
ILOAD 0
ILOAD 1
INVOKESTATIC java/lang/
Math.max (II)I
IRETURN
L1
LOCALVARIABLE a I L0 L1 0
LOCALVARIABLE b I L0 L1 1
MAXSTACK = 2
MAXLOCALS = 2
public static int calculateMax(int a,
int b) {
return Math.max(a, b);
}
Bytecode
Bytecode generation with ASM
strumenta.com
ASM is an open-source library to:

• Generate classes dynamically
• Edit class files
• Create class files
What is out compiler?
A piece of code that reads other code and depending on what it
reads either:

1. Tell us what is wrong

2. Generate one or more class files.
Plan
strumenta.com
•Structuring the code

•Compile expressions

•Convert control structures
Structuring the code
strumenta.com
The code (statements, expressions) stays in methods. 

Methods live inside classes.
StateMachine JVM Class
State
JVM Class 

(implenting a common interface)
Transition JVM Method
Entry block/Exit block JVM operation
Structuring the code
strumenta.com
Class files generation with ASM
strumenta.com
val classWriter = ClassWriter(ClassWriter.COMPUTE_FRAMES
or ClassWriter.COMPUTE_MAXS)
…
// put stuff in my class or interface
…
classWriter.visitEnd()
val bytes = classWriter.toByteArray()
// time to store those bytes into a file
Not that magic, eh?
Class files generation with ASM
strumenta.com
val classWriter = ClassWriter(ClassWriter.COMPUTE_FRAMES
or ClassWriter.COMPUTE_MAXS)
…
mv = classWriter.visitMethod(ACC_PUBLIC,
"myMethodName", "()V", null, null);
mv.visitCode();
…
// writing the method code
…
mv.visitMaxs(-1, -1);
mv.visitEnd();
And finally in methods goes the code
Compiling expressions
strumenta.com
Expressions use operands from the stack and put results on the stack
Boolean Bytecode
FALSE ICONST_0
TRUE ICONST_1
Byte/Short/Int Bytecode
0 ICONST_0
1 ICONST_1
2 ICONST_2
3 ICONST_3
4 ICONST_4
5 ICONST_5
6+ BIPUSH/SIPUSH/SIPUSH x
Compiling expressions
strumenta.com
Expressions use operands from the stack and put results on the stack
Reading
variables
Bytecode
Type byte ILOAD var_index
Type int ILOAD var_index
Type float FLOAD var_index
Type double DLOAD var_index
Type object ALOAD var_index
Writing
variables
Bytecode
Type byte ISTORE var_index
Type int ISTORE var_index
Type float FSTORE var_index
Type double DSTORE var_index
Type object ASTORE var_index
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Bytecode
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Bytecode
Index Variable Value
0 this this
1 n 3
2 i -
Stack
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Index Variable Value
0 this this
1 n 3
2 i -
Stack
0
Bytecode
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Index Variable Value
0 this this
1 n 3
2 i 0
Stack
Bytecode
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Index Variable Value
0 this this
1 n 3
2 i 0
Stack
0
Bytecode
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Index Variable Value
0 this this
1 n 3
2 i 0
Stack
0
3
Bytecode
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Index Variable Value
0 this this
1 n 3
2 i 0
Stack
not jumping
Bytecode
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Index Variable Value
0 this this
1 n 3
2 i 0
Stack
0
Bytecode
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Index Variable Value
0 this this
1 n 3
2 i 0
Stack
0
1
Bytecode
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Index Variable Value
0 this this
1 n 3
2 i 0
Stack
1
Bytecode
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
public void count(int n) {
int i = 0;
while (i < n) {
i = i + 1;
}
}
Index Variable Value
0 this this
1 n 3
2 i 1
Stack
Bytecode
How to compile control structures
strumenta.com
// access flags 0x1
public count(I)V
L0
ICONST_0
ISTORE 2
L1
ILOAD 2
ILOAD 1
IF_ICMPGE L2
L3
ILOAD 2
ICONST_1
IADD
ISTORE 2
GOTO L1
L2
RETURN
mv.visitLabel(l0)
mv.visitInsn(ICONST_0)
mv.visitVarInsn(ISTORE, 2)
mv.visitLabel(l1)
mv.visitVarInsn(ILOAD, 2)
mv.visitVarInsn(ILOAD, 1)
mv.visitJumpInsn(IF_ICMPGE, l2)
mv.visitLabel(l3)
mv.visitVarInsn(ILOAD, 2)
mv.visitInsn(ICONST_1)
mv.visitInsn(IADD)
mv.visitVarInsn(ISTORE, 2)
mv.visitJumpInsn(GOTO, l1)
mv.visitLabel(l2)
mv.visitInsn(RETURN)
Bytecode
ASM
Recap
strumenta.com
Building a languages means:

1) Parsing: use ANTLR

2) Validating: simple code navigating the model

3) Generating class files: use ASM

You need to familiarize with how a stack-based machine works
and with the instructions available.
Where to find out more
https://tomassetti.me/berlin
strumenta.com
•Slides
•Free course on building
languages (8 articles)

•Coupon for my book on building
languages
Ad

More Related Content

What's hot (20)

Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developers
Bartosz Kosarzycki
 
#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure
Hadziq Fabroyir
 
Kotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsKotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrains
Jigar Gosar
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
Upender Upr
 
An introduction to JVM performance
An introduction to JVM performanceAn introduction to JVM performance
An introduction to JVM performance
Rafael Winterhalter
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
Duoyi Wu
 
C++11
C++11C++11
C++11
Andrey Dankevich
 
What's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOutWhat's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOut
Paulo Morgado
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines
Parashuram N
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
Dmitry Baranovskiy
 
Scalaz Stream: Rebirth
Scalaz Stream: RebirthScalaz Stream: Rebirth
Scalaz Stream: Rebirth
John De Goes
 
Java byte code in practice
Java byte code in practiceJava byte code in practice
Java byte code in practice
Rafael Winterhalter
 
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo Cahersiveen
Graham Royce
 
Understanding Java byte code and the class file format
Understanding Java byte code and the class file formatUnderstanding Java byte code and the class file format
Understanding Java byte code and the class file format
Rafael Winterhalter
 
Functional Programming in Scala
Functional Programming in ScalaFunctional Programming in Scala
Functional Programming in Scala
Bassam Abd El Hameed
 
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: Notes
Roberto Casadei
 
Functional solid
Functional solidFunctional solid
Functional solid
Matt Stine
 
RESTful API using scalaz (3)
RESTful API using scalaz (3)RESTful API using scalaz (3)
RESTful API using scalaz (3)
Yeshwanth Kumar
 
Ankara Jug - Practical Functional Programming with Scala
Ankara Jug - Practical Functional Programming with ScalaAnkara Jug - Practical Functional Programming with Scala
Ankara Jug - Practical Functional Programming with Scala
Ensar Basri Kahveci
 
SeneJug java_8_prez_122015
SeneJug java_8_prez_122015SeneJug java_8_prez_122015
SeneJug java_8_prez_122015
senejug
 
Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developers
Bartosz Kosarzycki
 
#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure#OOP_D_ITS - 4th - C++ Oop And Class Structure
#OOP_D_ITS - 4th - C++ Oop And Class Structure
Hadziq Fabroyir
 
Kotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrainsKotlin: A pragmatic language by JetBrains
Kotlin: A pragmatic language by JetBrains
Jigar Gosar
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
Upender Upr
 
An introduction to JVM performance
An introduction to JVM performanceAn introduction to JVM performance
An introduction to JVM performance
Rafael Winterhalter
 
Javascript engine performance
Javascript engine performanceJavascript engine performance
Javascript engine performance
Duoyi Wu
 
What's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOutWhat's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOut
Paulo Morgado
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines
Parashuram N
 
Scalaz Stream: Rebirth
Scalaz Stream: RebirthScalaz Stream: Rebirth
Scalaz Stream: Rebirth
John De Goes
 
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo Cahersiveen
Graham Royce
 
Understanding Java byte code and the class file format
Understanding Java byte code and the class file formatUnderstanding Java byte code and the class file format
Understanding Java byte code and the class file format
Rafael Winterhalter
 
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: Notes
Roberto Casadei
 
Functional solid
Functional solidFunctional solid
Functional solid
Matt Stine
 
RESTful API using scalaz (3)
RESTful API using scalaz (3)RESTful API using scalaz (3)
RESTful API using scalaz (3)
Yeshwanth Kumar
 
Ankara Jug - Practical Functional Programming with Scala
Ankara Jug - Practical Functional Programming with ScalaAnkara Jug - Practical Functional Programming with Scala
Ankara Jug - Practical Functional Programming with Scala
Ensar Basri Kahveci
 
SeneJug java_8_prez_122015
SeneJug java_8_prez_122015SeneJug java_8_prez_122015
SeneJug java_8_prez_122015
senejug
 

Similar to How do you create a programming language for the JVM? (20)

Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
Juan Pablo
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
Bartosz Kosarzycki
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
Doug Hawkins
 
Whats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPontoWhats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPonto
Paulo Morgado
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
JAXLondon_Conference
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
Chhom Karath
 
A First Date With Scala
A First Date With ScalaA First Date With Scala
A First Date With Scala
Franco Lombardo
 
How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...
Codemotion
 
Wrapper class
Wrapper classWrapper class
Wrapper class
kamal kotecha
 
Monitoring distributed (micro-)services
Monitoring distributed (micro-)servicesMonitoring distributed (micro-)services
Monitoring distributed (micro-)services
Rafael Winterhalter
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine
ChengHui Weng
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
Woody Pewitt
 
devLink - What's New in C# 4?
devLink - What's New in C# 4?devLink - What's New in C# 4?
devLink - What's New in C# 4?
Kevin Pilch
 
Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015
Raimon Ràfols
 
02basics
02basics02basics
02basics
Waheed Warraich
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Carol McDonald
 
CGI.ppt
CGI.pptCGI.ppt
CGI.ppt
Vivekanandhan Vijayan
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
Java Generics
Java GenericsJava Generics
Java Generics
Carol McDonald
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
GuardSquare
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
Juan Pablo
 
ADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developersADG Poznań - Kotlin for Android developers
ADG Poznań - Kotlin for Android developers
Bartosz Kosarzycki
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
Doug Hawkins
 
Whats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPontoWhats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPonto
Paulo Morgado
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
Chhom Karath
 
How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...How much performance can you get out of Javascript? - Massimiliano Mantione -...
How much performance can you get out of Javascript? - Massimiliano Mantione -...
Codemotion
 
Monitoring distributed (micro-)services
Monitoring distributed (micro-)servicesMonitoring distributed (micro-)services
Monitoring distributed (micro-)services
Rafael Winterhalter
 
12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine12 Monkeys Inside JS Engine
12 Monkeys Inside JS Engine
ChengHui Weng
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
Woody Pewitt
 
devLink - What's New in C# 4?
devLink - What's New in C# 4?devLink - What's New in C# 4?
devLink - What's New in C# 4?
Kevin Pilch
 
Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015Improving Java performance at JBCNConf 2015
Improving Java performance at JBCNConf 2015
Raimon Ràfols
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Carol McDonald
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
GuardSquare
 
Ad

More from Federico Tomassetti (12)

Jariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlinJariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlin
Federico Tomassetti
 
JavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeJavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java code
Federico Tomassetti
 
Building languages with Kotlin
Building languages with KotlinBuilding languages with Kotlin
Building languages with Kotlin
Federico Tomassetti
 
Building languages with Kotlin
Building languages with KotlinBuilding languages with Kotlin
Building languages with Kotlin
Federico Tomassetti
 
Automatically Spotting Cross-language Relations
Automatically Spotting Cross-language RelationsAutomatically Spotting Cross-language Relations
Automatically Spotting Cross-language Relations
Federico Tomassetti
 
Lifting variability from C to mbeddr-C
Lifting variability from C to mbeddr-CLifting variability from C to mbeddr-C
Lifting variability from C to mbeddr-C
Federico Tomassetti
 
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
Federico Tomassetti
 
Eclipse Florence Day: Modeling in the Italian Industry
Eclipse Florence Day: Modeling in the Italian IndustryEclipse Florence Day: Modeling in the Italian Industry
Eclipse Florence Day: Modeling in the Italian Industry
Federico Tomassetti
 
Estendere Java con il Meta Programming System di JetBrains
Estendere Java con il Meta Programming System di JetBrains Estendere Java con il Meta Programming System di JetBrains
Estendere Java con il Meta Programming System di JetBrains
Federico Tomassetti
 
What is Federico doing?
What is Federico doing?What is Federico doing?
What is Federico doing?
Federico Tomassetti
 
Xtext Un Framework Per La Creazione Di Dsl
Xtext   Un Framework Per La Creazione Di DslXtext   Un Framework Per La Creazione Di Dsl
Xtext Un Framework Per La Creazione Di Dsl
Federico Tomassetti
 
Model Driven Web Development Solutions
Model Driven Web Development SolutionsModel Driven Web Development Solutions
Model Driven Web Development Solutions
Federico Tomassetti
 
Jariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlinJariko - A JVM interpreter for RPG written in kotlin
Jariko - A JVM interpreter for RPG written in kotlin
Federico Tomassetti
 
JavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java codeJavaParser - A tool to generate, analyze and refactor Java code
JavaParser - A tool to generate, analyze and refactor Java code
Federico Tomassetti
 
Automatically Spotting Cross-language Relations
Automatically Spotting Cross-language RelationsAutomatically Spotting Cross-language Relations
Automatically Spotting Cross-language Relations
Federico Tomassetti
 
Lifting variability from C to mbeddr-C
Lifting variability from C to mbeddr-CLifting variability from C to mbeddr-C
Lifting variability from C to mbeddr-C
Federico Tomassetti
 
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
Maturity of Software Modelling and Model Driven Engineering: a Survey in the ...
Federico Tomassetti
 
Eclipse Florence Day: Modeling in the Italian Industry
Eclipse Florence Day: Modeling in the Italian IndustryEclipse Florence Day: Modeling in the Italian Industry
Eclipse Florence Day: Modeling in the Italian Industry
Federico Tomassetti
 
Estendere Java con il Meta Programming System di JetBrains
Estendere Java con il Meta Programming System di JetBrains Estendere Java con il Meta Programming System di JetBrains
Estendere Java con il Meta Programming System di JetBrains
Federico Tomassetti
 
Xtext Un Framework Per La Creazione Di Dsl
Xtext   Un Framework Per La Creazione Di DslXtext   Un Framework Per La Creazione Di Dsl
Xtext Un Framework Per La Creazione Di Dsl
Federico Tomassetti
 
Model Driven Web Development Solutions
Model Driven Web Development SolutionsModel Driven Web Development Solutions
Model Driven Web Development Solutions
Federico Tomassetti
 
Ad

Recently uploaded (20)

Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 

How do you create a programming language for the JVM?

  • 1. .com How do you create a programming language for the JVM? Federico Tomassetti
  • 2. Hi, I am Federico !Got a PhD in Language Engineering !Lived here and there !Now for a living I: Ora sono un Language En Progetto e co ! Parser ! Interpr ! Compi ! Editor strumenta.com • Create languages • Write parsers • Transform code • Build compilers
  • 3. Why creating languages? The language or notation we are using to express or record our thoughts, are the major factors determining what we can think or express at all! Edsger W. Dijkstra The Humble Programmer strumenta.com
  • 4. Motivation strumenta.com Build Domain Specific Languages To support domain experts or to support working on a very specific kind of applications Build your very own programming language When you want to program differently, because you can think you can do things better or just because having your own language is a lot of fun and something to be proud of
  • 5. Why targeting the JVM? strumenta.com •Performance: the JVM can perform optimisations through dynamic analysis and even outperform native code •Libraries availability: whatever you want to do, there is a library for it •Platforms supported: the JVM runs in a ton of places
  • 6. State Machine Turned off Turned on Low speed High speed EmergencyStop IncreaseSpeed IncreaseSpeed LowerSpeed LowerSpeed off on strumenta.com
  • 7. System State Machine strumenta.com Write the logic controlling the machinery Write the infrastructure code in Java/Kotlin Mechanical Engineers Software Developers Class files Class files
  • 8. An example of State Machine strumenta.com statemachine mySm input lowSpeedThroughtput: Int input highSpeedThroughtput: Int var totalProduction = 0 event turnOff … event emergencyStop start state turnedOff { on turnOn -> turnedOn } state turnedOn { on turnOff -> turnedOff on speedUp -> lowSpeed } state lowSpeed { on entry { totalProduction = totalProduction + lowSpeedThroughtput print("Producing " + lowSpeedThroughtput + " elements (total "+totalProduction+")") } on speedDown -> turnedOn on speedUp -> highSpeed on doNothing -> lowSpeed }
  • 9. General picture Code Class files strumenta.com JVM 01010101
  • 11. Parsing: from code to model strumenta.com statemachine mySm input lowSpeedThroughtput: Int input highSpeedThroughtput: Int var totalProduction = 0 event turnOff … event emergencyStop start state turnedOff { on turnOn -> turnedOn } state turnedOn { on turnOff -> turnedOff on speedUp -> lowSpeed } state lowSpeed { on entry { totalProduction = totalProduction + lowSpeedThroughtput print("Producing " + lowSpeedThroughtput + " elements (total "+totalProduction+")") } on speedDown -> turnedOn on speedUp -> highSpeed on doNothing -> lowSpeed }
  • 12. Parsing: from code to model strumenta.com statemachine mySm input lowSpeedThroughtput: Int input highSpeedThroughtput: Int var totalProduction = 0 event turnOff … event emergencyStop start state turnedOff { on turnOn -> turnedOn } state turnedOn { on turnOff -> turnedOff on speedUp -> lowSpeed } state lowSpeed { on entry { totalProduction = totalProduction + lowSpeedThroughtput print("Producing " + lowSpeedThroughtput + " elements (total "+totalProduction+")") } on speedDown -> turnedOn on speedUp -> highSpeed on doNothing -> lowSpeed }
  • 13. Parsing: from code to model strumenta.com statemachine mySm input lowSpeedThroughtput: Int input highSpeedThroughtput: Int var totalProduction = 0 event turnOff … event emergencyStop start state turnedOff { on turnOn -> turnedOn } state turnedOn { on turnOff -> turnedOff on speedUp -> lowSpeed } state lowSpeed { on entry { totalProduction = totalProduction + lowSpeedThroughtput print("Producing " + lowSpeedThroughtput + " elements (total "+totalProduction+")") } on speedDown -> turnedOn on speedUp -> highSpeed on doNothing -> lowSpeed }
  • 14. Parsing: from code to model strumenta.com statemachine mySm input lowSpeedThroughtput: Int input highSpeedThroughtput: Int var totalProduction = 0 event turnOff … event emergencyStop start state turnedOff { on turnOn -> turnedOn } state turnedOn { on turnOff -> turnedOff on speedUp -> lowSpeed } state lowSpeed { on entry { totalProduction = totalProduction + lowSpeedThroughtput print("Producing " + lowSpeedThroughtput + " elements (total "+totalProduction+")") } on speedDown -> turnedOn on speedUp -> highSpeed on doNothing -> lowSpeed }
  • 15. Parsing: from code to model strumenta.com Model
  • 16. Validation strumenta.com ModelCodefun StateMachine.validate() : List<Error> { val errors = LinkedList<Error>() // check a symbol or input is not duplicated val valuesByName = HashMap<String, Int>() this.specificProcess(ValueDeclaration::class.java) { checkForDuplicate(valuesByName, errors, it) } // check references this.specificProcess(ValueReference::class.java) { if (!it.symbol.tryToResolve(this.variables) && !it.symbol.tryToResolve(this.inputs)) { errors.add(Error("A reference to symbol '${it.symbol.name}' cannot be resolved", it.position!!)) } } // check the initial value is compatible with the explicitly declared type this.specificProcess(VarDeclaration::class.java) { val valueType = it.value.type() if (it.explicitType != null && valueType != null && ! it.explicitType.isAssignableBy(valueType)) { errors.add(Error("Cannot assign ${it.explicitType!!} to variable of type $ {it.value.type()}", it.position!!)) } } … return errors }
  • 17. How the JVM works: classes strumenta.com // class version 52.0 (52) // access flags 0x21 public class Person { // access flags 0x2 private Ljava/lang/String; name // access flags 0x2 private I age … // Here we have the table, etc … } class file public class Person { private String name; private int age; }
  • 18. How the JVM works: math operations strumenta.com public static sum(II)I L0 LINENUMBER 4 L0 ILOAD 0 ILOAD 1 IADD IRETURN L1 LOCALVARIABLE a I L0 L1 0 LOCALVARIABLE b I L0 L1 1 MAXSTACK = 2 MAXLOCALS = 2 public static int sum(int a, int b) { return a + b; } Bytecode
  • 19. How the JVM works: math operations strumenta.com public static sum(II)I L0 LINENUMBER 4 L0 ILOAD 0 ILOAD 1 IADD IRETURN L1 LOCALVARIABLE a I L0 L1 0 LOCALVARIABLE b I L0 L1 1 MAXSTACK = 2 MAXLOCALS = 2 public static int sum(int a, int b) { return a + b; } Bytecode Stack Index Variable 0 a 1 b
  • 20. How the JVM works: math operations strumenta.com public static sum(II)I L0 LINENUMBER 4 L0 ILOAD 0 ILOAD 1 IADD IRETURN L1 LOCALVARIABLE a I L0 L1 0 LOCALVARIABLE b I L0 L1 1 MAXSTACK = 2 MAXLOCALS = 2 public static int sum(int a, int b) { return a + b; } Bytecode Stack a Index Variable 0 a 1 b
  • 21. How the JVM works: math operations strumenta.com public static sum(II)I L0 LINENUMBER 4 L0 ILOAD 0 ILOAD 1 IADD IRETURN L1 LOCALVARIABLE a I L0 L1 0 LOCALVARIABLE b I L0 L1 1 MAXSTACK = 2 MAXLOCALS = 2 public static int sum(int a, int b) { return a + b; } Bytecode Stack a b Index Variable 0 a 1 b
  • 22. How the JVM works: math operations strumenta.com public static sum(II)I L0 LINENUMBER 4 L0 ILOAD 0 ILOAD 1 IADD IRETURN L1 LOCALVARIABLE a I L0 L1 0 LOCALVARIABLE b I L0 L1 1 MAXSTACK = 2 MAXLOCALS = 2 public static int sum(int a, int b) { return a + b; } Bytecode Stack a + b Index Variable 0 a 1 b
  • 23. How the JVM works: math operations strumenta.com public static sum(II)I L0 LINENUMBER 4 L0 ILOAD 0 ILOAD 1 IADD IRETURN L1 LOCALVARIABLE a I L0 L1 0 LOCALVARIABLE b I L0 L1 1 MAXSTACK = 2 MAXLOCALS = 2 public static int sum(int a, int b) { return a + b; } Bytecode Stack a + b Index Variable 0 a 1 b
  • 24. How the JVM works: math operations strumenta.com public static sum(FF)F L0 LINENUMBER 8 L0 FLOAD 0 FLOAD 1 FADD FRETURN public static float sum(float a, float b) { return a + b; } Bytecode
  • 25. How the JVM works: math operations strumenta.com public static tripleSum(III)I L0 LINENUMBER 8 L0 ILOAD 0 ILOAD 1 IADD ILOAD 2 IADD IRETURN public static int tripleSum(int a, int b, int c) { return a + b + c; } Bytecode
  • 26. How the JVM works: math operations strumenta.com public static tripleSum(III)I L0 LINENUMBER 8 L0 ILOAD 0 ILOAD 1 IADD ILOAD 2 IADD IRETURN public static int tripleSum(int a, int b, int c) { return a + b + c; } Bytecode Stack Index Variable 0 a 1 b 2 c
  • 27. How the JVM works: math operations strumenta.com public static tripleSum(III)I L0 LINENUMBER 8 L0 ILOAD 0 ILOAD 1 IADD ILOAD 2 IADD IRETURN public static int tripleSum(int a, int b, int c) { return a + b + c; } Bytecode Stack a Index Variable 0 a 1 b 2 c
  • 28. How the JVM works: math operations strumenta.com public static tripleSum(III)I L0 LINENUMBER 8 L0 ILOAD 0 ILOAD 1 IADD ILOAD 2 IADD IRETURN public static int tripleSum(int a, int b, int c) { return a + b + c; } Bytecode Stack a b Index Variable 0 a 1 b 2 c
  • 29. How the JVM works: math operations strumenta.com public static tripleSum(III)I L0 LINENUMBER 8 L0 ILOAD 0 ILOAD 1 IADD ILOAD 2 IADD IRETURN public static int tripleSum(int a, int b, int c) { return a + b + c; } Bytecode Stack a + b Index Variable 0 a 1 b 2 c
  • 30. How the JVM works: math operations strumenta.com public static tripleSum(III)I L0 LINENUMBER 8 L0 ILOAD 0 ILOAD 1 IADD ILOAD 2 IADD IRETURN public static int tripleSum(int a, int b, int c) { return a + b + c; } Bytecode Stack a + b c Index Variable 0 a 1 b 2 c
  • 31. How the JVM works: math operations strumenta.com public static tripleSum(III)I L0 LINENUMBER 8 L0 ILOAD 0 ILOAD 1 IADD ILOAD 2 IADD IRETURN public static int tripleSum(int a, int b, int c) { return a + b + c; } Bytecode Stack a + b + c Index Variable 0 a 1 b 2 c
  • 32. How the JVM works: math operations strumenta.com public static tripleSum(III)I L0 LINENUMBER 8 L0 ILOAD 0 ILOAD 1 IADD ILOAD 2 IADD IRETURN public static int tripleSum(int a, int b, int c) { return a + b + c; } Bytecode Stack a + b + c Index Variable 0 a 1 b 2 c
  • 33. How the JVM works: math operations strumenta.com public static calculateMax(II)I L0 LINENUMBER 8 L0 ILOAD 0 ILOAD 1 INVOKESTATIC java/lang/ Math.max (II)I IRETURN L1 LOCALVARIABLE a I L0 L1 0 LOCALVARIABLE b I L0 L1 1 MAXSTACK = 2 MAXLOCALS = 2 public static int calculateMax(int a, int b) { return Math.max(a, b); } Bytecode
  • 34. Bytecode generation with ASM strumenta.com ASM is an open-source library to: • Generate classes dynamically • Edit class files • Create class files What is out compiler? A piece of code that reads other code and depending on what it reads either: 1. Tell us what is wrong 2. Generate one or more class files.
  • 35. Plan strumenta.com •Structuring the code •Compile expressions •Convert control structures
  • 36. Structuring the code strumenta.com The code (statements, expressions) stays in methods. Methods live inside classes. StateMachine JVM Class State JVM Class (implenting a common interface) Transition JVM Method Entry block/Exit block JVM operation
  • 38. Class files generation with ASM strumenta.com val classWriter = ClassWriter(ClassWriter.COMPUTE_FRAMES or ClassWriter.COMPUTE_MAXS) … // put stuff in my class or interface … classWriter.visitEnd() val bytes = classWriter.toByteArray() // time to store those bytes into a file Not that magic, eh?
  • 39. Class files generation with ASM strumenta.com val classWriter = ClassWriter(ClassWriter.COMPUTE_FRAMES or ClassWriter.COMPUTE_MAXS) … mv = classWriter.visitMethod(ACC_PUBLIC, "myMethodName", "()V", null, null); mv.visitCode(); … // writing the method code … mv.visitMaxs(-1, -1); mv.visitEnd(); And finally in methods goes the code
  • 40. Compiling expressions strumenta.com Expressions use operands from the stack and put results on the stack Boolean Bytecode FALSE ICONST_0 TRUE ICONST_1 Byte/Short/Int Bytecode 0 ICONST_0 1 ICONST_1 2 ICONST_2 3 ICONST_3 4 ICONST_4 5 ICONST_5 6+ BIPUSH/SIPUSH/SIPUSH x
  • 41. Compiling expressions strumenta.com Expressions use operands from the stack and put results on the stack Reading variables Bytecode Type byte ILOAD var_index Type int ILOAD var_index Type float FLOAD var_index Type double DLOAD var_index Type object ALOAD var_index Writing variables Bytecode Type byte ISTORE var_index Type int ISTORE var_index Type float FSTORE var_index Type double DSTORE var_index Type object ASTORE var_index
  • 42. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Bytecode
  • 43. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Bytecode Index Variable Value 0 this this 1 n 3 2 i - Stack
  • 44. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Index Variable Value 0 this this 1 n 3 2 i - Stack 0 Bytecode
  • 45. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Index Variable Value 0 this this 1 n 3 2 i 0 Stack Bytecode
  • 46. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Index Variable Value 0 this this 1 n 3 2 i 0 Stack 0 Bytecode
  • 47. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Index Variable Value 0 this this 1 n 3 2 i 0 Stack 0 3 Bytecode
  • 48. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Index Variable Value 0 this this 1 n 3 2 i 0 Stack not jumping Bytecode
  • 49. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Index Variable Value 0 this this 1 n 3 2 i 0 Stack 0 Bytecode
  • 50. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Index Variable Value 0 this this 1 n 3 2 i 0 Stack 0 1 Bytecode
  • 51. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Index Variable Value 0 this this 1 n 3 2 i 0 Stack 1 Bytecode
  • 52. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN public void count(int n) { int i = 0; while (i < n) { i = i + 1; } } Index Variable Value 0 this this 1 n 3 2 i 1 Stack Bytecode
  • 53. How to compile control structures strumenta.com // access flags 0x1 public count(I)V L0 ICONST_0 ISTORE 2 L1 ILOAD 2 ILOAD 1 IF_ICMPGE L2 L3 ILOAD 2 ICONST_1 IADD ISTORE 2 GOTO L1 L2 RETURN mv.visitLabel(l0) mv.visitInsn(ICONST_0) mv.visitVarInsn(ISTORE, 2) mv.visitLabel(l1) mv.visitVarInsn(ILOAD, 2) mv.visitVarInsn(ILOAD, 1) mv.visitJumpInsn(IF_ICMPGE, l2) mv.visitLabel(l3) mv.visitVarInsn(ILOAD, 2) mv.visitInsn(ICONST_1) mv.visitInsn(IADD) mv.visitVarInsn(ISTORE, 2) mv.visitJumpInsn(GOTO, l1) mv.visitLabel(l2) mv.visitInsn(RETURN) Bytecode ASM
  • 54. Recap strumenta.com Building a languages means: 1) Parsing: use ANTLR 2) Validating: simple code navigating the model 3) Generating class files: use ASM You need to familiarize with how a stack-based machine works and with the instructions available.
  • 55. Where to find out more https://tomassetti.me/berlin strumenta.com •Slides •Free course on building languages (8 articles) •Coupon for my book on building languages