News for hackers. Stuff that matters.
Re:A History of Lua (2001) by rahkiin on Wednesday August 10, 2022 @03:22AM (#32408731)
I’ve worked in a large Lua codebase, and its lack of any types gets very cumbersome. It is also non-trivial to get the full performance and by doing so lose some of the nicer features. For example, creating tables causes an allocation which is slow, so forget about using tables for vector types. These tables could have bad a metatype for operator overloading, but metatables cause multi-level lookups which is also slower.

I could use it for some light scripting, but definitely would not write whole projects in it.

Re:A History of Lua (2001) by otikik on Wednesday August 10, 2022 @06:25AM (#32409856)
> lack of any types gets very cumbersome

You might be interested in Teal ("the typescript for Lua") https://github.com/teal-language/tl

Re:A History of Lua (2001) by emehex on Wednesday August 10, 2022 @06:45AM (#32409969)
I find in super frustrating when a language doesn’t put a representative view of it’s syntax front and center in the README… (as a QuickStart or something)!
Re:A History of Lua (2001) by nequo on Wednesday August 10, 2022 @07:22AM (#32410189)
The tutorial they link in the intro is quite good:

https://github.com/teal-language/tl/blob/master/docs/tutoria...

Re:A History of Lua (2001) by emehex on Wednesday August 10, 2022 @07:48AM (#32410387)
Agreed! I just find it unusual that this isn’t “front and center” (as I said)
Re:A History of Lua (2001) by otikik on Wednesday August 10, 2022 @02:08PM (#32416159)
The nice thing about this particular case is that you can actually do something to fix this problem that is super frustrating for you!

You can send a PR!

Re:A History of Lua (2001) by spc476 on Wednesday August 10, 2022 @05:10AM (#32409448)
At work, I use Lua (and LPEG) to process SIP messages for the Oligarchic Cell Phone Company, processing calls in real time, and only once in the seven years it's been running did I have to tune the code. It certainly works for us.
Re:A History of Lua (2001) by rahkiin on Wednesday August 10, 2022 @05:38AM (#32409575)
That’s great :) I do think it has its place.

We ran >200k lines of Lua for a 3d game at >60fps. We could not do allocations on the hotpath, or we would run out of our frame budget (which was around 1ms). Games are very hard to auto-test when not built with that in mind from the ground up, so any change to the code might unknowingly break any caller, and we would only know for sure once the game runs. Sadly the code base is 20 years old.

Re:A History of Lua (2001) by samatman on Wednesday August 10, 2022 @10:29AM (#32412581)
You mentioned in a sibling comment that this was using LuaJIT, do you know if it was before the allocation sinking optimization was added?

At some point (2.1?) LuaJIT added a peephole interpreter optimization which can follow a simple constructed table for awhile, and if it's never stored, the values it's conveying are just put on the stack.

I'm pretty fearless with creating transient tables, and run enough profiling to be moderately confident that the allocation sink is keeping that from providing memory pressure.

There's a larger thing here about the JIT being temperamental and having to kind of learn its moods, but: it's faster as an interpreter than other choices by a matter of multiples, and when the JIT works, it positively screams.

Re:A History of Lua (2001) by rahkiin on Wednesday August 10, 2022 @03:22PM (#32417147)
Honestly I am not sure. We were using the LuaJIT interpreter because JIT is not allowed on consoles or phones.
Re:A History of Lua (2001) by kgeist on Wednesday August 10, 2022 @06:15AM (#32409796)
>For example, creating tables causes an allocation which is slow, so forget about using tables for vector types

I once added vector4 as a primitive type in my fork of Lua (to avoid allocations altogether) - it was surprisingly easy to add, took me a weekend.

Re:A History of Lua (2001) by rahkiin on Wednesday August 10, 2022 @07:39AM (#32410311)
We were using LuaJit which is a whole other beast.