Skip to content

Comment on Zed Shaw: Tir Web Framework Officially Up

Comments

I love the natural style of page conversation on the example page. As a Java developer, I wish that this style were possible on the servlet platform:

  local login_page = Tir.view("login.html")
  local login_form = Tir.form { 'login_name', 'password'}

  local function login(web, req)
    local params = login_form:parse(req)

    repeat
        params = web:prompt(login_page {form=params, logged_in=false})
    until login_form:valid(params)
    
    return web:redirect('/')
  end

  Tir.start {route='/Login', main=login}
Also, +1 to this: "the framework creator shouldn't be shoving stateful/stateless dogma in your face".

The natural style is sweet for things like that. I did the Hype.la signup process with natural style and it meant I didn't have to touch the database the whole time. If they quit half-way through then no DB junk left over.

Where this kind of coroutine stuff sucks though is in anything that's "RESTy". In other parts of Hype.la I had simple Xhr callbacks that just grabbed lists of data, so the coroutines were just annoyingly in the way and half the time they were just a big loop with an if-statement for the URLs.

That's where the evented came in. In that way I just map actions to callbacks and done.

Then I ran into a few simple things that didn't work in evented and were still stateless, like the search interface, and so I use the stateless handler for that. Nice and snappy with no extra junk.

Another advantage of all this is that, if you have a part of your app that needs to be resistant to restarts, then you can craft it evented or stateless. In other parts, restarts aren't a big deal so you can do natural. And since everything is just a bunch of little processes, it scales out nice and doesn't have as much of the "gotta-copy-the-world-for-users" that Seaside upgrades do.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.