views:

391

answers:

3

Over a year ago, I remember watching one of DevExpress evangelists previewing or at least promoting rich Javascript refactoring (beyond just limited intellisense) within the Visual Studio shell, I recall part of CodeRush/DevExpress product line. I was excited.

On checking today (lmgtfy) I can find only very very limited reference to it, just one small italtic line about beta in product description, no videos, no blog posts, no community buzz. Was it dropped? Vapourware? Poor implementation that they dont even promote it?

With Javascript arguably the most popular programming language ever and with a VM for it on practically every machine in last 10 years, why is editor support so poor? (Compared with those for Java and C#)? You see the likes of ScottGu bragging we now have jQuery intellisense but compare this to richness of C# support in the IDE it is a joke.

Someone once said since there are many style of writing Javascript a rich IDE (beyond intellisense) with refactoring support is difficult, but if several engines can interpret/compile JS with same result surely it should be hard to analysis it to support stuff like rename variable, extract method, move to another namespace (or JS minic of it), etc.. Am I wrong?

+1  A: 

The problem with something like Javascript Intellisense is that it really needs to have supernatural powers in order to have any clue about what a piece of code means. Like here, in this function fragment:

return function(a) {
  var x = a.

Now I've just typed that "." after "a", and I hit "tab" for auto-complete. What is an IDE to do?

In some limited cases, you can make some OK guesses; like, the editor can make some assumptions if you've told it you're using jQuery for example, and it sees

$('something').

well it's a decent guess that completing with jQuery APIs is the right thing to do. That's never going to be much better than a guess, however. Even with that jQuery example, the editor is still going to be stuck with some hard problems:

$('something').each(function(_, element) {
  if (element.

After that ".", what should auto-complete show me? Well, a super-smarty editor might be willing to go out on a limb and assume that the "element" is a DOM node, but it'd have to be paranormal to know what kind of DOM node.

Now, another thing one could do would be to enable some sort of comprehensive hinting system, such that the programmer could explicitly tell the editor what's what. That'd take a little bit of the soul out of Javascript for me, but I guess some people might find it useful.

Pointy
FlexBuilder has pretty decent AS3 support, though still not quite on the same level as Java support. AS3 and JS are both ECMA script of different versions so it should be possible, but comparing with Python/Ruby might be more enlightening.
John
I'm sure that people have done some good work; the Microsoft stuff seems pretty impressive. The original question, however, acknowledges those efforts but dismisses them as inadequate.
Pointy
Oh and yes, comparisons to Ruby are pretty apt, because it's got the same problems.
Pointy
its more visual studio has terrible support for dynamic languages then dynamic languages are impossible to support. check out the jetbrains IDE, they do javascript, ruby, and python just fine. Even eclipse does a pretty good job with aptana.
Matt Briggs
A: 

JS has only recently become a serious heavy-weight development language for applications. Java by contrast has been used by big rich corporations many years, giving companies and open-source projects alike much longer to invest money/timey in building tools.

Building decent software takes a long time.

John
Well also with Java you've got the advantage that the very nature of the language is such that if you can't tell exactly what the type of a variable is, it won't compile anyway. The language forces everything to be explicitly declared, so the IDE has a huge amount of guesswork taken care of.
Pointy
Hmmm... I'd disagree from what I see Javascript been a serious contender for at least 4+ years. By serious contender I mean when big corps, up-starts and 1 man joe bloggs were written enough client side stuff to benefit/require the tools to refactor/tidy.
MattX
Like I said, not long. How long have people been writing Java/C++ tools for? In comparison 4 years is not a long time, there are few pieces of software I can think of that are this young and considered great.
John
+9  A: 

CodeRush supports fifty-two JavaScript refactorings:

  • Add Block Delimiters
  • Add Parameter
  • Break Apart Arguments
  • Break Apart Parameters
  • Case to Conditional
  • Combine Conditionals (nested)
  • Combine Conditionals (parallel)
  • Compress Assignment
  • Compress to Ternary Expression
  • Concatenate Strings
  • Conditional to Case
  • Create Multi-variable Declaration
  • Create Overload
  • Create Setter Method
  • Create With Statement
  • Expand Assignment
  • Expand Ternary Expression
  • Extract Method
  • Flatten Conditional
  • For to ForEach
  • ForEach to For
  • Initialize Conditionally
  • Inline Recent Assignment
  • Inline Result
  • Inline Temp
  • Inline With Statement
  • Introduce Local
  • Introduce Local (replace all)
  • Introduce Result Variable
  • Line-up Arguments
  • Line-up Parameters
  • Move Declaration Near Reference
  • Move Initialization to Declaration
  • Promote to Parameter
  • Remove Block Delimiters
  • Remove Parameter
  • Remove Redundant Conditional
  • Rename Local
  • Reorder Parameters
  • Replace Temp with Query
  • Replace with Local
  • Reverse Conditional
  • Simplify Expression
  • Split Conditional
  • Split Conditional (and duplicate else block)
  • Split Initialization from Declaration
  • Split Multi-variable Declaration
  • Split String
  • Split Temporary Variable
  • Split With Statement
  • Widen Scope
  • Widen Scope (promote to field)

And eight consume-first declaration and quick fix features:

  • Add Contract
  • Add Else Statement
  • Declare Field
  • Declare Local
  • Mirror Code
  • Reverse For Loop
  • Rotate 90 Degrees
  • Spell Checker

Also, we're working to improve our refactoring support for the 10.2 release. We've also recently improved Quick Nav to make navigating to JavaScript functions as easy as navigation in C# or VB. This improvement will ship in 10.2 but is available now for CodeRush customers in a daily build.

Full Disclosure -- I lead the CodeRush team at DevExpress.

Mark Miller
+1 for leading the team responsible for the software in question :)
Cam