teal-language / tl

The compiler for Teal, a typed dialect of Lua
MIT License
2.1k stars 108 forks source link

TypescriptToLua vs Teal #565

Closed hepiyellow closed 1 year ago

hepiyellow commented 1 year ago

Can someone explain the advantages of Teal over TypescriptToLua teanspiler?

(I know this might not be the proper place for such a discussion, sorry)

lenscas commented 1 year ago

Typescript is made to transpile to JS and to look like JS. That means that when using Typescript to lua it is easier to write code that would be idiomatic JS rather than idiomatic Lua. For example error handling, which in typescript is easier to do with throwing and catching exceptions while in lua, generally spoken a function that can fail returns 2 values, one to indicate if it was successful or not while the other is either the value or the error.

It also means that the Typscript to lua code needs to generate a lot more code than teal and some typescript features just don't translate well to lua (InstanceOf for example).