News for hackers. Stuff that matters.

Ask HN: JavaScript dev environment ?

I finally decided to dive deeper in JavaScript.

Move away from simple JS and Firebug debugging. To large and more complex software for the front-end and explore the new opportunities in the back-end (Node.js and such)

What I need is not just an editor (vim will do) but rather a full environement where I can edit, run, test and debug JavaScript.

All recommendations are welcome.

( 36 comments | 49 points | on HN )
Re:Ask HN: JavaScript dev environment ? by igrekel on Saturday July 03, 2010 @02:19PM (#1484182)
I was actually looking into that over the last few days and haven't found anything satisfying yet.

I have tried Aptana, WebStorm (from Jet brains), textmate, bbedit, jseclipse, visual studio, vim. But still haven"t found what I am hoping to find.

I find the eclipse based solutions (Aptana and jseclipse) are too slow for my taste and while they do provide things like completion, it is fairly limited to the obvious things. Aptana probably does what you are looking for, it has a debugger that integrate with your browser.

I tought webstorm seemed better but it is also a bit slow and brings a bit too much with it. Give it a try it may be what you are looking it also has debugger integration.

I couldn't find any special editing facilities other than text highlighting and indentation in bbedit and eventually gave up. TextMate does it ok but since I am not that familiar with javascript and the libraries I am using, I was hoping for something that would let me edit and introspect things at the same time. its really comparable to what you could achieve with vim or emacs.

Re:Ask HN: JavaScript dev environment ? by DTrejo on Saturday July 03, 2010 @06:29PM (#1484626)
I've really enjoyed using Textmate with various JS bundles like Javascript Tools (comes with jslint, js beautify, and some snippets).

Regarding a "more full development environment," my good friend said the following to me:

IDEs can be nice, as they help you handle complicated code. On the other hand, they don't prevent you from writing complicated code in the first place.

Re:Ask HN: JavaScript dev environment ? by igrekel on Monday July 05, 2010 @03:37PM (#1488915)
I was more looking for a more complete IDE because I am not very familiar with javascript and JQuery and hope it would make looking up available functions easier.
Re:Ask HN: JavaScript dev environment ? by daleharvey on Saturday July 03, 2010 @12:53PM (#1484021)
I use emacs with jslint + flymake, js2 mode + espresso, it isnt perfect yet but its getting pretty close.
Re:Ask HN: JavaScript dev environment ? by phuff on Saturday July 03, 2010 @02:20PM (#1484184)
You can also use something like my js-comint mode (see http://js-comint-el.sourceforge.net/) to run code that isn't dom-ish in a js repl like spidermonkey or rhino from emacs. It's pretty sweet to be able to run an expression with C-x C-e and see how it works.
Re:Ask HN: JavaScript dev environment ? by mahmud on Saturday July 03, 2010 @04:32PM (#1484388)
Thanks, I was looking for that.

What are people's opinions of ES4? I am using it to learn the good parts of Javascript. Is it recommended?

Re:Ask HN: JavaScript dev environment ? by koenbok on Saturday July 03, 2010 @12:42PM (#1484002)
I use a combination of TextMate, d8 (v8 shell) and Sprockets (http://getsprockets.org). For debugging mostly Webkit's debugger.
Re:Ask HN: JavaScript dev environment ? by gmurphy on Saturday July 03, 2010 @02:06PM (#1484156)
You didn't specify the platform, but Visual Studio with Visual Assist X surprisingly makes for a really good JS editor. I've found it a lot faster and easier on my system than the larger Java-based JS editors (JSEclipse, Komodo etc).

It doesn't have integrated debugging, it costs a lot, and people won't believe you when you tell them about it, however.

Re:Ask HN: JavaScript dev environment ? by evo_9 on Saturday July 03, 2010 @03:28PM (#1484298)
Yeah, I like VisualStudio 2010 also, I know it's not a popular choice amongst HN'ers, but MS started as a Tools company and out of everything they make, I think their dev tools are actual quite good. I do a lot of JS/jQuery coding and it works reasonably well.

I'm curious about Visual Assist X - does it add more/better support for Javascript and/or jQuery?

I also use Aptana Studio on OSX when I do pure UI coding. It's not bad for pure JS/jQuery but their isn't much autocomplete support.

Edit: Side note on the cost of VisualStudio 2010 - I signed up for MS's BizSpark program and was given a free MSDN license including full copies of VisualStudio 2010, SQL 2008, etc.

Re:Ask HN: JavaScript dev environment ? by Encosia on Sunday July 04, 2010 @02:41AM (#1485269)
For those purposes, Visual Studio is free: http://www.microsoft.com/express/Web/
Re:Ask HN: JavaScript dev environment ? by olegp on Saturday July 03, 2010 @03:48PM (#1484317)
IntelliJ IDEA (http://www.jetbrains.com/idea/) has good JavaScript support, including refactoring. I also quite like Komodo Edit (http://www.activestate.com/komodo-edit), since it's more lightweight but has JavaScript code completion & is easily extensible.

While you're looking at Node, I also suggest you take a look at RingoJS (http://ringojs.org/). It should be easier to get started with & has debugging support.

Re:Ask HN: JavaScript dev environment ? by kodisha on Saturday July 03, 2010 @05:41PM (#1484538)
+1 for IntelliJ IDEA, js support is really superb.
Re:Ask HN: JavaScript dev environment ? by maushu on Saturday July 03, 2010 @04:34PM (#1484391)
This rather related to my startup in development. I hope to release this service soon.

Anyways, I use a decent editor (Notepad++ is a good one) for most code that doesn't need debugging (besides the good old trace statements) and for debugging I use eclipse.

In the latest version of Node.js (0.1.100) a console.log() was added.

Re:Ask HN: JavaScript dev environment ? by antichaos on Saturday July 03, 2010 @01:46PM (#1484117)
What's wrong with Firebug? I fail to find a better alternative for JS debugging.
Re:Ask HN: JavaScript dev environment ? by hundredwatt on Saturday July 03, 2010 @02:13PM (#1484170)
I have run into problems in the past caused by forgetting to remove console.log() lines from my scripts. If the console wasn't open, then the scripts didn't work.

This isn't a huge problem or reason not to use Firebug (which I would be totally lost without), just something to be wary of.

Re:Ask HN: JavaScript dev environment ? by geocar on Saturday July 03, 2010 @02:30PM (#1484198)

    if(!console)console={log:function(){}};
You're welcome.
Re:Ask HN: JavaScript dev environment ? by marcuswestin on Saturday July 03, 2010 @02:39PM (#1484219)
This will throw if console is not defined. Try

   if (!window.console)
Or

   if (typeof console == 'undefined')
Or

   if !('console' in window))

 N
Re:Ask HN: JavaScript dev environment ? by geocar on Saturday July 03, 2010 @02:43PM (#1484230)
Doesn't here. What are you using?
Re:Ask HN: JavaScript dev environment ? by toni on Saturday July 03, 2010 @02:32PM (#1484203)
My solution to this issue was to write a console2.log helper function and call that instead of the original console.log:

  var console2 = {
   log: function(msg){
    if(typeof console != 'undefined'){
     console.log(msg);
    }
   }
  }
Re:Ask HN: JavaScript dev environment ? by notauser on Saturday July 03, 2010 @02:23PM (#1484188)
You can solve(?) this by creating a dummy console.log object when one isn't already present, then throwing away all of the output.
Re:Ask HN: JavaScript dev environment ? by devpopol on Saturday July 03, 2010 @03:31PM (#1484303)
if(!window.console){window.console = {};} if(!(toString(window.console.log) === '[object Function]')) {window.console.log = function(){};}

there, fixed..

Re:Ask HN: JavaScript dev environment ? by jmtulloss on Sunday July 04, 2010 @12:01AM (#1485095)
This won't work in node. That's not a huge deal, but it's pretty simple to come up with a cleaner solution that works in all environments.
Re:Ask HN: JavaScript dev environment ? by maxanger on Saturday July 03, 2010 @02:27PM (#1484193)
if (window.console) console.log(...);
Re:Ask HN: JavaScript dev environment ? by jackowayed on Saturday July 03, 2010 @02:40PM (#1484222)
That really should be built in to console.log.
Re:Ask HN: JavaScript dev environment ? by mitjak on Saturday July 03, 2010 @03:19PM (#1484285)
I may not be entirely sober yet but I believe the problem at hand is what happens when window.console isn't defined at all.
Re:Ask HN: JavaScript dev environment ? by ydant on Saturday July 03, 2010 @03:43PM (#1484313)
It can be, but only if console.log is defined in your source code. It isn't when you use Firebug, so it won't be when you're not using Firebug.
Re:Ask HN: JavaScript dev environment ? by convel on Saturday July 03, 2010 @02:06PM (#1484153)
Chrome Dev Tools.
Re:Ask HN: JavaScript dev environment ? by Detrus on Saturday July 03, 2010 @02:11PM (#1484167)
Yea those have some fancy live JS editing capability, where you can edit the JS, it runs the code with the changes but without restarting the whole program.

http://www.youtube.com/watch?v=TH7sJbyXHuk

Re:Ask HN: JavaScript dev environment ? by igrekel on Saturday July 03, 2010 @02:08PM (#1484161)
Last time I used firebugs you couldn't really edit files in it, it was also missing many goodies for easily browsing code or code completion.
Re:Ask HN: JavaScript dev environment ? by augustl on Saturday July 03, 2010 @02:31PM (#1484202)
Use JsTestDriver to write and run your tests.

One of my pet projects is open source and tested with JsTestDriver [1], that should be a good starting point for learning more about how to test JavaScript in webapps.

I also like to use Sinon [2] for stubbing and mocking. The author of Sinon is also putting the finishing touches on a book about TDD-ing JavaScript.

EDIT: calendar-logic.js [4] an example of how you can extract and test logic in separate libraries. It's being used on figureoutwhen.com.

[1] http://github.com/augustl/figureoutwhen.com [2] http://cjohansen.no/sinon/ [3] http://www.amazon.com/Test-Driven-JavaScript-Development-Dev... [4] http://ditrw.com/calendar-logic-dot-js/

Re:Ask HN: JavaScript dev environment ? by shawndumas on Saturday July 03, 2010 @07:27PM (#1484743)
I have been enjoying WebStorm. BTW: it'll do Zen Coding[1]. That's a plus!

.

[1]: http://code.google.com/p/zen-coding/

Re:Ask HN: JavaScript dev environment ? by CyberFonic on Tuesday July 06, 2010 @04:52AM (#1490414)
This is what works for me:

3 screens: 1 with two windows for editing code, 1 to run Chrome and 1 for Chrome Dev Tools. Overkill? Nope, good to see it all in context.

I modularize code (bottom up dev style) and test each class / function before integrating with code body. Chrome Dev Tools is fantastic for tracking down CSS cascade probs, etc.

Other tools: Vim, Rhino book and www.w3schools.com for references. I develop only for Chrome / Safari (some FireFox) so can't suggest as for IE, Opera, etc.

Re:Ask HN: JavaScript dev environment ? by gmosx on Sunday July 04, 2010 @05:57AM (#1485455)
I use the Google chrome developer tools. Highly recommended!
Re:Ask HN: JavaScript dev environment ? by nostrademons on Saturday July 03, 2010 @05:19PM (#1484490)
Most of the JS pros I know just use vim/emacs + FireBug.
Re:Ask HN: JavaScript dev environment ? by arc_of_descent on Saturday July 03, 2010 @06:25PM (#1484619)
What has complex got to do with the editor? Maybe it would help a bit. But if you design the codebase to be modular, you have only a little part of the code to worry about at a time, so you can use your current editor setup. :)
Re:Ask HN: JavaScript dev environment ? by warfangle on Saturday July 03, 2010 @03:16PM (#1484283)
emacs with espresso mode; rhinounit.