Skip to content

Jamo 0.6.0

Choose a tag to compare

@jamolang jamolang released this 27 Nov 18:38
· 14 commits to main since this release

Jamo 0.6.0 is the big-projects release. Tests, private helpers, files with their own names, interfaces and a docs page: the things that keep a program easy to work on as it grows from one file to twenty. Programs still build in a blink (Jamo's own 16,000-line compiler builds in about 0.2 seconds) and still come out as small .exe files with nothing to install.

Get started

  1. Download jamo-0.6.0-windows.zip below, unzip it anywhere, and double-click install.cmd.
  2. Open a new terminal and type jamo version. It should say Jamo 0.6.0.
  3. Try a game: jamo run examples\star_guard.jamo from inside the unzipped folder.

Already have an older Jamo? Just run the new install.cmd. Your own programs stay as they are.

For colors, red underlines, hover help and go to definition in VS Code, download jamo.vsix below. In VS Code, open the Extensions panel, click the ... menu at its top, and choose Install from VSIX. It now knows private and interface too.

What's new

Interfaces: different structs in one list

An interface lists the functions some structs share. Any struct that has them fits, with nothing extra to write:

interface Animal
    func name(): string
    func sound(): string
end

func main()
    var pets: [Animal] = [Dog{tricks: 3}, Cat{lives: 9}]
    for pet in pets
        print(pet.name() + " says " + pet.sound())
    end
end

That's how one list can hold every enemy, coin and bullet in a game. If a struct is missing something, Jamo says exactly what: Square can't be a Shape, because it has no grow function.

jamo test

Put tests in a file whose name ends in _test.jamo, as functions whose names start with test_:

use "test.jamo"

func test_points()
    expect_equal(points_for(3), 300)
end

Then type jamo test. Every test runs as its own little program, so one that crashes can't stop the rest, and a failing one shows what went wrong and on which line.

Files with their own names: use ... as

Two files can both have a make_noise and a SPEED:

use "goblins.jamo" as goblins
use "ghosts.jamo" as ghosts

func main()
    print(goblins.make_noise())
    print(ghosts.make_noise())
end

Forget the goblins. and Jamo asks: Did you mean goblins.SPEED?

private

Put private in front of a file's helpers, and no other file can use them:

private var balance = 0

Another file trying balance = 1000000 gets: balance is private to bank.jamo, so only that file can use it.

jamo doc

jamo doc game.jamo writes a web page of every function, struct and interface in your program, with your # comments and a search box. It works on the built-in libraries too: jamo doc gfx.jamo shows everything you can draw with.

Smaller things

  • A function written inside another one shows by its own name in jamo run --trace and in a crash's list of calls.

Built carefully

  • Every new feature is in both of Jamo's compilers, the C++ one and the one written in Jamo itself. They make byte-for-byte the same .exe, and the Jamo one still builds itself the same every time.
  • The whole test suite passed after each feature, run by run. Each error message was written out by hand first and checked against what Jamo says.
  • Every code sample in the guide is built and run as part of the tests, so the guide can't go out of date.

Good to know

  • A file used with as keeps its functions, constants and variables to itself. Its structs and enums are still shared by the whole program.
  • jamo doc and jamo fmt work in jamo.exe, not in the C++ backup compiler.
  • Windows may still warn about a program it has never seen before. Click More info, then Run anyway.

The full list is in CHANGELOG.md.