News for hackers. Stuff that matters.
Re:JavaScript Scope Context Coloring by scjr on Sunday April 07, 2013 @01:35AM (#5506220)
It might be better to use variations in the background color. It may feel more natural to do so and it would allow normal syntax highlighting alongside scope highlighting.
Re:JavaScript Scope Context Coloring by ufo on Sunday April 07, 2013 @12:35PM (#5507711)
Another possibility might be just colloring variables and assignments (since thats where the scoping actually matters)
Re:JavaScript Scope Context Coloring by archangel_one on Sunday April 07, 2013 @03:52AM (#5506454)
I was just thinking the same; when all my syntax highlighting in a region looks backwards, I normally assume I've got a mismatched quote just before it. I think I'd be thinking that with this all the time.

Subtle changes in the background colour would be a nice alternative.

Re:JavaScript Scope Context Coloring by solox3 on Sunday April 07, 2013 @01:39AM (#5506227)
It is a good idea indeed. I believe Notepad++ does background scope highlighting already, just not accurate enough for JavaScript specifically.
Re:JavaScript Scope Context Coloring by Mahn on Sunday April 07, 2013 @01:26PM (#5507882)
Exactly my thoughts, this could work really well if implemented properly.
Re:JavaScript Scope Context Coloring by seanp2k2 on Sunday April 07, 2013 @09:21AM (#5507118)
Yes; highlight BG lighter grey. This would be an awesome plugin for ST.
Re:JavaScript Scope Context Coloring by Zecc on Sunday April 07, 2013 @12:21PM (#5507654)
Make the background color become less contrasting with the foreground color the more you nest. The larger the number of nested scopes, the harder it's going to be to read it anyway!

I'm actually serious by the way.

Re:JavaScript Scope Context Coloring by wavesounds on Sunday April 07, 2013 @03:29AM (#5506421)
Really great idea, would be super useful, it looks like its still got a ways to go though, it doesn't seem to recognize global variables yet for one

http://stackoverflow.com/questions/235360/what-is-the-scope-...

Re:JavaScript Scope Context Coloring by Kudos on Sunday April 07, 2013 @06:43AM (#5506756)
If you're using strict Javascript (and you should be) there are no implicit global variables.
Re:JavaScript Scope Context Coloring by riffraff on Sunday April 07, 2013 @08:09AM (#5506923)
how would an example of javascript without implicit global variables work? For example, how does it get access to "Array", "require" or "window" ?

(I don't think "use strict" goes to the length of turning javascript into bracha's newspeak but I may likely have no idea what "strict javascript" actually refer to)

Re:JavaScript Scope Context Coloring by mostlystatic on Sunday April 07, 2013 @08:32AM (#5506979)
You can access global variables as normal, but you can't implicitly declare them by doing `myGlobaVar = 5` - you have to use `window.myGlobalVar`.
Re:JavaScript Scope Context Coloring by necolas on Sunday April 07, 2013 @02:08AM (#5506268)
Ever since watching that Crockford talk, I've wanted to try this out as a Vim plugin.
Re:JavaScript Scope Context Coloring by dag11 on Sunday April 07, 2013 @01:34AM (#5506214)
This is great.

Idea: Implement loose "syntax" highlighting over the scope highlighting by bolding syntax keywords instead of highlighting them. Perhaps also slightly change the brightness of certain syntax keywords.

Re:JavaScript Scope Context Coloring by crazygringo on Sunday April 07, 2013 @12:08PM (#5507613)
Great idea. Bolding language-specific words, and then making strings and comments less bright, would probably achieve 90% of the usefulness of normal syntax highlighting, and combine well with this.
Re:JavaScript Scope Context Coloring by druska on Sunday April 07, 2013 @01:28AM (#5506204)
Now we just need a Sublime Text plugin for this.
Re:JavaScript Scope Context Coloring by LAMike on Sunday April 07, 2013 @02:30AM (#5506309)
Let's make a Kickstarter
Re:JavaScript Scope Context Coloring by VeejayRampay on Sunday April 07, 2013 @10:28PM (#5509688)
That's excellent. A nice variation around this that I've been keen on for a long time and have been wanting to see in modern IDEs is using 3D (or drop shadows) to simulate the nesting of blocks/closures/scopes and give the programmer an instant understanding of the different levels and depths.
Re:JavaScript Scope Context Coloring by Vivtek on Sunday April 07, 2013 @05:39AM (#5506639)
This is probably one of those things that's really effective if you have working color vision, right?
Re:JavaScript Scope Context Coloring by TheFuntastic on Sunday April 07, 2013 @03:57AM (#5506466)
Can anyone point to which particular crockford talk this was inspired by? I've had the idea for scope highlighting bashing around my head for a while now, would love to know more.
Re:JavaScript Scope Context Coloring by jnotarstefano on Sunday April 07, 2013 @04:32AM (#5506524)
It's from "Monads and Gonads", a talk delivered at YUIConf 2012. Here it is: http://www.youtube.com/watch?feature=player_embedded&v=d...
Re:JavaScript Scope Context Coloring by VeejayRampay on Sunday April 07, 2013 @10:26PM (#5509685)
I'm really surprised this talk didn't generate a PC outcry given all the mentions of "huevos", "gonads" and the likes...
Re:JavaScript Scope Context Coloring by davvid on Sunday April 07, 2013 @06:30PM (#5509038)
Re:JavaScript Scope Context Coloring by TheFuntastic on Sunday April 07, 2013 @05:30AM (#5506624)
Many thanks!
Re:JavaScript Scope Context Coloring by mateuszf on Sunday April 07, 2013 @11:43AM (#5507546)
Actually Intellij Idea has the same concept, here it is working in HTML: https://dl.dropbox.com/u/456905/idea.png

I think it would be great if they added it to JS, with their powerful syntax parsing it would be probably trivial to do.

Edit: probably works in their php, django and rails ide-s.

Re:JavaScript Scope Context Coloring by jtreminio on Sunday April 07, 2013 @12:14PM (#5507628)
PhpStorm has this ability - and I've turned it off.

Too much colors for my blood, and it doesn't look good against Solarized.

One thing I really enjoy about this IDE is the indentation level markers - basically lines draw down to show you where the current scope ends (braces, parens).

Re:JavaScript Scope Context Coloring by macca321 on Sunday April 07, 2013 @07:58AM (#5506893)
I forked it with fonts: http://snag.gy/TnNBO.jpg

Maybe not so useful...

Re:JavaScript Scope Context Coloring by arianvanp on Sunday April 07, 2013 @08:09AM (#5506927)
Discussions between developers will be so much more jolly :) "Dude, why isn't my `this` in the comic sans scope referring to the DOM D:"
Re:JavaScript Scope Context Coloring by ebiester on Sunday April 07, 2013 @03:11AM (#5506387)
I think this would make a lot of sense for Lisp or Clojure, at least when starting out.
Re:JavaScript Scope Context Coloring by efnx on Sunday April 07, 2013 @03:02PM (#5508234)
Someone should abstract this out (for an arbitrary number of languages) into a program that would provide annotations for vim or emacs or...
Re:JavaScript Scope Context Coloring by phy6 on Sunday April 07, 2013 @09:26AM (#5507128)
Wow, I'd love to have this in a Java IDE. I often have to deal with reverse engineering amateurish code in many 1000 line classes.
Re:JavaScript Scope Context Coloring by seanp2k2 on Sunday April 07, 2013 @09:21AM (#5507111)
What if it changed based on cursor position?
Re:JavaScript Scope Context Coloring by curiousdannii on Sunday April 07, 2013 @02:36AM (#5506325)
It doesn't seem to handle comments correctly. I need to delete all mine to make it work.
Re:JavaScript Scope Context Coloring by nadinengland on Sunday April 07, 2013 @07:09AM (#5506797)
I noticed that too. It also only highlights variables from other scope once per function which is a tad odd but for experimental you can't complain!