Hacker News new | past | comments | ask | show | jobs | submit login

My love hate relationship is entirely with the language itself. It's incredibly useful as a game scripting language and is extremely easy to bind native functionality to, but man, the language itself rivals JavaScript for quirks.

1-based indexing is just a silly departure from decades of ingrained thinking, dictionaries masquerade as lists but can unintentionally become dictionaries if you mistakenly put a non-numeric key in them, and the only inheritance is prototype-based "classes" that are implemented via gross metatable hacking. Library support is also weak.

I will give it credit though for a robust coroutine implementation.




> 1-based indexing is just a silly departure from decades of ingrained thinking

This on only true for (not too old) programmers.

- Older programmers, taught pre-C, may remember that most languages were typically 1-based (Fortran, Pascal, Algol, Smalltalk...).

- Scientists usually use 1-based notation. I have avoided countless off-by-one by implementing papers in Lua. Matlab is also 1-based, probably because it is a language for mathematicians and scientists.

- In general, non-programmer tend to count from 1 and not 0.

> the only inheritance is prototype-based "classes" that are implemented via gross metatable hacking

If you need to you can implement non-prototypal object models, with metatables or with closures if you don't like them. My recommended object library is https://github.com/kikito/middleclass for people who want to write ojbect-oriented code (I usually don't).

> dictionaries masquerade as lists but can unintentionally become dictionaries if you mistakenly put a non-numeric key in them

I agree with this one, mostly. I would appreciate a purely sequential data structure ("list").


Looks like you got some down votes but I entirely agree. It isn't as bad as JavaScript, but turning typos into nil rather than raising an exception or having a compile time error is also annoying, in addition to the other things you mentioned.

I really wanted to like it for the small and simple implementation, but the language isn't pleasant IMO.


> turning typos into nil rather than raising an exception or having a compile time error is also annoying

So true. However, you can disable this behavior and then just forget about it:

http://metalua.luaforge.net/src/lib/strict.lua.html


There are reasons for that. Have you considered using something like luacheck?


I have to agree here, however this is mostly not an issue if you use luacheck, assertions and unit tests.

Still, stronger typing would help, and this is why several people are working on adding gradual typing to Lua. The main initiative is probably https://github.com/andremm/typedlua


You have all typical problems of Lua non-user.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: