luajit(1)

πŸ“¦ version 5.1.2.1.0+git.1731601260.fe71d0f, in opensuse-leap 16.0

πŸ’… luajit(1) β€” the LuaJIT page, but make it make sense

okay so bestie, welcome to the luajit(1) page from the LuaJIT documentation ✨ this is the whole thing, every flag, every example, no skips, no cap 🫢


🌈 SYNOPSIS

luajit [options]... [script [args]...]

literally that's it. options, then maybe a script, then maybe args for that script. slay πŸ’…


🌐 WEB SITE

https://luajit.org β€” go off, icon πŸ‘‘


✨ DESCRIPTION

okay so this is the command-line program you use to run Lua programs with LuaJIT πŸŽ€

LuaJIT is a just-in-time (JIT) compiler for the Lua language. The virtual machine (VM) is based on a fast interpreter combined with a trace compiler. It can significantly improve the performance of Lua programs πŸ”₯ like, your Lua goes zoom.

and here's the iconic part: LuaJIT is API- and ABI-compatible with the VM of the standard Lua 5.1 interpreter. So when you're embedding the VM into an application, the built library can be used as a drop-in replacement πŸ‘‘ no rewrites, no drama, just swap it in. periodt.


πŸ’– OPTIONS

one bullet per flag, all of them, in order, bestie 🫢

  • -e chunk β€” run the given chunk of Lua code. like, right there on the command line, no file needed ✨
  • -l library β€” load the named library, just like require("library"). same vibe, command-line edition πŸ’œ
  • -b ... β€” save or list bytecode. run it with no arguments and it gives you help on the options πŸŽ€
  • -j command β€” perform a LuaJIT control command (there's an optional space after -j, so -jv and -j v both work, iykyk).
  • -O[opt] β€” control LuaJIT optimizations 🌸 the [opt] is optional, so it's snug right up against the -O.
  • -i β€” run in interactive mode πŸ’…
  • -v β€” show the LuaJIT version. quick flex.
  • -E β€” ignore environment variables πŸ™ˆ
  • -- β€” stop processing options. everything after this is not an option, no matter how option-y it looks.
  • - β€” read the script from stdin instead πŸ¦‹ (yes, a single lonely dash)

aaaand after all options are processed, the given script is run. the arguments are passed in the global arg table ✨

🌟 important lil note: interactive mode is only entered if no script and no -e option is given. and once you're in, you can leave interactive mode with EOF (Ctrl+Z).

πŸ”₯ EXAMPLES

πŸ“ example one

luajit hello.lua world

Prints "Hello world", assuming hello.lua contains:

print("Hello", arg[1])

see how world lands in arg[1]? that's the global arg table doing its thing πŸ’–


⭐ example two

luajit -e "local x=0; for i=1,1e9 do x=x+i end; print(x)"

Calculates the sum of the numbers from 1 to 1000000000. and finishes in a reasonable amount of time, too 😭 like, a billion iterations. the JIT is carrying this whole thing on its back and it's not even breaking a sweat.


🧚 example three

luajit -jv -e "for i=1,10 do for j=1,10 do for k=1,100 do end end end"

Runs some nested loops and shows the resulting traces πŸ‘€ -jv = control command, verbose traces. main character energy fr fr.


LuaJIT is Copyright Β© 2005-2023 Mike Pall. LuaJIT is open source software, released under the MIT license. πŸ’œ


πŸ¦‹ SEE ALSO


and that's the page bestie!! πŸ’… this was luajit(1) from the LuaJIT documentation β€” footer says luajit(1) and nothing else, no date, no version number, so that's all you're getting from me on that front πŸ™ˆ mwah, go compile something iconic 🌈✨

πŸ“¦ where this page comes from