4 ms·
Lua Criticism Is Unwarranted
1 based syntax - it is easy to define functions that are index-agnostic or correct off by 1 errors. Looks like people don't want to define a single trivial function. I like how erlang handles indices - by not really relying on them much
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
- caligian 3y agoLet's take another example. Consider structs as tagged tables with a metatable key that distinguishes it from ordinary tables. You can implement inheritance as chained __index closures for parent tables or simply chained tables. Or you can use the struct as is by defining a global table and creating a simple lookup. Theoretically the lookup will work faster because you can store the hierarchy as an list, run a simple index() to get the needed parent and call the method in the associated table. This is much faster than going to multiple chained tables thus slowing down lookup. 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
- rlawson 3y agoI very much like Lua and the fact that I can hold much of the language in my head. I do hate the local/global thing but on the other hand I really do appreciate it's simplicity
- dtagames 3y agoLua came first but was both encouraged by and hampered by Brazil's limitations on technology imports at the time. The lack of access to other tools is what led the team to develop it in the first place. But the country's lack of connection with other IT outlets at the time prevented Lua from taking over. 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.
- sneed_chucker 3y agoNot sure there's all that much Lua criticism around here?
- cies 3y agoRead my comment :)