3 ms·
> the indentation-based syntax can make for relatively verbose code in quick ad-hoc scripts. Isn't significant indentation less verbose than Lua's use of `do .
by pansa2 5y ago
> the indentation-based syntax can make for relatively verbose code in quick ad-hoc scripts.
Isn't significant indentation less verbose than Lua's use of `do ... end`?
- scythe 5y agoNot if you write one-liners like if x < 3 then x = 3 end I actually really like Lua's syntax, though I think a form for short Python-style lambdas would really help (short lambdas are the easiest ones to understand, so I don't see a comprehensibility objection, and Lua's grammar already makes the necessary expression-statement distinction). The Lua ecosystem was seriously damaged by the 5.1>5.2 split for a while since LuaJIT (hence Torch/nginx) and LÖVE both basically stayed with 5.1 and those were major projects that drew people to the language. The other cool unique thing in the Lua ecosystem, the native-widget (Windows/Gtk) IUP toolkit, remains barely known about and never ported to OS X, possibly due to a lack of Mac users in Brazil. Hence the "language without an ecosystem": it didn't happen for no reason, though the willingness to make breaking changes is a reason the language became so popular in the first place. NB. IUP is still around, but it still doesn't have a Cocoa port.
- nerdponx 5y agoMaybe a silly question, but isn't it possible to run Gtk applications on a Mac?
- pansa2 5y ago`if x < 3: x = 3` is valid Python, although I see your point - you could add an `else` to the Lua example but Python would require a second line. > a form for short Python-style lambdas would really help Interesting - many in the Python community feel that its lambdas (particularly the use of `lambda` as a keyword) are too verbose and would prefer something like `x => x+1`. Maybe such an arrow-function syntax is achievable with Python's new PEG parser - I'm fairly sure it couldn't have been supported by the old LL(1) parser.
- kzrdude 5y agoIn this particular example, Python has the more wordy `x = 3 if x < 3 else x` which you'd rather write as `x = max(x, 3)` to demonstrate Python's muscles in terms of useful builtins. About lambda syntax, to me it would be far more important to allow multiline lambdas than to have a shorter keyword.
- pansa2 5y ago> `x = max(x, 3)` to demonstrate Python's muscles in terms of useful builtins Even Lua has a built-in `math.max` function that works with integers. Maybe it’s Lua’s way of flexing on Go :) > About lambda syntax, to me it would be far more important to allow multiline lambdas than to have a shorter keyword. Never going to happen, unfortunately. It’s just not possible within the fundamental rules of Python’s grammar: that statements use significant indentation and expressions do not.
- deleted 5y ago[deleted]
- scythe 5y agoAll good points. Just compare: (lambda x: x + 1) (function (x) return x + 1 end) For arrow syntax I like this: ((x) -> x + 1) but reducing the number of keyword characters from 17 to 6 is already a big win.
- dottrap 5y agoIUP's Cocoa port is unfinished, but there was enough complete that it was accepted into the official SVN repo.