views:

144

answers:

7

Is debugging JavaScript as easy as debugging a C++/C#/Java application (given the best IDE available), or are the current tools much more limited and less user friendly, making debugging a headache?

+3  A: 

With Addons in FireFox (FireBug, GreaseMonkey to name a few) along with support from IDEs like Visual Studio, it makes it pretty easy to debug javascript. Is it as "easy" as Java, C#, etc. I think that is really depends from programmer to programmer. I know a lot of programmers who think programming and debugging JavaScript is the most terrible thing in the world, eventhough they have all the tools available to them. To me, it doesn't seem so difficult, but I started programming JavaScript when there were no tools to help debug it. Like many things it's all a matter of perspective.

Kevin
Firebug is an AMAZING add-on for Firefox for web/javascript development. No installation is complete without it, IMHO.
Chris Kaminski
even though 'sufficient' javascript dev tools exist, everybody admits that they are not the same caliber as native PC development tools.
Dustin Getz
+1  A: 

In Visual Studio 2008, there's pretty good support for debugging JavaScript... breakpoints work, and you can hover over variables to see their values, etc. It's the best way to debug JS that I'm aware of.

Andy
For IE only.. .
Arnis L.
+1  A: 

I find it to be rather painless with Firebug. It comes with a full blown debugger. However, I find dynamic languages to be more difficult to debug if they make heavy use of closures and functional abstractions.

Matthias
+3  A: 

The Firebug plugin makes debugging JavaScript fairly easy- I'd say at least on par with debugging a C# application.

apocalypse9
A: 

No, JavaScript is horribly sloppy language. You have to use a tool such as Firebug or JSLint to help you debug or you may never find your problem in a large application.

Here is some of why JavaScript is so problem prone:

  • Undeclared variables inside a function are global scoped by default.
  • JavaScript allows sloppy line breaks and attempts to insert semicolons where it thinks they are missing at compile time. This can wreck your code.
  • JavaScript has problems with type comparison when using equality comparison "==". You have to use "===" type of equality comparison or "!==" type of inequality comparison to get around those problems.
  • JavaScript has many more problems that any well written language would not have. I recommend reading the book The Good Parts to avoid many traps and write programs that beautiful, efficient, and maintainable.

http://jslint.com/

+1. A good list of compile time issues. -1 "horribly sloppy", an opinion not shared by all and not relevant., IMO C++ is also "horribly sloppy". Personally I think Javascript is an excellent language as long as you place it in the perspective that it is a "script" language. I wouldn't want to write an entire LOB app in it.
AnthonyWJones
+1  A: 

A key point that the answers so far have missed is that unlike C++/C#/Java you get far less help at "Compile" time.

Hence a Javascript debugging session will often involve a considerable amount of time discovering a set of bugs that would be picked up very quickly and easily by the others before anything has run at all.

So the answer is a clear no, its harder to debug javascript than the other languages listed.

AnthonyWJones
+1  A: 

Firebug brings JS out of the stone age but isn't as elegant as debugging .NET. PC development tools leverage maybe 10 years extra evolution...

Dustin Getz