4 ms·
I have been programming Python by day and Lua by night my entire career for the past 7 years, and I find the main difference between the two is, Python has the
by meric 11y ago
I have been programming Python by day and Lua by night my entire career for the past 7 years, and I find the main difference between the two is, Python has the overwhelming advantage in its package manager providing ease of access to thousands of packages[1], and Lua is faster and lighter by a constant factor. In your case, Python's package system is a disadvantage - you want to have as few dependencies as possible.
I think your company made a good decision. The only reason not to have done it was because your existing code was valuable, but as you've said it wasn't in great shape and required tons of work to refactor and rewriting anyway.
[1] Lua has LuaRocks, but it's just not the same.
- stuffinstuff 11y agoI 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.