Live data from Hacker News

Teal – A statically-typed dialect of Lua

teal-language.org

101–110 of 176 posts

Re: Teal – A statically-typed dialect of Lua

#102
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

In our experience, single-element tuples are just never used in practice. There has been some discussion on how to add syntax for them, but I think it's more of a desire for orthogonality than for a practical need.

Re: Teal – A statically-typed dialect of Lua

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

it's a three element tuple.

Re: Teal – A statically-typed dialect of Lua

#104
post #28

Earlier quoted context omitted.

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

Having a favorite language is weird (to me). They're tools, and some are more effective and usable than others, and some are better suited to some tasks than others.

But, equivalently, of course I'm going to criticize a hammer if it's literally covered in warts making it difficult to grasp without slipping. (or, if the gun I'm trying to use keeps firing bullets into my foot when I'm aiming down range.)

Re: Teal – A statically-typed dialect of Lua

#105

How confident are you in the soundness of the type system? Also, are there any Lua constructs that are difficult/impossible to type? Is type checking decidable? (Is the type system Turing complete?)

Hi, Teal creator here!

> How confident are you in the soundness of the type system?

I am confident it is not sound! That is by design. A typical example is how function arguments are bivariant, to allow for callbacks expressed the way programmers usually expect them to work (TypeScript does something similar).

> Also, are there any Lua constructs that are difficult/impossible to type?

Yes, many of them. The type system and the compiler are pragmatically very simple -- there are many design decisions made to favor simplicity of specification and/or implementation. (Compare the single-file, single-pass Teal compiler done mostly by a single person with the amount of engineering resources that Microsoft has put into TypeScript.) For a concrete example, we have special-cased polymorphism for functions, intended to use with very dynamically-typed Lua functions from the broader Lua ecosystem, but you cannot express similar polymorphism in Teal itself.

> Is type checking decidable? (Is the type system Turing complete?)

There is a proof (which I can't find right now) that type checking is not decidable once you combine parametric polymorphism (generics) and intersection types (like the poly functions I mentioned above), but the forms of these features supported by Teal have some restrictions which make me not extend such claims directly. And of course, I can't even claim that the implementation of the theoretical model is bug-free. The model is evolving, the implementation always lags a bit behind.

In any case, the goal for Teal's type system is not academic purity, but pragmatic utility. Other comments in this thread alluded to this as well -- there are practical constraints that come from targeting an existing language and ecosystem. Of course, there are many ways one can approach such challanges. Teal is one of them and there were and are certainly others! Everyone is free to take their shot at where they want to be in the Unix-Philosophy/Worse-is-Better vs. Lisp-Philosophy/The-Right-Thing design gradient.

Re: Teal – A statically-typed dialect of Lua

#106
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

In our experience, single-element tuples are just never used in practice. There has been some discussion on how to add syntax for them, but I think it's more of a desire for orthogonality than for a practical need.

Yeah I can't imagine any scenario where it's not just a value or an array of values that happens to have only one value right now.

Re: Teal – A statically-typed dialect of Lua

#107

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…

Another one of the biggest uses of Lua outside the hyperscaler-type software like nginx or redis: Roblox. Soooo many kids run games on Roblox every day!

Roblox not only runs entirely on Lua, but they've been working on their own type inference version of Lua named Luau, and open sourced it, and it's still in very active development.

https://github.com/luau-lang/luau

Re: Teal – A statically-typed dialect of Lua

#108
post #2

There is another TEAL (uppercase) programming language: https://developer.algorand.org/docs/get-details/dapps/avm/te... >

I designed and named the Transaction Execution Approval Language for the Algorand blockchain in 2020. I'm partial to the original, but as it grew it got rebranded to be the "Algorand Virtual Machine". Glad someone still remembers it as TEAL!

Re: Teal – A statically-typed dialect of Lua

#110

How confident are you in the soundness of the type system? Also, are there any Lua constructs that are difficult/impossible to type? Is type checking decidable? (Is the type system Turing complete?)

Hi, Teal creator here! > How confident are you in the soundness of the type system? I am confident it is not sound! That is by design. A typical example is how function arguments are bivariant, to allow for callbacks expressed the way programmers usually expect them to work (TypeScript does something similar). > Also, are there any Lua constructs that are difficult/impossible to type? Yes, many of them. The type syst…

Thanks for the detailed answer! I just wish the website was more upfront about this. I cannot find anything about "soundness" on the front page or in the docs.

I think you could basically copy your comment into an FAQ section or something on the front page.

Post reply on HN