Teal:一种静态类型的Lua方言
Teal – A statically-typed dialect of Lua

原始链接: https://teal-language.org/

Teal是Lua的一种静态类型方言,通过为数组、映射、记录、接口、联合和泛型添加类型注解来增强Lua语言。它的目标是在保留Lua极简主义特性、可移植性和可嵌入性的同时,为Lua带来类似TypeScript的类型安全。 `tl`编译器将`.tl`源代码转换为`.lua`文件。你可以通过LuaRocks (`luarocks install tl`)安装它,或者使用预编译的二进制文件。对于大型项目,推荐使用Cyan,这是一个为Teal设计的构建工具。IDE集成可通过VS Code扩展`vscode-teal`和NeoVim的`teal-language-server`实现。 在线提供文档和Teal Playground。该项目是开源的(MIT许可证),欢迎社区在GitHub上贡献代码,并设有论坛和Matrix聊天室供讨论。Teal由Hisham Muhammad及其贡献者开发,并使用Teal自身编写。

This Hacker News thread discusses Teal, a statically-typed dialect of Lua. The original poster (0xFEE1DEAD) initially disliked Lua but now appreciates its simplicity and dynamic duck typing. However, they find Lua's limited standard library and package manager (LuaRocks) problematic, and question the value of Teal. Other commenters chime in, highlighting Lux as a potential alternative package manager and discussing the pros and cons of Lua's 1-based indexing and table structure. Many express a desire for native types in Lua. Pallene, another typed subset of Lua, and its interoperability with standard Lua is also mentioned. There's a debate regarding the comparison of Lua and Javascript's type systems and the value of static typing in a dynamic language. Several commenters discuss Teal's similarity to TypeScript and the practicality of gradually-typed languages. The creator of Teal joins the discussion, answering questions about the language's type soundness and design choices.

原文

About Teal

Teal is a statically-typed dialect of Lua. It extends Lua with type annotations, allowing you to specify arrays, maps and records, as well as interfaces, union types and generics.

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.

Is it implemented as a compiler, tl, which compiles .tl source code into .lua files.

A taste of Teal

Here is a quick taste of what Teal code looks like:

local function add(a: number, b: number): number
   return a + b
end

local s = add(1, 2)
print(s)

...or check out this page's source code!

You can also play with the Teal compiler right from your browser, using the Teal Playground.

Install Teal

If you're using LuaRocks, you can install the compiler with:

luarocks install tl

You can also find pre-compiled binaries for Linux and Windows.

To build larger projects, you probably won't want to run tl on each file individually. We recommend using Cyan, the build tool designed for Teal.

You can also install vscode-teal for Visual Studio Code integration, teal-language-server for NeoVim and others, and more.

Documentation

You can browse the Teal documentation online.

Here are some recorded talks discussing the history of Lua and types, outlining the motivations behind Teal and talking about the project's progress:

Community

Development happens on GitHub.

We have a community forum hosted by GitHub. You can also chat with us via Matrix at #teal-language_community:gitter.im.

Teal is a project started by Hisham Muhammad, developed by a growing number of contributors and is written using Teal itself!

License

Teal is free and open source software.
Its
license is MIT, the same as Lua.

联系我们 contact @ memedata.com