I’ve been sold on Plack for a while. This clarifies a part of the reason nicely1.
If you design a fibonacci() function, would you make it print the result to STDOUT, or return the result as a return value?
(It’s referring to the PSGI spec rather than Plack, but I figure the latter needs press a bit more)
Quick thought though – if a page takes a long time to generate, the stdout technique can deliver a bit at a time. Is there a plack plugin for that, or is the answer to go for ajax these day and deliver the page outline asap?
1. Namely that printing to stdout always seemed like a horrible and inefficient hack.
If you know your page is going to take a long time to generate output and would like to send the output progressively, there is an answer for this is the PSGI specification: the returned value from the application can be a subroutine reference. See http://search.cpan.org/~miyagawa/PSGI-1.03/PSGI.pod#Delayed_Reponse_and_Streaming_Body
Of course, streaming like a comet app. Why didn’t I think of that. Thanks Doug.
From PSGI specification: