• spartanatreyu@programming.dev
    link
    fedilink
    arrow-up
    14
    ·
    7 months ago

    Presenting: an excerpt from my lua windows management script:

    -- Exists because lua doesn't have a round function. WAT?!
    function round(num)
    	return math.floor(num + 0.5)
    end
    

    Yeah, not a fan.

    • suy@programming.dev
      link
      fedilink
      arrow-up
      8
      arrow-down
      1
      ·
      7 months ago

      Related: There is an article on LWN called Lua and Python, which is mostly about the approach of the two languages WRT being “batteries included” or not.

      I think Lua being a bit barebones is 100% fine… if you just pair it with a good helper library, or set of libraries with a coherent API, that allows it to thrive. Then you can either use the framework library or not, depending on whether your project requires the extras, or can do without.

      As a parallel, I’ve been doing C++ development for almost two decades, and I cannot imagine doing anything non-trivial without Qt. For example, Qt has a debug framework that pretty prints automatically most containers, and adds the newline also automatically. Also, QString is an actual string type, whereas std::string is more like QByteArray. It’s functionality that it’s essential for me (and it’s just the minimal examples… then Qt has all the GUI functionality, of course, but I use Qt even in console-only programs!).

      This is surely opinionated on my side, and most C++ devs don’t see it this way, but my point is that a language with a “core experience” that it’s lackluster to you should not be a bad thing if the language is capable enough to provide an ecosystem with a good 3rd party library that adds exactly what you want. In the Lua ecosystem that maybe it’s Penlight.

      But I totally get your point. Penlight doesn’t even seem to have a math library, so I found no round implementation there. This can be not a problem for some, but deal breaking for others.

      • TehPers@beehaw.org
        link
        fedilink
        English
        arrow-up
        5
        ·
        7 months ago

        I’ve been writing Lua off and on for probably close to a decade, and I can’t remember the lack of a round function being an issue. I may have needed it at some point, but it’s not exactly a complicated function to write up in a minute.

        To me, the biggest appeal of Lua is actually the lack of an overbearing standard library. It has just enough to be usable as a scripting language within a larger application, and the larger application can always include its own helper library that gets loaded into the interpreter automatically on initialization. Feature-wise, there is enough to define your own OOP helpers (but no language built-in specific OOP stuff beyond metatables basically), there is enough to build your own async/await and generators using coroutines, etc.

        Not having a huge built-in standard lib comes with the benefit of not needing to distribute a huge standard lib with your larger application.