Hacker News new | ask | show | jobs
by joestelmach 5106 days ago
Thanks for sharing your viewpoint.

I realize that templates are a popular choice for many, but I view them as an unneccesary layer of indirection. Sort of like printing out an email, hand writing a response, and scanning it back in as a reply. Once your markup has been converted to a document object model, why not embrace it?

2 comments

I think it's kind of like the difference between writing in assembly and C.

Using a bunch of calls to appendChild() and setAttribute() results in code that is difficult to read, because it's so low-level. You can't "see" the generated HTML, just like in assembly you can't really "see" the code structure.

Whereas using templates lets you "see" your HTML, with an easy-to-understand structure. So it's the natural, default choice for ease-of-use and maintenance.

Well, one style is imperative, one is declarative. Some prefer the former, some the latter.

Myself, I much prefer imperative.

I really like this style of templating, it's pretty close to how Seaside generates it's HTML, but more direct since it manipulates the dom directly. Also using the DOM directly is very fast.