
Zed Shaw: Tir Web Framework Officially Up - ctkrohn
http://sheddingbikes.com/posts/1291412302.html
======
mikeryan
So in 2010 Zed has written his own web server which runs his new framework he
wrote for the new webapp he wrote.

What did you do this year?

~~~
angelbob
In 2010? I reworked my Comet-based realtime game-in-a-web-server library,
RailsGame.

I fully rewrote, updated and released a webapp called WantMyJob.com.

I wrote a circuit simulator game called Shanna's Pizza to start teaching my
two-year-old the basics of programming. I also started doing Snap Circuits
with her so she'd have a physical basis to understand the circuit simulator
game. Also, had a second kid.

I wrote a Rails 3 tutorial, including an app with logins and nested resources,
called RefactorIt!

I finally put together a real programming portfolio, on the web and everything
(angelbob.com/portfolio).

I read up on Bayesian Statistics and Data Analysis (thanks, O'Reilly!).

I blogged and blogged and blogged.

I reworked, resurrected and took screen shots of a scary amount of my old
work, partly for the portfolio. This sort of blurs with converting my old
Rails stuff to Rails 3, but I did some of both.

I continued to work on my day job, of course. And gave a JRuby presentation
for Engine Yard based on what we do there.

Did you know you get more done if you write it down somewhere (like a blog and
portfolio) and tell people about it? True story.

That's probably part of Zed's trick, too.

~~~
citricsquid
_Did you know you get more done if you write it down somewhere (like a blog
and portfolio) and tell people about it? True story._

Do you find that? I'm the opposite, once I "announce" something all desire and
motivation for completion goes out of the window. For me I _think_ it's about
the appreciation, so when I explain the idea and love it, why complete it.

~~~
zedshaw
It varies for me. Sometimes it's just an idea and I want to share it. Maybe
I'll never do it, maybe I want to get feedback on it. Some pretty cool stuff
came out of just "What-If" like Mongrel2 and Librelist.

Other times I get infected with an idea and have to crank out a prototype to
see if it'd work. When I'm done, I still try to throw it up there and see what
people think. Usually the process of writing about it actually helps me work
out if it's worth it or not as well.

------
mmastrac
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".

~~~
zedshaw
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.

------
viraptor
This one really surprised me: "Finally, there's not much for deployment. I run
my apps in GNU screen and that's about it." Seriously? Is he that lucky,
serves that little traffic, or does he run with redundant power, network,
server and 24/7 monitoring in an inaccessible bunker?

I haven't been able to run even my toy web apps without something like monit -
due to both things under my control and outside of it.

~~~
buro9
On my hobby projects I run stuff in screen, I haven't had a problem and my
server uptime is currently above 200 days. Is it being used? Something like
1,000 concurrent users for most of the day, so yes.

I regarded this as cowboy, but as it worked for me I haven't needed to re-
visit it.

~~~
aaronblohowiak
It is cowboy, but there is a time and place for that. If you did this in a
large organization, you'd be putting the team at risk. Since it is just you,
well, do what you find prudent.

------
meric
Last time this was posted I was really interested in it. So interested in
fact, I built a django-style template library to go with it because I really
liked 'extends' and 'block'.

Github <https://github.com/meric/tier/>

Example <https://github.com/meric/tier/blob/master/main.lua>
<http://pastehtml.com/view/1c26ovp.html>

Zed would think this is contradicting the point of Tir, though; it being a
_micro-framework_. =\

~~~
zedshaw
Interesting, I'll take a look at this some more. My only question is, isn't
plain old Lua already like django's templates. What specifically are you
adding that embedded lua doesn't just give you?

~~~
meric
Template inheritance. See
<http://docs.djangoproject.com/en/dev/topics/templates/#id1>

    
    
      `Template inheritance¶
      The most powerful -- and thus the most complex -- part of 
      Django's template engine is template inheritance. Template 
      inheritance allows you to build a base "skeleton" template 
      that contains all the common elements of your site and 
      defines blocks that child templates can override.`
    

Having made it in lua myself, I can tell you it is indeed quite complex. ;)

The lua template only has "include" (i.e. copying another template into this
template), but not "extends", (i.e. use another template as a skeleton and
this template only provides details on how to fill it).

~~~
grandalf
this is awesome, feel like writing it for ruby too?

~~~
meric
I don't know ruby... but RoR is an established platform, I would think it
would have something similar?

~~~
grandalf
Not with the same notion of inheritance that django templates have (with
multiple blocks that can be overridden in child classes). There is one project
someone attempted but never finished.

~~~
btucker
Isn't this just content_for/yield(:sym)? Or are you talking about something
else?
[http://api.rubyonrails.org/classes/ActionView/Helpers/Captur...](http://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-
i-content_for)

~~~
grandalf
That's close. Nowhere near as elegant as Django templates though, in my
opinion.

------
samd

       -------------- NO TESTS ----------------
         You must work at a startup.
    

Brilliant.

Hype.la is also pretty slick. Maybe it will become the blogroll of open-source
projects.

~~~
zedshaw
Ha, yeah I had to put that in. I find working in the valley is kind of like
working with a bunch of guys before Knuth and Dijkstra established structured
programming. It's like they say, "Yo, I don't do if-statements man. I use
gotos only. That logic and structure crap just slows me down and busts up my
creative chi."

As for hype.la, stay tuned. I gotta fix up the ad blocks and improve the UI a
bunch, but I'm really aiming for it to be for FLOSS and other artists to do
ads without feeling like sleeze. Definitely something I want.

------
jcromartie
Very cool. I was just looking for other Seaside-style web frameworks today.
The "natural style" mode in Tir is just like the main way to build web apps in
Seaside.

Aside from Lua and Smalltalk, what other languages could host this kind of
framework? I know Ruby 1.9 has Wee, but that doesn't seem to be "ready for
prime time."

~~~
jhpriestley
Code written in the continuation monad (i.e., simple imperative style) can be
translated to an Automaton arrow and fit into a Haskell on a Horse
application. This approach has the advantage of type-safety and greater
composability.

~~~
cullenking
Not sure if I should laugh at myself for not knowing if this was a joke when I
first read it.

------
grandalf
very cool! looking forward to trying it out.

