lua-users home
lua-l archive

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


On Tue, Jun 03, 2014 at 12:06:19PM +0200, steve donovan wrote:
> On Mon, Jun 2, 2014 at 10:24 PM, Elias Barrionovo
> <elias.tandel@gmail.com> wrote:
> > Well, it's a bit OT and nitpicking, but in Python when you do this:
> >
> > def foo(a, b):
> >   return a, b
> >
> > you are actually returning only one value, (a, b), which is an
> > instance of tuple [1]  (parenthesis is optional for tuple literals).
> 
> And that's the point - it's more expensive than it looks.  True
> multiple returns in Lua and Go are cheap.  (In both languages, often
> used for distinct error returns)
> 
> That's why I prefer Lua to Python - there is less 'convenience magic' happening.

I think alot of it has to do with the beautiful (i.e. straight-forward) VM
design. Python has always been held back by it's VM. This is why Python
can't support coroutines that can yield across function invocations (instead
you have to use ridiculous trampoline patterns). Same problem exists in
JavaScript engines (too many optimizations under the hood preclude
reengineering the stack management**), and it's why thread-like coroutines
won't come to ECMAScript anytime soon. And why they're hyping Promises and
other half-measures. Not that the Promise pattern isn't useful, but with
more powerful primitive like Lua's coroutines you can implement such
patterns and many more.

The Lua VM has been overhauled and rewritten many times, and it seems like
the authors have got it down to a science.

> As for Swift - it's fashionable for big companies to have their own
> new programming language. A well-known advertising agency [1] has
> spawned at least two recently. Despite its oddities, Swift seems a lot
> more readable than Objective-C, which always made my eyes bleed.
> 

I've only briefly looked at the langage, but I'm guessing the language was
basically a vehicle for Apple's fat-pointer compiler technology. A lot of
the language looks rough hewn and annoying, but I bet their type system and
memory management looks really slick underneath the hood.


** Yes, I know about Node.js Fibers, but it's clearly a hack and has many
limitations.