π Milestone 6 Release: Ballerina Nutcracker
This milestone adds server-side HTTP, seven new standard library modules, a bal build command, and language subset 9.
π HTTP service support
The headline feature: ballerina/http can now serve traffic, not just call it.
http:Listenerwith declarative attachment or programmaticattach/detach- Resource functions for all methods, with typed path parameters (
[int],[string],[boolean],[decimal]) and rest paths ListenerConfigurationβhost,timeout,httpVersion(HTTP/2 by default, serving both HTTP/1.1 and HTTP/2),secureSocket- TLS and mutual TLS; graceful stop that drains in-flight requests
- Automatic
404for unmatched paths,405for the wrong method
import ballerina/http;
service /api on new http:Listener(9090) {
resource function get greeting/[string name]() returns http:Response {
http:Response resp = new;
resp.setTextPayload(string `Hello, ${name}!`);
return resp;
}
resource function post item() returns http:Response {
http:Response resp = new;
resp.statusCode = 201;
resp.setJsonPayload({status: "created"});
return resp;
}
}Not in this cut: resource functions return
http:Response,error, or()β barestring/anydatareturns and status-code response types are not yet supported, and there is nohttp:Caller, parameter binding, or@http:ServiceConfigstyle configuration.
On the client side: compression negotiation, proxy support, responseLimits, poolConfig, the forward action, a Request class and Method enum, plus payload setters, header mutators, and query-parameter accessors.
π Language features (subset 9)
Annotations β declarations and attachments (marker, repeated, source-only), values from constant and runtime expressions, and annotation access:
type Info readonly & record {| string label; |};
annotation Info runtimeInfo on type;
@runtimeInfo {label: "person"}
type Person record {| string name; |};
Info? value = Person.@runtimeInfo;Template expressions β string templates are new, and XML templates gained interpolation in content and attributes:
string name = "world";
io:println(string `Hello, ${name}!`); // Hello, world!
io:println(xml `<greeting>Hello, ${name}!</greeting>`);Concurrency β the lock statement and isolated module-level variables:
isolated int counter = 0;
isolated function bump() returns int {
lock {
counter += 1;
return counter;
}
}Query expressions β the group by and collect clauses:
var grouped = from var x in xs group by x select [x];
int[] all = from var x in xs collect x;Also in subset 9:
- Services & objects β module
listenerand service declarations, resource methods and resource access actions (f->/path/["a"]/[1]()),service/readonly/distinctclass qualifiers, object type inclusion - Types β distinct error and object types,
typedescsupport,streamvalues backed by user-defined iterators - Expressions β spread members in list constructors,
foreachover XML, XML equality - Language libraries β new
lang.float(full math surface),lang.decimal,lang.boolean,lang.object; base64/base16 onlang.array;toBytes/fromBytesonlang.string;cloneWithTypeandfromJsonWithTypeonlang.value
π Standard library
Seven new modules, plus file I/O for ballerina/io:
| Module | What it covers |
|---|---|
crypto |
Hashing, HMAC, password hashing (BCrypt, Argon2, PBKDF2), AES, RSA and ECDSA, key loading |
io |
Whole-file read/write for strings, lines, bytes, JSON, and XML |
log |
printDebug / printInfo / printWarn / printError with structured key-value pairs |
math.vector |
Norms, dot product, cosine similarity, Euclidean and Manhattan distance |
os |
Environment variables, user info, subprocess execution |
random |
Cryptographically secure random values |
time |
UTC and civil time, IANA time zones, RFC 3339 / RFC 5322, duration arithmetic |
url |
Percent-encoding and decoding across several charsets |
import ballerina/crypto;
import ballerina/io;
import ballerina/log;
import ballerina/time;
public function main() returns error? {
time:Utc now = time:utcNow();
check io:fileWriteJson("stamp.json", {at: time:utcToString(now)});
json content = check io:fileReadJson("stamp.json");
io:println(content);
byte[] digest = crypto:hashSha256("hello".toBytes());
log:printInfo("digest computed", length = digest.length());
}π οΈ CLI & tooling
Two new commands round out the CLI:
| Command | Description |
|---|---|
bal pack [<package-dir>] |
Build the .bala distribution archive of a package |
bal build [<package-dir>] |
Build a standalone executable that bundles the Ballerina runtime |
bal build produces a self-contained binary at target/bin/<package-name> (override with -o), and cross-compiles to any supported platform with --target-os / --target-arch:
bal build hello
bal build hello --target-os linux --target-arch arm64Release binaries are published for linux/amd64, linux/arm64, darwin/amd64, darwin/arm64, and windows/amd64.
π¦ Projects & packages
- Standard libraries and language libraries now ship as bundled
.balapackages - Depend on packages from a local repository, or route resolution through a custom repository
- Resolve external packages that carry native code
π New diagnostics
The compiler now reports unused local variables, unused import prefixes, returns never functions that can complete normally, and invalid service declarations.