4 ms·
Why would they create their own obscure solution? I imagine LUA is very easy to run sandboxed, but I can’t shake the feeling roblox would be better off integrat
by kamac 6y ago
Why would they create their own obscure solution? I imagine LUA is very easy to run sandboxed, but I can’t shake the feeling roblox would be better off integrating scripting with JS. It would come with powerful typing via typescript, a great tooling (along with a type checker), and a lot of resources available online.
- anonymoushn 6y agoIt's not easy to tell all your players that their games don't work anymore or that they cannot use coroutines. Regarding the second point, more concretely: they no longer can attach a function to a game object that defines its behavior over any length of time, and they no longer can call the sleep() function to suspend execution for a length of time.
- deleted 6y ago[deleted]
- kamac 6y agoTrue, there’s some pain involved for the developers. The migration could happen over time, like unity3d did by deprecating scripting with boo.
- samatman 6y agoThat's a popular opinion among people who have only used Javascript. Few who have used both would give it a second thought. Roblox is immensely popular, has a wide install base and thousands of developers with code in Lua already. Why throw all of that away for an inferior language?
- tasogare 6y agoIt’s also especially ironic to vouch for Javascript, and then in the next sentence switch to Typescript, which was precisely created to overcome some of JS defects.
- rpastuszak 6y ago> Roblox is immensely popular, has a wide install base and thousands of developers with code in Lua already. 100% agree till here: > Why throw all of that away for an inferior language? I'd say "not the right tool for the job, given their target audience". Saying that JS is inferior to Lua (Lua's great IK) isn't much of a productive comment—if they built their audience with JS, they wouldn't be pivoting to Lua because it has achieved superiority in the eternal language wars.
- samatman 6y agoIt was a provocative comment, sure, but I wouldn't say unproductive: others asked why Lua is superior, and several people answered, myself included. Heartily agree that the same basic argument would apply if Roblox had started with JS! Lua isn't so much better than JS that it would be worth scrapping collective centuries of labour over. But given that it is the better language, in my not-so-humble opinion, why on Earth would they switch? I think the only rational way to argue superiority of Javascript over Lua, is to point to aspects outside of the language itself: larger install base, more libraries, bigger, more vibrant community, better tooling, and so on. But I prefer to call that the ecosystem, and can confidently say that Javascript, alas, has the superior ecosystem. A pity, because Lua is the superior language.
- unchar1 6y agoI agree that lua is a good fit here, being a smaller and easier language to embed, with a much simpler runtime to boot. But could you elaborate on why you think JS is an inferior language?
- CyberDildonics 6y agoLua is smaller, more consistent, and much more flexible with integration since it just C. Debugging is built into the language in a simple way. _G gets a table of all global variables debug.getlocal allows you get any and all variables at each stack frame at that point including name, value and type. You can even use debug.sethook to have a callback after every function, line, or instruction. On top of all that you have LuaJIT which not only runs ridiculously fast, but can deal with dynamically loaded files incredibly fast. It even has a direct foreign function interface and allows you to use shared libraries directly without writing any more C or recompiling them.
- samatman 6y agoYour last paragraph is the essence of why I chose Lua for my own projects, especially the FFI, but unfortunately doesn't apply to all of Lua. The divergence between Lua and LuaJIT is certainly not a strength. The 'stock' Lua interpreter is very fast, very small (good for cache retention) and all its C functions are reentrant, so no global interpreter lock: those apply to both flavors. As the tiniest of nitpicks, `_G` is the default home of the global environment, but it's just a variable. The correct way to get the environment is `getfenv(1)` or just `_ENV`, depending on your flavor.
- lifthrasiir 6y ago> Debugging is built into the language in a simple way. Lua debugging interface notably lacks breakpoints. You can simulate breakpoints by per-line hooks but it's not performant. Many popular JS engines including V8 do support performant breakpoints by bytecode patching, and Lua do have multiple patches doing the same (well, a common theme) but none is official.
- samatman 6y ago
- wruza 6y agoI have a pretty decent experience in lua, js, python, perl and a few in other scripting languages, and personally wouldn't just throw js away in general. Yes, it is a legacy freak, but some latest parts of it are at least worth adopting in other languages. To name a few, constructing objects ({a, ...b, c:[...d, e]}), destructuring, arrow functions conciseness, proxies, default arguments. This helps much in scripting and libraries for scripting. Also I find separate objects and arrays being a better approach than just lua-tables. I like lua, really, but some parts of it... you have to struggle with constantly. Select and "..." sematics in general, meta restrictions, a bloaty syntax. Imo, the next language with a little stricter typing than both js and lua, which takes best parts of these and gets rid of bad practices, and with a typed version in mind, will be a big win for everyone.
- anonymoushn 6y agoWhat are proxies for?
- samatman 6y agoI upvoted this, although I disagree about tables vs. separate objects and arrays. If you were to say separate maps and a specialized array type, I would be more inclined to your point of view! Not sold completely, mind you. In either case, it's a productive disagreement. I agree that Lua isn't a perfected language; merely a very, very good one. From your list, I would takeaway default arguments as the first thing to bring over to this hypothetical successor language. Arrow functions could be avoided by the simple expedient of renaming the keyword `function` to simply `fn`.
- lifthrasiir 6y ago> That's a popular opinion among people who have only used Javascript. Few who have used both would give it a second thought. I have extensively used both languages for years and you haven't adequately answered my previous criticism [1]. > Why throw all of that away for an inferior language? As if Lua (either the language, the implementation or the ecosystem) is not inferior. > Roblox is immensely popular, has a wide install base and thousands of developers with code in Lua already. This is probably the only reason to justify Luau, and shows yet another problem with the Lua ecosystem: they don't (or rather, can't) share their creations to each other. JavaScript is not a perfect language but the JS ecosystem has successfully converged into a single widespread set of solutions including TypeScript. [1] https://news.ycombinator.com/item?id=24067362 https://news.ycombinator.com/item?id=24067362
- samatman 6y agoAlright, if I must: I still have no idea what your stubborn bug is. Asking someone else to debug your code is obnoxious; insisting on it, doubly so. I've never encountered it in the wild, and it sounds like a 'you' problem. Please don't bring it up again. Or if you simply must, explain yourself. This isn't a tech interview; you're not paying me to solve puzzles, or even promising to.
- lifthrasiir 6y agostring.gsub receives at most three arguments where the final optional argument is the maximum number of replacements, and returns two values where the second value is the number of replacements made. Therefore if the arguments do not have escape sequences the outer string.gsub receives 0 and `<arguments>` doesn't get replaced. I intentionally asked you to find this bug out because you can acknowledge the particular class of bugs only after biten by that bug, and you didn't seem to even know what might be problematic. In the other words, by now you can't get away by saying "you should give all function calls a name" posthumously. It's a frequent novice mistake to write `if (a = b)` in C/C++, but any good enough C/C++ programmer will point it out (and modern compilers will flag a warning). Eventually people get used with this problem and the cycle repeats, this time with less novices falling into the trap, so this class of bugs is---while problematic---not considered a huge deal. Given your reaction though, I doubt this is the case for Lua and that's yet, yet another reason to avoid Lua.
- saagarjha 6y agoLua does exceptionally well as a nice, lightweight language embedded in another project.