Live data from Hacker News

Teal – A statically-typed dialect of Lua

teal-language.org

121–130 of 176 posts

Re: Teal – A statically-typed dialect of Lua

#122
After having embedded Lua in my game engine and having worked with some Lua games I've come to conclusion that:

- Lua is great from the integrator/engine dev perspective. It's easy to embed and there are several libraries that help with creating bindings between Lua and your game classes.

- Lua has absolutely terrible runtime performance especially when the GC stalls. You soon learn that you have to start moving code to the native side and carefully consider the APIs that you provide for the game so that you can even dream of any type of performance. Haven't tried LuaJIT since that doesn't work with WASM so it's not an option for me.

- The loose runtime typing in Lua is absolutely terrible, and while it's easy and fast to knock up some simple script you really pay the price when you try to maintain or refactor your code and you have no typing information. For the game engine developer this also makes it very hard to provide any kind of help for the game developer, i.e. "intellisense" kind of functionality. I've basically "solved" this by assuming that variables have certain name suffixes and prefixes and when those are present I assume that it has a certain type which lets me provide a list of functions in the script editor to the game developer. Far from perfect. [see link below]

https://github.com/ensisoft/detonator/blob/master/screens/ed...

Re: Teal – A statically-typed dialect of Lua

#123
post #79

Earlier quoted context omitted.

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.

> Looks similar to Teal. That's because they share a common origin from Typed Lua and Titan languages: https://teal-language.org/book/other_projects.html

Wait, Pallene just compiles to C using whatever local C compiler?

https://github.com/pallene-lang/pallene/blob/master/src/pall...

Well that's kinda disappointing. I expected something more in 2025, like directly generating asm like a lot of languages are starting to do.

And your article makes it ambiguous whether it's from the Lua authors or grad students. I assume it started out just the students and then the Lua authors joined in?

Re: Teal – A statically-typed dialect of Lua

#124
post #122

After having embedded Lua in my game engine and having worked with some Lua games I've come to conclusion that: - Lua is great from the integrator/engine dev perspective. It's easy to embed and there are several libraries that help with creating bindings between Lua and your game classes. - Lua has absolutely terrible runtime performance especially when the GC stalls. You soon learn that you have to start moving code…

Any alternatives you've tried that are better in those areas?

Re: Teal – A statically-typed dialect of Lua

#125
post #114

Earlier quoted context omitted.

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.

You’re using C as an example of a language that is easy to understand?

C is indeed simple.

Re: Teal – A statically-typed dialect of Lua

#126
post #99

Earlier quoted context omitted.

Have a look at the results and the code; there are benchmarks in the suite where the (ideomatic) C/C++ implementation is "only" twice as fast as the corresponding (idiomatic) Lua implementation, but on average (geomean of all factors) it's about five times as fast. The guidelines of the benchmark are pretty strict to enable fair comparisons (see https://github.com/smarr/are-we-fast-yet/blob/master/docs/gu... ).

I looked at the docs. This seems to be comparing against Lua, which is why I specifically said LuaJIT This is quite a distinction to be made. Can you clarify? Directly from their guidelines page: Lua We write code compatible with Lua 5.1, 5.2 and 5.3. Smalltalk/Ruby symbols are represented as normal strings. We use Lua 1-based array and the length operator #. We use single object when a class is not required. Bitwise…

It's essentially written in Lua 5.1 with specific alternative implementations of mandelbrot and hashindextable for Lua 5.3 selectable by the test runner. But this doesn't matter much because my reference is LuaJIT. I have also compared different LuaJIT and also PUC Lua implementations, see http://software.rochus-keller.ch/are-we-fast-yet_LuaJIT_2017... and http://software.rochus-keller.ch/are-we-fast-yet_Lua_results....

Re: Teal – A statically-typed dialect of Lua

#127
post #39

I really love teal! Here is a 10k loc project I have in it - https://github.com/Koeng101/libB/blob/dev/src/dnadesign/dnad... - Basically, I reimplemented all my synthetic biology bioinformatics from Go into teal so that LLMs can script with it better in a hermetic environment. It's got all sorts of things like cloning simulation, codon optimization, genbank parsing, synthesis fixing, reliable sequence hashing, sequen…

Teal creator here! Thank you for the kind words, super happy to see people being productive with it!! On your wishlist items: 1. There are a few third-party projects that bundle Lua code. One that comes to mind is https://lrocket.codeberg.page/ — I don't know if this functionality should be brought into Teal itself, it sounds to me like something better left to the surrounding tooling? 2. Unfortunately those annoyanc…

1. Yeah, there are third party bundlers, but none of em worked too well for me. You are right: it should be separate

2. If I recall correctly, gen-target didn't hit it because I was using some very esoteric bullshit from the luajit internal spec that couldn't have nice typing

3. Yes, untyped lua in the same file. The problem is that I want everything in a single file for distribution and embedding - kind of like the SQLite amalgamation. It'd be super cool to just add in my dnadesign.lua or dnadesign.tl file and have full bioinformatics in almost any language! Definition files don't work as well there - I still kind of use them for the type definitions, but then embed the raw file as a string

4. YES THANK YOU! I'm not sure if it is in the docs but this is SO useful!

Re: Teal – A statically-typed dialect of Lua

#128
post #122

After having embedded Lua in my game engine and having worked with some Lua games I've come to conclusion that: - Lua is great from the integrator/engine dev perspective. It's easy to embed and there are several libraries that help with creating bindings between Lua and your game classes. - Lua has absolutely terrible runtime performance especially when the GC stalls. You soon learn that you have to start moving code…

The lua language service [1] supports type annotations inside comments [2]. Sure, it is not the same as having types as first class citizens, but I would say that it solves 95% of the editor support and typying problems you mentioned in your 3rd point.

But yeah, PUC-Rio Lua is not fast, but it is acceptable, and maybe one of the most performant of all non-JIT dynamic languages. If you need speed, JIT is a requirement.

[1]: https://luals.github.io/

[2]: https://luals.github.io/wiki/annotations/

Re: Teal – A statically-typed dialect of Lua

#130
post #122

After having embedded Lua in my game engine and having worked with some Lua games I've come to conclusion that: - Lua is great from the integrator/engine dev perspective. It's easy to embed and there are several libraries that help with creating bindings between Lua and your game classes. - Lua has absolutely terrible runtime performance especially when the GC stalls. You soon learn that you have to start moving code…

It's a shame you can't use LuaJIT. It's one of if not THE highest performance JIT out there.
Post reply on HN