Re:Paul Graham: Lisp in Web-Based Applications (2001)
by shiro on Wednesday May 13, 2009 @03:32PM
(#607477)
> If you are using functions you have to first construct the whole page and only then render it's html.
Not necessarily... even using functions, you can create a 'lazy node' in the page graph to delay completion of calculation until the final renderer actually starts rendering the node.
I guess the only advantage of using macros is that you can make page generation code without consing relatively easily. I'm not sure how necessary it is for web servers, but it may matter for extremely high-traffic sites.
If you are using macros you may start sending the html parts before the whole page is constructed.
The latter approach is advantageous if a page needs some heavy computations to generate it: with macros the user will start seeing at least something right away; plus, the browser will load CSS faster if you send that part before the computations.
On the other hand if there was an error in the middle of page generation you will not be able to handle it gracefully since you've already send half of the page to the user.