Zyn0.1.0

The JVM

zyn build compiles a program to JVM bytecode, in a jar that runs anywhere Java 17 or newer does. Compiled programs are much faster than interpreted ones, about as fast as the same program in Java or Kotlin, and they can use any Java library.

#Building a jar

zyn build app.zyn
java -jar app.jar

The jar has Zyn's small runtime inside (plain Java, no Kotlin), so it needs nothing else. Arguments work as usual: java -jar app.jar one two.

OptionWhat it does
-o out/tool.jarWhere to write the jar
--no-runtimeLeave the runtime out (when something else puts it on the classpath)
--classpath libs/*Compile against Java libraries. They aren't copied into the jar

In a project, zyn build needs no file and builds build/<name>-<version>.jar, with the project's implementation libraries inside, so java -jar runs it with nothing else.

To compile and run in one step, without keeping a jar: zyn run --jvm app.zyn. zyn test --jvm app.zyn runs the tests compiled.

#Resources

Files in a resources/ folder next to the program are copied into the jar as they are, keeping their folders: configuration files, templates, images, or a plugin's plugin.yml.

app.zyn
resources/
├── config.yml        → config.yml in the jar
└── images/logo.png   → images/logo.png in the jar

#How fast

Running fib(27) and a 3-million-step loop:

Way of runningTime
zyn run (interpreter)1.37 s
zyn build, then java -jar0.08 s
The same program in Java0.06 s
zyn build --native0.01 s

The interpreter starts at once and is best for trying things; compile anything that does real work.

#How Zyn maps to the JVM

Knowing this helps when Java code uses Zyn classes, as a plugin's server does.

ZynJVM
A file app.zynA class AppZyn; utils/text.zyn becomes utils.TextZyn
Top-level functionsStatic methods of the file's class
Top-level let and varStatic fields, set up the first time the file is used
class Dog in app.zynA class Dog, with public fields; in utils/text.zyn it's utils.Dog
A project's classesAll of the above in the package zynproject.<project>: zynproject.hello_zyn.utils.Dog
Int, Float, Bool, Charlong, double, boolean, char
Stringjava.lang.String
List, Mapjava.util.List, java.util.Map
LambdasObjects of a small class; they also become Java interfaces like Runnable where those are expected
data types and enum casesObjects of zyn.runtime.Record
GenericsErased to Object, as in Java

The bytecode targets Java 17.