Live data from Hacker News

Teal – A statically-typed dialect of Lua

teal-language.org

71–80 of 176 posts

Re: Teal – A statically-typed dialect of Lua

#72
post #11

Tuples: {number, string} Arrays: {number} How does it disambiguate it? Are single-element tuples just never used in practice? To be fair, maybe the only time I've had to use them in TypeScript is via Parameters

Now I am curious what {number, string, number} would be considered as.

Re: Teal – A statically-typed dialect of Lua

#73
Years ago, I tried lua and wasn't impressed. Then I started using Neovim, did the necessary configuration in lua, but continued writing my own scripts in vimscript. Later I started using wezterm and decided to give lua a second shot, and I began to really like it.

I realized my initial dislike for lua stemmed from my experience with javascript (back in the jwquery days), where maintaining large codebases felt like navigating a minefield. The lack of type system made it all too easy to introduce bugs.

But lua isn't like that. It's not weakly typed like javascript - it's more akin to pythons dynamic duck typing system. Its simplicity makes it remarkably easy to write clean maintainable code. Type checking with type is straightforward compared to python, mostly because there are only five basic types (technically seven but I've never used userdata or thread). And I even started to enjoy using metatables once I understood how and when to apply them.

That being said, lua's lack of popularity probably stems from its limited stdlib, which often feels incomplete, and the absence of a robust package manager. luarocks is a pain to work with.

All that being said, I don't really see the point of using this project.

While I do wish type annotations were a native feature, the ones provided by the lsp are good enough for me.

Re: Teal – A statically-typed dialect of Lua

#75
I really like Lua and I work with it almost daily. But, I hate luarocks. It just don't work well on Windows. And I don't know why. The management of external libraries makes Lua still too difficult to use, which is a real shame considering the qualities of this programming language.

Re: Teal – A statically-typed dialect of Lua

#76
post #40
post #27

Earlier quoted context omitted.

> Teal replaces Lua's tables - the language's signature single, highly-flexible data structure - with separate arrays, tuples, maps, records and interfaces They're all just Lua tables with specialized type checking for specific behavior. I really wish the Lua authors would add official types to Lua. The time has come.

> I really wish the Lua authors would add official types to Lua. Never going to happen IMO. Adding static types would change the nature of the language completely, even more than it has in Python. As Teal shows, it would require giving up one of Lua's core features: tables as the language's single data structure. It would significantly complicate a language known for its simplicity. Even the implementation would need…

> As Teal shows, [official typed Lua] would require giving up one of Lua's core features: tables as the language's single data structure.

Is that true ... you can't have typed tables without giving up tables as a data structure?

Re: Teal – A statically-typed dialect of Lua

#77
post #9

Earlier quoted context omitted.

It's nothing like C, and that's so much of its charm. Semantically, Lua is almost identical to the core of JavaScript. Metatables are a genius alternative to prototype chains. Lua's syntax is beautifully simple and unambiguous, but at the cost of being moderately inconvenient in 2025 unfortunately. It could benefit from an ESNext-style renewal. I get why they made the C API that way, but in practice it's very easy to…

Sure, if you compare via semantics Lua and Javascript make sense to liken. But in terms of complexity, Lua is far more like C. There's no unfucking all the horrible decisions baked into javascript and I wouldn't touch it with a ninety-foot pole, but Lua still has some hope.

To be fair Lua also made some bad decisions, though maybe not as bad as javascript:

- tables being used for both objects and arrays can create a lot of confusion, especially when you have some integer keys, but not all, and especially when they are not consecutive or one of them is 0 - indexes start at 1 - assigning nil deinitializes variables/entries instead of assigning the value `nil` (this becomes especially bad if you mistakingly try to use nil as a value in an array/table) - nil and false are falsy, but not 0, which instead is truthy

Re: Teal – A statically-typed dialect of Lua

#78

I really like Lua and I work with it almost daily. But, I hate luarocks. It just don't work well on Windows. And I don't know why. The management of external libraries makes Lua still too difficult to use, which is a real shame considering the qualities of this programming language.

Something to keep an eye out for is Lux: https://github.com/nvim-neorocks/lux. Looks like a promising replacement to Luarocks, but is still pretty early in development.

Re: Teal – A statically-typed dialect of Lua

#79
post #45
post #40

Earlier quoted context omitted.

> I really wish the Lua authors would add official types to Lua. Never going to happen IMO. Adding static types would change the nature of the language completely, even more than it has in Python. As Teal shows, it would require giving up one of Lua's core features: tables as the language's single data structure. It would significantly complicate a language known for its simplicity. Even the implementation would need…

>> I really wish the Lua authors would add official types to Lua. > Never going to happen IMO. Adding static types would change the nature of the language completely, even more than it has in Python. You both are kind of right. The Lua authors have been working on the new companion language to Lua named Pallene. Pallene is a subset of Lua that adds types, not for the sake of types themselves, but for the purpose of p…

Docs https://github.com/pallene-lang/pallene/blob/master/doc/manu...

Looks similar to Teal.

This is relatively exciting.

Also, called it!

Disappointed that it maintains syntactic Lua compatibility. Would have been a good time for a clean slate on the shoulders of hindsight.

Re: Teal – A statically-typed dialect of Lua

#80
post #20

> Teal is a statically-typed dialect of Lua. I was expecting Teal to be "Lua + type annotations", similar to Mypy. However from a quick look it does indeed seem to be a "dialect" in its own right. Teal is Lua-like and compiles to Lua, but there's more to it than just static types. Perhaps it's more similar to TypeScript? For example, Teal replaces Lua's tables - the language's signature single, highly-flexible data s…

I'm not sure if I follow.

Teal still compiles all those things into plain Lua tables, it's just that the type system has different table subtypes for better type checking. I think the variable scoping is also the same as regular Lua?

Post reply on HN