News for hackers. Stuff that matters.
Re:JSBin by phleet on Friday February 01, 2013 @06:04PM (#5154139)
This suffers from one of the same problems as most live editors: try typing `while(true) {}` in the javascript editor - the UI thread will block and freeze up the whole page. Worst of all, you'll lose unsaved work (unless you're persisting to local storage on every character).

This problem is partially solved in the Khan Academy CS editor using a web worker - the code is evaluated in a web worker with most of the side effects stuff mocked out (which is going to be difficult for general javascript) and timed - if it takes more than a couple ms, we kill the execution and give an error. (Try `while (true) {}` in http://www.khanacademy.org/cs/new)

Re:JSBin by remysharp on Saturday February 02, 2013 @03:56AM (#5155568)
It's been mentioned, but the Khan editor gets around the problem because its a close environment - and I can't run the code the user submits in to a worker easily.

The while problem has been raised before, and there is a tiny bit of protection (we parse the code line you're on, and if its a while loop, it's supposed to ignore live execution - though clearly that's not enough). It's true to say I'm still looking for a solution :)

That all said, you dont lose your work if you hit this kind of loop and it hangs the UI. The reason is two fold: 1) jsbin, since it was released in 2008 always saves code to localStorage, but more importantly, 2) it's saving your code to the server AS YOU TYPE - so you hit refresh, and you get you bin back (and the correct URL and saved in your history if you're signed in, etc).

Re:JSBin by daviddoran on Friday February 01, 2013 @09:19PM (#5154842)
Funny enough, I went and put in `while (true) {}` and the right hand side did show an error about it running too long. But I clicked Save and was prompted to create an account (or "...I don't want to be awesome...") and I couldn't click the buttons. I open Activity Monitor and sure enough Chrome's Renderer is pegged at 100%. I killed the process but now whenever I open the /cs/new page (even in incognito amazingly) it pegs at 100%. I also had to kill the script in Firefox but when I refresh the pages it's okay. I guess while(true){} is always nasty.
Re:JSBin by remysharp on Saturday February 02, 2013 @03:48AM (#5155559)
I'll reply about the while stuff separately, but jsbin shouldn't and doesn't prompt anyone to create an account. The only two features you don't have access to is the history, and the /[user]/last shortcut.

Everything else, including saving, is available as a non registered and anonymous user.

Re:JSBin by chadscira on Friday February 01, 2013 @08:11PM (#5154633)
I don't think the webworker solution would work for something like this, anything that needed to use anything outside of the workers context would break. It seems like khan's environment is much more restricted, so they can get away with it.
Re:JSBin by phleet on Friday February 01, 2013 @09:37PM (#5154890)
Yep - totally right. It would involve mocking out the entire browser API in a way that would somehow still follow the same codepaths. That said, it could still catch some things. If the web worker errors out, you just completely ignore the errors and just run it anyway. But if it times out, it's (almost) definitely going to time out in the real page too, unless you're waiting for some specific DOM event or something weird.
Re:JSBin by aroberge on Friday February 01, 2013 @06:50PM (#5154327)
Any detailed explanation available about how this is implemented (other than by having to dig in the code...)?
Re:JSBin by phleet on Friday February 01, 2013 @09:35PM (#5154885)
There's a significant amount of voodoo involved (mostly crazy with() {} statements) in the CS editor that only John Resig fully understands AFAIK, but the rough idea used was to ship the code over to a web worker where all the global APIs it might use were mocked out. This was a relatively short list for KA CS since it's boxed into the processing framework with a few extensions, but would be pretty complicated for full browser environment (probably bordering on impossible). Then we start a timer in the main UI thread, and if the web worker doesn't respond in some amount of time, we kill the web worker and present the error message.
Re:JSBin by Guillaume86 on Friday February 01, 2013 @07:20PM (#5154438)
Didn't looked into it but I guess you just need to pass the code as a string to the WW and then use new Function to generate/run the code inside it.
Re:JSBin by Kerrick on Friday February 01, 2013 @08:33PM (#5154718)
I personally prefer http://JSFiddle.net
Re:JSBin by CoryG89 on Friday February 01, 2013 @09:41PM (#5154904)
I think jsFiddle is great! However, I haven't really tried any of the others. This one looks nice, and just at first glance one thing that I find really interesting is the built in console. I think the devs at jsFiddle should totally implement something like this. Probably the biggest reason I don't use jsFiddle more often is that after I build a demo, occasionally I will need to use the Chrome console to get at and inspect one of my objects or the like, and for whatever reason I can't get at the objects in my fiddle, the console never seems to work right. I will probably give this one a whirl instead the next time I want to use jsFiddle. If everything else is on par with jsFiddle and it has a good console with visibility of all my objects then I'll probably switch to it.

Does anyone know if there is a way to get the Chrome console to work right, ie. have visibility to all the variables, functions, etc that I create in my fiddle?

Re:JSBin by chadscira on Saturday February 02, 2013 @03:34AM (#5155542)
In chrome you can change the context like this: http://img42.com/oNrDj
Re:JSBin by neumann_alfred on Saturday February 02, 2013 @02:38AM (#5155479)
There is also CodePen ( http://codepen.io/ ), and dabblet ( http://dabblet.com/ ) now seems to have (alpha) javascript support, too; the more, the merrier :D
Re:JSBin by fourstar on Friday February 01, 2013 @08:48PM (#5154757)
jsfiddle is SO much better. I respect Remy, but I just like the way jsfiddle is. I tried all of them out and I found that jsfiddle > jsbin > codepen > others. The panels are just more intuitive and it feels less constrained than the others.
Re:JSBin by mxxx on Friday February 01, 2013 @09:17PM (#5154835)
yeah generally i've preferred fiddle, but this is a nice redesign. might give it a whirl the next couple of times i need it, see how it goes.
Re:JSBin by chr1 on Saturday February 02, 2013 @04:50AM (#5155637)
I wonder why? It doesn't update result as you type, doesn't support Less, CofeeScript etc., doesn't have console and until recently it used ancient and broken version of codemirror.
Re:JSBin by dave1010uk on Saturday February 02, 2013 @04:10AM (#5155582)
Also http://jsconsole.com which also lets you connect to remote sessions (eg on a phone).
Re:JSBin by shocks on Saturday February 02, 2013 @06:34AM (#5155785)
Nice for some quick and dirty testing, but if I'm going to spend more than 2m hacking something together I prefer Chrome and gvim. I can't work without the Chrome Dev Tools or vim, and jsbin just doesn't work well enough with these for my purposes.

It's good for sharing code and helping people though. :)

Re:JSBin by binarydreams on Friday February 01, 2013 @10:56PM (#5155093)
Re:JSBin by asimjalis on Sunday February 03, 2013 @03:02PM (#5160906)
Very nice. I particularly like being able to spin off the final page on a separate URL. Great for demoing HTML5/CSS3 features. I am teaching a class on HTML5 tomorrow and will definitely mention this.
Re:JSBin by dmschulman on Friday February 01, 2013 @06:17PM (#5154196)
There are some bugs, but i like the layout, workspace customization, and UX.
Re:JSBin by godfrzero on Saturday February 02, 2013 @01:45AM (#5155408)
Why did no one notice that Dave runs away if you get it too dizzy?
Re:JSBin by javajosh on Friday February 01, 2013 @08:51PM (#5154763)
No tab completion for tags. Bleh.
Re:JSBin by camus on Saturday February 02, 2013 @09:45AM (#5156065)
great , i use http://plnkr.co/ too which allows to create one's own files.