Orzo is a Java-based language for the JVM.
It's named after my beverage of choice while coding it.
✨ Orzo-only features (not available in Java)
- primitive types (byte, short, int, char, boolean, long, float, double)
- one-dimensional arrays
- String
- interfaces
- reference types (partially supported)
- enums (partially supported)
- class inheritance
- exceptions
- multi-dimensional arrays
- assignment
=
- parallel assignment ✨
- parallel declarations, e.g.
int a,b,c,d,e,f = 1,2,3
✨ - repeat ✨
- arithmetic
+
,-
,*
,/
,%
-
**
power operator ✨, e.g.int b = a ** 5
-
√
sqrt operator ✨, e.g.double x = √n + √(n+1)
- parenthesis
(
,)
- unary post/pre-increment and decrement
++
,--
- compound assignments
+=
,-=
,*=
,/=
,%=
,<<=
,>>=
,>>>=
,&=
,^=
,|=
- relational
<
,<=
,>=
,>
- equality
==
,!=
, - bit
&
,^
,|
,<<
,>>
,>>>
- unary minus
-
- casting
()
(partially supported) - object creation
new
(partially supported) - logical
&&
,||
- unary logical
!
- unary bitwise
~
- unary plus
+
-
instanceof
- String and char concatenation
+
- ternary
?:
- if, else if and else
- while
- do
- for
- break
- return
- method and constructor calls (partially supported)
- continue
- try
- switch
- lambdas
- unless ✨
- array defintions must be of the form
int[] a
,int a[]
is not supported - Orzo creates class files with major version 50 (Java 6). Newer versions would require implementation of the StackMapTable attribute.
- fields and variables share the same namespace
Calculating π using the Gauss-Legendre algorithm:
public double pi(int n) {
double a, b, t, p, x = 1, 1/√2, 1/4, 1;
repeat n
{
x, a, b = a, (a + b) / 2, √(x*b);
t, p = t - p * ((x-a) ** 2), 2 * p;
}
return ((a+b) ** 2) / (4 * t);
}
More examples can be found here.
mvn package
javac $(find ./src/main/java -name "*.java") -d bin && jar cfe orzo.jar io.github.martinschneider.orzo.Orzo -C bin .
java -jar target/orzo.jar inputFiles -d outputFolder