News for hackers. Stuff that matters.
Re:Tessel: The end of web development as we know it by morkbot on Monday September 30, 2013 @04:17AM (#6468353)
Sorry to nit pick, but (for example) variables being global by default it's not exactly an epitome of elegance.
Re:Tessel: The end of web development as we know it by panic on Monday September 30, 2013 @04:20AM (#6468360)
It's the same in JavaScript:

   x = 5; // global
   var x = 5; // local
Lua just replaces var with local:

   x = 5  -- global
   local x = 5  -- local
Re:Tessel: The end of web development as we know it by icambron on Monday September 30, 2013 @04:55AM (#6468465)
"JavaScript Done Right" requires actually doing it right.
Re:Tessel: The end of web development as we know it by riquito on Monday September 30, 2013 @04:37AM (#6468413)
Whatever javascript does, it does not make Lua's default global variables look any better
Re:Tessel: The end of web development as we know it by nilkn on Monday September 30, 2013 @09:37AM (#6469515)
To be fair, using 'local' instead of 'var' does make the situation a lot clearer.
Re:Tessel: The end of web development as we know it by woah on Monday September 30, 2013 @11:18AM (#6470052)
'Use strict';
Re:Tessel: The end of web development as we know it by catwell on Wednesday October 02, 2013 @05:19AM (#6481448)
This is actually what we do in Lua, often written `require "pl.strict"`...
Re:Tessel: The end of web development as we know it by haberman on Monday September 30, 2013 @04:34AM (#6468399)
If you are arguing in favor of "local by default", there are strong arguments against this: http://lua-users.org/wiki/LocalByDefault
Re:Tessel: The end of web development as we know it by icambron on Monday September 30, 2013 @05:02AM (#6468491)
The parent isn't arguing for local by default, just against global by default. Insomuch as you buy into the arguments in that link, the answer is to do neither (i.e. you must always use "var"). Most of those arguments are actually even more damning to global by default.
Re:Tessel: The end of web development as we know it by catwell on Wednesday October 02, 2013 @05:26AM (#6481465)
I tend to agree with you, but here is the reasoning behind how Lua works:

- local by default weakens what you can do with the scope;

- we want something by default because the language is used for things like configuration files.

The 2nd point means this must be valid:

    param_1 = "foo"
    param_2 = "bar"
I would personally be happy to sacrifice that feature and add an explicit "global" keyword but not everybody agrees, and it would break a lot of code.

What we do instead is use two kinds of tools: static global detectors and strictures (like in Perl). Similar tools are integrated in IDEs as well.

With these tools, I have never had an issue with scoping in code I have written. But it takes a little time to get used to it.

Re:Tessel: The end of web development as we know it by icambron on Sunday October 06, 2013 @03:26PM (#6505126)
> I would personally be happy to sacrifice that feature and add an explicit "global" keyword but not everybody agrees, and it would break a lot of code.

For sure. That ship has probably sailed. And, like you said, linters alleviate a lot of that pain. But that's a separate question from, "is this a good language feature?"

Re:Tessel: The end of web development as we know it by Grue3 on Monday September 30, 2013 @06:26AM (#6468726)
These arguments don't look particularly strong.
Re:Tessel: The end of web development as we know it by dukerutledge on Monday September 30, 2013 @10:59AM (#6469956)
Anything by default is idiotic. Lexical scoping works when variables are declared. Lexical scoping becomes a burden when deceleration is not required and variables fall back to some default scope.