One more item to the collection of Lua hate-speech

classic Classic list List threaded Threaded
56 messages Options
123
Reply | Threaded
Open this post in threaded view
|

One more item to the collection of Lua hate-speech

Alexander Gladysh
Hi, list.

Just stumbled upon this little gem.

http://groups.yahoo.com/group/atlantisdev/message/8101

I'll quote it in full text.

<quote>

  From: Andrey Repin <hell-for-yahoo@...>
  for [hidden email]; Tue, 09 Mar 2010 00:25:02 +0300
  To: Arno Saxena <[hidden email]>
  Date: Tue, 9 Mar 2010 00:22:20 +0300
  Subject: Re[2]: [atlantisdev] Eressea: Open Source

  AS> but what's the advantage of lua? (it is the tecgraf lua language
isn't it?)

  If you ask me, the only advantage of Lua, is that it's easy to learn.
  Everything else is disadvantages. If you have choice - avoid it like plague.
  No strict syntax (only procedural parsing of source code is
possible), braindead
  typization, everything defaults to global scope (so-called global polluting),
  slow addressing of global scope, thus you have to localize (reassign) about
  every function and structure you're using in single script...

</quote>

Brilliant, isn't it?

Alexander.
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Luiz Henrique de Figueiredo
>   slow addressing of global scope, thus you have to localize (reassign) about
>   every function and structure you're using in single script...

This perception is probably our (the community's) fault with its insistence
on "performance". Lua is probably quite fast already even if you only use
global variables, ie, don't bother with locals.
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Petite Abeille

On Jul 1, 2010, at 9:25 PM, Luiz Henrique de Figueiredo wrote:

> Lua is probably quite fast already even if you only use
> global variables, ie, don't bother with locals.

FWIW, in modules, I use locals as an import mechanism, irrespectively of "performance" consideration.

E.g.:

-- import dependencies
local table = require( 'table' )

local assert = assert
local getmetatable = getmetatable

module( 'DB' )

-- no access to globals from that point on

For example:

http://dev.alt.textdrive.com/browser/HTTP/DB.lua






Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Alexander Gladysh
In reply to this post by Luiz Henrique de Figueiredo
On Thu, Jul 1, 2010 at 23:25, Luiz Henrique de Figueiredo
<[hidden email]> wrote:
>>   slow addressing of global scope, thus you have to localize (reassign) about
>>   every function and structure you're using in single script...

> This perception is probably our (the community's) fault with its insistence
> on "performance". Lua is probably quite fast already even if you only use
> global variables, ie, don't bother with locals.

For the performance — perhaps.

However most of the arguments against using globals in other
programming languages are valid for Lua.

In addition, globals in Lua not live well with sandboxes.

So, one, probably, should bother with locals, but not for performance
reasons, but to keep code clean.

Alexander.
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Javier Guerra Giraldez
In reply to this post by Petite Abeille
On Thu, Jul 1, 2010 at 2:34 PM, Petite Abeille <[hidden email]> wrote:
> FWIW, in modules, I use locals as an import mechanism, irrespectively of "performance" consideration.

same here.  i really don't like the 'seeall' option to module()

--
Javier
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Alexander Gladysh
On Thu, Jul 1, 2010 at 23:39, Javier Guerra Giraldez <[hidden email]> wrote:
> On Thu, Jul 1, 2010 at 2:34 PM, Petite Abeille <[hidden email]> wrote:
>> FWIW, in modules, I use locals as an import mechanism, irrespectively of "performance" consideration.

> same here.  i really don't like the 'seeall' option to module()

In my current engine it is forbidden to create and access new globals.

The only allowed globals are ones from standard Lua libraries — just
because I'm too lazy to really enforce aliasing them at the top of the
file. This feature is in my TODO list for years :-). Anyway,
developers are encouraged to do such aliasing.

The other allowed global is an import() function (a wrapper around
loadfile() with cache).

So, my Lua files usually look like this:

----------
local print = print
local foo, bar = import 'foobar.lua' { 'foo', 'bar' }

local baz = function() print("baz") end

local qux = function() print("qux") end

return
{
  baz = baz;
  qux = qux;
}
----------

The import() function, probably, should be reimplemented as a wrapper
around require() instead of loadfile() — to allow path searching etc.
Current implementation is too ecosystem-dependent.

Alexander
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

liam mail
If I were to be totally honest the thing which I dislike most about Lua is the keyword 'local', I dislike typing it over and over again and that the fact the default scope is global. Having edited third party code, it also seems to encourage the use of the globals although this is not to say that the same authors would have used scoped variables in other languages.

Liam
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Rena
On Thu, Jul 1, 2010 at 15:18, liam mail <[hidden email]> wrote:
> If I were to be totally honest the thing which I dislike most about Lua is
> the keyword 'local', I dislike typing it over and over again and that the
> fact the default scope is global. Having edited third party code, it also
> seems to encourage the use of the globals although this is not to say that
> the same authors would have used scoped variables in other languages.
>
> Liam
>

I agree, defaulting to global scope is one thing that always irks me
in Lua. It's easy to define a local variable in some module function,
then later delete the definition but neglect to delete an assignment -
now it's a global variable that suddenly appears, causing potential
confusion. Not to mention inexperienced/lazy programmers making
everything global because they don't realize/forget/don't care that
they need to specify otherwise, thus polluting the global namespace.

I'm sure it has some advantages, but they're escaping me at the moment.

--
Sent from my toaster.
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Geoff Leyland
On 2/07/2010, at 9:58 AM, HyperHacker wrote:
> On Thu, Jul 1, 2010 at 15:18, liam mail <[hidden email]> wrote:
>> If I were to be totally honest the thing which I dislike most about Lua is
>> the keyword 'local'...
>
> I agree, defaulting to global scope is one thing that always irks me
> in Lua...
>
> I'm sure it has some advantages, but they're escaping me at the moment.

Local by default used to confuse me no end in Python.  If Lua used it then:

do
  a = 1
  do
    a = 2  -- is this a new local or the same as the one above?  How do I tell Lua whether I want it to be the same or different?
  end
  print(a) -- does this print 1 or 2?
end

I much prefer global by default - it seems do be defined better.

Cheers,
Geoff

Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Duncan Cross
In reply to this post by Alexander Gladysh
On Thu, Jul 1, 2010 at 7:51 PM, Alexander Gladysh <[hidden email]> wrote:

> Hi, list.
>
> Just stumbled upon this little gem.
>
> http://groups.yahoo.com/group/atlantisdev/message/8101
>
> I'll quote it in full text.
>
> <quote>
>
>  From: Andrey Repin <hell-for-yahoo@...>
>  for [hidden email]; Tue, 09 Mar 2010 00:25:02 +0300
>  To: Arno Saxena <[hidden email]>
>  Date: Tue, 9 Mar 2010 00:22:20 +0300
>  Subject: Re[2]: [atlantisdev] Eressea: Open Source
>
>  AS> but what's the advantage of lua? (it is the tecgraf lua language
> isn't it?)
>
>  If you ask me, the only advantage of Lua, is that it's easy to learn.
>  Everything else is disadvantages. If you have choice - avoid it like plague.
>  No strict syntax (only procedural parsing of source code is
> possible), braindead
>  typization, everything defaults to global scope (so-called global polluting),
>  slow addressing of global scope, thus you have to localize (reassign) about
>  every function and structure you're using in single script...
>
> </quote>
>
> Brilliant, isn't it?
>
> Alexander.
>

Frankly, as much as I like Lua, I'm a bit uncomfortable with this
"look at THIS idiot" approach to criticism. If someone believes strong
typing is The Way To Go, and dynamic typing is Just Plain Wrong, it's
not likely they'll ever get on with Lua. It's not a position I agree
with, but I *can* understand it, and respect it as an opinion. Same
thing with one-based/zero-based issue, or using keywords to delineate
blocks, although he doesn't mention either of those. These things
don't bother me, but for some people these things will always
overshadow the language. That's just the way it is, I don't think
there's anything to be gained by trying to belittle them.

The global-by-default issue is an interesting one. Because I have to
admit that I *do* find myself wishing, sometimes, that it wasn't
necessary to explicitly define locals all the time, particularly in
the big list at the top of a module. (Like others, I dislike using
"seeall", but that's a side issue.) At the same time, I do completely
appreciate that it is not a solution to switch to local-by-default,
because local-by-default just doesn't work at all well with full
lexical scoping. And, I consider full lexical scoping to be one of the
most important and useful aspects of the language, definitely not
worth sacrificing in the name of local-by-default. Now, I only know
about that because I've read discussions on here with Roberto etc.
explaining it - I don't think I would ever have realised it on my own,
it's quite a subtle thing. So, I would never think any less of someone
*else* for not realising it.

-Duncan
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Christopher Eykamp
In reply to this post by Geoff Leyland
In Bitfighter (a game with Lua scripting), I require users to explicitly
declare their vars as either local or global, so there is no ambiguity.  
Using an undeclared variable produces an error.

This also helps identify spelling errors.

Chris



On 7/1/2010 3:20 PM, Geoff Leyland wrote:

> On 2/07/2010, at 9:58 AM, HyperHacker wrote:
>    
>> On Thu, Jul 1, 2010 at 15:18, liam mail<[hidden email]>  wrote:
>>      
>>> If I were to be totally honest the thing which I dislike most about Lua is
>>> the keyword 'local'...
>>>        
>> I agree, defaulting to global scope is one thing that always irks me
>> in Lua...
>>
>> I'm sure it has some advantages, but they're escaping me at the moment.
>>      
> Local by default used to confuse me no end in Python.  If Lua used it then:
>
> do
>    a = 1
>    do
>      a = 2  -- is this a new local or the same as the one above?  How do I tell Lua whether I want it to be the same or different?
>    end
>    print(a) -- does this print 1 or 2?
> end
>
> I much prefer global by default - it seems do be defined better.
>
> Cheers,
> Geoff
>
>    

Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Alexander Gladysh
In reply to this post by Rena
> I agree, defaulting to global scope is one thing that always irks me
> in Lua. It's easy to define a local variable in some module function,
> then later delete the definition but neglect to delete an assignment -
> now it's a global variable that suddenly appears, causing potential
> confusion. Not to mention inexperienced/lazy programmers making
> everything global because they don't realize/forget/don't care that
> they need to specify otherwise, thus polluting the global namespace.

> I'm sure it has some advantages, but they're escaping me at the moment.

Perhaps this wiki page would be useful:

http://lua-users.org/wiki/LocalByDefault

Alexander.
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

David Given
In reply to this post by Rena
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/07/10 22:58, HyperHacker wrote:
[...]
> I agree, defaulting to global scope is one thing that always irks me
> in Lua.

Me, too --- but if you look back at the list archives you can find
endless arguments about local-by-default (which is horrible) vs
local-by-default (which is slightly less horrible). The usual conclusion
is neither-by-default would be better but that it's now too late to change.

- --
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────

│ "Money is a sign of poverty." --- Iain Banks

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFMLRtNf9E0noFvlzgRAjIxAKDg/66NiYyjjV0QyWeJXQTnXHhrggCgotfz
NXrzYcvw7Xc0d1QgMBzLH5Q=
=l4Qm
-----END PGP SIGNATURE-----
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Jeff Pohlmeyer
On Thu, Jul 1, 2010 at 5:48 PM, David Given <[hidden email]> wrote:


> local-by-default (which is horrible) vs
> local-by-default (which is slightly less horrible).

For some reason that statement reminds of an old saying:
  A computer always does what you tell it to do, but not
  necessarily what you wanted it to do. :-)

 - Jeff
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Alexander Gladysh
In reply to this post by Duncan Cross
On Fri, Jul 2, 2010 at 02:30, Duncan Cross <[hidden email]> wrote:
> On Thu, Jul 1, 2010 at 7:51 PM, Alexander Gladysh <[hidden email]> wrote:
>> Just stumbled upon this little gem.
...
>> <quote>
...
>>  Everything else is disadvantages. If you have choice - avoid it like plague.
...
>> </quote>
...
>> Brilliant, isn't it?

> Frankly, as much as I like Lua, I'm a bit uncomfortable with this
> "look at THIS idiot" approach to criticism. If someone believes strong
> typing is The Way To Go, and dynamic typing is Just Plain Wrong, it's
> not likely they'll ever get on with Lua. It's not a position I agree
> with, but I *can* understand it, and respect it as an opinion. Same
> thing with one-based/zero-based issue, or using keywords to delineate
> blocks, although he doesn't mention either of those. These things
> don't bother me, but for some people these things will always
> overshadow the language. That's just the way it is, I don't think
> there's anything to be gained by trying to belittle them.

Um.

1. I apologize if my original post was too rude. I'm too passionate
about Lua criticisms sometimes :-)

2. That being said, when someone advises in public to "avoid [Lua]
like plague", that is a... very closed-minded position to say the
least. Especially when given relatively minor arguments to support it.

I wouldn't advise to avoid "like a plague" even, say, BASIC — every
language has its uses.

3. Anyway, the main point of my original post was not to call someone
a closed-minded person (or even an idiot).

I believe that we (as a community) have a lot to learn from the such
hate speech. It raises questions (like "*Why* do not they Love Lua as
we do?"). Such questions may help us to tune the public image of Lua
so it is perceived even better.

Alexander.
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Geoff Leyland
In reply to this post by David Given
On 2/07/2010, at 10:48 AM, David Given wrote:

> Me, too --- but if you look back at the list archives you can find
> endless arguments about local-by-default (which is horrible) vs
> local-by-default (which is slightly less horrible). The usual conclusion
> is neither-by-default would be better but that it's now too late to change.


(I think you meant global-by-default the second time?)

I'd say:

local-by-default: flawed
global-by-default: works, care required
neither-by-default: works, extra typing or extra visibility depending on your point of view

strict.lua gives you some of the advantages of neither-by-default without extra typing, and I imagine further fiddling with _G's __newindex can offer extra visibility.

That's what I like about Lua: the core of the language seems carefully designed, and it has mechanisms to do what suits you best.

Cheers,
Geoff

Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Stephen Kellett
In reply to this post by Alexander Gladysh

> I believe that we (as a community) have a lot to learn from the such
> hate speech. It raises questions (like "*Why* do not they Love Lua as
> we do?").
Because they don't understand.

Solution: Better education on:
o What Lua is
o Why Lua is the way it is
o What are benefits of this approach
o What are the deficits of this approach

On a separate note I thought the original article that prompted this
thread was a good pre-interview selector. It seems to me that the writer
of the original web article had not thought very deeply about why Lua is
the way it is. For me, that fails him as an interview candidate.

Stephen
In some ways the Lua language and community reminds me of Vorlons. So
much is implied, so little is stated up front. Doesn't even have a
consistent object system. You have to discover for yourself. Kind of
pre-selects for the curious and intelligent. Not the best fit for
generating maximum uptake of what you are offering, even if it is great.
For example, despite thinking Lua is great and knowing that Lua is much
faster than Ruby, for my next web project I'm doing it using Ruby. I
want a consistent object model that I can leverage other toolkits with.
Thats worth more to me than the speed and flexibility that Lua offers.
Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

Wesley Smith
> In some ways the Lua language and community reminds me of Vorlons. So much
> is implied, so little is stated up front. Doesn't even have a consistent
> object system. You have to discover for yourself. Kind of pre-selects for
> the curious and intelligent. Not the best fit for generating maximum uptake
> of what you are offering, even if it is great. For example, despite thinking
> Lua is great and knowing that Lua is much faster than Ruby, for my next web
> project I'm doing it using Ruby. I want a consistent object model that I can
> leverage other toolkits with. Thats worth more to me than the speed and
> flexibility that Lua offers.
>

IMHO, I don't think any language on its own merits attracts many new
users relatively speaking.  What really gets people using a language
is what kind of projects, libraries, apps, frameworks, etc. that are
available for a given language.  Actions speak louder than words.
Lua's usefulness should be measured by what people have done with it.
There's a reason lots of people use Python for scientific computing or
Ruby for web-whatever.

wes
Reply | Threaded
Open this post in threaded view
|

globals (was Re: One more item to the collection of Lua hate-speech)

Mark Hamburg
In reply to this post by Stephen Kellett
The Lightroom approach is to simply run a "linter" over the byte code to look for access to local variables not on our white list.

What I haven't dug into yet is how easy this will be to adapt to the 5.2 work 3 model for environments. Presumably we need to look for field accesses on particular parameters or upvalues. What could be particularly interesting relative to 5.1 would be if it were easy to tell the difference between accesses to the chunk-level _ENV and accesses to a more local _ENV parameter or variable since that would then enable cases where we wanted to repurpose global access -- e.g., more sophisticated table construction.

Another interesting option for the import everything into locals first approach would be a way to undeclare _ENV in the source code so that accesses past a certain point would be flagged as errors.

Mark

Reply | Threaded
Open this post in threaded view
|

Re: One more item to the collection of Lua hate-speech

David Manura
In reply to this post by liam mail
On Thu, Jul 1, 2010 at 5:18 PM, liam mail <[hidden email]> wrote:
> If I were to be totally honest the thing which I dislike most about Lua is
> the keyword 'local', I dislike typing it over and over again and that the
> fact the default scope is global. Having edited third party code, it also
> seems to encourage the use of the globals although this is not to say that
> the same authors would have used scoped variables in other languages.

The "Huffman encoding" language design principle in Perl says that
common operations should have shorter syntax than less common
operations.  A slightly different formulation expressed in the Lua
community is that dangerous operations should look ugly [1].  In Lua,
we have "a=b" for re-assignment or, if coding policy permits [2],
global variable definition, and we then have the longer "local a=b"
for lexical variable definition.  In the interest of minimizing
complexity (number of plausible states), users should strive to use
lexical variable definitions and minimize use of variable
re-assignments and globals, but the syntax may encourage the opposite
here.  The same criticism could be said of other procedural languages,
but a number of these use the shorter keyword 'var' [4], and Perl has
an even shorter though curiously named 'my'.  The Go language also has
a short-hand: using "a := b" rather than "a = b" is analogous to
"local a = b" in Lua.  Regardless of syntax though, the linter [2]
could limit the use of '=', and one's text editor could use color and
font to make less desirable operations like mutating assignment and
global variable definition more prominent [3], or in a way more
"expensive" syntactically.

BTW, concerning the relationship between Lua syntax and user coding
practice, what I see regularly is poorly indented Lua code when Lua is
used embedded (and perhaps not by professional programmers).  Baring a
draconian approach like Python, the solution again may be the linter
and text editor offering assistance.

[1] http://lua-users.org/lists/lua-l/2010-05/msg00481.html
[2] http://lua-users.org/wiki/DetectingUndefinedVariables
[3] http://lua-users.org/wiki/LuaInspect
[4] JavaScript, Go, and to some extent C#
123