4 ms·
I looked at Lua briefly, but the immediate impression I got was that Python gives you more help in avoiding errors. In Lua, you might be bitten by: * variable
by stuffinstuff 11y ago
I looked at Lua briefly, but the immediate impression I got was that Python gives you more help in avoiding errors. In Lua, you might be bitten by:
* variable name typos (undeclared vars are nil),
* accidentally confusing array-style tables and hash-style tables (or vice versa),
* tables with "holes" (nils) in them,
* multiple assignment with wrong number of vals or vars (mismatch silently ignored),
* variables are global by default.
Have you found this to be the case at all? Is it more difficult to avoid bugs when writing in Lua?
- meric 11y agoHave you found this to be the case at all? Is it more difficult to avoid bugs when writing in Lua? Good questions. - variable name typos (undeclared vars are nil), There's a linter to catch undeclared variables. https://github.com/mpeterv/luacheck https://github.com/mpeterv/luacheck There's also some runtime checking techniques you can use. http://www.lua.org/pil/14.2.html http://www.lua.org/pil/14.2.html - accidentally confusing array-style tables and hash-style tables (or vice versa), I've had that happen about as often as confusing Python dictionaries returned by different types of functions. (Which is - not often enough for me to remember the last time that happened) - tables with "holes" (nils) in them, When I'm building a vector and I want holes, I use false to fill the holes. - multiple assignment with wrong number of vals or vars (mismatch silently ignored), For me, when I'm thinking about multiple assignment to function returns, it does mean having to read documentation for a library function more carefully than if I was reading the same for another language. If it's as simple as "local a, b, c = 1, 2, 3", then it's no issue. - variables are global by default. If I'm using linting, when I can't have global variables implicitly, then it's like C or Java where I must declared all my variables and by default they are local to the scope. Otherwise it's just like javascript where it's best practice to always declare variables using "var".
- stuffinstuff 11y agoThanks for the feedback! Will have a look at the linter.