4 ms·
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 som
by rahkiin 4y ago
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.
- spc476 4y agoAt 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.
- rahkiin 4y agoThat’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.
- kgeist 4y ago>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.
- rahkiin 4y agoWe were using LuaJit which is a whole other beast.
- otikik 4y ago> lack of any types gets very cumbersome You might be interested in Teal ("the typescript for Lua") https://github.com/teal-language/tl https://github.com/teal-language/tl
- emehex 4y agoI 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)!
- nequo 4y agoThe tutorial they link in the intro is quite good: https://github.com/teal-language/tl/blob/master/docs/tutorial.md https://github.com/teal-language/tl/blob/master/docs/tutoria...
- emehex 4y agoAgreed! I just find it unusual that this isn’t “front and center” (as I said)
- otikik 4y agoThe 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!
- samatman 4y agoYou 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.
- rahkiin 4y agoHonestly I am not sure. We were using the LuaJIT interpreter because JIT is not allowed on consoles or phones.