Lua Criticism Is Unwarranted
2. nil-handling - no dynamic language has good nil handling. The proper solution is having optional types. People cannot grasp the fact that nils in control flow do not have to be equivalently implemented in data structures. Having nil and false is the same thing when nil is treated as a value than an empty variable which causes confusion because nil is supposed to denote absence. This leads to all such langs having 2 functions for retrieving and checking key's existence. Because treats nil as literal absence of value whilst allowing nil variable declarations is not illogical because since you have declared it, you might use it in the future. Because lua requires explicit declaration of local variables, it does not make sense to ignore a nil-defined variable to be omitted from the syntax but because nil is absence, it does not make sense to treat it as a presence in a mapping structure because mappings are treated as literally dynamic which makes nil a key deleter and a sign of nonexistence. This should not have a bearing on development because false still signifies an extant binding while nil does not
3. Unified containers aka tables If people jerk off to polymorphism, a united container should not hurt because almost all languages have identical indexing syntax for all containers. Similarly all dynamic languages require type checking to distinguish among values and it is easy to write an is_list and is_dict structure
4. Iteration sucks - the iterators are ridiculously very powerful because there is no generator syntax nor any special keywords. It is just a closure. Lua closures are perfectly made and callback based programming is extremely consistent and often idiomatic in lua
5. Local declaration I think it is similar to var declaration in statically typed languages. This has something to do with lua not using tables like python and instead using registers. Global declarations are the programmer's fault because the lua guide clearly states that the global table is a 'table'. So the nil logic applies here.
6. Is too simplistic People mistake terseness with simple here. By simple they usually mean the lack of syntactic sugars which makes many not-so-intuitive things seem much harder in lua. For example list slices in langs with slicing syntax involve a generator across an index range which retains the memory location to allow list manipulation via slices. That is certainly not easy for most noobs who just want a table slice. Now i agree that the stdlib sucks with regards to table ops, there are plenty of good libraries out there
6. No type system Then you have probably taken types as a concept too far to the point of mere visual and heuristic convenience. Types can be largely be understood via set theory which is middle school math. It is a shame then how cs kids and working professionals i have met being unable to grasp anything that does not have the default syntactic sugars of their working languages. Is it so difficult to create an object by just setting some attribs and tagging the table with a name? If you have grasped set theory then you can almost certainly create your own valid type system with ease.
KeyErr
I consider lua to not be an easy language to learn despite it itself advertises as being an easy language to learn. I think it has a simple design but is not simple to learn much like mechanical engineering which goes beyond jamming nuts, bolts, screws to wood and creating simple pulleys for your wells but when a mechanical engineer grad cannot construct a double pulley for their grandpa's well then you know what it means
If Lua had gotten "out in the wild" earlier, it would be where JS/TS are today. It's just as powerful as JS and more in some ways, such as embedding and encapsulation. It's also widely used as a modding language in the game industry precisely because it can be "dropped into" another project and allow coding in a limited way without affecting the other project.
Is it so difficult to create a struct by just memcpy-ing some data into a malloc-ed buffer and not even putting a tag anywhere? No, it is not. Neither is reading the fields back by using the pre-computed offsets. But people for some reason dislike writing such easy code by hand.
I think it’s doing pretty well and am happy with this fact. I think its success is well justified.
So I’m not sure about it being overly-criticised.
Getting worked up about defending the honor of programming languages is a waste of time. People either have technical reasons to choose one language over another within a specific use case, which is valid, or else their opinions are based on aesthetics or memes, which you can't really argue against effectively. Just accept that sometimes people won't like the things you like, for reasons you can't accept.
Also if you want to use arrays and structs in Lua, and you're fine being stuck with 5.1, you can always just use LuaJIT and have actual C structs and arrays. Best of both worlds, in my opinion.
Lua felt like JS and PHP had a secret child they abandoned and somehow survived up growing up in a dumpster.
I know I should not bash open source software: I know it takes a lot of work to build/maintain it. I'm merely reacting to this post.
But I'm not sure java is exactly without criticism either.
Lua and Love2D (and with Fennel on top) makes for a good teaching setup, IMHO.
When you say "fennel on top", sure that makes all the difference! I've argued in favour of using a LISP/Scheme for teaching students in the local uni i'm active in, but the businesses requesting "give us close to Java/C# certified graduates" won.
Edsgar Dijkstra wrote a nice piece on this.
https://www.cs.utexas.edu/users/EWD/transcriptions/OtherDocs...
Something like this? You replace % with mod0()
I find it a bit difficult to write, but that's probably lack of experience with it.
I normally use it for customizing something that forces me into using it, so I don't really want to spend the time knowing its intricacies, so anything where it diverges from more popular languages it grinds me and I try to avoid.
But this is true of any language that feels unfamiliar.
Anyway, Language adoption is a bit of luck and a bit of personal taste. A language needs a certain critical mass to become popular.
I had some hope that Luau https://luau-lang.org or Teal https://github.com/teal-language/tl would make things better but with the following example
they produce no warning and sadly only print When I was younger I might have put up with that sort of WTF but now that I have better options I try to stick to type checked languages where I don't have to.Fortunately there are other configuration languages available now besides Lua which provide type checking, so I remain hopeful that a future version of Lua or one of the newer typed Lua variants will eventually learn from those.
When you register local variables, they are merely defined as register locations and have a default value of nil which is absence and hence memory saved. They would have to mark nil explicity as a new data structure which is probably wastage as they would have to allocate memory for every variable declaration that may or may not be used.
It is just nil, nil at a literal level with the exception being local variables which are handled differently as offsets to register locations than other dynamic languages without such 'local' qualifiers.
> I had some hope that Luau https://luau-lang.org or Teal https://github.com/teal-language/tl would make things better
Inline type annotations are not a prerequisite for typechecking; there's nothing stopping you from writing straight Lua (or whatever) and then having a separate tool that does typechecking _without_ having to change the language. People are failing to take away the most important lessons from TypeScript.
The same goes, frankly, for languages that ostensibly have typechecking but have such deficient type systems that it's not exactly that much better than not having one. (Like C, for example.) Considering that type annotations are more valued for being a form of documentation than they are valued for making it easier to write the compiler's code generator...
If you have a function like printf that is ostensibly typechecked but not really, and you already have documentation (like man pages) for that function that says that the arguments need to be such-and-such, but the typechecker for your compiler/IDE isn't able to factor that in at or before build time, then that's a compiler/IDE problem, not anything that necessitates a change to the original grammar.
https://github.com/caligian/lua-utils
The former uses the latter for nvim. And the latter makes lua perl with structs. We all loved perl for its lispy functions to deal with lists - grep, map, push, shift, unshift, etc. Nested ops are inspired by elixir.
Another example is python iterators which requires a separate instance with __next__ method. It is not generic because now you can create n instances for n dicts just to use it in for syntax. Whereas in lua it is a simple closure returning the next value until nil