Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

PHP guy here, don't know much about other languages, but seeing HTML mixed in with code is usually a bad code smell. Is this type of thing common in Python?


No, it's not. He's just showcasing the simplicity of bottle.py


Not as bad as those examples you just saw, but as others already said, those are mainly illustrative. Beyond that, it's a matter of template engines and most frameworks allow you to choose one.

Generally you won't see PHP/JSP levels of code, but the more popular engines do allow quite a bit of logic, i.e. don't adhere to StringTemplate-level purity[1].

[1]: http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf


Those micro-frameworks are designed to make a hello-world app very short and to the point. There's one (aspen.io) that uses the ^L character as a section separator to achieve maximum concision: setup, request handling, optional template. No space is wasted on function blocks or explicit registration calls.


PHP is about mixing it with other stuff (hence the <?php tag). So PHP smells by definition :-)


JSP, ASP, CFM, Rails ERB, DJango ALL have the same exact thing. The only difference is PHP tutorials typically have a big block at the top of the "page" for business logic, and then intersperse logic throughout the view.

Most of these other frameworks/languages (barring CFM and old ASP) expect you to adhere to some sort of MVC.

Saying PHP smells by default is a little less than fair. :-)


This is a simple example to make a point about the simplicity of using bottle, a python micro-framework contained in a single file with all the stuff you need for simple web projects (like routing, templates, various utilities and even a test server).




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: