85 points · by Apakovtac · 6y ago · 49 comments
It seems silly to be concerned about parse time given that Luau uses a multi-pass optimizing compiler to generate bytecode.
Edit: see also teal[0] (newish) and typedlua[1] (dead?)
From the site: https://roblox.github.io/luau/
"Luau is currently only runnable from the context of the Roblox engine, which exposes a large API surface documented on Roblox developer portal."
return someFunction<A, B>(x)
This is actually a case where TypeScript's promise:> All valid JavaScript code is also TypeScript code. You might get type-checking errors, but that won't stop you from running the resulting JavaScript.
...is broken. The following JavaScript is perfectly valid:
function f(something, other) {
const A = 1;
const B = 2;
return something < A, B > (other + 1);
}
console.log(f(0, 0), f(2, 2));
If you run it in your browser you get 'true false' as output. Passing it through the TypeScript compiler produces the following: function f(something, other) {
const A = 1;
const B = 2;
return something(other + 1);
}
console.log(f(0, 0), f(2, 2));
Trying to run that produces the error 'something is not a function'.TypeScript can get away with things like this because such expressions are weird, rare, and mostly pointless.
The equivalent function in Lua would not be nearly as weird. It would simply return two booleans. There is no clear argument to be made here that the user actually meant a generic function call.
https://github.com/Benjamin-Dobell/IntelliJ-Luanalysis/
https://plugins.jetbrains.com/plugin/14698-luanalysis
It's essentially Flow for Lua. It's not at all trying to be its own language, but rather been built out of my own needs to write maintainable code in environments that only run Lua.
Sounds to me like they are trying to reinvent python3 in lua. Why not embed python anyway?
You can embed Python, but making it safe to run untrusted code written by users will take enormous effort. Roblox is a platform for easily creating games and playing other people's games. They can't allow those games to pose a security risk to players' computers.
> Not sure how fast it needs to perform once embedded, apparently you know.
You're commenting this on a post that talks explicitly about wanting a faster interpreter than Lua 5.1. Nobody is switching from Lua to Python and getting better performance out of it.
Same reason TypeScript was created: to allow gradual typing in already-existing Lua codebases. Unless you mean adding it in addition to Lua, in which case, what advantages does that offer?
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?
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.
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.
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.
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`.
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.
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.
But could you elaborate on why you think JS is an inferior language?
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.
Tables are immensely better than JS objects, in every way. I could entertain a separate array type in the abstract, but given what actually exists, I will take tables over the JS collection of objects, arrays, and maps, any day.
Extensible syntax, which is used to implement "objects", but also to, well, extend the syntax. Indexing, assignment, calling a table like a function, operator overloading: it all works the same way, and it all works. Metatables are superior to prototype chains, simple as.
Coroutines. I don't have the energy to write up my personal take on why these are the best baseline abstraction for cooperative concurrency in a dynamic language; one of these days I'll publish something so I can simply link to it.
Multiple return values. A language without variadic parameters and multiple returns is less dynamic than one which has them, if you're going to go dynamic, go all in.
Environments! This is one of those things which you might not need very often, but when you do: oh man, great to have. Number one thing I would carry over into the browser, where we really don't want to leak context, and JS fights against this constantly.
As minor desiderata, Lua's type coercion, the fact that 0 is truthy, a separate `..` concatenation operator, and optional semicolons which basically cannot bite you: Lua has no need for a separate `==` and `===`, and I consider that a strength. I also think the separate `null` and `undefined` is clunky, but that opinion isn't strongly held; Lua has considered adding an `undef`, and it's an interesting debate which I'm just barely on the "no" side of.