News for hackers. Stuff that matters.
Re:Why HN was slow and how Rtm fixed it by pg on Wednesday January 19, 2011 @06:46PM (#2121816)
Instead everyone in the Lisp community (pg included) is still enamored with using continuations to produce ugly URLs and unmaintainable web applications.

If you read the source of HN, you'll see that it doesn't actually use continuations.

I find the source of HN very clear. Have you read it? Is there a specific part you found so complicated as to be unmaintainable?

Re:Why HN was slow and how Rtm fixed it by sedachv on Wednesday January 19, 2011 @07:37PM (#2121983)
Pagination/"More" uses fnids; looking at the source it's a callback, but from an HTTP client perspective it might as well be a continuation.

How do you test and debug things like that that have random URIs and function names and get GCed on a regular basis? That's what I mean when I say continuations lead to unmaintainable web apps.

Re:Why HN was slow and how Rtm fixed it by pg on Thursday January 20, 2011 @02:02AM (#2122943)
I've been using this technique since 1995 and it has never once been a problem. It's an instance of programming with closures, which has been common in the Lisp world for even longer. One doesn't need to examine something represented as a closure any more than one needs to examine a particular invocation of a recursive function.

Perhaps the reason I've never had a problem is that I've been careful to use this technique in fairly restricted ways. Lisp macros are the same sort of thing. They could yield unreadable code if abused. But good programmers use them in principled ways, and when used with restraint they are clearly a net win.

Re:Why HN was slow and how Rtm fixed it by blasdel on Thursday January 20, 2011 @05:24AM (#2123220)
It's a problem for me when the fnids in every reply <form> cause them to expire several times a day when the server crashes.

Edit: also when the server redirects me back to the wrong origin, I was sent to http://news.ycombinator.com/threads?id=pg instead of http://news.ycombinator.com/item?id=2120756 after posting this reply initially.

Re:Why HN was slow and how Rtm fixed it by pg on Thursday January 20, 2011 @02:05PM (#2124843)
also when the server redirects me back to the wrong origin

Sounds like that could be a bug. Was http://news.ycombinator.com/item?id=2120756 the page you were on when you replied?

Re:Why HN was slow and how Rtm fixed it by blasdel on Thursday January 20, 2011 @02:23PM (#2124899)
Yes, I clicked the reply link on your comment from there.

I figured you had to know about this bug, since it happens to me regularly (maybe 10% of eligible comments) when I comment in active threads during standard procrastination hours. The misdirect is usually to the threads page of a user further up the comment tree, though sometimes it's to the permalink of a grandparent comment.

Seems like you're mixing up the redirects of concurrent users but never across comment hierarchies so it's not omnipresent.

Re:Why HN was slow and how Rtm fixed it by jules on Thursday January 20, 2011 @08:57AM (#2123604)
> I've been using this technique since 1995 and it has never once been a problem.

Thousands of HN users experience the problems every day: link expired.

Re:Why HN was slow and how Rtm fixed it by pg on Thursday January 20, 2011 @01:49PM (#2124763)
The issue we were talking about was maintainability.

Giving links longer expirations is trivially easy, and I already do it in cases where it matters, like submit buttons on big forms.

Re:Why HN was slow and how Rtm fixed it by jules on Thursday January 20, 2011 @02:14PM (#2124874)
The problem is that links expire at all. There are two products: HN with "link expired" and HN without "link expired". You can write the former in a highly maintainable way.

Also, even if you accept that links expire, it's not trivial to make the links not expire for a long time. You can add a lot of RAM to a single machine, but only up to a point. Supporting multiple machines is very hard, although it can be done (distributed object system). RAM is not the only problem however. The server is inevitably going to restart once in a while. Perhaps not in the literal sense of killing and restarting the mzscheme process if you're very careful, but still in the practical sense. The data structures for storing content change as you develop a web app/site, thereby invalidating old closures hanging around.

Re:Why HN was slow and how Rtm fixed it by Flow on Thursday January 20, 2011 @09:44AM (#2123749)
I get the same problem on Reddit, except they call it "there does not seem to be anything here".
Re:Why HN was slow and how Rtm fixed it by axod on Wednesday January 19, 2011 @06:56PM (#2121859)
> If you read the source of HN, you'll see that it doesn't actually use continuations.

> It had to be some dialect of Lisp with continuations, which meant Scheme, and MzScheme seemed the best.

(From further down the page).

I'm confused. What needs continuations?

Re:Why HN was slow and how Rtm fixed it by pg on Wednesday January 19, 2011 @07:00PM (#2121867)
I just wanted to have them in the language. The fact that I don't currently use them in HN doesn't mean they're useless.
Re:Why HN was slow and how Rtm fixed it by axod on Wednesday January 19, 2011 @07:06PM (#2121885)
ah ok thanks for clarifying.
Re:Why HN was slow and how Rtm fixed it by ezalor on Wednesday January 19, 2011 @07:49PM (#2122026)
I always thought the purpose of Arc was to be cruft-free, "don't include it unless it is actually needed".
Re:Why HN was slow and how Rtm fixed it by dauphin on Wednesday January 19, 2011 @06:58PM (#2121863)
Errors/exceptions, for one, are implemented using continuations.
Re:Why HN was slow and how Rtm fixed it by axod on Wednesday January 19, 2011 @07:02PM (#2121874)
Sounds terribly inefficient to me, but what do I know -shrug-
Re:Why HN was slow and how Rtm fixed it by jrockway on Wednesday January 19, 2011 @07:34PM (#2121970)
All control flow is a subset of continuations. The stack is a continuation (calling a function is call-with-current-continuation, return is just calling the "current continuation"), loops are continuations (with the non-local control flow, like break/last/redo/etc.), exceptions are continuations (like functions, but returning to the frame with the error handler), etc. Continuations are the general solution to things that are normally treated as different. So continuations are just as efficient (or inefficient) as calling functions or throwing exceptions.

In a web app context, though, it's kind of silly to keep a stack around to handler something like clicking a link that returns the contents of database row foo. People do this, call it continuations, and then run into problems. The problem is not continuations, the problem is that you are treating HTTP as a session, not as a series of request/responses. (The opposite of this style is REST.)

Re:Why HN was slow and how Rtm fixed it by sedachv on Wednesday January 19, 2011 @09:48PM (#2122390)
In theory yes, in practice you need to reify the stack (even for one-shot continuations). Clinger, Hartheimer and Ost have a really good survey paper of the different ways to do that:

http://www.scribd.com/doc/47221367/Clinger-Implementation-St...