The Artima Developer Community
Sponsored Link

Python Buzz Forum
Smart vs. Dumb Templates

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ian Bicking

Posts: 900
Nickname: ianb
Registered: Apr, 2003

Ian Bicking is a freelance programmer
Smart vs. Dumb Templates Posted: Oct 31, 2003 6:34 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ian Bicking.
Original Post: Smart vs. Dumb Templates
Feed Title: Ian Bicking
Feed URL: http://www.ianbicking.org/feeds/atom.xml
Feed Description: Thoughts on Python and Programming.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ian Bicking
Latest Posts From Ian Bicking

Advertisement

Sometimes people think that layout is simple. You need a big, smart language like Python to do programming -- but something more limited will do for the layout and rendering. In fact, there's usually a little arrogance in there -- the templating language should be simple, and it should be underpowered, because you want to hobble the template writers lest they escape into the Dark Forest of Programming, taking maintainability with them.

At first it seems like this would work. But all programs start out simple (at least if you are writing them correctly). I think people believe layout can be simple because rendering is sloppy. Good rendering doesn't lead to "You have 0 message(s)" (and if you're going to be sloppy, at least make it obvious by saying "Messages: 0" -- use natural language right, or just don't use it at all).

There's lots of other layout issues. Many pages render improperly when the content is too short, or has long lines, and so on. And these are problems just for rendering relatively static material, as opposed to interactive web applications.

Okay... so people do sloppy programming, that's fine. Sloppy output is a much smaller sin than other kinds of programmer sloppiness. But a templating language should be able to stay with you from sloppiness to refinement. If your template language is underpowered you're putting up a future barrier.

And instead, layout starts creeping back into the "control" code. You have to provide the template with partially rendered input, or precalculate values for consumption only by your templates. You can separate hard programming from easy programming, or you can separate logic from layout, but you cannot do both.

Things become even worse if you are dealing with an interactive web application. A web UI is a subtle thing, and prone to overall suckiness. (It is ironic that I am a web programmer, yet I rather dislike web interfaces) "Layout" and "display" become very complicated -- if you are writing your UI well! A simple display gives people only small snippets of information at a time, leads to low-content interstitial pages, forces information traversal instead of nested display, and lacks helpful or predictive direction. A good UI involves all sorts of little rules, exceptions, warnings, qualified feedback and compound screens. Wimpy template languages are not up to the job. Though you might ask: are any template langauges up to the job?

PyDS (which I use to publish this weblog) uses Cheetah Templates for much of its display. Cheetah is a full-featured templating language (perhaps the most full featured of Python templating options, though empy might be close). PyDS uses quite a few templates to control the process -- but they are very dense. Some sorts of layout control should be easy, like rearranging elements or tweaking the granuarity of CSS classes. But reading the PyDS templates isn't easy, they are dense with code and difficult to understand. So I'm not sure, should template languages be powerful, or should we leave them dumb and couple them with Python code?

(I might add: PyDS templates, or other complex templates, might be simpler to work with if they used Cheetah's inheritance features; a Cheetah editor would also be neat ;)

Read: Smart vs. Dumb Templates

Topic: The prodigal son Previous Topic   Next Topic Topic: The truth is out there

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use