[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Python vs Lua (Was: S.W.O.T analysis)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 21 Oct 2011 07:57:19 +0200
2011/10/21 Miles Bader <firstname.lastname@example.org>:
> "Patrick Mc(avery" <email@example.com> writes:
>> Python is so much easier to learn then Lua
> It isn't.
> Or rather, there's nothing about the _language_ that makes Python
> "easier" -- but it has better library support, better infrastructure
> support, many more eyes on it, more communities, more examples, and
> many more people who know it and are willing to help their friends.
> _That's_ why it's "easy" to learn Python.
> If you want to make Lua similarly "easy", the language itself has
> little to do with it.
I'll confess, I used to be a Pythonista. I'm still a seasonal one:
once a year I teach a course on Sage, which is built on top of Python.
That season is now, so yesterday I wrote a Python program, as
if len(a)==1: return [a]
return [[a[k]]+p for k in range(len(a)) for p in perms(a[:k]+a[k+1:]) ]
main = [tuple([1,2]+p) for p in perms([3,4,5,6])]+[
tuple([1,3]+p+) for p in perms([4,5,6])]
for m in main for U,F,L,R,B,D in [m]]
print '\n'.join(["%2i: "%(k+1) + ' '.join(["%i%i%i-%i%i%i"%c
for c in cube[k]]) for k in range(len(cube))])
You don't immediately see what it does? After all the trouble I've
taken to use descriptive names like "perms" and "cubes"? You surprise
That's Python. Concise. Hyper-elegannt. Incomprehensible. (Except
if you are a list, o0f course.)
Now imagine the same program in Lua. Twice the length, written in
half the time.