frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Teal – A statically-typed dialect of Lua

https://teal-language.org/
77•generichuman•4h ago

Comments

wslh•3h ago
There is another TEAL (uppercase) programming language: <https://developer.algorand.org/docs/get-details/dapps/avm/te...>
tkzed49•3h ago
I vote we give the name to the lua one!
90s_dev•3h ago
Seconded.
90s_dev•3h ago
I'm so relieved to see more types being added to good languages.

So Teal is to Lua as TypeScript is to JavaScript. Which means it automatically plays well with any Lua environment. Unlike luau and nelua which are also statically typed but have their own runtimes.

What version of Lua does it use? Lua gets new versions every few years so I don't know why so many impls don't continuously upgrade to the latest version.

90s_dev•3h ago
> The core compiler has no dependencies and is implemented as a single tl.lua file which you can load into your projects. Running tl.loader() will add Teal support to your package loader, meaning that require() will be able to run .tl files.

Genius design.

RS-232•3h ago
Lua is a good language. It's like C, if C were a scripting language.

It's got an awesome C API. It's fast, lightweight, and embeddable. It's more performant than Python. It's a staple in video game scripting.

90s_dev•3h ago
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 get wrong.

I'm not sure how fast vanilla Lua is today compared to similar languages. I think LuaJIT (and Luau?) are most often used when performance is needed.

growlNark•3h ago
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.
90s_dev•3h ago
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.

growlNark•3h ago
> 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.)

90s_dev•2h ago
Every time someone says this about JavaScript, their favorite language turns out to be something like APL or Ada.
isr•2h ago
FYI, for those who may not be aware, moonscript is the "coffeescript" for lua. It has been in production use for quite a while (the author of moonscript also created itch.io, using ... moonscript).

yuescript, from the dora-ssr game engine dev, is essentially moonscript-2.0

And of course, if you want to treat lua as the scheme-like it really is (deep down), then ... fennel.

Lots of choices. They all compile to straightforward lua, are very easy to incorporate (you can even compile at runtime, if you wish), and all employ full lua semantics, meaning zero runtime overhead

EDIT: and the curse of not reading fully ahead strikes again (doh!). Someone else has made the same points below ...

RonaldK9•3h ago
I don't think it's a good language, and I hate it. I've made thousands of the same mistakes with it—typing . instead of :. There's a reason Lua has a smaller audience than assembly.
0cf8612b2e1e•2h ago
Each new Lua version has breaking changes that are of dubious value to keep on the upgrade treadmill. Something like a Python2->3.

LuaJIT is famously on 5.1 with no signs of moving.

alanh•3h ago
Oh, clever name. Typed Lua → TL → "Tee Ell" → Teal

And the extension is .tl

Sharlin•3h ago
Off-topic comment, but as an ESL speaker I just this week randomly learned that teal the color is named after the duck species Anas crecca, called (edit: common or Eurasian) teal in English.
seafoamteal•3h ago
I'm one of today's lucky 10_000 apparently! Only learned that just now.
nozzlegear•2h ago
TIL! My wife is a photographer and she's been photographing a ton of Blue-winged Teals over the last couple months during their migration. I assumed that the ducks had been named after the color.
Sharlin•1h ago
Cool! (Just to be clear, I meant the common, or Eurasian, teal whose iridescent green head markings the color’s apparently named after. The NA teals are closely related, although it seems they were assigned to their own genus in 2009 as it was discovered that the then-Anas was not monophyletic.)

Generally colors are named after things in nature and not the other way around, given that the latter would’be had names for a long time, and most color names are comparatively recent inventions, driven by modern dyes and pigments and status, fashion, etc concerns. A West European peasant in the 11th century would’ve known the bird well, possibly trapped them for food, but would’ve had very little need for a separate word for ”blue-green”.

The history of color words is quite interesting. There’s a specific progression that almost all languages have gone through. It’s fairly well known that many East Asian languages don’t have separate names for ”blue” and ”green” at all (except as modern loans). Accordingly, they don’t usually make the distinction mentally, one could think that they simply consider them hues of ”cyan”.

90s_dev•3h ago
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<T>

rfl890•3h ago
Is it implemented as a compiler, tl, which compiles .tl source code into .lua files? Who knows
HexDecOctBin•3h ago
Has anyone used this? Any reviews? Based on the Github issues, the type system seems to have some holes in it, but it's not obvious how bad is it in real world.
hombre_fatal•13m ago
I used it to write a couple Pico-8 games a year or two ago since Lua + dynamic typing is a major obstacle for me managing game code over time. Teal worked well for that.
pmarreck•3h ago
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 number of products: https://en.wikipedia.org/wiki/List_of_applications_using_Lua The startup time of a script is in nanoseconds. An "echo" written in Lua runs faster than the native echo implementation.

The only warts so far are 1-based indexing (you get used to it), and the fact that LuaJIT is stuck at Lua 5.1 while Lua itself is up to 5.3 or 5.4 and has added some niceties... with Lua proper running slower. And no real standard library to speak of (although some would argue that's a feature; there are a few options and different flavors out there if that's what you need, though- Such as functional-flavored ones...)

Anyway, there's nothing else like it out there. Especially with its relative simplicity.

There are also some neat languages that compile to (transpile to?) Lua, and deserve more attention, such as YueScript https://yuescript.org/, which is a still actively-updated enhanced dialect of MoonScript https://moonscript.org/ (described as "Coffeescript for Lua", although it hasn't been updated in 10 years) although neither of these are typed. HOWEVER... there IS this: TypescriptToLua https://typescripttolua.github.io/, which takes advantage of ALL the existing TypeScript tooling, it just outputs Lua instead of JS!

kanbankaren•2h ago
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.

pansa2•3h ago
> 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 structure - with separate arrays, tuples, maps, records and interfaces. It changes the variable scoping rules and even adds macro expressions.

Teal therefore seems substantially more complex than Lua. The author recognizes this in the conclusion to a recent presentation [0]: Lua is "small and simple", maybe Teal is "something else"? Lua is for "scripting", maybe Teal is better suited to "applications/libraries"?

[0] https://youtu.be/Uq_8bckDxaU?t=1618

Benjamin_Dobell•2h ago
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...

lifthrasiir•2h ago
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/

wyldfire•2h ago
> 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.

90s_dev•2h ago
> 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.

pansa2•1h ago
> 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 to change radically - adding a type checker would invalidate the current approach of using a single-pass source-to-bytecode compiler.

dottrap•20m ago
>> 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 performance. The Pallene compiler can generate optimized native code that potentially removes the need to manually write a module for Lua in C.

The other cool trick is that Pallene and Lua are completely interoperable with each other, so Pallene can be added to existing Lua projects, and you can opt to use regular Lua for the dynamic parts of your code where compilers won't be able to optimize much and strong types might be more trouble than help.

Here is a talk Roberto Ierusalimschy gave about Pallene. https://www.youtube.com/watch?v=pGF2UFG7n6Y

SoylentOrange•2h ago
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.

pansa2•1h ago
Am I right in thinking that Python's type annotation syntax originally came from Mypy though?

IIRC Mypy started off as a type annotation syntax and corresponding type checker for Python. Mypy's type annotations were adopted by Python itself (in version 3.5 - PEP 484), which reduced Mypy's role to be just a type checker.

Since then, type annotations have indeed become a core part of Python - not only are they used in frameworks and libraries, but are also required to use language features like @dataclass.

thristian•56m ago
No, Python's current type annotation syntax was added in Python 3.0 as a generic annotation syntax, in the hope that somebody else might come along and build a type-checker or other tooling on top:

https://peps.python.org/pep-3107/

MyPy was one such tool, and I think it had conventions for adding type annotations in comments, in places where Python didn't yet support them (such as variable assignment), but I'm pretty sure it was never a TypeScript-style pre-processor - type-annotated programs always ran directly in the unmodified CPython interpreter.

creatonez•47m ago
It's interesting that you mention Typescript. In Typescript's early history, they added a bunch of features that they either thought would make it nicer for C# devs (classes, enums, option chaining, decorators, namespaces, etc.). Eventually, a bunch of these features were added to Javascript natively in nearly the exact same way they were implemented in Typescript. Now, the only remaining non-type-related features not added to Javascript are enums and namespaces, which will never be added because they're poorly designed. Even the Typescript type syntax (but with ignored semantics) may get added to Javascript under a WIP proposal. Some of these features were perhaps mistakes -- private in TS and private in JS will never be able to mean the same thing, and `class` syntax is iffy -- but overall there was an improvement.

By ambitiously adding useful features, could Teal push the upstream to make progress? Probably not because Lua's scope is intended to be small (and we're no longer in the same context as 2015 era Typescript and tc39), but it's interesting to think about.

VoidWhisperer•6m ago
Enums are possibly going to end up in JS eventually - this proposal[0] is at stage 1 (i know the readme says stage 0, it looks like there is a PR to update this). Granted, that means 'under consideration' but it is a start

[0]: https://github.com/tc39/proposal-enum

max0563•2h ago
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.
kachapopopow•2h ago
Looks way too similar to Luau.
CobrastanJorji•2h ago
This is very cool. I wonder if it works with Roblox, which is probably the environment with the largest number of Lua programmers. It certainly looks like it should work basically anywhere Lua works.
fithisux•59m ago
The use their dialect of Lua. Luau, stuck on 5.1 (correct me if I am wrong) like LuaJit for performance reasons.

It is gradually typed, so no need to use Teal.

phant0mas•1h ago
You can also check this talk from Hissam last fosdem https://fosdem.org/2025/schedule/event/fosdem-2025-6147-what...
kuruczgy•1h ago
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?)

pansa2•1h ago
> How confident are you in the soundness of the type system?

Teal's types are hints, like Python's and TypeScript's, so I suspect it's not sound by design.

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

Teal includes several types that model typical uses of Lua tables, e.g. as arrays, maps etc. It doesn't look like it can type fully general use of Lua tables, e.g. using both the "array part" and "hash part" of the same table.

lolinder•19m ago
People get this way about TypeScript too, and it always perplexes me. These projects are about adding types to untyped languages, and that comes with a few givens:

* Your type system cannot be sound. It's going to have escape hatches and exceptions because that's how dynamic languages roll.

* There will always be constructs that you can't type. See above.

* If your type system is going to usefully type enough of the ecosystem, it will be Turing complete.

All of these things are the trade-offs you make when you set out to layer types on a dynamic language, and they're well worth it to get 99% of the way to type safety in a language that otherwise couldn't scale. Theoretical purity is meaningless if the language isn't useful.

koeng•1h ago
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, sequence analysis, etc. I'm pretty sure it is a more complete synbio library than anything in python, actually.

A couple things I want from teal: 1. I wish there was a better way to bundle files together. I have a little build.lua, but eh, I think it could be better. I know of cyan and everything but I feel like that was developed for a different application than mine. I want to have 1 complete file that I can just give people and allow them to do synbio work in any target language with a lua machine. 2. There are some annoyances around luajit vs lua5.1 functionality 3. The compiler yelling at you gets old for integrating raw lua. I tried to port json.lua in and even with the definition file, I couldn't embed the whole json.lua without having compiler errors. So eventually I just imported it as a string that is type checked, which is bad 4. I really wish syntax highlighting on github was a thing

The good bits:

It's pretty much complete. I used it a couple years ago and there were things with generics that I just couldn't do, but now it is much better. For example, how I use generics for the different parsers (fastq, fasta, genbank, slow5, pileup, etc) https://github.com/Koeng101/libB/blob/dev/src/dnadesign/src/...

Overall, love it! It is one of those pieces of software which is nearly complete, and I love using software like that.

sitkack•1h ago
See also https://ravilang.github.io/ https://nelua.io/

Vaccination to Prevent Heart Attacks

https://www.hsci.harvard.edu/news/vaccination-prevent-heart-attacks
1•nothrowaways•34s ago•0 comments

Fake Your Legacy in Seconds:A Wikipedia-Style Bio Generator for the Internet Age

https://fakipedia.netlify.app/
1•izanamador•58s ago•1 comments

Hadza Hunter-Gatherers Averse to Inequality If Personally Unfavourable

https://papers.ssrn.com/sol3/papers.cfm?abstract_id=5193882
1•paulpauper•4m ago•0 comments

Sacred Hardware: Towards a Phenomenology of AI's Form Factor

https://secondvoice.substack.com/p/sacred-hardware
1•paulpauper•5m ago•0 comments

Rust Language Celebrates Ten Years by Releasing Rust 1.87

https://www.phoronix.com/news/Rust-1.87-Released
2•doener•6m ago•0 comments

Conservative activist Robby Starbuck sues Meta over AI responses about him

https://apnews.com/article/robby-starbuck-meta-ai-delaware-eb587d274fdc18681c51108ade54b095
1•doener•10m ago•0 comments

Apple opened the door to web paywalls – our test shows it might hurt conversions

https://www.revenuecat.com/blog/growth/iap-vs-web-purchases-conversion-test/
2•simplezeal•11m ago•0 comments

A new type of AI is helping police skirt facial recognition bans

https://www.technologyreview.com/2025/05/12/1116295/how-a-new-type-of-ai-is-helping-police-skirt-facial-recognition-bans/
1•walterbell•17m ago•0 comments

Microsoft support for "Faster CPython" project cancelled

https://old.reddit.com/r/programming/comments/1kncoi8/microsoft_support_for_faster_cpython_project/
5•rurban•21m ago•1 comments

Startup pitch generator with ai completely free

https://dmyj6ouqpngzg.mocha.app/
1•shdwkillz•22m ago•0 comments

Falcon-Edge: A series of powerful, universal, fine-tunable 1.58bit language mod

https://falcon-lm.github.io/blog/falcon-edge/
1•todsacerdoti•25m ago•0 comments

There's More to That Nugget of Wisdom (2023)

https://www.stackstaves.net/post/2023-12-07-theres-more-to-that/
1•todsacerdoti•29m ago•0 comments

Outsourcer in Chief: Is Trump Trading Away America's Tech Future?

https://www.nytimes.com/2025/05/15/business/economy/trump-chips-ai-uae.html
6•zerosizedweasle•30m ago•3 comments

eqsat: An Equality Saturation Dialect for Non-destructive Rewriting

https://arxiv.org/abs/2505.09363
1•matt_d•31m ago•0 comments

Moondream: 1GB Visual AI That Runs Anywhere

https://moondream.ai/
1•handfuloflight•34m ago•0 comments

Apollo MCP Server: Connect AI to Your GraphQL APIs Without Code

https://old.reddit.com/r/mcp/comments/1knrz3g/apollo_mcp_server_connect_ai_to_your_graphql_apis/
1•apollo-watson•35m ago•0 comments

Elliptic Curves and the Hopf Fibration

https://arxiv.org/abs/2505.09627
1•mathgenius•36m ago•0 comments

Show HN: Curl-parser-ts- a lib to parse curl into url, headers, body

https://www.npmjs.com/package/curl-parser-ts
1•hp77•36m ago•0 comments

Nvidia plans Shanghai research centre in new commitment to China

https://www.ft.com/content/c886a4c0-da75-4ea7-8230-6ffd18815fa4
3•zerosizedweasle•36m ago•1 comments

Comparing Parallel Functional Array Languages: Programming and Performance

https://arxiv.org/abs/2505.08906
2•matt_d•36m ago•0 comments

Yarvin's blueprint of a CEO-led American monarchy

https://theconversation.com/friday-essay-trumps-reign-fits-curtis-yarvins-blueprint-of-a-ceo-led-american-monarchy-what-is-technological-fascism-256202
8•rstuart4133•37m ago•1 comments

OData – the best way to do REST

https://www.odata.org/
2•motorest•37m ago•0 comments

Huawei is spamming open source community for its Harmony ecosystem (See Comment)

https://github.com/search?q=%22Proposal+for+OpenHarmony+Adaptation+of%22&type=issues
20•fernvenue•45m ago•4 comments

The Awful German Language

https://faculty.georgetown.edu/jod/texts/twain.german.html
9•nalinidash•46m ago•9 comments

"Goodwill", key member of the SoCal Python Community has passed away

https://socalpython.org/in-memoriam-michael/
7•rdegges•54m ago•2 comments

Fatal Vulnerabilities Compromising DJI Control Devices

https://www.darknavy.org/blog/fatal_vulnerabilities_compromising_dji_control_devices/
1•uneven9434•56m ago•0 comments

Nintendo accidentally improved Switch emulation performance, thanks to Switch 2

https://www.androidauthority.com/mario-kart-8-deluxe-switch-emulation-3557965/
2•tech234a•59m ago•0 comments

9 Essential Tools to Build Your Writing Business Online

https://www.zuliewrites.com/blog/9-essential-tools-to-build-your-writing-business-online
1•web-dev•1h ago•0 comments

Make Money by Selling Your Discord

https://discord-marketplace.bearblog.dev
1•kvallans•1h ago•0 comments

Remarks on AI from NZ

https://nealstephenson.substack.com/p/remarks-on-ai-from-nz
2•zdw•1h ago•0 comments