Live data from Hacker News

The Problem with Implicit Scoping in CoffeeScript

lucumr.pocoo.org

51–60 of 137 posts

Re: The Problem with Implicit Scoping in CoffeeScript

#51
post #46

Earlier quoted context omitted.

What do you think about node? Does it fall in your category of above-average people building tools for the average programmer?

they're certainly above average but even Ryan himself is humble enough to admit he's not amazing, I dont recall what his exact words were. I think it was on google+, he was talking about how he works with such brilliant people (which are lesser known), but yeah overall node's popularity is largely because it attracts more average people to the scene, vs things like erlang or haskell which are fantastic but attract a…

Well said.

Re: The Problem with Implicit Scoping in CoffeeScript

#52
It's worth pointing out that JavaScript 1.7 resolves this mess by introducing block scoping using the "let" keyword. It works just like it does in Scheme, Common Lisp, and Clojure (i.e., correctly). Not supported in anything except Firefox, unfortunately.

Re: The Problem with Implicit Scoping in CoffeeScript

#53

Considering we won't see this changed since the author has already closed the issue and expressed his satisfaction with the current rules this article should at least serve as a reminder for errors not to repeat with the next language someone designs. It's open source. Why not fork it and get some like minded coders to change it with you?

[deleted]

Re: The Problem with Implicit Scoping in CoffeeScript

#54
post #47

Earlier quoted context omitted.

99% of the popular people out there are just above average enough to make useful projects for those lesser experienced. Most truly talented people are not very well known, they're busy hacking on v8, the kernel etc. Tools for average programming just get more of a spotlight. Is Express complex? no, people just use it, is coffeescript complex? no, is boostrap complex? no..

Perhaps you are being too hard on yourself. The majority (more than half) of the well known programmers truly are "superstars". It's all very subjective, though. Where is the standard for complexity or even cleverness? How is it different than simply being esoteric. Maybe I am personally fascinated with regular expressions and after much study, can belt out a half page of parse and extract 'magic' that would make the…

I think it has already been proven that there is no obvious correlation between being capable in mathematics and being a talented programmer. Thats so 1950's

Re: The Problem with Implicit Scoping in CoffeeScript

#55
post #6

@mitsuhiko Not gonna happen ;) Forbidding shadowing altogether is a huge win, and a huge conceptual simplification. How arrogant! You'd think he'd step back for a second and consider the suggestion, but it sounds like he's on autopilot.

Don't jump the gun. The reason is that he's already had many discussions about this and has formed an opinion.

See: https://github.com/jashkenas/coffee-script/issues/712 https://github.com/jashkenas/coffee-script/issues/238

Whether he's right is another question. But if you don't like his decision you can use the Coco (https://github.com/satyr/coco) fork which fixes it by introducing := for nonlocal assignment.

Re: The Problem with Implicit Scoping in CoffeeScript

#56
post #36

FWIW this is how CS works: top_level_variable = null f = -> top_level_variable = "hello" f() console.log top_level_variable # prints hello

The concern is that because Coffeescript automatically scopes variables to the scope of their first reference, it can introduce maintenance issues. Consider the following: foo = -> bar = "woot!" console.log bar This compiles to: var foo; foo = function() { var bar; bar = "woot!"; return console.log(bar); }; bar is locally scoped to foo(). Now, 2 weeks later and 200 lines earlier, you come along and define: bar = -> a…

This is a better explanation of the problem than the blog post. Thanks!

Re: The Problem with Implicit Scoping in CoffeeScript

#57
post #47

Earlier quoted context omitted.

99% of the popular people out there are just above average enough to make useful projects for those lesser experienced. Most truly talented people are not very well known, they're busy hacking on v8, the kernel etc. Tools for average programming just get more of a spotlight. Is Express complex? no, people just use it, is coffeescript complex? no, is boostrap complex? no..

Perhaps you are being too hard on yourself. The majority (more than half) of the well known programmers truly are "superstars". It's all very subjective, though. Where is the standard for complexity or even cleverness? How is it different than simply being esoteric. Maybe I am personally fascinated with regular expressions and after much study, can belt out a half page of parse and extract 'magic' that would make the…

There are certainly truly epic people out there that are well known, but hell me and Jeremy have many more followers than the guy who wrote openssl along with people like Mike Pall who could out-code most of us any day, it's a weird thing, but you're average programmer isn't concerned about lower level things like that, so they simply don't care. There are of course exceptions to this, people like Carmack or Linus, but still, you see my point.

Re: The Problem with Implicit Scoping in CoffeeScript

#58
post #36

FWIW this is how CS works: top_level_variable = null f = -> top_level_variable = "hello" f() console.log top_level_variable # prints hello

The concern is that because Coffeescript automatically scopes variables to the scope of their first reference, it can introduce maintenance issues. Consider the following: foo = -> bar = "woot!" console.log bar This compiles to: var foo; foo = function() { var bar; bar = "woot!"; return console.log(bar); }; bar is locally scoped to foo(). Now, 2 weeks later and 200 lines earlier, you come along and define: bar = -> a…

The inconsistency doesn't stop there; `for` variables are specialcased:

    bar = ->
      alert "Holy crap cheese is awesome!"

    foo = ->
      for bar of bars
        console.log bar
      return

    var bar, foo;

    bar = function() {
      return alert("Holy crap cheese is awesome!");
    };

    foo = function() {
      var bar;
      for (bar in bars) {
        console.log(bar);
      }
    };

Re: The Problem with Implicit Scoping in CoffeeScript

#59
post #52

It's worth pointing out that JavaScript 1.7 resolves this mess by introducing block scoping using the "let" keyword. It works just like it does in Scheme, Common Lisp, and Clojure (i.e., correctly). Not supported in anything except Firefox, unfortunately.

... and Standard ML, OCaml, Haskell, Smalltalk, etc

Re: The Problem with Implicit Scoping in CoffeeScript

#60

Considering we won't see this changed since the author has already closed the issue and expressed his satisfaction with the current rules this article should at least serve as a reminder for errors not to repeat with the next language someone designs. It's open source. Why not fork it and get some like minded coders to change it with you?

There already is a fork that changes this (Coco), already mentioned in another comment: http://news.ycombinator.org/item?id=3380423
Post reply on HN