I knew Luarocks existed, had no idea Teal did, for a second I wondered how this compared to Terra, then realized this is more TypeScript for Lua (which is fine).
It seems like type hints are good for any dynamic language, since they wind up in most of them overall.
For all (most?) intents and purposes, Fennel is lisp-language, not just lisp-y. It's Clojure-y if anything, which makes sense considering the creator of Fennel.
Hehe, I swear anytime Fennel is mentioned this discussion comes up, no matter what the original statement is. It’s like code golfers discussing Esolang Turing completeness. :)
FWIW I didn’t mean to imply anything here, just draw the parallel between the ergonomics of transpiled Lua. Spiritually I consider Lua to be a Lisp, and Fennel a tool for revealing this quality. I’ve actually recently combined Teal and Fennel to create a statically typed Fennel compiler, which really improves QoL for larger projects. I’m doomed to enjoy lispy or command invocation languages, both of which have fallen out of style.
They both have type systems and such. The comparison doesn't have to be about the compilation/transpilation process, but the developer experience is still important.
Hisham is one of the key devs there. He started GoboLinux, htop and some more.
Personally I am not the biggest fan of lua as it really is such a light language in every sense of the word (meaning, syntax too and features - too light IMO). But it's good that creativity keeps pushing things forward.
Being light in every sense of the word is a primary feature of the language.
Lua is great for high-level control of a program written in C/C++. When setting that up, I’ve often appreciated that I could removed features like file I/O from the Lua standard library and the rest keeps on trucking.
Lua is terrible for writing programs by itself. People keep trying to make it happen. But, for anything non-trivial, it’s a fool’s errand.
As someone who wrote entire stacks and apps on top in LuaJIT that I got paid for and are running without any problems after many years, this is getting a little tiresome to hear.
I had no idea that GoboLinux and htop were made by the same dev, let alone Teal. I can sort of see why someone who preferred to keep things simple and straightforward in a way that would lead to GoboLinux would also be involved in something directly related to Lua.
As for how light it is, I don't disagree with you that it's frustrating, but as someone who only started using it at the beginning of last year for making a mod, I've realized that in a lot of ways, it feels like it's JavaScript if it were designed properly from the start. Both use a single map data structure for everything, including having arrays be "maps with incrementing integer keys", but Lua anticipated that iteration for arrays should work differently made the loop syntax give you a way to specify which way you want. Neither has a particularly large set of APIs that are available out of the box, but Lua defined a module system from day one (I assume, I guess I don't know for sure) and even provides a way to use it as for defining objects; JavaScript has a prototypical inheritance system that's probably more complex than it ever needed to be, and it took decades for a standard way of importing things to be defined. Lua also doesn't have the famous warts of implicit type coercion for operators (including the more familiar looking of the two equality checks); I'd take arrays starting at 1 over that any day.
I don't love working in Lua, but given how unfathomable it is to me that so many people genuinely seem to enjoy JavaScript, Lua seems more than sufficient in terms of the language features at least.
I find that in practice the amount of +-1 is about the same for zero-based and one-based indexing. Each has situations it is better suited for. For example, iterating a list backwards is nicer with one-based indexes.
I think it's inclusive indexing in general that make reverse iteration nice, not necessarily whether it's based on 1 or 0. (Namely, an ergonomic way to access the index of the last element as opposed to the length of the list. With inclusive indexing, the length is already naturally the index of the last element.)
I don't see a contradiction? I specifically pointed out inclusive indexing as part of my complaint.
The funny thing is, you could say the end index is zero-indexed and exclusive and that would result in the same behavior as one-indexed and inclusive. It wouldn't make sense to make it zero-indexed and inclusive, because the inclusivity only exists in the first place to account for the one-indexing. That would be an incomplete and nonsensical conversion.
These days all you gotta do is ask your local LLM to write you a Lua with 0-based indexing. Sure beats complaining about 1-based indexing on HN until the end of time.
Oh right. When I signed up for HN with the goal of complaining about 1-based indexing until the end of time, I hadn't considered that LLMs didn't exist yet. Thanks for updating my knowledge date!
Jokes aside, I did start to do a conversion like this manually some years ago, but it wouldn't really be Lua at that point. I just got bored because I knew it wouldn't really have value to anybody.
Observation: Teal would make a great scripting language for a simpler web browser, one not based on JavaScript... maybe something like the 'Surf' web browser: (https://surf.suckless.org/).
Also, there should exist the capability to compile Teal to Wasm... or at least Teal to Lua to Wasm(!)... to that end, there exists the following GitHub repo (but I'm not sure if it's 100% operational yet):
A good example of a large Teal codebase is Luarocks, the Lua package manager: https://github.com/luarocks/luarocks/tree/main/src/luarocks
I knew Luarocks existed, had no idea Teal did, for a second I wondered how this compared to Terra, then realized this is more TypeScript for Lua (which is fine).
It seems like type hints are good for any dynamic language, since they wind up in most of them overall.
I'm curious if there is a comparison to Luau.
This is a transpiler. Luau is a completely different language and runtime.
It’s part of the big three Lua syntax flavours: Teal (Typescript-y), Fennel (Lisp-y), Moonscript (Ruby-ish)
There is another one, which is not a transpiler: https://github.com/rochus-keller/luon
> Fennel (Lisp-y),
For all (most?) intents and purposes, Fennel is lisp-language, not just lisp-y. It's Clojure-y if anything, which makes sense considering the creator of Fennel.
Hehe, I swear anytime Fennel is mentioned this discussion comes up, no matter what the original statement is. It’s like code golfers discussing Esolang Turing completeness. :)
FWIW I didn’t mean to imply anything here, just draw the parallel between the ergonomics of transpiled Lua. Spiritually I consider Lua to be a Lisp, and Fennel a tool for revealing this quality. I’ve actually recently combined Teal and Fennel to create a statically typed Fennel compiler, which really improves QoL for larger projects. I’m doomed to enjoy lispy or command invocation languages, both of which have fallen out of style.
Lots to learn from each.
Do you have a link to that statically typed Fennel compiler? That sounds fascinating.
> considering the creator of Fennel
Techomancy is Fennel's maintainer, but Calvin Rose created it (and then Janet). Here are interviews with both:
- technomancy https://alexalejandre.com/interviews/interview-with-technoma...
- calvin rose https://alexalejandre.com/interviews/interview-with-bakpakin...
> (Ruby-ish)
Thanks for the chuckle.
They both have type systems and such. The comparison doesn't have to be about the compilation/transpilation process, but the developer experience is still important.
How many statically-typed dialects of Lua are there anyway? I know there is Terra. There was also... Sol, I think? Anything else?
How are we supposed to keep up with the sheer volume of cool note-worthy tools coming out. This is getting out of hand
Well for starters Teal is at least six or seven years old
Important info really
The Algernon web server comes with built-in support for Teal.
Hisham is one of the key devs there. He started GoboLinux, htop and some more.
Personally I am not the biggest fan of lua as it really is such a light language in every sense of the word (meaning, syntax too and features - too light IMO). But it's good that creativity keeps pushing things forward.
Being light in every sense of the word is a primary feature of the language.
Lua is great for high-level control of a program written in C/C++. When setting that up, I’ve often appreciated that I could removed features like file I/O from the Lua standard library and the rest keeps on trucking.
Lua is terrible for writing programs by itself. People keep trying to make it happen. But, for anything non-trivial, it’s a fool’s errand.
As someone who wrote entire stacks and apps on top in LuaJIT that I got paid for and are running without any problems after many years, this is getting a little tiresome to hear.
Perl folks dealt with that for years too :)
and JS folks too?
I had no idea that GoboLinux and htop were made by the same dev, let alone Teal. I can sort of see why someone who preferred to keep things simple and straightforward in a way that would lead to GoboLinux would also be involved in something directly related to Lua.
As for how light it is, I don't disagree with you that it's frustrating, but as someone who only started using it at the beginning of last year for making a mod, I've realized that in a lot of ways, it feels like it's JavaScript if it were designed properly from the start. Both use a single map data structure for everything, including having arrays be "maps with incrementing integer keys", but Lua anticipated that iteration for arrays should work differently made the loop syntax give you a way to specify which way you want. Neither has a particularly large set of APIs that are available out of the box, but Lua defined a module system from day one (I assume, I guess I don't know for sure) and even provides a way to use it as for defining objects; JavaScript has a prototypical inheritance system that's probably more complex than it ever needed to be, and it took decades for a standard way of importing things to be defined. Lua also doesn't have the famous warts of implicit type coercion for operators (including the more familiar looking of the two equality checks); I'd take arrays starting at 1 over that any day.
I don't love working in Lua, but given how unfathomable it is to me that so many people genuinely seem to enjoy JavaScript, Lua seems more than sufficient in terms of the language features at least.
musl + lua + c library + all lua codes can produce single static binary for linux which I utilize a lot.
I still remember when static linking was the only option compilers would give us.
Some of them had this cool modern idea of overlays, where we would manually manage loading additional code segments into the same process memory slot.
How well does Lua plug into Rust libraries? Also how good is Lua for UIs?
I've used Lua extensively with Rust via the mlua library and it's excellent and full-featured.
https://github.com/mlua-rs/mlua
Lua's 1-based inclusive indexing makes math so annoying. Plus- and minus-one everywhere.
I find that in practice the amount of +-1 is about the same for zero-based and one-based indexing. Each has situations it is better suited for. For example, iterating a list backwards is nicer with one-based indexes.
I think it's inclusive indexing in general that make reverse iteration nice, not necessarily whether it's based on 1 or 0. (Namely, an ergonomic way to access the index of the last element as opposed to the length of the list. With inclusive indexing, the length is already naturally the index of the last element.)
That is absolutely not the case.
Numerical loops in Lua are inclusive:
On the example above the i starts at 1 and goes up to (and including) the length of t.With 0-based indexes, and that numerical loop format, it would be minus-one everywhere:
I don't see a contradiction? I specifically pointed out inclusive indexing as part of my complaint.
The funny thing is, you could say the end index is zero-indexed and exclusive and that would result in the same behavior as one-indexed and inclusive. It wouldn't make sense to make it zero-indexed and inclusive, because the inclusivity only exists in the first place to account for the one-indexing. That would be an incomplete and nonsensical conversion.
These days all you gotta do is ask your local LLM to write you a Lua with 0-based indexing. Sure beats complaining about 1-based indexing on HN until the end of time.
Oh right. When I signed up for HN with the goal of complaining about 1-based indexing until the end of time, I hadn't considered that LLMs didn't exist yet. Thanks for updating my knowledge date!
Jokes aside, I did start to do a conversion like this manually some years ago, but it wouldn't really be Lua at that point. I just got bored because I knew it wouldn't really have value to anybody.
Observation: Teal would make a great scripting language for a simpler web browser, one not based on JavaScript... maybe something like the 'Surf' web browser: (https://surf.suckless.org/).
Also, there should exist the capability to compile Teal to Wasm... or at least Teal to Lua to Wasm(!)... to that end, there exists the following GitHub repo (but I'm not sure if it's 100% operational yet):
https://github.com/ysugimoto/webassembly-lua
Yoooo