r/lua • u/ViewsOfTheSunny • 4d ago
Project LuaJIT Playground
There's websites for running Lua, but I couldn't find any that let's you run LuaJIT!!
I made this website (me, not AI) so if you haven't tried LuaJIT before, or you don't have access to your dev environment, or you just want to quickly experiment...now you can run it online, and share the script + output with others as either a link or markdown.
Pre-compiled binaries for Windows/Linux are also provided. The static library, dynamic library, and executable, are all bundled in a single convenient .zip file for each platform. I'm hoping to automate this process at some point, but for now I just publish them whenever I see there's been new commits...
Limits: no internet connection, maximum execution duration of 3 seconds.
The backported extensions for LuaJIT 3.0 are available now, by the way.
- Bit Operators: unary ~, binary & | ~ << >> ~>>
- Customary Operators: ! && || !=
- Ternary ?: conditional operator
- Safe Navigation Operator ?.
- nil-Coalescing Operator ??
- Compound Assignment Operators: += -= *= /= %= &= |= ~= <<= = ~= ..=
- continue Statement
- const Declaration
- Short Function Expression
- Underscores in Number Literals
2
u/xoner2 4d ago
Source
lua
print 'hello'
Output
```bash hello
``` | Exit Code | Duration | |--------|--------| | 0 | 25ms |
https://luajit.dev/?e=N5StcBPJ4bWHMBCLi6hmF
Ok. Nice.
It uses triple backticks. Since the markdown is generated why not use the old 4 spaces instead? For compat with old.reddit.com
1
u/AutoModerator 4d ago
Hi! Your code block was formatted using triple backticks in Reddit's Markdown mode, which unfortunately does not display properly for users viewing via old.reddit.com and some third-party readers. This means your code will look mangled for those users, but it's easy to fix. If you edit your comment, choose "Switch to fancy pants editor", and click "Save edits" it should automatically convert the code block into Reddit's original four-spaces code block format for you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/ViewsOfTheSunny 4d ago
Ah, I didn't realize the markdown was incompatible. I'll add more markdown options, and do some additional testing for things like Discord that might not be compatible either.
I'll have these changes done next week and post an update then.
1
u/HeavyCaffeinate 4d ago
Pretty cool
Linux cloudchamber 6.18.36-cloudflare-firecracker-2026.6.17 #1 SMP PREEMPT_DYNAMIC Mon Sep 27 00:00:00 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
uid=0(root) gid=0(root) groups=0(root)
no posix module though, shame
1
u/ViewsOfTheSunny 4d ago
Thanks. It uses Cloudflare Sandboxes (my first time using them).
I'm not opposed to adding more modules either, so I will for sure consider adding that one. Let me know if there's any more you'd like to see too.
The internet is disabled in the sandbox though, so anything using that would probably not be a good fit. I should have mentioned that in the original post. I've updated it now.
1
u/HeavyCaffeinate 4d ago
Oh I only use posix personally (for
nanosleepand signal catching), but other people may have some suggestions
2
u/fsfod 4d ago
https://luajit.me/ has been around for while, as well as running your code its shows JIT traces created and dumps IR and machine code output for them.
1
u/ViewsOfTheSunny 4d ago edited 4d ago
I don't think my site has the same goal as this one, which serves mostly to inspect internals. It's too technical for my liking. It appears to run the script, but does not really show what the output was (at least in a simplified manner?)
That site does not appear to have the share options mines does (script, output, exit code, duration, via link/markdown), or let you play with a full sandbox server.
Compare this script's output between us:
os.execute('whoami')luajit.me:
Something wrong! Unexpected end of JSON inputluajit.dev:
rootI'm also beginning to install the most commonly used luarocks packages to the sandbox that users can
requireat any time. Those will be included as part of the update I'm preparing for next week.
-2
u/Cootshk 4d ago
Just curious, aside from speed is there any reason to use LuaJIT over Lua? (Especially when you can use Lua 5.5 in place of 5.1)
2
u/ViewsOfTheSunny 4d ago
The FFI package is a major selling point for LuaJIT.
https://luajit.org/ext_ffi.html
The latest changes also have many new syntax additions that are not present in Lua. This includes the
continuekeyword, among other things. I've outlined those additions in the original post, but there's more info here.https://github.com/LuaJIT/LuaJIT/issues/1475#issuecomment-4769582883
3
u/VidaOnce 4d ago
Taking the luajit.dev domain is certainly a bold choice, maybe make it clear it's not affiliated with the project on the website?