Dear Zed Shaw, can you change the <title> tag of your posts to the actual post title and not the blog title? Always annoying to have to change it when I save your articles to Pinboard. But most of all, it's annoying because it's like, just wrong, dude! :D You can also tell me to go away and that's it's your blog and you keep it the way you want to. (That's fine too.)
"The problem with Lisp is that it is acceptable to metaprogram until the only person who understands what you've created is you and The Flying Spaghetti monster."<p>Yeah, I guess this is sad but true. But as an alternative should I stop using macros and write lots of repetitive code?
<p><pre><code> I needed something real because you cannot build
a useful web server in a vacuum.
</code></pre>
I’d even go as far as saying that you can’t build anything in a vacuum. This is my main gripe about many <i>sample projects</i> for web frameworks. You get the traditional and useless <i>hello world</i> and the <i>blog engine in 20s</i>. Yet none of them highlights how to decouple your app, how to deal with non mundane stuff (security, error handling and reporting). Most of us, when learning about a new framework, have many years of experience with other frameworks, so why not try to sell us on how your framework is different and better suited to the <i>real world situations</i> we’re facing.
Very interesting...<p>Made me jot down a non-mini, non-existent web framework I think I might like to use.... It's only just a tad bit more compact than Tir and will take a lot more effort to implement... but (I hope) it is much easier to tell at a glance what it is doing. Must find time for building my own web framework some day.<p>Corresponding Arc Challenge: (cheated a bit, if you want to make this 'proper' you'd need to add a cookie, and maybe another function.)<p><pre><code> require "filter"
require "form"
require "response"
require "route"
said_form = form.default { saying = form.charfield() }
function said_page(args)
return response.http(said_form.render())
end
function said_click(args)
return response.http(
([[<a href="javascript:document.write(%s)">click here</a>]])
:format(args.post.saying))
end
route.set(filter.get, "^/said/$", said_page)
route.set(filter.post, "^/said/$", said_click)
</code></pre>
Login / Logout<p><pre><code> require "filter"
require "template"
require "form"
require "widget"
require "response"
require "route"
require "generic"
require "css"
login_form = form.default({
username = form.charfield(),
password = form.charfield{widget = widget.password}
})
function login_form:clean(args, data)
if authenticate(data.username, data.password) then
return true
end
args:set_error(self, {'username or password is incorrect'})
args:set_data(self, args.post)
return false
end
function login_check(request)
if request.session['user'] then
return nil, response.redirect("/")
end
return filter.get(request)
end
function login_page(args)
return response.http(template.default.render_with {
head = css.link("my.css"),
body = login_form.render()
})
end
function login_auth(args)
if login_form:clean(args, args.post) then
return response.redirect("/")
end
return login_page(args)
end
route.set(login_check, "^/login/$", login_page)
route.set(filter.post, "^/login/$", login_auth)
route.set(filter.any, "", generic.not_found)</code></pre>
"NO TESTS. You must work at a startup."<p>LMAO. You have to hand it to Zed Shaw sometimes...<p>Now, seriously tho, this has been waiting to happen since forever. I always knew that when the right people started messing around with Lua, awesomeness would emerge.<p>Lua is the closest scripting language to C. It's faster than Python, Perl and Ruby[1]. It's not just faster, but also uses less memory. It's also extremely elegant (in language concepts[2], at least -- not too much of a fan of its syntax but whatever). But the fact is, apps running in Lua would be hard to beat in terms of single-node performance. Your $20 cloud box that struggles to keep hefty Ruby processes running (or even Python processes, though these are way smaller than Ruby processes) will suddenly be able to handle a lot more than it does today.<p>I think Lua for instance would make a lot of sense for the big ones: Google, Facebook, Twitter. Google has a lot of C++ code on its infrastructure[3]. Facebook resorted to C++, Java, Python, and Erlang[4]. Twitter took the Java path with Scala.<p>The more I build applications (and keep them running), the more I respect the Unix nature and the more I want to become proficient in C. Mastering a scripting language and knowing how to glue it to raw C, or something close to C, gives you a lot of power.<p>Imagine a Python+Lua stack, where you can have handlers written in Python and use small, specific Lua-based extensions to run complex computations. I'm already contemplating using something like Lunatic-Python[5] to accomplish that in an app where I have to create similarity-based clusters. Today the Python code that handles it takes about 15 minutes to run as a queued, background task. I'm very curious to see if I can bring that down with Lua-based code controlled by Python...<p>[1] <a href="http://shootout.alioth.debian.org/u32/which-language-is-best.php" rel="nofollow">http://shootout.alioth.debian.org/u32/which-language-is-best...</a><p>[2] <a href="http://www.lua.org/history.html" rel="nofollow">http://www.lua.org/history.html</a><p>[3] <a href="http://www.quora.com/Ben-Maurer/Google-Infrastructure/answers" rel="nofollow">http://www.quora.com/Ben-Maurer/Google-Infrastructure/answer...</a><p>[4] <a href="http://www.makeuseof.com/tag/facebook-work-nuts-bolts-technology-explained/" rel="nofollow">http://www.makeuseof.com/tag/facebook-work-nuts-bolts-techno...</a><p>[5] <a href="https://github.com/dmcooke/Lunatic-Python/blob/master/docs/lunatic-python.rst" rel="nofollow">https://github.com/dmcooke/Lunatic-Python/blob/master/docs/l...</a>
Programming languages are about manipulating concepts. Give that Lua code to someone who doesn't have the necessary concepts (views, regexp-based routing, framework, dynamic websites, ...) and he'll be lost.<p>This rant just shows that the mighty Zed doesn't have the necessary concepts (and neither do I) to understand the Arc bit.<p>Edit: and obviously, reading the docs would help in this regard.
The idea of process-per-interface is an interesting one. My first thought was that this has the "PHP problem" which is to say that if you have a bunch of useful utility classes and helper code you have to optimize those to minimize loading. In a framework like Django where an app is reused between requests, you can have a lot of useful framework available at your fingertips.<p>My <i>second</i> thought was more interesting than the first, though: Tir shows the value of Mongrel2 (or, at least, Mongrel2's approach). You can use the process-per-interface structure in places that make sense, and use Django-esque structures elsewhere.<p>Of course, Mongrel2 is not the only way to do it and there are sites like Amazon where they take the approach of packing the results of many requests to separate services into a single page, rather than having a single process be responsible for the page.<p>I find that these days the hardware's good enough that most apps that people create never make it to the "scaling problem" anyhow.
Good stuff, I think Lua might be an excellent choice for this. Now for some shameless self-promotion: a year ago I posted a Haskell solution to the Arc Challenge, which might be even more readable for non-programmers: <a href="http://news.ycombinator.com/item?id=1004701" rel="nofollow">http://news.ycombinator.com/item?id=1004701</a>
Cool hack. I really like what I've seen of Lua so far. It would be great to see it become more viable for web work.<p>I think Zed's right that web applications are more and more constructed in terms of <i>interfaces</i> than pages.
Looks interesting. I found Lua to be a wonderfully predictable language, both regarding semantics and syntax. Which is quite nice, in an age of decorators, macros and weird histories (looking at you, JavaScript).<p>As opposed to Zed, I would say the same about Lisp, though (if you're a mature programmer, who went beyond the first excitement about macros).
Beating the ArcWTF challenge:<p><pre><code> page '/said' do
form do
message = input()
submit do
link("click me"){ text("You said #{message}") }
end
end
end
</code></pre>
Show this to a non coder and I'm pretty sure they'll recognize more than if you show them the 40+ lines of his Lua version.