4 ms·
Arguing for one language over another on the basis of how the syntax looks is basically worthless. Agreed, with an exception for when frequently used constructs
by silentbicycle 18y ago
Arguing for one language over another on the basis of how the syntax looks is basically worthless.
Agreed, with an exception for when frequently used constructs are needlessly verbose or awkward. Something really minor, like the Python slicing notation, can make something so convenient that you find new uses for it. This is big. (For example, someStr[1:-1] means, "drop the first and last char".) It works the same for every ordered collection (lists, strings, tuples), so it's easy to remember. Dictionaries also support dictname[index] notation, but aren't ordered, so slicing is meaningless. (Lua seems to do something similar with its "tables".)
I'm not especially fond of the Lisp parenthesis, but I don't know of a better solution for a prefix-notation, nesting syntax. (Switching parenthesis for another paired symbol, e.g. curly braces, would just be a meaningless detail.) Postfix/stack languages can drop them, though.
Perl is sort of in-between; on the one hand, it is trying to build on the considerable power in the terse syntaxes like sed and awk, which are remarkable for quick scripts, but it is also trying to be usable for mid-to-large projects, which need to be relatively clean or they will become an unmaintainable mess. The latter is true for any language, of course, but it seems like good habits are harder to stick to in Perl.
- LogicHoleFlaw 18y agoLua tables have two parts - the ordered part with indices 1 ... n and the other part is everything else. You can iterate over a table in various ways. pairs() is an iterator over the entire table in an undefined order. ipairs() gives the ordered integer keys from 1 to #t (#t gives the max integer key of a table t). My favorite aspect of Lua tables is that attribute-style access is exactly equivalent to dict-style access. At the repl: > tab = {} -- allocate a new table "tab" > tab.string = "hello!" > =tab.string == tab['string'] true Also, you can index a Lua table by any other value. Functions, strings, tables, and booleans are all valid keys. nil is the only invalid key. This has been your daily dose of Lua!
- silentbicycle 18y agoThanks. It looks like they nailed a big part of what I like about Python. When/if I do more projects with C, I'll check it out.