3 ms·
> I wish Lua had won against python Thank goodness it didn't. The number one benefit you should get from a scripting language as opposed to a compiled one is h
by adwn 9y ago
> I wish Lua had won against python
Thank goodness it didn't. The number one benefit you should get from a scripting language as opposed to a compiled one is higher productivity – otherwise, you could just write it in C and have higher performance and lower resource usage. What good is a scripting language where I have to either implement every utility function myself, or look for and include an external library? Lua does not even have a round() function! [1] You can't just write print(some_table) [2], which makes using the REPL needlessly burdensome.
Sure, as an embedded scripting language in very small, resource-constrained devices this is a good strategy, but that's a niche application.
Even worse is the "arrays are hashtables in disguise" concept, because even though it might appear to be elegant, it doesn't work well in practice. In the end, you have to treat arrays and hashtables differently (see, e.g., pairs() and ipairs()), because – big surprise – arrays and hashtables are very different conceptually, so you don't gain much from unifying them.
Also great is that if you set element #5 in a 10-element array to nil (maybe you write foo[5] = arg1, and arg1 comes from a caller), your array suddenly only has 4 elements. That's because the first nil in a hashtable demarks the end of an array. Similarly, you might get an array argument from a caller, check its length (4 elements), append a single value, and suddenly your array has 10 elements, instead of 5! That's terrible design.
[1] But it does have functions to convert degrees to radians and back. How is that more important than round()?!
[2] Lua will just print the address of the hashtable, which is completely useless if you want to see its contents.
- jgtrosh 9y agoThe lua interpretors are just fine ; it's not because it's designed to be easily embeddable that it doesn't work just fine on its own.
- adwn 9y ago> The lua interpretors are just fine I don't think I complained about the Lua interpreter itself? > it's not because it's designed to be easily embeddable that it doesn't work just fine on its own. I don't understand that sentence.
- jgtrosh 9y agoYeah sorry I guess your comment wasn't about that. But I don't understand the original comment's point. What is the problem you describe about Lua? That you can't just say "import module" and have many modules available? Sure you can if you have a distribution that provides them, which I think is the kind of thing that the previous comment was referring to. What's the big difference with Python? I guess the lack of round function is surprising too, but the explanations I see online about it being a minimalism and ease of implementation make sense. I think it's a fair choice and I don't think a core library's choice should be an argument to judge the whole language.
- adwn 9y ago> But I don't understand the original comment's point. 1) A minimalistic scripting language is appropriate for a few niches only, therefore Lua would be a bad replacement for Python in most cases. 2) Missing basic functionality (e.g., printing the contents of the language's fundamental datastructure) decreases productivity, the one thing which scripting languages are supposed to excel at. 3) Pressing arrays into hashtables-as-arrays-but-not-really is a very bad, unnecessary design decision with few upsides and many downsides. > I guess the lack of round function is surprising too, but the explanations I see online about it being a minimalism and ease of implementation make sense. I have read those implementations and they are all unsatisfying: 1) The "minimalism" argument: How is that consistent with the existence of math.deg() and math.rad()? Both are easier to manually implement and less rarely used than round(). 2) The "ease of implementation" argument: The C standard library actually provides a round() function, so binding it would be negligible in terms of both resources and implementation effort. > I don't think a core library's choice should be an argument to judge the whole language The lack of round() is symptomatic of Lua's standard library, it's not a singular example. Another one is that there's no function to copy a hashtable (neither for shallow nor for deep copies). How can a language offer such a bad support for its most important datastructure?
- kristianp 9y ago> The number one benefit you should get from a scripting language as opposed to a compiled one is higher productivity As I understand it, neither lua nor python are compiled languages, they're both dynamic, scripting languages. Which one do you think is a compiled language?
- repsak 9y ago> The number one benefit you should get from a scripting language (Lua) as opposed to a compiled one (C) is higher productivity OP is saying that since Lua is cumbersome to write you might as well write in C and get increased performance.
- Pica_soO 9y agoI tryied to read it- but in the second sentence the well rounded argument i expected, became a syntactic sugar and base library bitching about round not being part of the base. That this bubbled up, sums up the true power of javascript. No good arguments, but lots and lots of people who know and use it. Lua should just attach itself via script converters to that ecosystem and convince via time and better syntax the unwashed masses.