Skip to content(if available)orjump to list(if available)

Luau – fast, small, safe, gradually typed scripting language derived from Lua

Ciantic

Typed Lua is something I've always wanted, but writing a very comprehensive type-checker and LSP for another dynamic language is pretty difficult. All dynamic languages have similar problems to those TypeScript encountered, as most dynamic languages have a sort of structural typing in the form of dictionaries or objects.

I do wonder if we could reuse TypeScript in other dynamic languages.

Transform Luau to a subset of TypeScript, check with tsc, transform errors and results back to Luau. In the same way, one could reuse a TypeScript language server. This way of utilising TypeScript's engine could jump-start many other type checkers for other dynamic languages.

cjbgkagh

Like a LLVM but for type systems instead of compilation / interpreters / JIT. I don’t see why that couldn’t work.

My thinking in this space has always started from a type inferred MetaLanguage but starting from a dynamic language does enable some interesting options. I tend not to touch dynamic languages, even going so far as to use transpilers, but I definitely would be more open to the idea of working with them if they had TypeScript level of gradual type checking and tool support.

ngrilly

I learned about Luau via my 13 years old who is looking into Roblox Studio. That's how I ended up visiting luau.org and I'm quite impressed by Roblox's engineering on this.

pansa2

How does Luau compare to Teal [0], which is described similarly as a "statically-typed dialect of Lua"?

[0] https://teal-language.org/

cardanome

Teal compiles teal files into plain Lua just like TS does for JS. So all the advantages and disadvantages apply.

Luau is a backwards compatible superset of Lua that comes with it's own performance-tuned runtime. It offers more than just gradual typing.

So they are very different things. You can use Teal in cases when you don't control the runtime. Like write a Love2d game or your neovim config in it. Anywhere where Lua runs, you can use teal.

On the other hand Luau can offer superior developer experience because you don't have a separate compile step. They can do a lot more things that are impossible with teal as they have their own runtime and types do not get erased by compiling.

Scaevolus

Teal transpiles to Lua, but Luau is a fork of Lua. Luau can implement wider ranging changes, like improving interpreter performance and security or adding syntactic sugar.

Roblox has a market cap near $100B and has multiple developers working full-time on Luau.