DesertFlood

Bring life to a barren, technological wasteland

Picking a Development Language

Note: I wrote this post 2 years ago, in a Houston hotel room. I recently realized that I never actually posted it to the blog.

I’m thinking about ditching PHP and using Python for web development. @marcoarment linked to PHP: a fractal of bad design. It’s a comprehensive rant about everything that’s wrong with PHP.

Summary:

  • PHP is full of surprises: mysql_real_escape_string, E_ALL
  • PHP is inconsistent: strpos, str_rot13
  • PHP requires boilerplate: error-checking around C API calls, ===
  • PHP is flaky: ==, foreach ($foo as &$bar)
  • PHP is opaque: no stack traces by default or for fatals, complex error reporting

I’ve seen most of these myself. I’ve been ignoring on the theory that PHP runs everywhere and it’s the language I know best. But, realistically, I’m going to be running my stuff on a VPS from now on. So the “runs anywhere” logic is moot. I also don’t know it all that well. If I’m going to be doing more programming, it makes sense to invest my time in a language that will be better long term instead of one that’s horrible.

I’ve resisted committing to a modern language like Python or Ruby. I like that I can create one-off PHP scripts in a single new file, drop them on the server, and have them executed easily. I don’t like having to create a separate Python / Ruby application for each idea that I have.

Today, I had an epiphany: create one application for all of my one-off ideas. Implement each idea in a separate method (or module) and use application URLs to route between them. If I have a new idea, I only need to create a new method and then redeploy the application. In some ways, that will be simpler than creating new one-off scripts all over the place. For one thing, all of my scripts will be collected in one place, making maintenance easier.

Why Python? It’s the language of choice for Editorial, my favorite scriptable iOS editor. I can run Python scripts on iOS, via Pythonista. The highly recommended Sublime Text editor uses Python as its scripting engine. Sublime Text runs on Mac, Windows, and Linux. Python looks to be my best choice for a universal scripting / development language across all of my text editors and platforms.

The author of the rant recommended three Python projects for web development.

  • Flask for the web stuff
  • Pyramid - medium level
  • Django, which is a complex monstrosity that works well for building sites like Django's