0

When using Javascript, how can one develop and test speedly yet accurately (and focus on the algorithms rather than the mechanics)? Are there helpful tools that can be used in a batch or command line mode (i.e. outside of an IDE)?

I find when developing in Javascript I spend a tremendous amount of time locating the sorts of problems caused by careless typing or brain farts: misspelled variable names, misspelled property names, missing functions, wrong number of arguments to a function, and so forth.

A tool needs to understand the "semantics" of the language to find errors like this (what's a variable name, what's a function name, and so forth). In my experience, tools like JSLint/JSHint that look only at the "syntax" aren't very helpful. They emit a huge flood of stylistic warnings that are largely irrelevant, yet still don't identify the errors that really matter.

Without a "coverage" tool and many weeks of testing, errors in the uncommon paths often sneak through. It's not unusual to have a corpus of Javascript in production for months, and only then find some obscure crash error.

In Perl I can just "use strict" and my program won't even run until I fix these, and Perl's "warnings" quickly identifies most of the rest. How can Javascript development do something similar?

bmargulies
  • 97,814
  • 39
  • 186
  • 310
Chuck Kollars
  • 2,135
  • 20
  • 18
  • 'use strict' in js... might help a little http://stackoverflow.com/questions/1335851/what-does-use-strict-do-in-javascript-and-what-is-the-reasoning-behind-it – tjb1982 Aug 17 '13 at 01:09
  • @tjb1982 - Well I've already got "use strict" in all my Javascript. My experience is it helps only a little bit. It makes some error messages slightly more informative, but finding misspelled variable names one at a time -and only in exercised paths- is still far too painful. Why can't a tool tell me _all_ the misspelled variable names (including those in uncommon paths) with just one pass? (Is there some "trick" to making good use of "use strict", or is the same old method of examining the console error messages all that's needed?) – Chuck Kollars Aug 18 '13 at 23:55
  • I don't think there's really a trick to it; it's just not that helpful. – tjb1982 Aug 19 '13 at 12:36
  • Get a good IDE (anything from Jet Brains) – Sunil D. Mar 18 '14 at 15:47

1 Answers1

0

Sounds like you're looking for grunt.js

And for usability you should look up phantom.js

FredTheWebGuy
  • 2,546
  • 3
  • 27
  • 34
  • Thank you for pointing me toward node.js/grunt.js, a whole world I was unaware of. Follow-on question though: While the framework (and its installation) is undeniably clever and convenient, my impression is just a couple plugins (UglifyJS and jsvalidate) do all the work that matters, and everything else is just frosting on the cake - so: what am I missing? – Chuck Kollars Aug 18 '13 at 23:49