I am far from an expert at Lua, but I have done a couple of semi-serious projects in the language and will try to recall specifically what I didn't like:
- Simple-minded people seems love Lua due to Baby Duck Syndrome and too much World of Warcraft farming, instead of education.
- Yet another boring, badly designed, slow scripting language. Nothing to see here.
- No, wait! Lua managed to screw royally even where other scripting crap works nice - there is no list/vector type in Lua: you can't access elements sequentially or by an integer index. That needs some talent!
Name:
Anonymous2012-02-25 16:24
>>8
Some "people" use human faeces as a sexual stimulant
>>9 you can't access elements sequentially or by an integer index.
0/10
Name:
Anonymous2012-02-25 17:36
>>12 http://lua-users.org/wiki/TablesTutorial
Lua stores all elements in tables generically as key-value pairs. Lua does not differentiate between arrays and dictionaries. All Lua tables are actually dictionaries.
Name:
Anonymous2012-02-25 17:38
http://lua-users.org/wiki/TablesTutorial This didn't work because when we tried to retrieve the value of a[{1,2,3}] we constructed another table, i.e. the table that we used as a key in the table constructor is not the same one as we used to retrieve the value.
the fucking tutorial is full of Lua-criticism!
Name:
Anonymous2012-02-25 17:46
>>13
you'll have to explain how this prevents you from ``accessing elements sequentially or by an integer index''
Name:
Anonymous2012-02-25 17:51
>>14
and that has absolutely nothing to do with what you were talking about earlier
Run using lua generates:
error: attempt to call global `unpack' (a nil value)
Name:
Anonymous2012-02-25 18:35
>>14
actually this is my biggest beef with Lua: mutable data structures. The language is awkwardly "almost functional." I would love Lua with immutable persistent tables so that you could compare equality and key by them and do all sorts of functional shenanigans. Lua should be more like its second cousin Clojure.
>>21
what the fuck? does unpack even take more than one argument? what you smokin, son?
function car(l) return l[1] end
function cdr(l) return l[2] end
function cons(a,l) return {a,l} end
function map1(f,l)
local r
if l then
return cons(f(car(l),map1(f,cdr(l)))
end
end
Name:
Anonymous2012-02-25 18:38
>>22
>Run using lua generates
>error: attempt to call global `unpack' (a nil value)
because lua 4.0 has been out of date since 2003
>>23 function cdr(l) return l[2] end
but that returns only 2nd element, not the table without the first element! It's like this ugly Set Theory, where you have to do special Axiom of Choice magic.
I really can't see why one would choose to use an interpreter outside of development for any purpose other than green threads.
Name:
Anonymous2012-02-25 21:21
Here we are!
- Lua Tables are mutable and encourage modification, instead of creation, meaning there is no easy way to do functional programming with Lua.
- `t={[{1,2,3}]="abc"}; print(t[{1,2,3}])` wont print "abc", meaning that `{1,2,3} != {1,2,3}`. In general, Lua's logic seems odd: "nil+1" results in error, while "(not nil)+1" eval to 2.
- Lua uses floating point values instead of integers and 1234567890123456789 would result into 1.234567890123457e+18
- Lua is unstable: API changes frequently, functions are being added and deleted continuously, `table.foreach` being a good example of to be deleted function, and then there is `table.unpack`, which present only in some versions of Lua.
- Lua is inconsistent: `t = {"a","b","c"}; print(t[2])` works, but `print({"a","b","c"}[2])` fails.
- Hash-Table as a primary data structure has some issues. There is no simple and safe way to implement FIRST and REST function from Lisp: either you have to copy whole Table or modify it, and sequential access is somewhat slow. There is no easy way to remove an element from a list. Even worse, the size of a list may not be what you expect: "b={};b[666]="a";print(#b)" will print 1. Lua Tables also don't provide advantages of catenable double-ended queues -- a silver bullet data strucure, you'll find in modern Lisps and Haskell.
- Lua's REPL wont pretty-print tables, instead it'll print something like "table: 0x807e978"
- Hashtables hold much of Lua's data, and even simple variable access goes through table system, producing several L2 cache misses in process just to get to value. That makes Lua slower than comparable alternatives, like Lisp.
- Table indexing starts from 1, instead of 0, like everything in computing. That acts as a source of errors and confusion, when interfacing with external APIs or converting algorithm from Lua to C/C++, while 0 still acts as a dangling pointer.
- Lua's GC is a naive mark-and-sweep implementation, which stores the mark bit directly inside objects, a GC cycle will thus result in all objects being written to, making their memory pages `dirty` and Lua's speed proportional to the number of allocated objects. Lua simply was not designed to support hundred thousand objects allocation per second.
- Quirky syntax with underscores for special variables and cryptic symbols for simple functions, like `#xs` for `length(xs)` and `x = start,end,step` instead of range(start,end,step), while logical connectives (`and`, `or` in place of `&&`, `||`) are hard to notice between other symbols. do/then/end everywhere could be annoying.
- Lua was built as a glue language, and it shows. Much of Lua hype comes from it's usage as a simple integrated scripting language in video games industry. That makes typical Lua user a teenage gamer with little expectations or taste for computation features and productivity.
>>32
That is an imageboard post! Nobody cares about it's quality.
>>34
At least I'm not a jew. Some evil people here tried to insult me like that, calling me a "jew".
Name:
Anonymous2012-02-25 22:53
>>31 http://www.lua.org/about.html fast, lightweight, embeddable scripting language
ideal for configuration, scripting, and rapid prototyping
emphasis on embedded systems
http://www.lua.org/doc/hopl.pdf [i]One of Tecgraf’s largest partners was (and still is) Petrobras,
the Brazilian oil company. Several Tecgraf products
were interactive graphical programs for engineering applications
at Petrobras. By 1993, Tecgraf had developed little
languages for two of those applications: a data-entry application
and a configurable report generator for lithology profiles.
These languages, called DEL and SOL, were the ancestors
of Lua. We describe them briefly here to show where
Lua came from.
Please give me an good Lisp or Haskell implementation that:
- is < 500K
- has configurable gc cycles
- has better C <=> script ffi api
I tried to use some Scheme implementations, but they weren't what I expected.
Name:
Anonymous2012-02-25 23:28
>>36
I tried to use some Lua implementations, but they weren't what I expected.
Name:
Anonymous2012-02-25 23:33
>>37
yeah i was expecting horribly-designed hacks ala php but i was left disappointed
Name:
Anonymous2012-02-25 23:40
>>38
Agree. They were much worse -- you have to write half of your code in C/C++! Then use scary toLua++ bindings, exporting half of stuff manually.
Name:
Anonymous2012-02-25 23:44
>>31 which stores the mark bit directly inside objects
there
Sorry but there's no other way. If you seriously think about using double indirection or storing the GC flags in a separate table, then yo'ure retarded.