Skip to content

Search

Back
· 2 min read

One way to do each thing

Each thing a Balaur game does has one spelling: four naming principles, an audit of 985 script API items, and what moved into Balaur Script.

Each thing a Balaur game does has one spelling. Four principles pick the name, and the compiler names the form to write.

The code pane with saved.is_nil() underlined, and the Problems dock saying to write x == nil in its place

Names

  • docs/NAMING.md holds four principles: use the words the reader knows, one word for one meaning, one shape of name for one kind of thing, and a name that says what the call site cannot.
  • scripts/api_lints.py holds the script API to them, house_lints.py the Rust side and string_lints.py the words.

One spelling

  • An audit of every item a game can reach counted 985 over 50 modules. It found 56 second spellings: 27 in physics, 10 in UI and input, 8 in the kernel, 6 in audio and the network, and 5 in rendering.
  • One spelling of each stays, and every caller uses it. The panel widget kind is the one left, for its caption and nine-patch plate.
  • ui::edit(node, value) sets a slider, a swatch, a fold or a field by the value's type. scene::root().get_node(path) is the one path lookup.
  • The compiler refuses a second spelling of a nil test, an any read or a cast, and names the one to write.
  • Each of the 88 rapier and parry wrappers runs from a script in a test.

Into Balaur Script

  • Balaur Script has bit operators and text.bytes(). Base64 of 1 MiB takes 6 to 15 ms in the prelude, against 38 to 46 ms as a host call.
  • quat, five geometry2d helpers, random::uuid and audio::play_file are prelude scripts too. Saves are the library's save addon.
  • What stays native was measured first. hash::sha256_file took 13.3 to 20.4 ms a MiB as a script, against 0.75 to 0.88 ms.
  • Tile collision on a 256 by 256 map retired 16 times the native build's instructions as a script. A timer script on each of 1000 nodes retired 8.9 million a tick, against 44 thousand.

Are you sure?