4 ms·
No static typing, No ergonomic language features like lambdas, No functional programming, magic nil behaviour, global by default, no integer type (not sure if t
by lenkite 4y ago
No static typing, No ergonomic language features like lambdas, No functional programming, magic nil behaviour, global by default, no integer type (not sure if this was addressed), index tables instead of having a proper array/list type, missing switch, No assigning operators..the list goes on and on.
It was an average PL a decade ago and it is simply mediocre now. Only superb implementations like LuaJIT prop the language up.
I would prefer writing Enterprise Java (gasp) over writing Lua code for anything >5k lines. It's OK for small scripts but rapidly breaks down for anything larger. It's a bit funny that a complicated system PL like Rust is more comfortable to code than Lua.
Only using Lua personally nowadays due to Neovim and now that https://github.com/noib3/nvim-oxi https://github.com/noib3/nvim-oxi has come out, I am going to use it even less.
- maegul 4y ago> now that https://github.com/noib3/nvim-oxi https://github.com/noib3/nvim-oxi has come out, I am going to use it even less. Woah, interesting ... provided there's success and uptake with this ... I'm imagining it could lead to a really slick and responsive editing experience that those of using (at least) slightly sluggish plugins might have been missing for a while now.
- fanf2 4y agoLua has had proper lexical closures and function expressions since 5.0 https://www.lua.org/manual/5.1/manual.html#2.5.9 https://www.lua.org/manual/5.1/manual.html#2.5.9 It has had 64 bit integers since 5.3 https://www.lua.org/manual/5.3/manual.html#2.1 https://www.lua.org/manual/5.3/manual.html#2.1
- Benjamin_Dobell 4y agoWhat do you mean by no lambdas exactly? Lua supports anonymous functions and they're in fact closures, since those functions capture variables from their outer scope. I use functional programming extensively in Lua also. Could you elaborate on what it doesn't permit? Integers were introduced in 5.3. Assigning operators? It has metatables, you can absolutely implement your own operators. If you want static typing you can use my IDE: https://github.com/Benjamin-Dobell/IntelliJ-Luanalysis/ https://github.com/Benjamin-Dobell/IntelliJ-Luanalysis/ Granted, my IDE is incredibly opinionated and not for everyone. Also, Lua is not my favourite language to use, doesn't even make top 3. However, the robustness of its design, considering its simplicity, is incredibly elegant.
- edflsafoiewq 4y ago> Assigning operators +=
- Benjamin_Dobell 4y agoAh, thanks for the clarification. It does indeed lack those. I tend to call those short-hand operators since I guess technically `=` is an assigning operator. Personally, I don't have a strong opinion on their omission, however I know some prefer the simplicity.
- lenkite 4y agoOoh, didn't know about Luanalysis, thanks for creating it! Going to check that out. I personally found functional programming non-ergonomic in Lua considering that anonymous functions are very verbose and there is no map/filter/etc in the standard language/library unlike just about every PL these days. You need to pull stuff in for basics and everyone does it slightly differently leading to non interoperability. Sorry, I meant shorthand assignment operators. Those are quite convenient.
- blueflow 4y ago> No ergonomic language features like lambdas x = function(a,b) return a+b end x(4,5) Is that not a lambda?
- wruza 4y agoGP probably meant a short syntax for it, thus ergonomic. When you use lambdas a lot, this “function() end” part may become annoying.
- citrin_ru 4y ago> magic nil behaviour What is magic in Lua nil? nil being false makes nil different from other non-boolean types, but it is both intuitive and convenient (I don't know a language where null/nil/undef are true in boolean context). What makes Lua a bit different from other script languages is that 0, "0", "", {} e. t. c. are not false in Lua. But it allows to avoid mess with truthy/falsy values we have in other script languages.
- edflsafoiewq 4y agonil is like the absence of a value, reified into a value. Reading a variable that doesn't exist produces nil, and assigning nil deletes the variable.
- DemocracyFTW2 4y agoHaving a value that, when assigned to a variable or property, elides or deletes it is actually a desirable feature in MHO. Arguably, JavaScript's `undefined` should act like that, or nowadays more probably a well-known symbol. It's at any rate a nuisance that introducing one cavalier 'simplicity' (you can access `d.x` even when it does not exist, but you'll get `undefined` as value) causes so much accidental complexity (now you have to distinguish between so many fringe conditions (does `d` have a key `x`? does `d.x == undefined` mean `x` is set on `d`?). OTOH if you don't have a value that deletes a key from an object, then you'll have to special-case that operation because `delete d.x`, apart from being revolting syntactically, only exists as a syntactical construct.
- lenkite 4y agoLua tables make no distinction between a table value being nil and the corresponding key not existing in the table necessitating hacks like: http://lua-users.org/wiki/StoringNilsInTables http://lua-users.org/wiki/StoringNilsInTables
- edflsafoiewq 4y agoYeah, that's the point of nil. If you're trying to store it in a table, you're just fighting the language. Is there a good motivation for doing that?
- nielsbot 4y agoThere is Luau, however. "Luau (lowercase u, /ˈlu.aʊ/) is a fast, small, safe, gradually typed embeddable scripting language derived from Lua." https://luau-lang.org https://luau-lang.org
- DayDollar 4y agoi dont know lambda was really easy to do it by onself. filterdResult = lambda(Table, function(i) if i ~= 42 then return i; end end, setToFilterOut = {} function filterOutIfInSet(i, filterSet) if not filterSet[i] then return i; end end etc.. ) Combined with properly, once defined decision sets this is really powerful. Almost of all my game decisions are lambdas mit once global defined decisionsets for unittypes. If i want to change something, for a unit, i only insert its type into the corresponding decision set and suddenly it has that property. Like dropping a smooth stone into a pond without ripples. Its similar simple to the javascript implementations, once functions are firstclass members. Functional programming would be harder. You need alot of meta table, result hashing for that a + b hash(a) + hash(+) + hash(b) -> Resultlookup. So its doable, by the law of look it up yourself, it has been done.