Before
What a routine needs
A precondition (require) is the caller’s side of the deal. If it fails, the caller is at fault, and the routine never runs.
client blameMeikaku · 明確
Meikaku is a compiled programming language where the assumptions in your code are written as contracts, checked while the program runs, and pinned on whoever broke them. Meikaku's syntax was inspired by Eiffel, and matches most of the semantics. In most cases, Meikaku text is valid Eiffel text, except where noted. It's an homage to Eiffel, but built for low friction installation, setup, and use.
Meikaku means clear, unambiguous, explicit.
note
description: "A bank account that can never go negative."
author: "asanaSoft"
class ACCOUNT
create
make
feature
balance: INT
make(initial: INT) is
require
not_negative: initial >= 0
do
balance := initial
end
withdraw(amount: INT) is
require
positive: amount > 0
covered: amount <= balance
do
balance := balance - amount
ensure
debited: balance = old balance - amount
end
invariant
never_negative: balance >= 0
end
class APPLICATION
create
make
feature
make is
local
acc: ACCOUNT
do
create acc.make(100)
acc.withdraw(30)
std_print("Balance: ".concat(acc.balance.to_string).concat("\n"))
acc.withdraw(500)
end
endBalance: 70
panic: Contract violation: class 'ACCOUNT', feature 'withdraw', tag 'covered' [client blame]Contracts
Every promise you write gets a tag, like covered above. When one is broken, the failure tells you the class, the routine, the tag, and which side broke the deal. There is nothing to decode. Contracts may look like other languages' asserts, but they are enforced across polymorphism and inheritance.
Before
A precondition (require) is the caller’s side of the deal. If it fails, the caller is at fault, and the routine never runs.
client blameAfter
A postcondition (ensure) says what is true when the routine finishes, and old lets it compare against the state before. If it fails, the routine is at fault.
supplier blameAlways
A class invariant holds for the object’s whole life. It is checked after every call, and right after creation, so an object can’t start out broken.
supplier blameFor people and AI assistants
A comment can drift out of date without anyone noticing. A contract can’t: it runs. When a teammate, or an AI assistant, changes a routine, the contract says what the routine still has to satisfy, and the first broken promise is reported by name. This narrows, or eliminates, the
note clause at the top of a class says in plain words what it is for.:=, equality is =, and there is one way to write loops.Then it becomes native code
The compiler, mkc, translates Meikaku to Zig and the Zig toolchain builds the native program. You get a native executable, and Zig source you can read.
-A none and every check is removed. A correct program behaves the same either way, because contracts must not change what a program does.native block of Zig, still wrapped in its contract.Built with Meikaku
Our uptime monitor. It probes 17 endpoints every two minutes and alerts when one fails. It ran beside the original Go version for 16 days and reported the same probe results, and it now runs on a Raspberry Pi 4 with 4 GB of memory.
Meikaku includes bindings to the libui-ng toolkit, so one program can open native windows on macOS and Linux. We built a demo graph explorer on it that reads from AsanagiDB. Clone the repo at https://git.asanasoft.com/asanaSoft/meikaku-explorer
Our TUI graph tool is written entirely in Maikaku, using the meikaku-tui library.
Meikaku and Asanagi
AsanagiDB is written in Zig, and you talk to it with ordinary Gremlin clients. Meikaku is the language we choose for our own tools and services around it. If you only want the database, you can ignore Meikaku completely. If you like it, there is a Meikaku client for AsanagiDB in the standard library.
Where Meikaku is today
Openly licensed under the MIT license. 1.2.0 introduces packages and a uses list inmeikaku.json: a project names the standard library groups, native drivers and libraries it needs, and anything unlisted is not found. This is a breaking change (seePackages and uses). The compiler now exits with an error code when a build fails, and a class of your own can take the place of a library class of the same name.
Packages target macOS on Apple silicon (signed and notarized) and Linux on x86_64 and ARM64 (aarch64). Requires Zig 0.16 on PATH (Homebrew installs it automatically; native-window apps on Linux also need GTK 3 and pkg-config). No Intel Mac or Windows package yet.
Version 1.0 changed the syntax to match Eiffel, and the old forms are now rejected. Expect more refinement before it settles.
On macOS (Apple silicon), Homebrew installs Meikaku and [email protected] together:
brew tap asanagi/tap https://git.asanasoft.com/asanagi/homebrew-tap.git
brew install asanagi/tap/meikakuOr download a release archive (requires Zig 0.16 on PATH):macOS Apple silicon (6.1 MB) ·Linux x86_64 (8.6 MB) ·Linux ARM64 (8.7 MB)