r/programming • • Mar 11 '13

Programming is terrible—Lessons learned from a life wasted. EMF2012

http://www.youtube.com/watch?v=csyL9EC0S0c
650 Upvotes

368 comments sorted by

View all comments

Show parent comments

1

u/StrmSrfr Mar 11 '13

There's nothing stopping you from creating sessions for users who aren't logged in. Photobucket does it for sure.

2

u/moor-GAYZ Mar 12 '13

There's nothing stopping you from creating sessions for users who aren't logged in. Photobucket does it for sure.

Except for sanity. Are you sure they do it with server-side sessions, and not with cookies, like every other sane site out there?

I mean, all right, different strokes for different folks, but I would never associate a heavy as shit non-reified persistent activation record of a function with each of several buttons on a page that I show to everyone. That's a fun think to do for your pet rat's homepage, it's "elegant" (in a certain totally divorced from reality kind of way), but that's not how you do things with a public forum dedicated to sucking less at programming, as a community. In my humble opinion.

1

u/StrmSrfr Mar 12 '13

All I know for sure regarding photobucket is that if you visit it without a PHPSESSID cookie it seems to give you a fresh one.

I haven't really decided myself if using continuations in a web framework is a good idea or not for scalability reasons.

But doesn't storing the continuation just involve copying a portion of the stack? And since there's probably not a lot of state that needs to be saved, and a lot of things will be allocated on the heap anyway, they could use very little memory indeed.

1

u/moor-GAYZ Mar 12 '13

I haven't really decided myself if using continuations in a web framework is a good idea or not for scalability reasons.

It's not like "it can never be done responsibly ever!", it's more like PG did not do it in anything resembling responsible manner. He was, like, oh, I can do a cute thing, I can write handlers for my buttons inline, and transparently store them as callbacks in a hash table and it will just work, and in a distinctly lispy way.

He stores more than one of them per page, as you can see in my screenshot, that's bad.

He stores them in an un-reified fashion, instead of considering what information he wants to store for a session and storing it explicitly in some serialized form, efficiently and fully aware of how much of it he stores, he relies on the underlying language machinery to implicitly keep track of the stuff, of the activation record of a handler and everything it might reference. So he doesn't know how much of it he actually stores per callback, how much of his memory is used by this stuff, and when there's too much of it everything slows to a crawl, that's bad. You want to compartmentalize and separate stuff like that from your actual application (isn't it ironic, considering the post that started this thread).

And that's not "little" memory at all, I would guess, given the general-purpose nature of the mechanism, that's bad, too.

He can't say, oh, sessions take too much space, how about I plug a second server with a shitton of memory and memcached and nothing else storing them, that's bad.

He probably could but doesn't say, well, let's associate one session with each logged-in user and try our best not to expire them, expiring anonymous sessions etc first. Instead he constantly creates these closures for everyone, then garbage collector deletes them at random apparently, so if you open some HN post, wait a couple of minutes, and try to comment, or take too long writing a comment, you're in for a surprise.

All in all it's one hell of a dangerous idea, which is implemented in the most reckless way possible.

→ More replies (0)