1. 7
  1. 4

    It’s really funny how many of the things listed under “different” are things I’d consider just common sense.

    • nil and false are the only false values; 0, 0.0, “0” and all other values evaluate as true
    • A control variable in a loop is localized by default and is not available after the loop.
    • not, or, and keywords used for logical operators.
    • Assignments are statements, which means there is no a=b=1 or if (a=1) then … end
    • Limit and step values in the numeric for loop are cached; this means that in for i = init(), limit(), step() do … end all three functions init, limit, and step are called once before the loop is executed.
    • 0 == “0” is false, {} ~= 1 is true, and foo[“0”] and foo[0] refer to two different keys in the table; other relational operators generate errors on comparing values of different types.

    A lot of the “bad” section has been addressed since this article was written in 2012, but a lot of it does still require 3rd-party libraries. I don’t think this is necessarily bad, for instance, not building luaposix functionality into the language itself means that the language can be ported to microcontrollers that don’t have an OS. Pulling in 3rd-party libraries is a lot easier than it is in many languages since they tend to have very shallow dependency trees.

    The worst thing about the language semantics IMO is the way it does multiple values, which gets a very brief mention in the “ugly” section; this article explains it in a lot more detail: https://benaiah.me/posts/everything-you-didnt-want-to-know-about-lua-multivals/

    1. 2

      I dislike only two things about Lua

      1. Global scope by default

      2. No trailing comma in function signature

         function foo(
         ) -- invalid :(
      1. 2

        Is there any language that allow trailing commas in function signatures?

        1. 2

          Python does.

        2. 1

          2 is a bit strange because I am pretty sure that trailing commas in table declaration are acceptable.

        Stories with similar links:

        1. Lua: Good, bad, and ugly parts via jcs 9 years ago | 7 points | no comments