14 ms·
Lune: Standalone Luau Runtime
- euvin 1y agoCool to see a niche tool I use suddenly on hacker news! I just use it to serialize Roblox game assets, but I do wonder how many people are out there using it for non-roblox purposes.
- 90s_dev 1y agoThis looks like a great alternative to TypeScript + Node.js which I currently use. My main gripe with Lua (and thus Luau) is colons. It's so easy to forget them. Does the type checker catch this error? And if so, does it catch it every time, provided you always use types? If so, that could be good enough for me. Especially if it has strong LSP + VS Code support.
- gsck 1y agoDo you mean colons for calling methods of an object, or semicolons at the end of lines?
- LoganDark 1y agoLua doesn't require semicolons at the end of lines. (Or lines at all.) Meanwhile accidentally using a period instead of a colon (field call instead of namecall) is completely semantically different (namecall passes self).
- Moomoomoo309 1y agoOh, Lua's type checker doesn't check function calls at all. Pass too few arguments? The rest are nil. Pass too many? The extras are dropped. An editor could check for it relatively easily (and some do, I think), but the language doesn't care at all.
- debugnik 1y agoIs this true of Luau as well, which is the dialect used here? Or are you talking about just Lua (which doesn't have a type checker at all) or LuaLS? I'd check for myself but Luau's web demo seems to lack the most important feature of their dialect, type checking.
- parenwielder 1y agoHi there, I’m from the Luau team. Just wanted to clarify that no, nothing they said about the type system is true of Luau. It reads like a comment about Lua’s runtime typechecking maybe (which is as limited as you’d expect from a dynamically typed language).
- debugnik 1y agoThanks, I suspected as much! Since you're here: Is it reasonably feasible for users to add declaration files for code exported from the host application? The lack of documentation got me stuck the last time I tried to embed Luau. Aside from that, I'm very excited about it!
- deviaze 1y agoYes! As an embedder you can write definition and declaration files! Declaration files are usually named like `globals.d.luau` and have a slightly different syntax than regular Luau. But it's really easy to set up global def files that you can pass to luau-lsp. Atm for my Luau runtime (seal), I have a small globals.d.luau and just bundle all the stdlib type files in a typedefs folder that gets included alongside my binary: https://github.com/deviaze/seal/tree/main/.seal https://github.com/deviaze/seal/tree/main/.seal This is just because definition files don't support doc comments yet (for hovers w/ luau-lsp)
- SkiFire13 1y ago> Lua's type checker Lua has a type checker?
- parenwielder 1y agoLuau’s type system does arity checking and type checking for function calls, and even has a specialized error that detects when you probably meant to write a colon instead of a dot.
- CompeyDev 1y agoLuau is gradually typed, so as long as you type it strictly (which is a little bit more than just defining the method with colon-notation, but there has been interest in making it simpler), it will catch this. Unless you're using metatables, this would just be manually defining `self` with a type containing the fields you want it to represent. For example: ```luau local Module = {} export type Module = { field: string } function Module.Something(self: Module) print(self.field) end return Module ``` EDIT: oops, new to this site; expected codeblocks to be a thing :p
- ricardobeat 1y agoAt this point I see it as turn-off when a project like this uses Rust. Slow, massive tooling and such a huge barrier to entry, when we have Go, Zig or just C (this ends up being largely backed by libc/ucrt anyway?).
- lionkor 1y agoWhere is the barrier and what does it look like? Other systems languages have similar complexity, even though it may not be obvious when they don't enforce all their rules
- ellg 1y agowhats the actual barrier? installing rust? looking at the instructions this doesnt seem much harder than installing zig or go?
- codeflo 1y agoIt isn’t, arguably easier than installing Go (no GOPATH). Rust compile times are really slow compared to Zig or Go though. (Edit: As this seems to trigger some people: I code in Rust. I’m just stating the facts.)
- ellg 1y agoDont disagree that compile times are slower compared to alternatives in this space, although I'm not sure I'd quite describe that as some sort of barrier to entry from contributing
- timschmidt 1y agoRust compile times are *really* fast compared to running Zig or Go through a static checker and then a compiler, to arrive at similar confidence in the behavior of the code as a single run through rustc. It sounds like maybe you're used to skipping part of the development process required for stable well-tested software. Maybe that works for UIs? Wouldn't want my runtime authors feeling that way.
- Dekkonot 1y agoDisclaimer: I've contributed to Lune multiple times and have contributed off and on to Luau as well. For those who aren't familiar, Luau is a language based on Lua that is developed and maintained by Roblox. It's entirely open source (you can see the repo here: https://github.com/luau-lang/luau https://github.com/luau-lang/luau) and it's diverged a fair bit from Lua at this point. Most notably, it's quite a bit faster than the PUC-Rio distribution of Lua, has native vector support, and has a type checker. It's not as fast as LuaJIT, but it's about as fast as you can expect for a non-JITed language and it has support for AoT compiling to native instructions on x86 and aarch64, so it can be basically as fast as LuaJIT for some tasks. It's worth reading the website: https://luau.org/ https://luau.org/ Lune itself is nice and I use it for basically all of the scripting needs I have. Some of the API is limited compared to what you'd get in other runtimes (the obvious example is hashing, where it's just "string in, string out" instead of a stream that you can feed into and then finalize) but the logic is essentially that APIs should be "good enough" for the average user, not perfect. I think that's fine, but I'm also the one that wrote the hashing API so take it with a grain of salt. :-)
- merb 1y agoDoes it compile to wasm? So that it is useful inside the browser?
- Dekkonot 1y agoLuau itself does by design, but I've never tried compiling Lune to WASM. I know that there are some blockers with the Roblox library but that's an optional component and you can just leave it out. The WASM build is actually what powers the demo on their website: https://luau.org/demo https://luau.org/demo
- CompeyDev 1y agoHey! Yet another long-term contributor to Lune, and this is something I've experimented with for a while, but it wasn't possible due to our heavy reliance on Tokio for async I/O for a while. That has recently changed though, so I'm curious if that has changed much. I might try again and report back here. However, I should mention that there is another Luau runtime called cart which has the sole goal of being heavily portable across environments -- and it supports running within WASM! You can even interact with JS APIs and mutate the DOM to write websites with it, if you wanted to. cart: https://github.com/crossapprt/cart https://github.com/crossapprt/cart
- deleted 1y ago[deleted]
- gitroom 1y ago[dead]