11 ms·
Luau – A fast, small, safe, gradually typed scripting language derived from Lua
- eggy 6y agoInteresting. Seems like a Typescript for Lua. The Roblox platform is a great testing platform for it I am sure.
- giancarlostoro 6y agoI gave this game a try last night, it was amusing all the different types of games you could potentially play, I was wondering who developed each one. It seems you can build your own games (game modes? unsure of the term for Roblox) and earn some income on it. I had no idea it was done in Lua, might give it a shot to see what is possible.
- QuesnayJr 6y agoRoblox is like a game engine that you can script in Lua, plus the servers to run the engine for you. The barrier to entry to make a game is relatively low -- making an obstacle-course game requires almost no coding, for example.
- kitd 6y agoMy son spends his life on Roblox. If you're ever after beta testers? ;)
- exikyut 6y agoHmm, that's a good idea - connecting interested kids directly with Roblox developers and letting them play around in/QC alpha-stage worlds. That would teach the value of iteration, failing forward and how to deal with imperfection at a very early age. Of course reality is not a vacuum and there would be a lot of noise though :)
- giancarlostoro 6y agoAh man! I'm just starting to learn, so if I get far enough along maybe I'll write up a blog post and submit it on here documenting my concept, still unsure what I want to do currently though.
- homarp 6y agohttps://techcrunch.com/2020/07/28/roblox-jumps-to-over-150m-monthly-users-will-pay-out-250m-to-developers-in-2020/ https://techcrunch.com/2020/07/28/roblox-jumps-to-over-150m-... Roblox has 150m users. will pay 250m to devs. 2020 dev conference talks are now avail https://developer.roblox.com/en-us/resources/rdc https://developer.roblox.com/en-us/resources/rdc
- deleted 6y ago[deleted]
- AnonsLadder 6y agoI've played this a lot back when Roblox was still brand spanking new. It's absolutely a lucrative area if you can manage to make multiple game-modes with people buying your in-game items for RBux (RBux is the premium currency roblox, which can be used to extend your developer membership or be redeemed to cash). Those big game modes out there with a lot of traffic are actually making real decent money. The game is played by millions of kids willing to spend money on cosmetics/advantage on game-modes. If I recall, I think it was 2017, Roblox rewarded $200k to a young developer for his work on a DayZ Roblox clone.
- chc4 6y agoRoblox is essentially a full on game engine and store now, comparable to Unity + Steam with free, automatic cloud hosting and matchmaking. There's a lot of daily users, and the top earners on the platform make multiple millions of dollars from it. I first learned programming due to Roblox. It's really easy to pick up, and you can make almost whatever type of game you want. I honestly believe that highschool programming classes should universally use it for introducing how to code rather than Javascript or Unity.
- jwatte 6y agoThe way I see it, Unreal is eating Unity from above, extending down, and Roblox is eating Unity from below, developing awesome new technologies. Gotta be hard being Unity :-) Roblox has tons of innovation. It has a volumetric/voxel based lighting system. It has networked rigid body dynamics built right in. It lets you take your avatar between each game, keeping your look. And you can late-join any game -- you don't need to be there "at the start." Some games have tens of thousands of moving pieces, yet load reasonably quickly. Check out the tornado in Natural Disaster Survival for a good example!
- eggy 6y agoI've been playing with Minetest instead, because it is easier to work in isolation without a Roblox server. Can you run a Roblox server in single player mode?
- monkeypizza 6y agoYes, and you can run a local server as part of the test functionality in Studio.
- eggy 6y agoThanks! I'll give it a try this weekend. I tend to isolate, so social gaming is not my comfort zone, which is why I like to play Minetest on my local machine by myself. I do play with my kids in the same game on one computer though, so there is hope ;)
- McKayDavis 6y agoPlease check out Roblox Studio [1], the free Win/Mac IDE for creating and publishing games on the platform. Also look at the developer site [2], where you can find documentation, tutorials, and an awesome, active community in the developer forum [3]. [1] https://roblox.com/create https://roblox.com/create [2] https://developer.roblox.com https://developer.roblox.com [3] https://devforum.roblox.com https://devforum.roblox.com (disclaimer: I'm an engineer on the Roblox Studio team)
- giancarlostoro 6y agoAfter having read this HN post this morning I went ahead and installed the studio, it's pretty damn nice, there's a bit to unload for me mentally but I love the whole thing so far, you can test within the IDE and switch between user / server which seems interesting. I'm currently teaching myself Godot so I can make some games on my time off but this seems like an even easier approach given that a lot of graphics are already available plus the user base. I guess now I have to learn how this all works, and what kind of games most users like so I can try to make something interesting and different. Thanks for the links, so far from what I can see Roblox Studio is pretty good!
- minxomat 6y agoThere is a typescript for lua: https://github.com/teal-language/tl https://github.com/teal-language/tl
- dgb23 6y agoIs it actually a TS for Lua or does it use the annotations to improve performance?
- MaxBarraclough 6y agoIt transpiles to plain Lua, so presumably it doesn't improve performance. https://github.com/teal-language/tl/blob/master/docs/about.md https://github.com/teal-language/tl/blob/master/docs/about.m...
- minxomat 6y agoNo, literally TS. It compiles to plain Lua, doesn't add any language features apart from types, has an equivalent strict mode and uses .d.tl files just like .d.ts
- Kinrany 6y agoThere's also roblox-ts: a fork of the TypeScript compiler that compiles to Lua with Roblox's runtime. https://roblox-ts.com/ https://roblox-ts.com/
- HighlandSpring 6y agoMissed opportunity to call it Lau (Lua was sometimes called such jokingly in the Garry's Mod community)
- andrewmcwatters 6y agoCreated by "John Lua," another Facepunch gag.
- nafey 6y agoPossible to make this work on LuaJIT as well? If this is transpiled to Lua 5.1 it should be possible to make this work with LuaJIT runtime. Combined with Openresty and gradual typing this could be a quite a good language for writing Backend services.
- minxomat 6y agoTake a look at teal, it does exactly that.
- nafey 6y agoAny links? Teal appears to be an assembly language from my google search.
- durub 6y agoHere it is: https://github.com/teal-language/tl https://github.com/teal-language/tl
- nonbirithm 6y agoIt's also made by the same person who created LuaRocks and htop. I'm personally hoping tl or something will take off as the de-facto TypeScript for Lua. I'm already convinced that types are better. I'd use types all the time if I could. It's just that not a whole lot of people seem to care about Lua, even with how fast LuaJIT is, so you have to compromise with projects adding types to Lua that are only in their infancy, assuming they'll still be around after a couple of years. TypeScript has proven that gradual typing can be done right and had a bunch of innovations I never would have thought of (the keyof operator for creating a type of "the set possible key names of T" for instance). Having that kind of power in Lua on top of one of the fastest JIT compilers on Earth is my dream.
- minxomat 6y agoTogether with Teal, LuaJIT can become a very safe platform. Vela (fork with many improvements to LuaJIT) has optional, native recursive immutability built into the JIT for Lua-land objects and also compiles next() to dig pairs out of the nyi hole. Also Moon+ (even more expression version of MoonScript) is considering implementing the teal checker natively: https://github.com/pigpigyyy/MoonPlus/issues/15 https://github.com/pigpigyyy/MoonPlus/issues/15
- tcbawo 6y agoI like the mention of an internal tool called "SECRET TOOL". It makes me wonder why the name would be redacted, although I'm amused by the idea of that actually being its name.
- akavel 6y agoDon't know Roblox, but I guess this could be also a name of some kind of an in-game-world tool? I.e. like a sword or pickaxe?
- 1f60c 6y agoI want to believe there’s a piece of internal software that is literally called SECRET TOOL.
- hannula 6y agoAs a Roblox user, I believe it might be their tool that allows Luau code to be stored on the filesystem and automatically synced to games. There are references to "FileSyncService" in the binaries, but the engineers refuse to open it up for some reason.
- deleted 6y ago[deleted]
- zeckalpha 6y agoToo bad MetaLua never took off, these could be macros embedded in Lua rather than a separate language. http://metalua.luaforge.net/index.html http://metalua.luaforge.net/index.html
- fsfod 6y agoIt may not be exactly the same but Terra http://terralang.org/ http://terralang.org/ uses Lua a meta programming language and the Terra language itself is effectively a typed Lua compiled to machine code with LLVM.
- infinite8s 6y agoTerra looks really interesting (Halide is another language along this meta-approach - https://halide-lang.org/ https://halide-lang.org/). It's too bad it never made it further than being used for a few PhD theses.
- eggy 6y agoI like Terra, and I have played with it, but I have not found a use for it to push me to really explore it. I'd love to hear from anyone using Terra for cool projects. I had watched a talk about MAD-X [0] that I found very interesting, but it is specifically for particle accelerator design in physics [1]. [0] https://mediastream.cern.ch/MediaArchive/Video/Public2/weblecture-player/index.html?year=2016&lecture=487416c0&ftime=00:14:11 https://mediastream.cern.ch/MediaArchive/Video/Public2/weble... [1] https://mad.web.cern.ch/mad/ https://mad.web.cern.ch/mad/
- DarkWiiPlayer 6y agoSo another typed Lua, huh? What are the main differences to teal?
- chabad360 6y agoIt actually only gained proper type support relatively recently (I don't remember exactly when as I haven't touched it in a while). It also has some other features other than types (again, haven't used it in a long time, so I can't really remember, but have a look around). The real difference tho is age, Luau has been around since 2006 or so (used to be known as Rbx.Lua).
- implicit 6y agoHello! I am the lead developer of the Luau type checker. I actually hadn't heard of Teal! I don't think it existed when we started. Judging from the Teal documentation, I'd venture that it looks pretty similar to Luau in everyday use. If I were to guess, I'd venture that the biggest differences are probably the kind of type inference we do (Luau's inference engine draws inspiration in equal parts from OCaml and TypeScript), a bunch of Roblox-specific features, and that our inference engine is all C++ for performance.
- DarkWiiPlayer 6y agoOh, that's interesting :D I've been meaning to try out roblox for a while and lately I've been getting pretty hyped about teal (for context, the guy behind it is the creator of luarocks and htop, among others) so I might see the differences up close sooner rather than later :D EDIT: (unrelated) Already not looking forward to people asking "Lua" questions about typing and constantly having to explain that Lua is not just a roblox thing xD
- Jyaif 6y ago"Please note that at this time we are not ready to make Luau implementation publically available in the source form" 1/ Code source is not available, so it feels like the purpose of the page is just to brag about how good your interpreter is. 2/ s/publically/publicly/
- whizzter 6y agoNot necessarily, since it's in production they might be hoping for a bit of securty-by-obscurity if they haven't had time to get an audit the code (runtimes are always hard to get 100% correct since they're so generic, esp for a language such as Lua). Seems like this runtime was announced to Roblox developers almost a year ago. But i don't think they've put much thought or effort into open sourcing it and it just happend to pop up in peoples feeds now since Arseny published an article(#1) about his 8 years working for Roblox 2 days ago and somebody probably took the link from that article (Quite an interesting read if you're into gamedev). #1 , https://zeux.io/2020/08/02/eight-years-at-roblox/ https://zeux.io/2020/08/02/eight-years-at-roblox/
- varshithr 6y ago[Offtopic]: The name Luau reminds me of an episode from It's Always Sunny in Philadelphia :)
- tomp 6y agoI wonder how the interpreter works. In their Performance page they write: > It’s similar to Lua interpreter in that it’s written in C, but it’s highly tuned to yield efficient assembly when compiled with Clang and latest versions of MSVC. On some workloads it can match the performance of LuaJIT interpreter which is written in highly specialized assembly. One thing I've been experimenting for my own project, is using tailcalls. All main compilers (gcc, Clang, MSVC) are able to compile that into actual tail calls (i.e. `jmp`, not `ret`, so that the stack doesn't overflow) (with optimizations enabled), even for indirect calls (i.e. dispatching depending on the next instruction). Function parameters (VM state) are assigned to registers, alleviating Mike Pall's main complaint about writing interpreters in a high-level language, that the compiler cannot optimize the huge loop as well as a human can. I need to test this on a full interpreter with 50 or so instructions, to see if the optimizations still apply.
- chc4 6y agoThe Luau FAQ[1] when they first announced the project mentions that Mike Pall post. I assume they do the computed goto trick for fast interpreter dispatch (or just have some inline assembly now). 1: https://gist.github.com/zeux/bb646a63c02ff2828117092036d2d174#is-your-interpreter-written-in-assembly https://gist.github.com/zeux/bb646a63c02ff2828117092036d2d17...
- rurban 6y agoThey explain it in some subsequent page. Also computed goto is not really performant enough for fast scripting languages, it's essentially a switch (indirect func table) without range check. The performant variant is to squeeze it to have room for other code, keep important registers asis, and jit the bytecode array into sequences of static calls. They next best variant is to call the next op statically. Indirect func tables are hard to predict by the CPU. They explicitly removed tailcall for better user experience, as it messes up debugging and stack traces. Maybe it could be added back in perf mode.
- rapidlua 6y agoI am currently exploring the similar approach. The idea is to compile to llvm IR and then augment it. There's a musttail marker in the language to enforce tail calls no matter what the optimisation level is. Passing VM state via arguments is suboptimal since argument registers are often clobbered and one would normally use callee-saved registers. I have developed a patch for llvm allowing to specify registers used for passing arguments and making more registers available for allocation without spilling. I intend to reimplement LuaJIT VM in C with IR augmentation to verify the performance.
- dman 6y agoLua runs the same risks as Scheme which is another small language - of multiple incompatible implementations cropping up because it is so easy to create an implementation. [Dont mean to downplay the difficulty of writing an implementation just to highlight that the engineering cost of doing so is not prohibitive enough]
- jdc 6y agoEh the way I see it, an implementation either passes the canonical Lua test suite(s) or it doesn't.
- bch 6y agoSimilar for scheme (to degrees: I.e. r4rs, r5rs, r6rs, ...) and I still found it confounding and nerve racking to find a place to start. This may be a place where “technically correct is the best correct” doesn’t hold, at least in terms of community psychology.
- bjoli 6y agoStarting with scheme for most people I talk to seems to follow a similar path: start with one implementation. Write some code. Try it in another scheme. Discover r6rs. Either like it and switch to chez or guile or keep using whatever it was you are using. I have a pretty small data set (5 people) and three of them are guile users. Scheme is however willfully underspecified, whereas most other languages lack specifications of even a proper base language (except for code). Implementing scheme is pretty easy apart from continuations and macro hygiene, but those parts are very well specified somat least you know what you are aiming for.
- xanathar 6y agoI was almost semi-proud of having done my implementation, why did you ruin the party. Jokes aside, and not to boast about what I did, honestly, but Lua is (in hindsight - I wish I realized before) full of gotchas which are definitely not easy to implement (just one word which still makes my stomach hurt: COROUTINES). I honestly think there are simpler (and better) languages to target. With hindsight, experience and pain, of course.
- Symmetry 6y agoSeems much less of an invasive change than MoonScript is.
- JHelmsAt 6y agoIn case anyone is interested: Roblox (who is making Luau) is hiring. We've been growing fast, and are looking for strong C++, systems, and application engineers. As a highly vertically integrate gaming platform, we've got a lot of hard problems to solve - from programming language design (see OP!) to debugger tooling. You can email me at my username plus roblox.com.
- andrewmcwatters 6y agoHi JHelms, I'm the author of the largest pure-Lua game engine on GitHub, Planimeter's Grid Engine 9 (https://www.planimeter.org/grid-sdk/ https://www.planimeter.org/grid-sdk/). I'd love to chat, and sent you an email.
- deleted 6y ago[deleted]
- deleted 6y ago[deleted]
- bakuninsbart 6y agoMost important question not asked or answered: Is it pronounced Lua-you or Lu-au?
- implicit 6y agoAuthor here. :) It's Lu-au. It's like a party in your development environment!
- deleted 6y ago[deleted]
- looki 6y agoThe front page sample does not explicitly use the Point type in the declaration of p. Typo or does the compiler actually match table variable definitions to available type definitions?
- otikik 6y agoIf this sort of thing interests you, you might want to look at https://github.com/teal-language/tl https://github.com/teal-language/tl It implements types on top of Lua. In a single (middle-sized) Lua file. And it is open source.
- forrestthewoods 6y agoIs Luau available for other developers to use? Or is this a secret VM exposed to Roblox? Put another way, if I don’t play Roblox is there a reason for me to care?
- jdonaldson 6y agoVery happy to see this, Lua has a bunch of great properties (small footprint, speedy JIT, simple datastructures). It's great for quickly hacking together some script functionality, and it (already) handles enormous scale in enterprise applications (e.g. Cloudflare). I maintain the Haxe Lua target, and have a good understanding of how Lua relates to other languages (at least through a "Haxe" lens). I think the main things I get hung up on is the 1-indexing scheme, and the lack of true "null" fields on tables (Lua treats these as missing). This makes Lua tricky to integrate with other languages, especially if they serialize/de-serialize data. You essentially have to pick a work-around, and unless you know what you're doing (and what you're doing 5 years from now), you're going to feel a lot of pain. I realize changing these things would make Lua less "Lua", but virtually every other language Haxe supports has straightforward support for these behaviors. It's really the only two nits that have marred an otherwise pleasant experience working with Lua.
- G4BB3R 6y agoWhy not local-by-default? And have a global keyword instead?
- boring_twenties 6y agoCan someone ELI5 why Lua is so popular? I don't know anything about it, but just looking at it, it seems like a giant mess. 1-based indexes. Semicolons required here, but forbidden there. Like... why?
- theamk 6y agoI have heard it is very easy to embed into C/C++. Friendly API. Tiny stdlib, so no need to ship thousands of support files.
- kemayo 6y agoIt's small, simple, and really easy to integrate into a bigger application. It thus makes for a great language to use for glue code when you're doing things like writing game logic / UI. Also, semicolons forbidden? I don't think there's anywhere you're disallowed from using them to separate statements, though they're largely optional / redundant with newlines.
- samatman 6y agoI use Lua(JIT) extensively. cons: - 1-based indexing - you basically always want a local but you have to ask for one, it's a bit noisy. 'strict mode' is easily applied to the global environment, and catches most outright errors here. - there is an adequate amount of library and extension code, but less than you'd expect coming from Ruby or Python. The lack of a blessed object system sometimes means taking more effort to understand what other people's code does. pros: - variadic functions and multiple return values make for a truly dynamic language - first class functions which are fast and work well: everything is a closure, a whole file is just an anonymous function called a chunk - the table as a single compound data structure works very well, and metatables are a unique and excellent solution to extending behavior. Array portions are required to be compact (non-nil from 1 to #tab), which can be worked around on the few occasions when it's inappropriate. - asymmetric coroutines. - first class environments, which are just, yep, tables. this allows for a few really nice things. - fast. LuaJIT is very fast. Both Lua runtimes fit in a typical L1 cache, and it uses a register VM, which is a good fit for real processors vs. stacks. No global interpreter lock, all C level Lua functions receive a Lua_state as the first argument and are fully reentrant. - in general the emphasis on minimalism means the whole language "fits in head", and the tools provided are more than adequate to get jobs done. - the LuaJIT FFI, which parses C declarations directly, is simply a pleasure to use, and is the only one of which I'm aware where you pay an absolutely minimal penalty to use it. There's just nothing like it. More languages need to have this. miscellaneous: Semicolon insertion is simply a non-issue, unlike JS it was implemented properly. I have well under one semicolon per file, less than one per project, even. It's very, very occasionally nice to write more than one statement per line; that's what the semicolon does. It's a nice language.
- monkeypizza 6y agoVideo summary of the optimization process by the designer: https://www.youtube.com/watch?v=vScM-nk5Avk https://www.youtube.com/watch?v=vScM-nk5Avk
- pansa2 6y ago> Note: our garbage collector optimizations are still in progress, so this section doesn’t document them. It will be interesting to see whether they make any major changes to Lua's garbage collector, which is an incremental tracing GC. Several gaming-focused scripting languages use reference counting instead of tracing GC, even though throughput is lower. This is because RC (almost?) eliminates the need for stop-the-world pauses, making it easier to maintain a consistent frame rate.
- shaggie76 6y agoI'm curious what they do to the garbage collector; over the last few years we've made quite a few optimizations to our Lua 5.1 codebase to reduce the impact it has and yet just last week I was in there again squeezing blood from that stone.
- pansa2 6y agoWhat problems have you had with the garbage collector? Excessive pauses? Insufficient throughput? Many other game-focused scripting languages use reference counting instead of tracing GC to eliminate pauses at the expense of throughput. Would that help in your situation?
- shaggie76 6y agoWe use a hybrid of ref-counting for many things but Lua still needs to do sweep phases in its GC that cannot be amortized across multiple frames. While we do most of Lua's GC asynchronously some of the phases take so long that they can stall the main thread that wants to execute some bytecode. Here's an older tweet with some examples (I'm not the one tweeting but I made the optimizations): https://twitter.com/sj_sinclair/status/1097920762147733506 https://twitter.com/sj_sinclair/status/1097920762147733506