Fluxus is an absolutely serious, low performance, interpreted programming language implemented in Java. It features almost arbitrary width integers and no loops nor if-statements.
Hello World can look like this in a class:
import fluxus.flumen.System;
class;
static main() {
System.println("Hello World");
}Or like this in a script:
import fluxus.flumen.System;
System.println("Hello World");Hello World is a bit boring. So here is more code that does some nonsensical stuff. Can you find out what the output is?
import fluxus.flumen.System;
import fluxus.flumen.Str;
class;
static I64[U31] longs = [10I64, 9I64, 8I64, 7I64, 6I64, 5I64, 4I64, 3I64, 2I64];
U31 index = new 0U31;
(U31 index) {
this.index = index;
}
static main() {
let i = new 0I32;
when i < 4I32 {
let instance = Showcase(i as U31);
instance.run(i as U31 * 2U31);
i = i + 1I32;
}
i = new 1I32;
}
run(U31 upTo) {
do when (this.index < Showcase.longs.length()) && (this.index <= upTo) {
let long = This.longs[this.index];
System.println(long as Str);
this.index = this.index + 1U31;
}
}Spoiler: Output
9
8
8
7
6
7
6
5
4Primitives
Bool:trueandfalseChar: e.g.'a'I#: signed integer with#bits precisionU#: unsigned integer with#bits precisionF#: float with#bits precision where only 32 and 64 are supported (more may come in the future)I8[I32]: array instantiated with[42I8, 10I8, 0I32]as a literal or[0I8; 10I32]as an array with 10 elements containing the value0I8(I8can be replaced with any other type)
Variables
Variables can be initialized using the keyword let and
must start with a lower case letter.
let x = 5I32;
let b = true;Literals can also be reassigned.
0I32 = 1I32;
System.println(0I32 as Str); // prints 1Initializing a variable with a literal also couples that variable to the literal.
let a = 0U32;
a = 1I32;
System.println(0U32 as Str); // prints 1This can be avoided by using the new keyword. This
copies the value to a new location in memory so subsequent changes to
a do not modify the literal.
let a = new 0U32;
a = 1I32;
System.println(0U32 as Str); // prints 0Conditionals
There are no if-statements or loops. Both are very inferior and
therefore replaced with when-statements. Whenever a variable in the
condition changes, it is reevaluated and the body is executed if the
condition is true.
when x < 10I32 {
//...
}To evaluate the condition instantly without another reassignment, you
can prefix the when-statement with do.
do when x < 10I32 {
//...
}Thus, the archaic if-statements and loops can be implemented using when much more elegant. If-statements:
do when a && b {
...
}
do when !(a && b) {
...
}for / while loops:
let i = 0I32;
do when i < 10I32 {
System.println(i as Str);
i = i + 1I32;
}If you want to avoid triggering the when-statement multiple times,
you need to create variables with the new keyword.