<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[Important Shock]]></provider_name><provider_url><![CDATA[https://importantshock.wordpress.com]]></provider_url><author_name><![CDATA[Patrick Thomson]]></author_name><author_url><![CDATA[https://importantshock.wordpress.com/author/importantshock/]]></author_url><title><![CDATA[Worse is Better: Python templating systems vs. Rails&nbsp;ERb]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>(Disclaimer: Python is my favorite programming language; however, I do criticize it in this article. Please redirect flames to /dev/null.)</p>
<p>I&#8217;ve been comparing web frameworks lately, developing a relatively simple CRUD  database-backed application that can support a few bells and whistles. I&#8217;ve checked out Ruby on Rails (who hasn&#8217;t?) Django, and Turbogears in my search, and realized something as I was hacking together some templates in Kid:</p>
<p>Python, a far more restrictive and inflexible language &#8211; one that would seem, on the surface, to be worse for web application development than Ruby &#8211; is better for programmers, designers and security by nature of its inflexibility.</p>
<p>Let me explain what I mean. When designing &#8216;views&#8217; &#8211; the web pages that users will see &#8211; that need to be updated with data from a given database, it is natural to break the Model-View-Controller paradigm and embed some controller logic into the application. After all, it&#8217;s so much less effort to embed</p>
<p>&lt;% found_books = Book.find_all(&#8220;title = ?&#8221;, given_title) %&gt;</p>
<p>into your .rhtml files then to go back into the controller file, change the return types, and make sure everything works correctly.  However, Python is whitespace-sensitive, and therefore is much more difficult to embed into HTML. As such, you can&#8217;t write the mixture of Ruby and HTML that makes Rails so easy to use.</p>
<p>This is a good thing.  I am a strong advocate of separating the model, view, and controller; by the very fact that I can&#8217;t write a combination of Python and HTML, I am forced to go back into the CherryPy/Django controller codebase and write a properly formed, secure, and elegant SQL query. Normally laxity wouldn&#8217;t bother me, but I believe that any large web application will grow into a hideous, Nylartothepic tangle if the MVC rules are not followed to the letter.</p>
<p>I still love Rails, but I love the templating systems in Python even more. Because Python is so restrictive, people had to write templating systems the Right Way &#8211; and that&#8217;s a good thing for everybody.</p>
]]></html></oembed>