News for hackers. Stuff that matters.
Re:Finally... Goto in Javascript by edw519 on Monday July 06, 2009 @02:19PM (#690145)

  Goto floor(10);
  Open window;
  Jump();
Re:Finally... Goto in Javascript by tc on Monday July 06, 2009 @02:43PM (#690198)
I like the joke, but I consider the reflexive anti-goto attitude harmful. Javascript would be a better language with a native goto statement. I think people forget the context of Dijkstra's paper. Scope-local gotos are qualitatively different than type of function-less code that Dijkstra was referring to at the time. The clearest way to express certain algorithms really does involve a (local) goto. And goto makes it much easier to implement higher-level language constructs in Javascript through preprocessing.

Without goto and TCO (goto by another name), you're left to transform your code to be run under a trampoline, which really makes the resulting JS unreadable.

Re:Finally... Goto in Javascript by crux_ on Monday July 06, 2009 @05:09PM (#690463)
What JS really, really, really, really needs isn't TCO (well that too), but rather call/cc.

Looking over a fairly large project here, a majority of the code is written in CPS because of callbacks to the server or delays for user interaction.

(So far, I've avoided the need to trampoline, since my call stack isn't getting too deep yet before it unwinds on it its own. But, then again, I haven't done any cross-browser testing at all yet.)

Re:Finally... Goto in Javascript by frodwith on Monday July 06, 2009 @05:20PM (#690478)
First class continuations in Javascript would be a godsend.
Re:Finally... Goto in Javascript by eru on Tuesday July 07, 2009 @10:40AM (#691532)
You can get them with the Continuation Monad. (But of course that needs TOC to work well.)
Re:Finally... Goto in Javascript by Bjoern on Monday July 06, 2009 @03:10PM (#690251)
Actually I can only second that. Goto's are useful. For instance in the Linux Kernel it is used instead of exceptions in the function scope.

Unfortunately great power (goto) comes with great responsibility (don't produce spagetti). Most $programmers don't get that right.

Re:Finally... Goto in Javascript by gruseom on Monday July 06, 2009 @03:42PM (#690309)
Sure, but then we're down to arguing whether a language should be designed to constrain bad programmers or empower good ones. And quite apart from the general arguments one can make (for example, that bad programmers will make a mess no matter what), it's clear that Javascript has become a major platform for modern applications. To constrain the growth of the entire class of web apps in order to allegedly limit the spaghetti produced by $programmer is a poor tradeoff, I'd say.
Re:Finally... Goto in Javascript by eru on Tuesday July 07, 2009 @10:41AM (#691534)
Interesting jargon. Is a $programmer a PHP (etc) programmer?
Re:Finally... Goto in Javascript by 10ren on Monday July 06, 2009 @07:49PM (#690669)
> The clearest way to express certain algorithms really does involve a (local) goto.

Java doesn't have goto, but it has labeled break and continue statements. Great for exiting nested loops. Exceptions are another kind of structured goto. Of all the criticisms of Java, I've never heard the lack of goto bemoaned.

One thing I love about the Java designers is their humility: they thought the above was enough to cover all the cases where a goto was really convenient, but still made goto a reserved word. Just in case.

Re:Finally... Goto in Javascript by edw519 on Monday July 06, 2009 @02:45PM (#690204)
!reflexive, I promise you. Based not on Dijkstra's paper, but my own horror stories.
Re:Finally... Goto in Javascript by tc on Monday July 06, 2009 @02:51PM (#690212)
I know, I know; I've read bad code too. But I've also read plenty of bad code in languages that don't have goto. Copy-and-paste coding and reckless abuse of globals are worse and more prevalent than goto abuse in my experience.

Besides, I object to bondage and discipline in a programming language. If people don't have guns, then they'll use....

Re:Finally... Goto in Javascript by benmathes on Monday July 06, 2009 @03:36PM (#690300)
...a baseball bat, which while possible of inflicting terminal injuries isn't quite as good at it, lowering the number of deaths.

The analogy still holds :-)

edit: I mean to say literally that GOTOs certainly are useful, but are far easier to create spaghetti code with than something much safer like functions. It's a cost/benefit analysis.

Re:Finally... Goto in Javascript by eru on Tuesday July 07, 2009 @10:42AM (#691539)
I can code perfectly fine (and mind-blowing) spaghetti code with call/cc, too.
Re:Finally... Goto in Javascript by emontero1 on Monday July 06, 2009 @02:33PM (#690169)
Your response's utter geekiness earned my vote! I couldn't have put it better.

I hope this one is a joke. Isn't goto looked down on because of its role in the Roman Inquisition? Seriously though, the project is just a cool technical hack not meant for public consumption, right? Right?