Live data from Hacker News

Teal – A statically-typed dialect of Lua

teal-language.org

21–30 of 176 posts

Re: Teal – A statically-typed dialect of Lua

#21
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…

You can get pretty far by bolting annotations onto Lua (no compilation step), for example using my IDE:

https://github.com/Benjamin-Dobell/IntelliJ-Luanalysis

Admittedly, I've been focused on some other things recently, but still with some focus on type safety e.g. https://breaka.club/blog/godots-most-powerful-scripting-lang...

Re: Teal – A statically-typed dialect of Lua

#22
This is super cool. I have been using TypeScript To Lua (https://github.com/TypeScriptToLua/TypeScriptToLua) for a little game side project and it works quite well, I am pleased with it. It does end up generating a lot of Lua code though because it has to support all of TypeScript’s features, which isn’t ideal. I’d expect Teal’s output to be much more concise Lua which has me interested.

Re: Teal – A statically-typed dialect of Lua

#23

I've been diving into Lua (a little late to this party, but turns out it's a perfect language to rewrite some commandline scripts I had that were getting unwieldy in Bash, especially with LLM assistance!) and it's really something of an eye-opener. LuaJITted Lua code runs at 80% (on average, sometimes faster!) of the compiled C version of the same algorithm , typically. Lua is embedded in a surprisingly massive numbe…

It is true that LuaJIT is stuck at 5.1, but you could write any performance critical sections in C/C++ and call it from Lua.

Lack of LuaJIT for 5.1+ isn't that big of a deal for desktop apps. The embedded world is still stuck in 5.1, but for them, the benefits of the latest Lua is marginal.

Re: Teal – A statically-typed dialect of Lua

#24
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…

That was a major concern when I was using Lua at work. Pretty much every type checker in Lua required transpiling, which doesn't work for many environments (e.g. Redis script). My Kailua [1] was designed that in mind but didn't reach its full potential.

[1] https://github.com/devcat-studio/kailua/

Re: Teal – A statically-typed dialect of Lua

#25
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…

> Perhaps it's more similar to TypeScript?

Funny you should mention that:

> It aims to fill a niche similar to that of TypeScript in the JavaScript world, but adhering to Lua's spirit of minimalism, portability and embeddability.

Re: Teal – A statically-typed dialect of Lua

#27
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…

> 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.

Re: Teal – A statically-typed dialect of Lua

#28
post #18

Earlier quoted context omitted.

Every language has warts. Even Lua. Like another commenter said, using . instead of : is maybe the most common mistake, too easy to make. And Lua offers no help preventing or checking it. TypeScript is a great language. So is Lua. So is C. When used carefully to avoid their warts. Learning how to do that for any language takes time and practice though.

> Every language has warts. Yea, and then there's javascript (or typescript if you prefer), the C++ of scripting languages. It's sometimes difficult to see any value through the warts. (Unless you're paid to, of course.)

Every time someone says this about JavaScript, their favorite language turns out to be something like APL or Ada.

Re: Teal – A statically-typed dialect of Lua

#29
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…

Just a small note about mypy and python - annotations are first-class citizens in Python3 and are not tied to any particular type checking system such as mypy, but are instead a core part of the language and actually serve vital functions in frameworks and libraries that are used to check interfaces such as Pydantic and FastAPI (eg URL params).

Mypy is just one type checker for Python, but there are many others including pyright. In fact pyright is quickly becoming the dominant checker over mypy.

Post reply on HN