luk: lua, with less ceremony

Tim Menzies timm@ieee.org · timm.fyi · 2026-07-05 · github.com/aiez/luk · luarocks

luk is now on LuaRocks:

luarocks install luk

That is the whole toolchain, batteries included: the luk cli lands on your path (luk FILE.luk transpiles and runs; luk -d dumps the generated Lua), and the support battery installs where require can see it — lib.luk (PRNG, pretty-print, keysort, csv iterator, …), stats.luk (Cliff’s delta, KS test, top-tier ranking), and fft.luk (a worked example: multi-objective regression trees).

.luk is Lua plus Python-style indented blocks: a line ending in : opens a block, the dedent closes it, and the transpiler writes the ends for you. Add fn for function, ^ for return, := for locals, elif, !=, and comprehensions, and Lua stops feeling like it is mostly punctuation:

fn sign(x):                       -- function sign(x)
  if x > 0:                       --   if x > 0 then
    ^ 1                           --     return 1
  elif x < 0:                     --   elseif x < 0 then
    ^ -1                          --     return -1
  else:                           --   else
    ^ 0                           --     return 0 end end

best := [x for x in t if x.ok]    -- list comprehension

Explicit then/do/else/end still works, so any Lua is (almost) valid luk, and the two styles mix freely.

the whole trick is 120 lines

One module, luk.lua, does whole-source rewriting: strings and comments are hidden first (so sigils inside them are safe), blocks are closed at dedents, keywords are swapped, comprehensions are expanded. No parser, no AST, no dependencies.

Two properties make it livable:

Transpiling is one line pass plus some gsubs: ~2ms for a 250-line file. As a workout, the repo ships fft.luk, a multi-objective regression-tree learner that runs 1.5–2.5x faster than its Python sibling.

For the full language reference (one-liners, anonymous fns, gotchas), see the man page.


NC State ©2026, timm, MIT License
150 words of css
designed.2.last