lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 10/20/11 10:57 PM, Dirk Laurie wrote:
2011/10/21 Miles Bader<miles@gnu.org>:
"Patrick Mc(avery"<patrick@spellingbeewinnars.org>  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
follows:

~~~~
def perms(a):
    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:]) ]

def cubes():
    main = [tuple([1,2]+p) for p in perms([3,4,5,6])]+[
        tuple([1,3]+p+[2]) for p in perms([4,5,6])]
    return [(m,(U,L,B,F,R,D),(U,B,R,L,F,D),(U,R,F,B,L,D))
        for m in main for U,F,L,R,B,D in [m]]

cube=cubes()
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
me.

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.

Dirk



Man.... I have to do sometimes python coding (Autodesk MotionBuilder) and I hate the damn language... I actually hate me, as I can't seem to get into it, and on top of that I have to write my app to work in 2.5.1 and 2.6.2 (due to two different versions of MB that I support)....

from future import with_statement