Chuks v0.2.0-rc.3 is the last release candidate. There will be no rc.4: what testing turns up from here is fixed in place, and v0.2.0 is published from this build.
This post is the practical version. What changed, what to change in your code, and how to try it. Install first:
# existing install
chuks upgrade --prerelease
# first-time install
curl -fsSL https://chuks.org/install.sh | bash && chuks upgrade --prerelease
chuks upgrade skips pre-releases by default, so the --prereleaseflag is required. chuks --version should print 0.2.0-rc.3.
The one habit that makes this release useful
Chuks has two execution modes: chuks run (bytecode VM, instant start) and chuks build (native binary). They are meant to print identical output for the same program. The most useful thing you can do with this candidate is run your own program both ways:
chuks run main.chuks
chuks build main.chuks && ./build/main
If the output differs, that is the bug report we want. Include chuks --version and a minimal reproduction in a GitHub issue.
What is in it
Records know what they are. A value now becomes a typed record wherever the checker says it is one: as an array element, a nested field, a map value, a return value. A record parsed from JSON keeps its nested records as records, and validate() sees the rules on every one of them.
const order: Order? = req.parseBody(Order)
A bad field is an error that names it, for example lines[0].qty is 'string', and no validation library is needed.
One generics engine. Type parameters resolve once, from everything the compiler knows about them. Constraints (numeric, comparable, hashable, union and interface bounds) are checked, and generic types are sound by default: a Box is not a Box. A generic benchmark runs about twice as fast on the VM and five times as fast natively.
Tasks and locks you can rely on. A cancelled task stops at its next suspension point, so finally blocks and lock releases run and nothing after that point does. Every await of a task sees the same single outcome. A lock is released on every error, not only on a throw written in its body.
Numbers that behave. int8 to int64, uint8 to uint64, float32 and float64 work everywhere a type does. Constant arithmetic is exact, and a constant that does not fit its type is a compile error. New syntax: digit separators (1_000_000) and the bitwise assignments &=, |=, ^=, <<=, >>=, &^=.
A hardened HTTP server. One request reader follows the HTTP/1.1 specification, including the framing rules behind request smuggling. Ctrl-C exits 130 and SIGTERM exits 143. Handlers the compiler can prove never block run directly on the event loop: hello-world went from 154k to 283k requests a second on a Mac mini M5 Pro at 100 connections.
What to change in your code
Eight things can break existing code, and each is reported at the line responsible.
|| is for bools, ?? is for defaults.
var count: int = 0
var name: string? = null
count ?? 10 // 0 (only null is replaced)
count || 10 // true (a bool, no longer the deciding operand)
name ?? "guest" // "guest"
Conversions throw on bad input. int("12abc"), int(" 42") and float("abc") throw instead of returning a partial number or 0.
Headers and body are honest about missing values. req.header() and req.cookie() return string?, and req.parseBody(T) returns T?:
var auth: string = req.header("Authorization") ?? ""
Also on the list: a module variable read before its declaration is an error, two statements on one line are a syntax error, a record type must be imported rather than redeclared in two modules, and copy(value) is typed and deep, so nested arrays and records are no longer shared with the copy.
The full list, with the reasoning for each, is in the release notes.
How it is tested
Every change passes a ten-stage gate before it lands: 660 golden programs on both modes with identical output required, 43 differential suites (including 13 generators that cover every combination of three language features, about 7,800 programs), 585 HTTP checks on both backends, a 450-program corpus whose answers come from outside Chuks, the first-party packages' own tests, and every example on the website.
Try it
chuks upgrade --prerelease
Full release notes: https://chuks.org/blog/chuks-v020-rc3-the-last-candidate/
Top comments (0)