[HN Gopher] Lua Is So Underrated
       ___________________________________________________________________
        
       Lua Is So Underrated
        
       Author : nflatrea
       Score  : 106 points
       Date   : 2024-12-26 19:18 UTC (3 hours ago)
        
 (HTM) web link (nflatrea.bearblog.dev)
 (TXT) w3m dump (nflatrea.bearblog.dev)
        
       | transpute wrote:
       | If you like Lua, see Terra, https://terralang.org/
       | 
       |  _> Terra is a low-level system programming language that is
       | embedded in and meta-programmed by the Lua programming language..
       | Like C /C++, Terra is a statically-typed, compiled language with
       | manual memory management. But unlike C/C++, it is designed from
       | the beginning to be meta-programmed from Lua.. In Terra, we just
       | gave in to the trend of making the meta-language of C/C++ more
       | powerful and replaced it with a real programming language, Lua..
       | Terra programs use the same LLVM backend that Apple uses for its
       | C compilers. This means that Terra code performs similarly to
       | equivalent C code._
       | 
       | From Pat Hanrahan's research group at Stanford,
       | https://amturing.acm.org/award_winners/hanrahan_4652251.cfm
       | Hanrahan and his students developed Brook, a language for GPUs
       | that eventually led to NVIDIA's CUDA. The prevalence and variety
       | of shading languages ultimately required the GPU hardware
       | designers to develop more flexible architectures. These
       | architectures, in turn, allowed the GPUs to be used in a variety
       | of computing contexts, including running algorithms for high
       | performance computing applications, and training machine learning
       | algorithms on massive datasets for artificial intelligence
       | applications.
       | 
       | Papers: https://terralang.org/publications.html
        
       | miohtama wrote:
       | I guess one of the issues is that because Lua is tailored for
       | embedded use case, it lacks appeal as a general purpose software
       | development ecosystem and thus its usage is marginal.
        
         | hinkley wrote:
         | It's been adopted in game engines to handle story logic, so the
         | people writing the game can be decoupled from the people
         | writing the engine, and don't have to code in a low level
         | language against a constantly moving target.
         | 
         | And I would argue that a lot of the staying power of World of
         | Warcraft came from the Lua based addons democratizing the UI.
         | Blizzard co-opted a lot of features from best of breed addons
         | back into the base game. (That and negative pressure in the
         | economy to keep from having every new character wielding the
         | third best sword in the game due to deflation, but that's a
         | story for a different thread)
        
       | arccy wrote:
       | Lua is nice but it being embedded in many different places means
       | that there will often be environment specific context that's
       | injected for you to interact with, but any editor tooling won't
       | know what's injected
        
         | pseudony wrote:
         | Not necessarily true. LuaLS, the most popular LSP, uses LuaCATS
         | (Lua comments and type system) annotations. You can place
         | annotation files (type stubs) in a directory and the LSP will
         | pick them up.
         | 
         | I use this for a project of mine where I embed a Lua
         | interpreter where I made several additional Lua modules
         | available.
        
         | leptons wrote:
         | I ran into this recently with OBS scripting. I don't really
         | like Lua, so I wanted to try making a Typescript-to-Lua
         | toolchain specifically for OBS scripting. Well OBS injects a
         | ton of stuff into the Lua environment, and I'd have to find a
         | way to mock all of that in Typescript. Sadly, I don't have time
         | for it, and I've chosen a different product than OBS because I
         | don't really want to invest so much time learning a new
         | language to accomplish something with free software when I can
         | purchase something that just works for $40. My time is way more
         | valuable, and this is the only time I've ever needed to code
         | something in Lua. Yeah, OBS supports Python too, but I dislike
         | Python even more than Lua.
        
       | EGreg wrote:
       | Is Lua currently even faster than JS and PHP, after all the
       | effort that went into those languages' optimizations?
        
         | shakna wrote:
         | It depends. In Debian's [0][1] benchmarks, JS is clearly ahead
         | in a handful of the benchmarks, but in the rest, Lua is either
         | on-par or faster. They're within a shout of each other.
         | 
         | There are some places where Lua has surprisingly poor
         | performance. However, in almost everything else, it's one of
         | the fastest around. Luajit is still one of the fastest JITs in
         | existence.
         | 
         | In the real world, rather than constraints of a benchmark, Lua
         | tends to be on-par from what I've seen. When you're not cold-
         | cacheing everything, its memory use is lower. But it's standard
         | library is ISO-C, and that's about it. No batteries. And the
         | others beat it soundly there, whilst being close to the same
         | performance. Which will mean they will just about always win
         | out.
         | 
         | [0] https://benchmarksgame-
         | team.pages.debian.net/benchmarksgame/...
         | 
         | [1] https://benchmarksgame-
         | team.pages.debian.net/benchmarksgame/...
        
           | igouy wrote:
           | > a handful of the benchmarks
           | 
           | Now made a little easier for your comparison
           | 
           | https://benchmarksgame-
           | team.pages.debian.net/benchmarksgame/...
        
         | Rochus wrote:
         | I did performance measurements in 2020 based on the Are-we-
         | fast-yet benchmark suite which combines micro and larger
         | benchmarks.
         | 
         | Here are the results: http://software.rochus-keller.ch/are-we-
         | fast-yet_lua_results...
         | 
         | Overall, the JS/V8 version was twice as fast as the Lua/LuaJIT
         | version. LuaJIT was only faster in the Mandelbrot benchmark.
         | The results also demonstrate that one can get a pretty false
         | impression when just looking at single microbenchmarks.
        
       | lopatin wrote:
       | I think it's a stretch to call it underrated. Isn't it the
       | defacto language for embedded scripting stuff? I've seen it used
       | as a mini language in production in game engines, databases, and
       | trading systems.
       | 
       | On the other hand, if the article is saying that it deserves to
       | be more highly rated in the non-embedded space, I think I would
       | need more than a handful of syntactical niceties to explain why
       | it deserves to be in the same conversation as Python, Ruby,
       | etc...
        
         | librasteve wrote:
         | ...raku
        
       | helpfulContrib wrote:
       | I was infected by the Lua mind virus 15 years ago and I have not
       | recovered.
       | 
       | I simply don't see any reason not to use it .. _for everything_.
       | 
       | I've built games with it. I've built GUI's with it. I've built
       | scientific analysis tools with it. I've used it as a total
       | solution for previously-impossible embedded problems. I've used
       | it for desktop applications and mobile apps. I've automated
       | entire production lines with it. It has _huge_ appeal as a
       | general purpose software development ecosystem - but those who
       | know how to do this, tend to keep it to themselves for some
       | reason.
       | 
       | It can do everything.
       | 
       | There's just nothing I want to do with computers that I can't,
       | legitimately do, with Lua - or its VM. Or, LuaJIT. Or, all of the
       | above and a bit of luarocks built in. Throw some luastatic in
       | while we're at it, bundle it all up as a .deb, and nobody needs
       | to know a thing.
       | 
       | Its just so versatile. I hope someone builds an OS around it some
       | day, making everything and anything the user wants to do,
       | accessible through a Lua module, or some smart libffi wrappers
       | around a handful of .so's, somewhere ..
       | 
       | In my retirement, I'll take antirez' LOAD81, turn it into a
       | proper Lua editor, add integration with luarocks and luastatic
       | and maybe a shit-tonne of _IPFS_ , and then there won't be any
       | need, ever again, to deal with anything else.
        
         | discreteevent wrote:
         | This happened to me about 6 months ago. (I didn't seek it out,
         | just ended up working on something where lua was involved). So
         | thanks for the warning. I didn't realise it could last for 15
         | years or more. The big thing for me is how easy it is to make
         | something that feels like a DSL while it's still just Lua when
         | you debug it.
        
       | dr_kiszonka wrote:
       | It looks like Lua's conditionals, for loops, and function
       | definitions terminate with the "end" keyword. Is this considered
       | more readable or does it bring some other benefits besides
       | helping the interpreter parse code?
       | 
       | Many people love Lua, so I suspect there is a good reason for
       | this.
        
         | bawolff wrote:
         | All programming languages have tiny differences. Some use },
         | some use keywords like "end" or "fi", some use indentation like
         | python.
         | 
         | Its a trivial difference that does not matter.
        
         | 01HNNWZ0MV43FF wrote:
         | Wikipedia says that came from Modula, but I can't find why
         | Modula did it or why Lua decided to copy it.
         | 
         | I thought I read somewhere that Lua was meant for use by non-
         | programmers, so the "end" would be easier to type and read than
         | curly brackets.
        
           | bawolff wrote:
           | Modula is based on pascal which is based on algol. The "end"
           | thing is in the first version of algol from 1958. This is 14
           | years before C was invented.
           | 
           | Presumably they thought the more verbose syntax would be more
           | readable.
        
       | hprotagonist wrote:
       | especially with fennel on top, i can certainly see the uses and
       | appeal!
       | 
       | coming from mostly python, i miss a robust stdlib.
        
         | digdugdirk wrote:
         | I've been more and more intrigued by fennel lately, and I've
         | been meaning to dive into the functional end of the pool. Any
         | recommendations for how to get started with it, especially if
         | coming from a python background?
        
           | n8henrie wrote:
           | Also interested in resources here -- familiar with python,
           | go, rust, but never used a lisp.
           | 
           | As a learning experiment, I was able to use the fennel
           | website to convert my Hammerspoon config from lua to fennel,
           | but I still struggle to add new functionality. Certainly have
           | not delved into macros, but this is where much of the power
           | lies AIUI.
        
       | TekMol wrote:
       | When it comes to languages, I was enlightended when I changed
       | from {}; languages to Python. I could never go back.
        
         | Trasmatta wrote:
         | Ruby is the sweet spot for me. I don't like the syntactic
         | whitespace in Python, but still prefer the cleaner look it not
         | having braces everywhere.
        
           | librasteve wrote:
           | raku - the bastard child of functional and OO
           | class MyTable is export {         has @.data;
           | multi method new(@data) {           $.new: :@data;
           | }              method render {           table :border<1>,
           | tbody do for @!data -> @row {               tr do for @row ->
           | $cell {                 td $cell              } };         }
           | }
        
             | DonHopkins wrote:
             | Many languages like Ruby have sweet "Syntactic Sugar", but
             | Raku has "Syntactic Syrup of Ipecac".
        
       | synergy20 wrote:
       | i wish luajit has been actively evolving though
        
         | hinkley wrote:
         | It's hard to tell since there's no changelog, but it looks like
         | there are at least some improvements ongoing other than just
         | simple bug fixes. Some of the changes in August for instance
         | look like more than just for correctness.
        
         | mardifoufs wrote:
         | It is evolving, they just don't want to take the same direction
         | Lua has been taking since the past few releases.
        
       | aeturnum wrote:
       | I have really enjoyed working with Lua when it's come up and I
       | think it's an extremely good language. In particular, as Noe
       | says, its interface for embedding into C/C++ is clean and
       | flexible. There are performance concerns, but considering how
       | widely Lua is used for game logic in high performance video games
       | clearly those concerns can be addressed.
       | 
       | That said, I think there are other warts that can be confusing
       | and make the language difficult. The _Nil-Terminated Arrays_
       | section points out one oddity about `nil` - but there are many
       | others. There are a number of confusing corner cases (or were - I
       | haven 't used it in a while). As an example, if you have a list
       | of values and you pass that list into a new table, the resulting
       | table may be different than if you add each value in that list in
       | order.
       | 
       | I also think that the flexibility of embedding means that you are
       | often learning the Lua <=> C interface as much as you are
       | learning Lua. So jumping from deploy to deploy is more confusing
       | than most languages.
       | 
       | Nevertheless I fully agree the language is underrated!
        
         | 01HNNWZ0MV43FF wrote:
         | > you are often learning the Lua <=> C interface as much as you
         | are learning Lua.
         | 
         | One time I had a memory leak in a game, something like exactly
         | 4 bytes per frame.
         | 
         | It turned out I was not popping the Lua-C parameter passing
         | stack properly after each frame.
         | 
         | I found this out after some unhelpful person suggested that
         | "all programs just leak memory" lol
        
           | spacechild1 wrote:
           | The Lua C API is fantastic from a design perspective, but as
           | you have discovered, it is rather error prone. Fortunately,
           | there are many wrapper libraries that take care of all the
           | stack manipulation. For example, I'm using
           | https://github.com/ThePhD/sol2 to interface with C++ and the
           | API is incredibly ergonomic.
        
         | forrestthewoods wrote:
         | > but considering how widely Lua is used for game logic in high
         | performance video games clearly those concerns can be
         | addressed.
         | 
         | It's ok, but should be much better.
         | 
         | Once upon a time Supreme Commander used Lua. Perf on consoles
         | for SupCom2 was catastrophically bad. We switched to Kore which
         | was effectively Lua but way faster (10x?).
         | 
         | Kore was bought by Havok and rebranded into Havok Script. Havok
         | got bought by Microsoft. I'm honestly not even sure if you can
         | still buy it today. It's not listed on their website.
         | 
         | These days I think you'd use Luau? I'm not sure.
         | https://github.com/luau-lang/luau
        
           | a_t48 wrote:
           | LuaJIT is pretty good, but some platforms might not allow it.
           | iOS technically didn't allow it when I used it before, but
           | Apple either didn't _actually_ care or just looked the other
           | way.
        
       | pavlov wrote:
       | My humble opinion is that most applications that need scripting
       | should just embed JavaScript.
       | 
       | It has a massive advantage in the existing ecosystem. People
       | don't always love it, but millions of them already know it. You
       | don't need to re-learn array indexing and nil termination quirks
       | and the dozens of other things where Lua is subtly different in
       | ways that you'll find out at runtime.
       | 
       | There are JS engines in all sizes, from tiny interpreters to
       | world-leading JIT performance monsters. And most operating
       | systems nowadays ship with a high-quality engine and embedding
       | framework that you can access without installing anything, like
       | JavaScriptCore on the Apple platforms.
       | 
       | Do your users a favor and just use the boring standard language
       | instead of making them learn a completely new one that doesn't
       | offer meaningful practical benefits for them. It's probably not
       | as much fun for you, but you'll save time for both the users and
       | yourself in the end.
        
         | Demiurge wrote:
         | On one hand, you do have JavaScript ubiquity, on the other
         | hand, you have the JavaScript "WTF" equality and typing
         | conversion matrix, "WTF" scoping, and dozens of other foot guns
         | that Lua doesn't have. Some people would rather everyone
         | learned Lua subtle differences and wrote less buggy code. I've
         | had to use for the web for 20 years, and if I have any choice,
         | I would avoid it.
         | 
         | Anyway, every language has some fans, and I don't mean to
         | dismiss them, but ubiquity is not the top priority, all the
         | time.
        
           | therein wrote:
           | There is the equality gotchas on JavaScript but then you have
           | 1-indexed arrays in Lua, which is a footgun that I know
           | exists, I try to avoid shooting myself in the foot with it
           | but I keep doing it.
           | 
           | It is beyond a footgun, more like a footgun concealed as a
           | shoehorn.
           | 
           | Either way I find embedding a Lua VM into a project so much
           | easier than embedding a Javascript one.
        
           | leptons wrote:
           | The only people saying "WTF" about Javascript are people who
           | haven't taken the time to learn how to use it effectively.
           | There are "WTF" things about every language, not just
           | Javascript.
           | 
           | Noobs are going to find the footguns in any language. Every
           | language can be misused. I've been using Javascript over 20
           | years and have never thought it was any worse than any other
           | language. Yes, it's dynamic, and yes, you can do stupid
           | things with that dynamism, but for someone who actually knows
           | how to use it, it's quite easy to work with.
           | 
           | I recently started using Lua and I'm not impressed at all.
           | It's just another language, it's really up to the programmer
           | what can be done with it, just like Javascript.
        
             | 3a2d29 wrote:
             | This is the common arguement used by people defending
             | languages with tons of footguns.
             | 
             | If this is true, why not write everything in C++?
             | 
             | Javscript includes so many footguns that people know are
             | bad (see the billion of examples of different types being
             | added and getting random answers). Every langauge has some
             | difficult parts, pretending that means any amount is fine
             | is crazy. Javascript has earned its reputation.
        
             | Supermancho wrote:
             | Lua feels and acts like a worse javascript. Yes the runtime
             | can make the memory footprint really small, but
             | manipulation and validation of the crappy list/table
             | structures makes the implementations miserably large. I've
             | only written about a million lines of it (literally), so
             | I'm pretty set in my opinion.
        
         | Groxx wrote:
         | For cases where you can realistically include a full v8 in your
         | project, yea - that seems fairly reasonable nowadays.
         | 
         | Javascript took an extremely high-complexity, high-cost, and
         | nearly-all-effort-in-just-two-impls-for-over-a-decade route to
         | get to the current (stunning) performance though. How do small-
         | scale embedded interpreters stack up? That's what many things
         | that aren't Electron apps will be using.
         | 
         | I ask this honestly, to be clear - I'm not sure how they stack
         | up. I know Lua has historically targeted and dominated this
         | area so I'd expect it to win, but I have not seen _any_ data
         | and I largely agree - JS is a massively better development
         | environment now, and I would love to choose it. Everything I
         | can find pits it against v8, and that 's kinda like comparing
         | the performance of a bike against a train - they are so
         | different in many situations that it's meaningless. Otherwise
         | I'd probably choose WASM today, or maybe docker containers
         | where performance and platform needs isn't an issue.
        
         | SoftTalker wrote:
         | This probably makes more sense in 2024 but for many years
         | JavaScript was not a serious option. I wasn't until the mid-
         | late 2000's that it started to get traction as an application
         | language and had any way to run it outside of a web browser.
         | 
         | Lua as an embedded language already had over a decade head
         | start.
        
           | leptons wrote:
           | Netscape had javascript running server-side in 1994, only a
           | year after Lua was created. So no, Lua did not have "over a
           | decade head start", it had 1 year.
           | 
           | Microsoft also had server-side JS, and still do. Active
           | Server Pages (ASP) were scriptable with javascript since
           | 1996. Microsoft's JScript.net has been around since 2002
           | (even if not well supported or maintained by M$, it still
           | works). I've written web back-ends, Windows desktop
           | applications, and even .dlls with JScript.net as far back as
           | 2003.
           | 
           | Javascript has been Adobe's scripting engine for Photoshop
           | since 2005. Sony chose Javascript for Vegas Video's scripting
           | language in 2003.
           | 
           | Javascript has so many uses outside of a web browser, and has
           | for a very long time.
        
         | krapp wrote:
         | "most people should use the things I use and am familiar with"
         | is a common opinion but you should realize that between
         | Javascript and Lua, Lua _is_ the boring standard language in
         | this context.
         | 
         | Also there are whole books written on the quirks you need to
         | master with Javascript. Lua has its rough edges but it's a much
         | simpler language, so there are far fewer of them.
        
           | pavlov wrote:
           | What's the end-user segment where Lua is more widely known
           | than JavaScript?
           | 
           | Game dev, possibly (even that seems highly debatable). But
           | the article was making the case that Lua should be more
           | widely used outside of that niche.
        
             | mikey_p wrote:
             | Doesn't matter if it's widely known, it honestly is much
             | nicer to work with than Javascript and is being used as it
             | is intended, instead of being a half-baked language
             | designed in a hurry, to work in a browser, that got
             | repurposed as a general purpose scripting language later.
        
           | mardifoufs wrote:
           | Lua has a ton of sharp edges, they just don't manifest
           | themselves as much as with JavaScript since JS has a
           | different "typical use case" and aren't as often discussed.
           | Writing user facing UIs, with all that it entails, is a great
           | way to uncover and experience all possible sharp edges.
           | 
           | And a lot of the issues with JavaScript just wouldn't matter
           | for an "embedded scripting engine" use case imo.
        
         | 2OEH8eoCRo0 wrote:
         | This! I shouldn't have to learn Lua to program my Logitech
         | mouse ffs.
        
       | cute_boi wrote:
       | I feel Scala is also very underrated.
        
         | fsloth wrote:
         | How do you use Scala as an embedded scripting language?
        
       | 01HNNWZ0MV43FF wrote:
       | I've had fun embedding Lua a couple times, but as with wasm I
       | almost never have a case where I need to run new code without
       | being able to recompile the whole binary, so I don't get to use
       | it often.
       | 
       | The most fun was when I made a game engine ("engine") in C++ that
       | used Lua for all the game logic. The fast debug cycles are very
       | useful there. Maybe I should still do that for Rust gamedev,
       | since Rust notoriously compiles slowly.
       | 
       | The second-most fun was an IRC bot that could reload its Lua
       | logic without disconnecting. Nowadays I'd write a bouncer and
       | just let the main process restart. (Or use wasm, a wasm IRC bot
       | would be good...)
       | 
       | The third-most fun was using Lua as a Turing-complete
       | configuration language. If I needed an array of something, I just
       | made Lua make an array, instead of generating Lua code.
       | 
       | One of the least fun was the Blender plugin that exported 3D
       | models as generated Lua. If I did that one again today, I'd just
       | use MsgPack or some ad-hoc binary format.
        
       | Levitating wrote:
       | I can't say I appreciate Lua any more after reading this. It only
       | reinforced my annoyances with it.
       | 
       | It's been a while since I wrote any Lua but I didn't think it was
       | intuitive at all. Why are arrays tables, why are they nil
       | terminated and why do they start at 1.
       | 
       | I don't think it's underrated either. It's very popular for
       | writing scripts in (older) game engines.
        
         | selimthegrim wrote:
         | The system software for newer TI graphing calculators is
         | written in Lua and often emulated to Z80.
        
         | kristopolous wrote:
         | a bunch of that comes from awk.
        
         | matheusmoreira wrote:
         | > Why are arrays tables
         | 
         | I might be able to provide at least some insight into that.
         | 
         | One of the things I found while implementing my language was
         | that the ordering of elements in a hash table is essentially
         | random. Literally random if you mix in some randomness into the
         | hash function's initial state in order to harden it against
         | collision attacks.
         | 
         | Many languages guarantee insertion ordering. It's a useful
         | property to have, makes testing easy and deterministic and it's
         | intuitive for users. A simple way to implement that is to put a
         | perfectly normal array of values into the hash table, and then
         | have the buckets which the keys hash into contain indexes into
         | that array. That way the indexes of values remain stable no
         | matter what the keys hash to.
         | 
         | So a sufficiently advanced hash table will have an array of
         | values inside it. I suppose some language designers took one
         | look at that situation and decided to just merge both types
         | already by using hash tables for everything. For example, PHP
         | also did that. Associative arrays, they call it.
        
       | protomolecule wrote:
       | It's my language of choice for letting users customize an app,
       | but the last client wanted Python because many people are already
       | familiar with it and 'Scriptable with Python' looks better from
       | the marketing point of view(
        
       | keb_ wrote:
       | I love Lua as a language; even if it can be a bit cumbersome at
       | times, its simplicity and low barrier of entry is refreshing. I'm
       | currently building a full-stack web application with
       | https://redbean.dev in Lua and it's mostly been a joy.
        
       | hipadev23 wrote:
       | Luau [1] developed by Roblox is a backwards-compatible fork of
       | Lua 5.1 with some very significant improvements to speed and QoL
       | [2]. It also mostly alleviates the nil-terminated array problem.
       | 
       | [1] https://github.com/luau-lang/luau
       | 
       | [2] https://github.com/luau-lang/rfcs/tree/master/docs
        
       | pentaphobe wrote:
       | Out of curiosity: does this post read like LLM (generated or
       | assisted) to anyone else?
        
         | johnzim wrote:
         | The conclusion at the end definitely does
        
         | lioeters wrote:
         | Pretty sure in a year or two the ratio will flip to where
         | people will pick up on articles that are _not_ assisted by LLM.
         | Does this post read like it 's been written completely by a
         | human? And the models will probably get better until it's
         | mostly indistinguishable.
        
           | leptons wrote:
           | LLMs and bots will probably be the thing that leads to a
           | second version of the internet being created. Eventually the
           | thing we currently know as "the internet" will be nothing but
           | bots and LLMs continually regurgitating in a giant
           | 100-billion-watt-consuming feedback loop.
        
       | soapdog wrote:
       | Really liked that post, then again Lua is one of my favourite
       | languages.
       | 
       | I wrote this post https://andregarzia.com/2021/01/lua-a-
       | misunderstood-language... some time ago and it kinda touches
       | similar points as the OP. Read on if any of yous want to see yet
       | another person talking about Lua.
        
       | beanjuiceII wrote:
       | nah, it's overrated ackshulaly
        
       | Animats wrote:
       | Except for "tables". Lua tables are too weird. Trying to make one
       | construct do the work of an array, a struct, and a dict leads to
       | a messy construct.
        
         | giraffe_lady wrote:
         | There is also a very common two-liner invocation that turns
         | them into prototypical classes as well. Extremely versatile
         | data structure (pejorative).
        
           | ramses0 wrote:
           | Perl would like to have a word... ;-)
           | 
           | But seriously, they do have some interesting quirks which
           | make sense if you think of it (and maybe Lua as a semi-
           | contemporary got its ideas from there), specifically, hashes
           | are pairs of keys (even/odd) in a flat array... and of course
           | objects are just key/values, but with some values being names
           | and functions...
           | 
           | https://perlmaven.com/creating-hash-from-an-array
        
       | jmnicolas wrote:
       | Meh. I don't get the love Lua gets on HN. At least version 5.1, I
       | didn't try the others.
       | 
       | No first class support for OOP, you got to use tables instead.
       | 
       | No "continue" keyword to go to the next iteration of a loop. So
       | you have to use some ugly elseif.
       | 
       | No try catch!
       | 
       | It's a dynamic language so everything goes. A function will
       | return nil or a number or whatever you wish. A function can also
       | returns any number of variables, so obviously some moron will
       | abuse it: looking at you Blizzard intern (you must have been an
       | intern right?) that thought returning 20 variables on the combat
       | event log was a good idea. Ever heard of tables???
       | 
       | The LSP can't do miracles when there are almost no rules so auto-
       | completion is more miss than hit, which is quite shocking in
       | 2024. The IA is helpful sometimes but create subtle bugs some
       | other times. A simple uncaught typo will create a hard to find
       | bug (yesterday copilot auto-completed myObject.Id instead of
       | myObject.id, there went 20 minutes of my life trying to find why
       | some code that was running solidly for weeks was now failing
       | silently).
       | 
       | So all in all, Lua is fine to write small imperative scripts of a
       | few hundred loc. Anything bigger and more complex you should run
       | away IMHO.
       | 
       | I never realized C# was such a well designed language until I
       | tried Lua.
        
       | tga wrote:
       | Mandatory plug for Redbean[0], a standalone Lua webserver (a
       | single-file that runs natively on six OSes!), and Fullmoon[1], a
       | web framework built on top of it.
       | 
       | Not exactly mainstream, but so simple and elegant.
       | 
       | [0] https://redbean.dev/
       | 
       | [1] https://github.com/pkulchenko/fullmoon
        
       | jmclnx wrote:
       | Lua can be used to access the NetBSD kernel, which is
       | interesting. I have said it before, I should spend time learning
       | Lua.
        
       | fsmv wrote:
       | I built a chatbot with lua plugin commands and I really had an
       | awful experience trying to incorporate it in my C++ program. I
       | really don't understand why people say it's easy to embed because
       | you have to do a ton of stack manipulation to do anything. Not
       | only that but the language itself is cumbersome, frustrating, and
       | does nothing at all to help you when you make a mistake.
       | 
       | I will never use lua again and avoid any project that uses it.
        
       ___________________________________________________________________
       (page generated 2024-12-26 23:00 UTC)