The Zeno Book Zeno 0.8 zeno-lang.org

23 Libraries of Other Languages

A package of Zeno is written in Zeno. Most of the libraries in the world are not: Python has one for nearly everything, npm has more packages than any other place, and Java has a very large library of its own and a jar for whatever else. A Zeno program can use them as they are, with one line at the top:

mean.zeno

import python

let statistics = python.module("statistics")
let readings = [21.5, 22.0, 23.5, 22.5]
print(statistics.mean(readings), statistics.median(readings))
22.375 22.25

python.module("statistics") is what import statistics is in Python. What it gives is the module, and from there the program is written as it would be in Python: a dot for what the module has, brackets for a call.

Seven languages are reached this way. Python, JavaScript and Java came with 0.5.2, and Ruby, PHP, Lua and C# with 0.6. They all work the same way, so this chapter takes Python first, and then says what is different about each of the others. C is the eighth, and it is reached in another way, because a library of C can be built into the program: it has the next chapter (Libraries of C).

Written Gives
import python python.module(name) and python.copy(value)
import node node.module(name), node.global(name), node.new(Class, ...) and node.copy(value)
import java java.type(name), java.jar(path) and java.copy(value)
import ruby ruby.require(name), ruby.constant(name), ruby.symbol(name) and ruby.copy(value)
import php php.type(name), php.callable(name), php.constant(name), php.require(path), php.variable(value) and php.copy(value)
import lua lua.require(name), lua.global(name) and lua.copy(value)
import csharp csharp.type(name), csharp.assembly(path) and csharp.copy(value)

Nothing changes for a program that does not import one of these. They are added beside the language, and they are there only when they are asked for. The language that runs the library is started the first time the program calls into it, once, and stays until the program ends. A program that imports python and never calls it starts nothing.

23.1 What it needs

The other language must be on the computer, with the library installed for it:

Import Needs Zeno looks for
python Python 3 python3, then python (on Windows python, python3, then py); ZENO_PYTHON names another
node Node 22 or later node; ZENO_NODE names another
java Java 11 or later java, then in JAVA_HOME; ZENO_JAVA names another
ruby Ruby 3 ruby; ZENO_RUBY names another
php PHP 8 or later php; ZENO_PHP names another
lua Lua 5.1 to 5.4, or LuaJIT lua, then lua5.4, then luajit; ZENO_LUA names another
csharp the .NET SDK, 6 or later dotnet, then in DOTNET_ROOT, then in ~/.dotnet; ZENO_DOTNET names another

The Python that a virtual environment puts first, when it is active, is the one Zeno finds. A library is looked for where that language would look for it if the program were written in it and lay in the same place: so a helper.py beside the program is python.module("helper"), and an npm package is installed with npm install in the folder of the program. The program can then be run from anywhere. A gem of Ruby, a package of Composer, a rock of Lua and a package of NuGet are each found the same way, and the section of each language says where.

23.2 Values go across in two ways

none, a bool, a number and a str go as themselves. What the other language returns of these kinds is a value of Zeno at once, and what Zeno passes arrives as that language’s own:

day.zeno

import python

let datetime = python.module("datetime")
let day = datetime.date(2026, 11, 18)
print(day, day.year + 1, day.strftime("%A"))
2026-11-18 2027 Wednesday

day.year is an int of Zeno, so + 1 is Zeno’s. day.strftime("%A") is a str of Zeno. Python’s None is none.

Everything else stays where it was made. datetime and day above are not copies of anything. Zeno holds a number that Python knows the value by, and each time the program writes a field, a call or an item of it, Zeno asks Python. When nothing in the program holds the value any more, Python is told, and lets it go.

A value that stays in the other language can be used in these ways:

Written What the other language does
thing.name thing.name
thing.name = value the same
thing(1, 2, key=3) the call; what a named argument becomes is in the sections below
thing[index] the item, and thing[index] = value sets it
len(thing) how many items it has
for item in thing { } every item, taken when the loop begins
item in thing whether it holds the item
thing == other that language’s own test for equal
print(thing), str(thing) the value as that language writes it

What it cannot be is the test of an if, because a condition in Zeno is true or false and nothing else. Write len(thing) > 0 or thing is not none. Nor can it be one side of + or <: take a number of Zeno out of it first.

later.zeno

import python

let day = python.module("datetime").date(2026, 11, 18)
let later = day.replace(month=12)
print(later.isoformat(), later == day, [day, later])
2026-12-18 false [datetime.date(2026, 11, 18), datetime.date(2026, 12, 18)]

month=12 is a keyword argument of Python. Inside a list, a value of Python is shown as Python writes it there, as a str of Zeno is shown with its quotes inside a list.

23.3 Lists and dicts

A list of Python stays in Python too, and that is on purpose:

names.zeno

import python

let builtins = python.module("builtins")
let names = builtins.list(["cy", "ann"])
names.append("bob")
names.sort()
print(names, len(names), names[0], "bob" in names)
for name in names {
    print(name.upper())
}
['ann', 'bob', 'cy'] 3 ann true
ANN
BOB
CY

names is the one list there is. append and sort are Python’s, and they change the list that Python has. If the list came across as a copy, names.append("bob") would add to the copy, Python would never see it, and nothing would say so. Each name in the loop is a str of Zeno, so upper is Zeno’s.

When a list of Zeno is what the program wants, to pass to a function that takes list[str] or to use Zeno’s own methods on, the copy of the module makes one:

mine.zeno

import python

let names = python.module("builtins").sorted(["cy", "ann", "bob"])
let mine = python.copy(names)
mine.append("dee")
print(mine, len(names))
["ann", "bob", "cy", "dee"] 3

copy takes a list, a tuple or a dict of Python, and gives a list or a dict of Zeno, with every list and dict inside it copied as well. A dict whose keys are not all str or int cannot be a dict of Zeno, and copy raises a ValueError that names the key.

The other way is always a copy. A list or dict of Zeno passed to Python arrives as a new list or dict there:

shuffle.zeno

import python

let xs = [3, 1, 2]
python.module("random").shuffle(xs)
print(xs)        # Python shuffled its copy
[3, 1, 2]

To have Python work on a list and see the result, make the list in Python (builtins.list(xs)) and copy it back.

23.4 Errors

An error that the other language raises is an error of Zeno, and try catches it (Errors):

oops.zeno

import python

let json = python.module("json")
try {
    json.loads("{oops")
} except ValueError as error {
    print(error.message)
}
JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

The message begins with what Python called the error when that is not the name of the kind. The kinds are matched like this:

From Becomes
Python OSError and its kinds are a FileError; ValueError, IndexError, KeyError, OverflowError and ZeroDivisionError are the kind of the same name
JavaScript an error the system gave (no such file, no network) is a FileError
Java IOException and its kinds are a FileError; IndexOutOfBoundsException is an IndexError; IllegalArgumentException is a ValueError
Ruby Errno::... and IOError are a FileError; ArgumentError is a ValueError; IndexError and StopIteration are an IndexError; KeyError and ZeroDivisionError are the kind of the same name
PHP a warning or an exception that says a file could not be used is a FileError; ValueError, InvalidArgumentException, DomainException and JsonException are a ValueError; OutOfBoundsException and OutOfRangeException are an IndexError; DivisionByZeroError is a ZeroDivisionError
Lua nil, a message and a number of the system, which is how Lua’s functions for files fail, is a FileError
C# IOException and those under it are a FileError; KeyNotFoundException is a KeyError; IndexOutOfRangeException and ArgumentOutOfRangeException are an IndexError; ArgumentException and FormatException are a ValueError; DivideByZeroException and OverflowException are the kinds of nearly the same name

Anything else is an Error. Two things can go wrong before any library is reached, and both are a FileError: there is no Python (or Node, or Java, or any other of them) to run, or it has no module of that name. The message says which one Zeno found, and where it looked.

missing.zeno

import python

let video = python.module("no_such_library")
error: uncaught FileError: Python has no module `no_such_library` (No module named 'no_such_library'). Is it installed for this Python? It is /usr/local/bin/python3
 --> missing.zeno:3:13
  |
3 | let video = python.module("no_such_library")
  |             ^

What another language can raise is not known before the program runs. A function that declares what it raises (Errors) and calls into one says raises Error, which is every kind.

23.5 Types

What a module has is known when the program runs, and not before. So a value from another language has the type that json.parse gives (Reading and Writing): the checker lets everything through, and a wrong name is an error at its line when the program gets there. Give a value a type of Zeno where it lands, and from there on it is checked:

let title: str = about["title"]       # checked when it happens

For the same reason zeno check --strict refuses a program that imports one of the seven.

23.6 JavaScript

node.module(name) is what require(name) is in JavaScript. A module that comes with Node, such as fs, path, os, crypto or zlib, needs nothing more; a package from npm is installed in the program’s folder with npm install. A file of JavaScript beside the program is a module by its path, node.module("./helper.js").

Much of JavaScript is not in a module at all. JSON, Math, Date and process are there everywhere, and node.global gives them. JavaScript makes an object of a class with new, and Zeno with node.new:

globals.zeno

import node

let path = node.module("path")
print(path.basename("/home/ann/notes.txt"), path.extname("notes.txt"))

let JSON = node.global("JSON")
let about = JSON.parse("{\"name\": \"ann\", \"age\": 31}")
print(about.name, about.age + 1, about.email is none)

let start = node.new(node.global("Date"), 2026, 10, 18)
print(start.getFullYear(), start.toDateString())
notes.txt .txt
ann 32 true
2026 Wed Nov 18 2026

about.email is none, and not an error: a field that an object of JavaScript does not have is undefined, and both null and undefined are none in Zeno.

Four things are different from Python.

  • One kind of number. A number of JavaScript that is whole arrives as an int, and any other as a float. So Math.sqrt(16.0) is 4, an int; where a float is needed, float(x) makes one.

  • Named arguments are the options. JavaScript has no named arguments. A function there takes its options as one object, its last argument, and so the named arguments of a call are gathered into that object: fs.readFileSync("notes.txt", encoding="utf8") is readFileSync("notes.txt", {encoding: "utf8"}).

  • What takes time is waited for. A call that gives a promise gives its answer, and the program goes on when it is there. There is no await to write, and a promise that fails is an error at the line of the call.

  • Equal is the same object. == is JavaScript’s ===, so two arrays with the same items are not equal. Compare their copies: node.copy(a) == node.copy(b).

waited.zeno

import node

let Math = node.global("Math")
print(Math.max(3, 9, 4), Math.sqrt(16.0), Math.sqrt(2.0))

let options = node.global("Object")(recursive=true, retries=3)
print(options, options.retries + 1)

let crypto = node.module("crypto")
print(crypto.createHash("sha256").update("zeno").digest("hex"))
9 4 1.4142135623730951
{ recursive: true, retries: 3 } 4
988465d28db4d902b53d9e902ea5d7bba65489f4aafdb2df4c271a9e4f6364a4

node.global("Object") called with named arguments makes such an object by itself, to keep or to add to. node.copy takes an array or a Set and gives a list, and a plain object or a Map and gives a dict.

23.7 Java

java.type(name) is what import of a class is in Java, and the name is always the whole name that Java’s own documentation gives. A dot after a class is what is static in it, and calling a class makes an object, as new does there:

classes.zeno

import java

let Math = java.type("java.lang.Math")
print(Math.max(3, 9), Math.floorMod(-7, 3))

let LocalDate = java.type("java.time.LocalDate")
let day = LocalDate.of(2026, 11, 18)
print(day, day.getDayOfWeek(), day.plusMonths(1), day.getYear() + 1)

let names = java.type("java.util.ArrayList")(["cy", "ann"])
names.add("bob")
java.type("java.util.Collections").sort(names)
print(names, len(names), names[0], "bob" in names, names == ["ann", "bob", "cy"])
9 2
2026-11-18 WEDNESDAY 2026-12-18 2027
[ann, bob, cy] 3 ann true true

A list of Zeno passed to a class of Java arrives as a new ArrayList, and a dict as a LinkedHashMap: so ArrayList(["cy", "ann"]) is the short way to make a collection of Java from what Zeno has. == is Java’s equals, so a list of Java equals a list of Zeno with the same items.

What is different from Python:

  • A library is a jar. java.jar("lib/gson-2.11.0.jar") says where one is, counted from the folder of the .zeno file, and after it the classes of that jar are found. A folder in place of a jar is every jar in it. Kotlin, Scala and Clojure libraries are jars as well.

  • Java’s method decides. Java can have several methods of one name that take different types. The one that the arguments fit best is called, in the order Java itself would choose: an int is an int before it is a long, and a long before a double. When none fits, the error lists what there is.

  • No named arguments. Java has none, so a call with one is an error that says so.

  • The first run takes a second longer. Zeno’s own part on the Java side is compiled once, with javac, and kept in the folder for what can be made again (~/.cache/zeno on Linux).

valueof.zeno

import java

let String = java.type("java.lang.String")
print(String.valueOf(5), String.valueOf(2.5), String.valueOf(true))

try {
    java.type("java.lang.Integer").parseInt("forty")
} except ValueError as error {
    print(error.message)
}
5 2.5 true
NumberFormatException: For input string: "forty"

Those are three different methods of Java, and Zeno picked each from the type of what it was given.

One trap is Java’s own. A List has remove(int), which takes out the item at a place, and remove(Object), which takes out an item. list.remove(30) is the first, in Java as here. To take the number 30 out of a list of numbers, write list.remove(list.indexOf(30)).

23.8 Ruby

Ruby brings a library with require, and what the library brings is a constant: a class, a module, or a plain value whose name begins with a capital letter. So Zeno has both:

weekday.zeno

import ruby

ruby.require("date")
let Date = ruby.constant("Date")
let day = Date.new(2026, 11, 18)
print(day.strftime("%A"), day.year() + 1, day.next_month())
Wednesday 2027 2026-12-18

ruby.constant takes the name as Ruby writes it, with :: for what is inside something else ("Net::HTTP"). Math, Kernel, File, Time, Array and Hash are there with no require. An object is made as Ruby makes it, with .new(...). A gem is installed with gem install and then required by its name; a file helper.rb beside the program is ruby.require("helper"); and a program that wants exactly the gems of the Gemfile beside it says ruby.require("bundler/setup") first, as a program of Ruby does.

What is different from Python:

  • A call has brackets. In Ruby words.size is a call. In Zeno a call has brackets, always, and that holds here: words.size(). Without them the program has the method, to be called later, as it would have a method of Zeno.

  • A name Zeno cannot write goes through send. Ruby’s own send calls a method by its name as text. That is the way to every name that ends in ? or !, to every operator, and to the names that are words of Zeno.

  • What Ruby writes with no object in front is a method of Kernel: format, rand, Integer("42").

  • Named arguments are keyword arguments. name=value in a call is name: value in Ruby.

  • A symbol stays in Ruby. :up is not the text "up" there, and a Hash that has the key :up does not have the key "up". ruby.symbol("up") makes one.

  • An Integer of Ruby has no largest value. One that fits 64 bits is an int. A larger one stays in Ruby, prints in full, and can be used there.

words.zeno

import ruby

let words = ruby.constant("Array").new()
words.push("pear")
words.push("apple")
print(words.size(), words.sort(), words.sort().first(), words.join(" and "))
print(words.send("empty?"), words.send("include?", "pear"), words.send("class"))
print(words.size)

let Kernel = ruby.constant("Kernel")
print(Kernel.format("%05.1f", 3.14159), Kernel.send("Integer", "ff", 16))
2 ["apple", "pear"] apple pear and apple
false true Array
method `size` of an Array. In Zeno a call has brackets: `.size()`
003.1 255

Integer in the last line begins with a capital letter, so after a dot it would be read as the constant, the class Integer. send says that the method is meant. A name that only lacks its ? is pointed out:

frozen.zeno

import ruby

print(ruby.constant("Array").new().frozen())
error: uncaught Error: an Array has no method `frozen`. It has `frozen?`, which is written `.send("frozen?")` in Zeno
 --> frozen.zeno:3:7
  |
3 | print(ruby.constant("Array").new().frozen())
  |       ^

An Array or a Hash of Ruby stays in Ruby, as a list of Python does, and ruby.copy makes a list or a dict of it. A copy is plain data, so a symbol in it is copied as its name:

ages.zeno

import ruby

let ages = ruby.constant("Hash").new()
ages["ann"] = 31
ages[ruby.symbol("bob")] = 40
print(len(ages), ages["ann"], ages[ruby.symbol("bob")], ages["bob"], "ann" in ages)
let copy = ruby.copy(ages)
print(copy, copy["bob"] + 1)

let Point = ruby.constant("Struct").new(ruby.symbol("x"), ruby.symbol("y"), keyword_init=true)
let point = Point.new(x=1, y=2)
point.x = 10
print(point.x() + point.y(), point == Point.new(x=10, y=2))
2 31 40 none true
["ann": 31, "bob": 40] 41
12 true

ages["bob"] is none: the key is the symbol, and Ruby gives nil for a key a Hash does not have.

Much of Ruby is written with blocks: items.map { ... }, File.open(name) { ... }. A function of Zeno cannot be the block yet, and Zeno says so at the line. Most of them have another form: a for loop of Zeno goes through anything that has each, and File.read and File.write need no block.

23.9 PHP

PHP keeps three things apart that Zeno reaches by name: its classes, its functions and its constants.

date.zeno

import php

let DateTime = php.type("DateTime")
let day = DateTime("2026-11-18")
print(day.format("l"), php.callable("ucwords")("hello from zeno"), php.constant("PHP_INT_MAX"))
Wednesday Hello From Zeno 9223372036854775807

php.type("DateTime") is the class, and calling it is what new DateTime(...) is in PHP. php.callable("ucwords") is the function ucwords as a value, which is called with brackets as any function is. A dot stands where PHP writes -> or ::, so DateTime.ATOM is the constant of the class. A class is named with its namespace, and \ is written \\ in a str of Zeno: php.type("Carbon\\Carbon").

A package from Composer is looked for where PHP would find it: vendor/autoload.php in the folder of the .zeno file, then in each folder above. So composer require is run in the folder of the program. A file of PHP beside the program is read with php.require("helper.php").

What is different from Python:

  • An array comes across whole. An array of PHP is a value, as a list or a dict of Zeno is, and not an object that lives somewhere. So an array that PHP gives is a list of Zeno where its keys are 0, 1, 2 and so on, and a dict for any other. Only an object stays in PHP.

  • Named arguments are PHP’s own, by the name of the parameter.

  • A warning is an error. In PHP file_get_contents of a file that is not there prints a warning and gives false, and a program would go on with the false. In Zeno it is a FileError.

  • A function that changes what it is given needs a variable. sort and preg_match write into their argument (PHP writes &$array). Given a list of Zeno they would change a copy that nobody sees, so they are given php.variable(value), and its .value is what it holds after the call.

parts.zeno

import php

let parts = php.callable("explode")(",", "pear,apple,fig")
parts.append("plum")
print(parts, len(parts), php.callable("implode")(" and ", parts))
print(php.callable("array_flip")(parts), php.callable("array_sum")([1, 2, 3.5]))
print(php.callable("number_format")(1234567.891, 2, thousands_separator=" "))

let found = php.variable()
if php.callable("preg_match")("/(\\d+)-(\\d+)/", "tel 12-34", found) == 1 {
    print(found.value, found.value[1] + found.value[2])
}
let numbers = php.variable([3, 1, 2])
php.callable("sort")(numbers)
print(numbers.value)
["pear", "apple", "fig", "plum"] 4 pear and apple and fig and plum
["pear": 0, "apple": 1, "fig": 2, "plum": 3] 6.5
1 234 567.89
["12-34", "12", "34"] 1234
[1, 2, 3]

parts is a list of Zeno, and append is Zeno’s. Given a plain list, sort is not called at all:

sort.zeno

import php

php.callable("sort")([3, 1, 2])
error: uncaught Error: `sort` changes its `array` (PHP writes `&$array`), so it needs a variable of PHP to change: `php.variable(value)`
 --> sort.zeno:3:1
  |
3 | php.callable("sort")([3, 1, 2])
  | ^

An object stays in PHP, and php.copy makes a list or a dict of what foreach goes through, or of an object that only holds values:

object.zeno

import php

let DateTime = php.type("DateTime")
let utc = php.type("DateTimeZone")("UTC")
let day = DateTime("2026-11-18", utc)
day.modify("+1 month")
print(day.format("Y-m-d"), DateTime.ATOM, day == DateTime("2026-12-18", utc))

let thing = php.callable("json_decode")("{\"name\": \"pen\", \"tags\": [\"a\", \"b\"]}")
thing.name = thing.name + "cil"
print(thing.name, thing.tags, php.copy(thing))

try {
    php.callable("file_get_contents")("/no/such/file")
} except FileError as error {
    print(error.message)
}
2026-12-18 Y-m-d\TH:i:sP true
pencil ["a", "b"] ["name": "pencil", "tags": ["a", "b"]]
file_get_contents(/no/such/file): Failed to open stream: No such file or directory

23.10 Lua

Lua is small, and is everywhere a program is put inside another program. What every program of Lua has, string, table, math, os and io, is given by lua.global, and a module by lua.require:

format.zeno

import lua

let string = lua.global("string")
print(string.format("%-6s|%5.2f", "pi", 3.14159), string.rep("ab", 3), string.upper("zeno"))
pi    | 3.14 ababab ZENO

A module from LuaRocks is installed for the Lua that Zeno starts (luarocks install), and a file shapes.lua beside the program is lua.require("shapes"). A table, a function and a userdata stay in Lua; lua.copy makes a list of a table whose keys are 1, 2 and so on, and a dict of any other.

What is different from Python:

  • Several values are a list. A function of Lua can give several values. One value is that value, none is none, and several are a list of Zeno, in order.

  • nil and a message is an error. Most functions of Lua say they failed by giving nil and then why. Zeno raises that as an Error with the message. Lua has no kinds of error, so every error of Lua is an Error, but for the FileError of the table above.

  • Lua counts from 1. A table stays in Lua, and its items are where Lua has them: t[1] is the first. The list that lua.copy makes counts from 0, as every list of Zeno does.

  • One dot for a method and a function. Lua writes object:name(x) to call a method and module.name(x) to call a function. Zeno has one dot, and gives the object to a function that was written as a method: one whose first parameter is called self, or one the table has from its metatable. The name in brackets, p["length"](p), is what the table holds, and nothing is given to it.

  • Named arguments are the options. Lua has none. What a library of Lua takes instead is a table of options, last, and that is what named arguments become.

  • One kind of number before 5.3. On Lua 5.3 and later a number knows if it is an int or a float. On 5.1, 5.2 and LuaJIT every number is a float, and a whole one arrives as an int.

values.zeno

import lua

let string = lua.global("string")
print(string.find("hello", "l"), string.gsub("hello", "l", "L"), string.find("hello", "z"))

let table = lua.global("table")
let t = table.pack(30, 10, 20)
t.n = none
table.sort(t)
print(t, t[1], len(t), 10 in t, lua.copy(t), lua.copy(t)[0])

try {
    lua.global("io").open("/no/such/file")
} except FileError as error {
    print(error.message)
}
[3, 3] ["heLLo", 2] none
{10, 20, 30} 10 3 true [10, 20, 30] 10
/no/such/file: No such file or directory

A module of your own shows the dot and the options. This file lies beside the program:

shapes.lua

local shapes = {}

local Point = {}
Point.__index = Point
Point.__tostring = function(p) return "Point(" .. p.x .. ", " .. p.y .. ")" end

function shapes.Point(x, y)
    return setmetatable({x = x, y = y}, Point)
end

function Point:length()
    return math.sqrt(self.x * self.x + self.y * self.y)
end

function shapes.greet(name, options)
    options = options or {}
    local said = {}
    for i = 1, options.times or 1 do
        said[i] = "hello " .. name
    end
    local all = table.concat(said, ", ")
    if options.loud then
        return all:upper()
    end
    return all
end

return shapes

shapes.zeno

import lua

let shapes = lua.require("shapes")
let p = shapes.Point(3, 4)
print(p, p.length(), p.x)
print(shapes.greet("ann", times=2, loud=true))
for word in lua.global("string").gmatch("one two three", "%a+") {
    print(word)
}
Point(3, 4) 5.0 3
HELLO ANN, HELLO ANN
one
two
three

p.length() is Lua’s p:length(), and the two named arguments of greet arrived as one table, {times = 2, loud = true}. A for over a function of Lua takes what it gives until it gives nil, which is how Lua’s own for goes through gmatch.

On Windows Lua also needs LuaSocket (luarocks install luasocket), because Lua comes with no way to talk to another program there. That was not tried: no Lua with LuaSocket was there to try it with.

23.11 C# and .NET

.NET is what C# runs on, and F# and Visual Basic too. csharp.type gives a type by its name with its namespace, and calling a type makes an object, as new does in C#:

builder.zeno

import csharp

let Builder = csharp.type("System.Text.StringBuilder")
let text = Builder("Zeno")
text.Append(" and .NET ").Append(8)
print(text, text.Length, csharp.type("System.Math").Round(3.14159, 2))
Zeno and .NET 8 15 3.14

It is the closest of the seven to Java. A type is named as C# names it: with its namespace; without one where a new program of C# needs no using ("File", "Math", "Task"); with C#’s own words ("int", "string"); and made of others, "List<int>", "Dictionary<string, List<int>>", "int[]".

collections.zeno

import csharp

let list = csharp.type("List<int>")()
list.AddRange([30, 10, 20])
list.Sort()
print(list, list[0], len(list), 10 in list, csharp.copy(list))

let ages = csharp.type("Dictionary<string, int>")()
ages["ann"] = 31
ages["bob"] = 40
print(ages, ages["ann"], "bob" in ages, csharp.copy(ages))
[10, 20, 30] 10 3 true [10, 20, 30]
{"ann": 31, "bob": 40} 31 true ["ann": 31, "bob": 40]

What is different from Python:

  • It needs the SDK. The runtime of .NET alone runs programs but cannot build them, and the first run on a computer builds Zeno’s own part on the .NET side with dotnet build. That takes some seconds, once. Every later run starts in a tenth of a second.

  • Of several methods, the arguments choose. C# can have several methods of one name. The one called is the one the arguments fit, as C# chooses it: an int of Zeno fits an int before a long, and both before a double. When two fit as well, Zeno does not guess, and the error says which two.

  • A named argument goes to the parameter of that name, as in C#. The names are those the method gives its parameters.

  • A Task is waited for. A method that gives a Task is one that takes time, and the call gives what the task gives when it is done: none for a plain Task.

  • A package of NuGet is added to a project beside the program. Two commands of dotnet, shown below the program that follows, make the project and add a package to it. Zeno reads from the project where NuGet keeps each .dll.

  • A .dll of your own is loaded with csharp.assembly(path), which also takes a folder for every .dll in it, counted from the folder of the program.

methods.zeno

import csharp

let math = csharp.type("System.Math")
print(math.Max(3, 7), math.Max(2, 3.5), math.Round(2.567, digits=1))
let text = csharp.type("string")
print(text.Join("-", ["a", "b"]), text.Join("+", "x", "y", "z"))

let day = csharp.type("DateTime")(2026, 11, 18)
print(day.DayOfWeek, day.AddDays(10).ToString("yyyy-MM-dd"), day.DayOfWeek == csharp.type("DayOfWeek").Wednesday)

let task = csharp.type("Task")
print(task.FromResult(7), task.Delay(10))

try {
    csharp.type("Convert").ToInt32("twelve")
} except ValueError as error {
    print(error.message)
}
7 3.5 2.6
a-b x+y+z
Wednesday 2026-11-28 true
7 none
FormatException: The input string 'twelve' was not in a correct format.

math.Max(3, 7) and math.Max(2, 3.5) are two different methods of .NET, and so are the two Join. An enum of .NET, such as the day of the week, stays there and prints as its name.

These are the two commands that make a project in the folder of the program and add a package of NuGet to it. After them, csharp.type("Humanizer.NumberToWordsExtension") is there:

dotnet new classlib -n libraries -o .
dotnet add package Humanizer.Core

23.12 More than one in a program

A program can import several of them. Each value stays where it was made. A str or a number that one gave can be passed to another, because by then it is a value of Zeno; a value that stayed in one cannot be given to another, and Zeno says so at the line:

both.zeno

import python
import node

let day = python.module("datetime").date(2026, 11, 18)
let JSON = node.global("JSON")
print(JSON.stringify(day.isoformat()))
print(JSON.stringify(day))
"2026-11-18"
error: a Python value cannot be given to JavaScript. Each stays where it was made
 --> both.zeno:7:7
  |
7 | print(JSON.stringify(day))
  |       ^

The first print works, because isoformat() gave a str of Zeno. The copy of each module makes a list or a dict of Zeno, and that can go anywhere.

23.13 A name that is a word of Zeno

Python has re.match, JavaScript has Array.from, and Java has System.in; match, from and in are words of Zeno, so none of them parses after a dot. Each language has its own way around it, and in most of them it is the name in brackets:

Language Write
Python builtins.getattr(re, "match")(p, text)
JavaScript Array["from"](items): brackets are a dot there
Java System["in"], LocalDate["from"](other)
Ruby thing.send("class"), thing.send("in?", list)
PHP Size["from"]("l"), thing["for"]
Lua string["match"](text, pattern)
C# thing["match"]: on a type, and on an object with no items of its own, the name in brackets is the name after a dot

23.14 What is not there yet

  • A function of Zeno cannot be given to another language. A library that calls back, for progress, a sort key, an event or a request to a server, cannot call into Zeno yet, and Zeno says so at the line. Much of Node gives a promise instead, and that works. A block of Ruby is such a function too, and so are the lambdas of LINQ in C#.

  • What a method of C# puts back in an out or ref parameter is not seen, and an extension method is called on its class and not on the value.

  • A loop takes everything first. for line in thing asks for all the items, then loops. Over something that never ends, it never begins.

  • A class of Zeno cannot extend a class of Java, of Ruby or of any other, or be one of its interfaces.

  • Built programs. zeno run and zeno test have all seven, with and without --vm. zeno build, in every form and for every target, refuses them, because a built program must run where the other language may not be. C is the one that a build takes (Libraries of C).

  • Where they were tried. All seven were used on Linux. The tests also run Python, Node, Java and Ruby on Windows and macOS, and the others there only as far as the machine has them.

23.15 How it is built

The other language runs as a program of its own, beside Zeno. A small helper for it is part of the zeno file, and the first call starts the language with it. Zeno opens a socket that only this computer can reach, and gives the helper its port and a word made up for this run; the helper connects, says the word, and only then is it listened to. Because the conversation has a line of its own, the other language keeps the screen and the keyboard: its print, a progress bar that redraws itself and input() all work as if it had been started by hand.

Each question is one line of JSON, and so is each answer:

{"op":"get","on":["p",3],"name":"year"}                 day.year
{"ok": 2026}
{"op":"call","on":["p",9],"args":["{oops"],"named":[],"free":[5,7]}
{"err": ["ValueError", "JSONDecodeError: Expecting ..."]}

["p", 3] is the value the helper keeps under the number 3. "free" rides along with the next question: the numbers Zeno has let go of since the last one. In Zeno the value is one more kind of Value, which holds the number, and the operations that both engines share (a field, an item, len, ==) ask over the socket when they meet it. Nothing on Zeno’s side knows Python but the name of the helper, so each of the other six is another helper that speaks the same lines. Two of them are not quite like the rest. Lua comes with no sockets, so on Linux and macOS its helper talks through two named pipes that Zeno makes for it, and on Windows through LuaSocket. And the helper of .NET is a small program of C# that dotnet build makes on the first run and keeps in the folder for what can be made again. The reasons are chapters 26, 28, 29 and 37 to 40 of docs/decisions.md.

23.16 Things to try

  1. Run the first program of this chapter. Then misspell statistics and read the message. Which Python does it name?

  2. Print python.module("sys").executable. Start a virtual environment and run it again.

  3. builtins.sorted([3, 1, 2]) gives a list that stays in Python. Print it, then print python.copy of it. What is different about the two lines, and why?

  4. Write function mean(xs: list[float]) -> float in Zeno, and pass it a list of Python with and without copy. What do the checker and the program say?

  5. With Node, read a file through node.module("fs/promises"). Where is the promise?

  6. With Java, call java.type("java.util.ArrayList")().get(3) inside a try. Which kind of error catches it?

  7. With Ruby, make a Hash with the key ruby.symbol("name"), and read it with "name". Then read it from ruby.copy of the Hash. Why does one find it and not the other?

  8. With PHP, call php.callable("str_replace") to change every a in a word to o. Then ask it how many it changed: its fourth parameter is written &$count.

  9. With Lua, take os and string with lua.global. Print os.date("%A"), and then string.byte("abc", 1, 3). Which of the two is a list, and where does it count from?

  10. With C#, make a csharp.type("List<string>")(), add three names and call Sort(). Then give Add a number and read the error.