2 ms·
Lua 5.1 is the most amazing language design I've ever come across; you can do almost anything with this language and it's as minimal as it gets. It is true that
by Rochus 4y ago
Lua 5.1 is the most amazing language design I've ever come across; you can do almost anything with this language and it's as minimal as it gets. It is true that dynamic typing sets limits in terms of project size.
- giraffe_lady 4y agoHave you ever built anything complex in it though? One of the pains of professional lua development is how much lay users admire its design. And it is true that its design is elegant and emerges from interesting and admirable constraints. In practice though it doesn't give you any of the tools you need to do anything except make tools to do those things. Which appeals to yak-shavers like us for sure. But if you need to sit down with it for months at a time and just get work out the door it fucking sucks. Also 5.1's GC is goddamn tragic. In practice you're usually at the mercy of whatever was implemented by the embedding runtime, but if you're ever left alone with just the raw 5.1 GC you'll wish you weren't. Later versions improved that dramatically.
- snek_case 4y agoCan you elaborate on why the 5.1 GC is so bad?
- giraffe_lady 4y agoHonestly I'm not an expert on that part of the lua internals so I can't confidently say why. I don't think it's a fundamental problem since later versions use the same approach afaik, so I assume it's just implementation nuance. 5.0 used, IIRC, mark-and-sweep which is not great either but it's predictable: it's easy to develop intuition for how much you're allocating and what the collection cost will feel like. The main practical issues I've run into with 5.1: - per-object overhead in time and space both increased significantly, making many small allocations much more expensive than fewer big ones. further pushing you into the "mutate a few huge global tables" pattern that is already a problem in lua conventions. - some of lua's more lauded and genuinely powerful features, esp metatables, don't work smoothly or predictably with the GC. it leads to people trying to manually tune it with __gc metamethods, which is hard to do correctly and causes memory leaks if done incorrectly. - weak tables idk,. esp with strings for some reason. similar to the __gc, there is a solution there but in practice it's very hard to be sure you've got it right and it's worse to get it wrong than to not try. I'm sure a PL expert can explain and justify all this but I am just a normal person who codes for money. Lua is admired for being simple and accessible, but especially in the older versions you get into the low level weeds real fast over this stuff. Kind of a good example of minimal implementation exposing you directly to irrelevant complexity, really.
- Rochus 4y agoThis is nonsense; where do you have that from?
- Rochus 4y agoI'm using it since 20 years (e.g. for http://cara.nmr.ch/doku.php http://cara.nmr.ch/doku.php, or e.g. this one https://github.com/rochus-keller/Smalltalk https://github.com/rochus-keller/Smalltalk), also used it as backend for programming languages and developed tools on it (e.g. https://github.com/rochus-keller/LjTools/ https://github.com/rochus-keller/LjTools/). Is this complex enough? Never had an issue with the GC. > you're usually at the mercy of whatever was implemented by the embedding runtime Are we talking about the same Lua? The engines I know (PUC Rio and LuaJIT) are not at the mercy of embedding runtimes, but haver their own, sufficiently good memory management.
- giraffe_lady 4y agoWe might not be talking about the same lua! Like I kind of hinted, I think it's likely very good for expert users to build tools on. I'm not an expert user of anything though, or building tools. My professional experience of it has been using ancient versions that are embedded into C or C++ systems to build simple guis and automation within those systems. I don't think it's well suited to this, but this is a common (I believe even it's original?) use case! I've never used luajit, or any version where I had full control over the runtime at all. I understand people love this language and I'm not saying they're wrong to. But for the things I've needed to use it for it has not been enjoyable at all, particularly 5.1 which is the one I have the most experience with by far.
- Rochus 4y agoI've used a lot of different embedded scripting languages with C and C++ and Lua is by far the most efficient and easiest to integrate one. Especially the 5.1 version is excellent and I still use it today. In what notable project have you used Lua? > I'm not an expert user of anything though But apparently confident enough to make negative comments about the technology.
- giraffe_lady 4y agoYeah pretty much, sorry. I do this for money and generally more or less enjoy it as far as that goes. But I've always had a miserable time working in lua, more than any other language I've touched professionally. I might be wrong about the technical reasons why, and I'm genuinely sorry if I've unfairly maligned your baby here. But it has always been unpleasant for me and I think I'm entitled to my confidence about my own experiences in it.
- samatman 4y ago> Have you ever built anything complex in it though? I have, yes, it's great. No complaints, would choose LuaJIT again. I do regret that the quad-color collector will likely never be implemented, I'd content myself with a back-port of the new generational collector, but the allocation sinking in LuaJIT has kept me out of trouble for the most part since it can put 'tables' on the stack if it can prove they don't escape.