From PHP to Python: things I wish I’d known

The story so far…

Back around 2005 I took my first leap into the world of writing useful programs armed only with my laptop, a Pentium II running Debian, and a fat book on PHP5. Though I’d taken a few classes on C++ and tinkered with BASIC on a few different platforms over the years, I’d never managed to produce anything that actually did anything practical (or, did it very well, at any rate); with PHP, though, it didn’t take long to spread my coding wings and take to the air as a novice web developer.

Before long, my skills proved useful in some critical situations at work, and my place as a web developer was cemented. My PHP code became more mature as I learned hard lessons of experience and combined them with the programming theory and computer science I was avidly consuming on the web.

Around the same time, I got interested in Python when I saw a coworker using it to build powerful desktop applications quickly and effortlessly; I wanted to round out my programming skills with a “desktop stack” as quick and simple as PHP, and Python turned out to be a good choice.

So for a few years now I’ve written mainly in these two languages, PHP for the web and Python for the desktop. As my applications have grown bigger and more complex, I began to develop a growing discontentment with PHP on a number of levels. So when people started talking about doing web development in Python, I had to see if I could make the switch.

What “they” say

Programmers who like to be vocal about things on the Internet often like to be vocal about PHP; it seems every so often someone will write an epic diatribe on what’s wrong with PHP and why everyone should avoid it. They will tell you to instead use Java, or Ruby, or Python, or whatever – just not PHP. And while I can’t bring myself to completely denounce PHP, when I’ve been waist-deep in a hacked-up PHP codebase for a while, words like “elegant”, “expressive” and “truly object oriented” stir something in me that PHP’s clumsy and inconsistent attempts at bettering itself just don’t answer.

Yet when I finally vaulted the fence in search of the greener grass, I found, predictably, that paradise has a few bald spots of its own. More importantly, though, I found that there is a significant paradigm shift that a PHP developer has to make before embracing other languages. Since nobody ever really talked about this shift, I decided to write this article to help others with the journey.

What is PHP anyway?

If your web development story, like mine, begins with PHP, you probably have a similarly skewed idea of what developing a web application is really all about. Correcting that perspective starts with understanding what PHP really is.

A templating system

At its heart, PHP is a templating system – a templating system, mind you, that’s been bitten by a radioactive web spider and mutated into a massive, object-oriented language – but still fundamentally a templating system. What I mean by this is best explained by describing what happens when a PHP document is accessed in a browser:

  • The web server (Apache, e.g.) receives a request for a PHP document.
  • The web server runs PHP, passing in the requested file and some details about the request
  • PHP processes the requested file, dumping in any “required” or “included” files, and evaluating the “<?php ?>” bits wherever they occur.
  • PHP returns the evaluated document (now pure HTML/XML/CSS/etc) to the web server, which sends it to the browser.

This is why you can stick HTML directly in a PHP file (outside the tags), and it will work just fine: a PHP file fundamentally is an HTML file (even if there’s no raw HTML in it), just one that is marked for some pre-processing1 before it’s served.

A framework

PHP is also a kind of minimal framework. It does a few nice things for you (such as parsing HTTP requests into nice arrays like $_GET and $_POST), and exposes a huge library of optional functionality like database connectivity and image processing.

It’s important to recognize this, because you need to understand that PHP by itself (apart from any third-party add-ons or abstraction layers) has solved a lot of problems for the web developer out-of-the-box. They way it solves these problems is sometimes good, and sometimes not; but in either case, it’s rarely the only way to solve them. It’s easy to take for granted that the way PHP has done something is the only, or canonical, way. Get used to the idea that it is not.

Bad, but no so bad

As I’ve said, people will bash PHP incessantly, and you can be sure they will continue to. If you can read all the way through “PHP: a fractal of bad design2 and still feel completely good and happy about coding in PHP – well, you’ve got resolve anyway. PHP clearly has problems, ranging from niggling warts to major structural issues.

But in the end, what really matters is you, your software, and the people who use your software. PHP’s alleged shortcomings are meaningless academic drivel until they start to impact these things; and I’d guess that in a lot of cases, they don’t. Not everyone is trying to build the next big Web 3.0 killer-app-in-a-browser; some people just want to automate some things on a personal website, or build a basic CRUD system for a set of data they use at work. Don’t get caught up in the PHP hate and throw away a perfectly good tool that has solved these problems in a decently usable way out-of-the-box.

What is Python, and how do you build a web application with it?

Python is a general-purpose programming language. It has a huge set of libraries to make it useful for a wide variety of tasks, but fundamentally it’s a programming language that wasn’t designed for any specific use.

It’s also an absolutely awesome language to work with.

It’s not, however, a web framework (not even a minimal one) or a templating system; so if you intend to use it for web development on a level similar to PHP, you’ll need to add these things to Python.

I mention this because in the PHP world, there are also frameworks and templating systems – Zend Framework or CakePHP for example. Personally, I used CodeIgniter for two or three major (for me) projects, and found it very helpful… at first. After maintaining the code (and keeping CI upgraded) for a couple of years, I got disenchanted with the framework thing. I found that most of what I really wanted from a framework could be answered with a couple hundred lines of convenience functions and some careful class structure planning. So to me, “framework” initially conjured up a big bloated can of overkill.

If you feel the same way, understand that in the Python world you will need to use a framework – at least a minimal one – because (you’ll recall) you were already using a minimal framework called PHP.

The same goes for a templating system. I originally thought, “meh, why bother with a templating system?”; but really, unless you like having big non-syntax-highlighted blobs of HTML in your logic code (you shouldn’t like this!), you will want a templating system.

So, understanding this, let’s look at some frameworks and templating systems.

Python Web Frameworks

Venturing into the world of Python frameworks will immediately have you staring down the keen double-edged blade of choice. There are dozens of them, ranging from minimal and low-level to massively abstracted software suites with more gadgets than Batman’s utility belt. I have only worked with a few, so I’m going to stick with what I know here, in roughly the order that I tried them.

mod_python and python server pages

Before I really “got” python web development, I of course went to it with the mindset of a PHP developer; this sent me straight into the arms of mod_python and python server pages (PSP). This setup allows you to do with Python pretty much what you do with PHP: you write a python script, and Apache executes it in-place whenever it gets a GET or POST request for the script. The script in question can either be pure python, or an html file with PSP embedded (PSP is basically a templating system; to use it, you just drop in tags (delimited by <% %>) much like you do with PHP).

At first this seems pretty cool; but after a while, you realize that you haven’t really improved the structure or security of your application over PHP, and you’ve traded away all the really nice web-oriented conveniences of PHP just to get a language with slightly (OK vastly) better syntax. It seems kind of a wash, and in the end I never saw much incentive to switch based on mod_python.

Apparently, the Python & Apache communities concur, because as of 2010 the mod_python project was abandoned. No great loss, as far as I can tell.


If you say “Python Web Framework?” in a room full of people, chances are they’ll just look at you funny; but if anyone actually does respond, they’ll probably say “Django”. Some consider it to be the one-and-only Python web framework worth talking about, and the banner under which all such development should rally.

Django is what you’d call a full framework; it’s got pretty much everything built-in and ready to roll: templating, database abstraction/ORM, sessions & security, and even its own web server.

Despite the features and popularity, Django didn’t really get traction with me for a few reasons:

First, because it’s not really my style to use tools that are “everything you could ever possibly need right out of the box”; I tend to prefer more minimal, modular tools that I can build on easily.

Second, because it’s one of those frameworks that has you start out a project by running a special “init” command which flomps out a tree full of generated code, into the midst of which you’re to write your application. I could be wrong, but in my previous experiences, this sort of thing means painful upgrades down the road as you surgically inject code updates into your app.

Finally, (and I could be wrong here), it seemed to me that Django wanted to be in charge of the database layout and code, and wouldn’t work well with an existing database. Since I am very often tasked with writing alternate front-ends or reporting tools for existing (and often read-only) databases, this doesn’t work for me.

I decided to give up on Django after a few days of tinkering, and went back to PHP.


After Django, I was attracted to CherryPy on a couple of counts. First, it doesn’t generate a big tree of boilerplate code – it’s just a library that you import. More importantly, it isn’t attached to a particular templating system or database layer, so you can use whatever you want (or nothing at all). I was still in the “I don’t need no stinkin’ template system” mindset when I tried it, and the project I wanted to do didn’t talk to a database at all; so this minimal framework was ideal for me.

I managed to produce a nice utility which we still use at my work, but my experience was somewhat mixed. Chalk it up to my inexperience with Python web development, but I had basically two problems with my CherryPy project:

  • There were at least two or three ways to do certain things, like setting configuration options, and the documentation would mix and match them. The same method didn’t always work for me, either; this made my code feel inconsistent.
  • Many things in the program require some automagical combination of function and variable names, such as session authentication. I had a lot of trouble getting these to work properly, and the debugging messages were not helpful.

Maybe with more time and experience, and longer study of the documentation, I could get along with CherryPy; but at the time, I had work to do and PHP was ready to roll up its sleeves.


Lately I’ve discovered Flask. Like CherryPy, it’s also a simple library that just has to be imported, and allows you to use whichever templating system or database layer you like (though it seems well-integrated with jinja2). So far I get along pretty well with Flask; it feels a little more straightforward than CherryPy, without a lot of the automagical things based on function or variable names. I’ve had some problems with the way it parses complex form data (doesn’t like nested arrays, apparently3). It’s also helped me realize my need for a templating language, and I learned pretty much all I needed to learn about Jinja2 in roughly ten minutes.

Granted, I don’t have any Flask-based code in production at this point4, so I may still be on the hype curve. I’m working on my second Flask-based app right now, and still pretty pleased.

Python Templating systems

I don’t have a ton to say about templating systems, because I’ve only used Jinja2 so far; but I will say this for the benefit of PHP developers like me who think they don’t need a templating system: do yourself a favor and use a templating system. Remember that PHP is a templating system, so it isn’t as if you haven’t already been using one (you probably just didn’t realize it). Don’t do what I did in my CherryPy project and just put your HTML in strings and use printf()-style substitution. Yeah, it works, but it’s ugly, you don’t get proper syntax highlighting, and it mixes presentation with logic.

Don’t stress about which one to use, either. They’re all pretty much the same, just different syntax. I picked Jinja2 because it’s well integrated with Flask and purported to be fast. But really, there’s no wrong answer here; it takes about 30 minutes tops to figure out a new templating system.

One nice aspect I found with Jinja2 (and others probably have similar features) was the ability for templates to inherit from other templates. So I can create a basic template for all pages with some named blocks, then have specific other templates inherit that template and only add to the specific blocks they need to change. This is a nice change from the way I usually did it in PHP, where I’d have functions or class methods to produce various parts of the page (header, navigation, content, etc).

Some general notions you need to get familiar with

So you’ve got your framework and templating system picked out, but there are now some concepts you’ll want to get used to and some bad habits you’ll want to break in order to produce a Python web application.

The web page is not STDOUT

In PHP, if you want to put something on the web page, you just echo it. Since we’re just pre-processing a document in-place, anything PHP spits out ends up on the resulting page. This isn’t the best style of PHP coding, but now and then it’s how you solve a coding problem, and admittedly a lot of us PHP coders debug this way (using echo or var_dump() at any arbitrary points in the code to see what’s going on).

Python frameworks like Flask and CherryPy don’t operate this way; instead, you write functions that return a chunk of HTML, which the framework packages into an HTTP response. So unlike PHP, if you just “print” something, it won’t end up on the resulting web page. Instead, it ends up wherever STDOUT has been directed5

This wasn’t so much of an adjustment for me, because this is generally how I wrote PHP applications anyway: as a set of functions that returned chunks of HTML. For some PHP coders, who may be accustomed to just echoing data as they get it, this is a very foreign approach.


Earlier I described how a web server goes about handling a request to a PHP file; basically, if I browse to, the web server would look for <webroot>/lib/docs/help/index.(something). If that “something” happens to be “php”6, then PHP gets the file, does its thing, and we’re all happy. If there isn’t an appropriate index file there, you get a 404 or maybe 403 error. Bottom line, if you want to make the URL available with PHP, then (short of doing some magic in the web server configuration, e.g. mod_rewrite), you need to create a PHP file at that URL.

With modern Python frameworks, it’s not like this. Making a particular URL on the server return a page of HTML doesn’t require that actual files exist at the path; rather, the framework has a system to map URLs to functions or classes in your program. This is generally called “routing”.

So, in the example above, making that URL work on a Python-framework site would not require you to create any files under /lib/docs/help, or even create those directories under the webroot. It just requires that your code maps the path ‘/lib/docs/help’ to a function or class that returns a valid response (a chunk of HTML, or an HTTP response object, e.g.).

Some PHP frameworks or applications let you do something like routing (a.k.a. “pretty/simplified/clean URLS”), usually by using mod_rewrite to hide a request for some actual php file.


Before I got into doing web applications with Python, I confess that I didn’t really understand HTTP all that well. If you only work with PHP, you probably know that information can be sent to the server as a “GET” or “POST”, and you know the difference in terms of how it looks in the URL bar. It turns out there’s a good bit more to HTTP than just GET and POST, and if you’re working with a Python framework there’s a lot of benefit in understanding it all.

It’s not that Python frameworks don’t abstract HTTP; it’s that they abstract it differently than PHP does – and frankly, I think they abstract it in a cleaner and more natural way. For instance, while PHP makes the contents of an HTTP request available to your script through a series of global arrays (e.g. $_GET, $_SERVER, etc) or function calls (e.g. getallheaders()), Python frameworks tend to give you some kind of request object that encapsulates the entire HTTP request.

If you consider the fact that your Python framework and application are handling many of the things that PHP just let the web server handle, it makes sense that you’re going to be living a little closer to HTTP; don’t let this scare you though. The more I’ve learned the more I start to think that HTTP itself is actually simpler than the mess that PHP abstracts it into.


If you’ve used one of the more well-known PHP frameworks (like CodeIgniter, e.g.) you’ve probably come across the term “MVC”7. MVC is a software design strategy that cleanly divides your application into three parts:

  • The Model, which is your data model and handles all read/write operations to the database or data store
  • The View, which is the interface the end user actually sees and interacts with
  • The Controller, which manages interactions between the View and the Model

If you haven’t used a framework, or disciplined yourself to using the MVC pattern already8, you’re in for a shock. Python frameworks, so far as I have seen, all pretty much enforce the idea of MVC on one level or another. This is ultimately a good thing for your code, and without patterns like this it gets difficult to scale to a real application; but it’s a real learning curve if your usual MO is to sandwich database queries and business logic between large chunks of HTML ad-hoc.

Planning and design

OK, the “real programmer” crowd out there may sneer a bit at this point, but if you’re going to move off PHP you need to prepare to do a little more planning when you create a web app. If PHP excels at anything, it’s in allowing you to just sort of hop in and code by the seat of your pants and build something huge without a lot of advanced planning, sticking code wherever it seems to fit to get the job done.

The python frameworks I’ve encountered enforce a bit more rigidity than this. Unlike PHP, you aren’t just tromping through a script from top to bottom, so you can’t just define things willy-nilly and expect them to be in scope when you need them. Similarly, your templating language is merely a templating language, not a full-blown programming language; so you can’t just stick a bunch of function calls and variable assignments in your template because it feels good.

In addition, frameworks like Flask use a lot of design patterns and abstract constructs whose application isn’t immediately obvious to people who don’t get deep into software design theory. Properly applying these constructs takes some contemplation about what your application is doing on a more abstract level.

This is ultimately good for you, because it forces you to design a better and cleaner application than you might have done in another language. It absolutely requires a different mindset and approach, though.

Downsides to Python

In addition to the need to navigate the paradigm shifts I mentioned, there are some downsides and pitfalls to using Python for web development, and I think it’s fair to mention them.


Deploying your PHP application is as simple as dumping your .php files into a folder under the webroot9. Deploying a Python web application is a little more involved, and there are multiple ways of doing it each with its own pros and cons to weigh.

And of course, your web host may not support Python, Flask, or any of the other Python libraries you need to run your application; I can almost guarantee that the company who hosts this website doesn’t. If you were thinking of writing a CMS in CherryPy for people to use on their $1.99/mo shared web host, you’re wasting your time.

Database access

If you’re into high-level abstractions that take all the icky SQL out of your code and replace it with objects and method calls, Python has you covered well with ORM layers like SQLAlchemy. If you’re like me, and you actually prefer to write your own SQL, the situation is a little different.

PHP has a nice database abstraction layer called PDO, and if you aren’t using it, you need to quit typing “mysql_” and start using PDO. PDO is a single library with consistent classes, methods, and properties no matter what database driver you’re using.

Python, on the other hand, has the DB-API, which is a specification for writing database libraries for Python. Instead of one library with drivers for different databases, Python gives you product-specific libraries that (mostly) adhere to the DB-API. In theory, this should be as nice as PDO, but in practice it’s more chaotic. Some libraries extend DB-API with extra functions, and within the spec there is flexibility in how certain things are implemented (e.g., parameter style for parameterized queries). I found this problematic when (for example) I ported a Flask application written for psycopg2 (a popular PostgreSQL library) to cx_Oracle (the one and only Oracle DB-API library) and had to adjust a lot of code10 due to differences in interpretation of the spec.

Of course, someone out there is screaming at me now to use ORM, but I’m just not there yet.

Application focus

Frameworks like Flask or CherryPy seem to assume that you are actually writing an application, not just an arbitrary collection of unrelated web content. This is great if you actually are writing an application, but not everyone is. Sometimes you’re just creating a page that needs to do a little computational work before it displays, or a form that needs some simple processing on submission.

If you have a website like, say, which contains several subsections of marginally-related content, much of which is legacy and doesn’t need to be touched, using PHP is pretty frictionless. If I want to add a new page which has nothing to do with the rest of the site, but which needs to do some special processing before it displays (like, say, scanning a directory of MP3 files and displaying ID3 information), this is as simple as writing a new .php file and dropping it into a directory.

If my website were handled by a Python application, this would get trickier. I’d either have to write and deploy a new WSGI application (which seems a lot of work and overhead for a single page), or I’d have to add a new function to my existing application (complicating and potentially destabilizing my whole site).

Python 2/3

The current curse of the Python universe is this whole Python 2 to Python 3 transition that’s been going on for the last few years. In the web development space, there are many popular libraries and frameworks that don’t yet support Python 3; Notably Flask, Python Imaging Library, and Django11, though hopefully this will change soon.

What this means for new Python coders is that you need to keep coding in Python 2, but you need to do so in a way that will be easily portable to Python 3 in the future. Which basically means you need to learn both versions. Eek. If you’re not already invested in Python, this can be a deterrent.

Do you need to switch?

I’m not going to be one of those bloggers who insists that you need to switch away from PHP to Python or anything else. PHP isn’t going away any time soon, and for a lot of applications it’s perfectly adequate and easy to ideate. I will say, however, that taking the time and effort to embrace a language like Python and the disciplines of the more popular frameworks is beneficial to any web programmer.

What really motivated me to get into Python was when I started using AJAX more and more, and found my applications moving from a set of dynamic web pages to Javascript applications that occasionally talked to a web service to read & write data. In other words, when my server-side code was more about exposing a large range of read/write database operations to AJAX calls than generating full pages of formatted HTML, the Python frameworks did this with a lot less fuss and a lot less data-shuffling.

I’d suggest sticking with PHP in the following scenarios:

  • Your pages are mostly HTML with just a little bit of dynamic content here and there
  • Your work needs to be deployed on cheap shared web-hosting
  • You don’t think of what you’re writing as an “application”, just “web pages”

If you’re doing serious web development work, and you have control over the production server, then I think it’s well worth the effort to use Python for your next big project. I will most likely continue to do a lot of work with

PHP for legacy projects at work and for clients; but as much as possible, I’ll be moving to Python from here on out.

Addendum, October 2016

Since people are still reading this post as of 2016, and I’m still offering it as my own take on the perennial topic of PHP vs. Python, I thought I’d add an update as of late 2016.

I’m still plugging away with Python, and frankly well rid of PHP.  I’ve written a good half-dozen applications for work (including a database front-end framework) and a handful of open-source applications (see my Github page) all using Flask and Python.  I’ve also given Django another shot, and found it quite useful for a couple of larger applications at work.

PHP has, reputedly, received a decent overhaul with version 7, but I’ve not been in any way tempted to go back to it.  I dread having to deal with my old PHP code!

If I miss one thing about PHP, it’s the immediacy with which one can create a small and simple dynamic web page.  Bootstrapping a Python project — regardless of framework– is mildly annoying, and deploying one is often half a day of beating my forehead against the keys trying to figure out why µWSGI won’t start this time.  Even so, all the bits in between and afterwards are much more enjoyable with Python than they were with PHP.

Bottom line: for me it’s Python.  Even so, I still stand by my “Do you need to switch?” comments above.  Use what works for you, and don’t be afraid to try a new language once in a while.


1 Note the official PHP backronym is “PHP Hypertext Preprocessor.

2 I mention this rant a few times because it’s made waves in the web development community over the last year or so, and makes a lot of good points. For the record, I don’t agree with everything in it (some points seem a little contrived or unfair), but a lot of the criticism is spot on (like the inconsistencies in naming and parameter ordering) and convinced me to try harder at branching out. I think any PHP developer should read that rant with an open mind.

3 To be fair, I fixed this issue with about 10 lines of python.

4 This isn’t Flask’s fault, I have a reporting application ported from PHP mostly done, but held up by one of our vertical app vendors.

5 Which, when you’re using the built-in development server, is usually to the terminal from which you ran the application. Which is pretty wizard, really.

6 or any other extension which the web server is configured to interpret as PHP

7 Model View Controller

8 Read: “If your code is haphazardly littered with calls to mysql_query()…”

9 Assuming PHP is already set up and configured, which is pretty trivial in these days of cheap web hosts and easy Linux distributions.

10 I mean Python code; it’d be natural and expected to have to adjust SQL code between products, of course.

11 Python 3 support is currently experimental

18 Thoughts on “From PHP to Python: things I wish I’d known

  1. zxq9 says:

    Its good to see a comparison by tool-value instead of by sentiment; that is, PHP as a templating system and Python-language frameworks instead of “PHP/Python sux/rulz”.

    I would add two things:

    * The Python2/Python3 situation is finally coming to a resolution. Django now supports both 2 and 3 simultaneously (and within a year or so will probably be 3-only), and several other frameworks are coming along as well.

    * Django makes a series of libraries available, so it can be used as a templating system, an ORM, a URL munger, or whatever. “App”, settings and middleware definitions are optional depending on how you want to do things, though its usually easier to travel at least partway along the beaten path and define thing like the WSGI gate and a few settings. None of the pieces actually require one another, though; you just have to talk to them the way their interfaces expect. I use Django atop predefined schemas, do a lot of db communication outside the ORM, use the Django templating system to render ODF files (mostly odt and ods), and other things that parcel out Django library functionality. There’s no need to think of Django as a necessarily overkill solution, as it is remarkably decoupled. But this takes time to discover, and that really means time to write useful applications in it, and you certainly can’t be faulted for not discovering this early on.

    Here’s to joy in discovery.

    1. Alan says:

      I also think we’re getting closer to Python3 being ready. I was actually working on a blog post detailing the road blocks I’ve been encountering in my latest attempts to abandon Python2. The language itself is great, but there are still a few libraries that I need, including some very commonly-used functionality which I was surprised to find lacking.

      As for Django, what can I say? It just didn’t click with me. No tool is all things to all people; every tool is ultimately geared toward a certain type of person doing a certain type of task with a certain mindset and approach. Flask just fits me better, though I’ll readily admit that if I were tasked with building a large and complex web application, I’d probably look at Django again.

  2. This is spot on. I was looking for something to help me decide whether to throw in the towel, and this has; back to PHP with me. Python is awesome. After months, I have pretty much exactly what I need/wanted with the Falcon framework — which, at this point, means I’ve basically written my own web server when all I really need is basic templates.

    PHP makes me feel dirty. I never remember what I did with it, when I revisit it months later, even with comments. It’s just… nasty. But it’s ubiquitous. I’ve spent the majority of my day trying to coordinate my Python changes from my local system and the remote host (using different modules/setups) and deployment is just a nightmare.

    Definitely perfect for ‘web apps’, but for mostly static content, as you said, PHP really is the best; it just gets it _done_. Python’s elegant, and clean, and a pure joy to hack out. PHP pays the bills, which is important, considering the amount of soap one needs after working in it. Anyway, great blog post; helped me accept I’m using the wrong tool for the job.

  3. Rory Jarrard says:

    I also appreciate that you didn’t just go to PHP sucks. I work for a consulting agency, and I don’t get the convenience of picking what language I use. I am using C#, VB, PHP, all sorts of JavaScript varieties, C++, etc., on any given day.

    I get in fights at work all the time about how PHP sucks and C# is great because blah blah blah. The truth is, we have a bunch of code that comes in the door as PHP and, yes, it does suck, because development costs in .NET are prohibitive and PHP is free. However, I can use something like Laravel MVC and it is much better to work with than .NET MVC. In fact, .NET is much harder to figure out what is going on and where, so much behind the scenes handling of everything. It just happens that Visual Studio is such a superior IDE that it does so much work for you.

    I like both languages. I think C# is like legos, and PHP is like watercolors. In C#, you stick appropriate blocks together. In PHP, if you are skilled, you can make a beautiful masterpiece. Of course, if you aren’t, you get mud.

    That being said, I love Python. It is just more…fun to program in. I feel like I’m really in control. And I can do whatever with it. Websites, deployments (Fabric), games…well I wouldn’t put tinker up against an xbox, but you get the idea.

    However, if you want to be a professional programmer, the vast majority of our software development demands are C#, then PHP. Java is a vast third (and I hate it, but I won’t go into that), and Python is a 5x vaster fourth (or more), only Django.

    I think Flask is much more fun to work on, but do we have clients come in and say “we have this Flask project….”, well no. Sadly, but no.

    I guess I’m rambling. Basically, it’s all BS. They are all languages. If you come in the door and say “do you have any experience in Xyzzy?” I’ll say no but give me a few days. Learn PHP and/or C#, you’ll go far. But if I’m sitting around at night playing around, I’m probably writing in Python. And if I’m writing web stuff, I’m using Flask.

  4. Jim says:

    Thanks man, this is just what I wanted to hear.
    Coming from a PHP background and trying to learn Flask has been a bit of a bumpy ride for me.
    I needed to hear that it wasn’t just me that was going bananas with all the control some frameworks try to exert over YOUR code.

    And it’s not even that. Because python is mostly used by advanced python programmers the learning resources for it are really scarce.
    Yes, if you have been coding software oriented Python for years, all you need is some small libraries and you’re done.
    Or also for people that just want to make a fast website.
    That’s why you get BOOKs telling you to use bootstrap of all things.

    I want to LEARN how to CODE my website myself. Not use a bunch of libraries that automate everything to me. If I need to automate my form creation I will just write a library for that or search for one that does it. But no tutorial should just say “Oh, just use WTForms for that”.

    I guess I’ll try a bit harder to (find) learn the basics and filter out all those libraries they try to shove on you.

  5. ianm says:

    Thank you for your trouble. It sure answers most of my confusion clearly. THANKS.

  6. Gaurav Sharma says:

    Thanks for sharing your thoughts, much appreciated.

  7. This was wonderful! Your first paragraph describes my own progression with programming almost exactly – BASIC, C++, and PHP in 2005! I’ve been considering expanding beyond PHP and Py comes up often so this article was very helpful. Keep up the good work. Cheers!

  8. Diego Franceschetti says:

    I like it
    I come from the VBA and MS Acces. Do not laugh.
    I’m thinking of creating web applications and found AppML
    This is a technique to write caaplicazioni CRUD: Html, CSS, JavaScript for Aloft client and php or asp to the server side.
    The necessary fields script are only these three:
    This is a good technique?
    it is possible and makes sense to re-write server-side scripts in python?
    I thank you for the attention you will devote myself.

  9. dd263 says:

    Great piece. It convinced me to STAY with (and get better at) PHP in the short term, and come up with a 5-year roadmap in the long term for Python. Agreed that MVC in whatever language is a sea change in thinking, a leap I’m yet to make.

  10. saranya says:

    Hiii…Your posting about the php and Python is really much helpful to all people…Thanks for sharing these types of informative…

  11. Peter Steele says:

    Great read. Thanks! I use PHP and have since 2007 but I have always dabbled in Python as well. I have played with django in the past and am very interested in seeing how Flask performs. I love the quickness of PHP and how simple it is to bang out websites, but I would love to be able to write more robust apps with python for the web. Thanks for all the great tips and hints.

  12. EW says:

    Some of the stuff I hear programmers complain about PHP is reasonable, inconsistencies and awkward OOP. But a lot of it is really just bad practices. PHP is freeing and requires discipline to use it in a way that keeps your code extensible and manageable. It’s not a flaw in the language but a flaw in lazy humans. PHP has very few constrains, it’s also very easy to use, combine these things and a novice programmer and you can wind up with some real garbage. I don’t think of it as a shortcoming but rather a need to exercise self control, develop conventions, stick to them, learn about and use techniques from MVC, and learn to insert abstraction layers between UI, processing, DB, network comms, etc.

  13. djynnius says:

    Amazing article! I found a useful site in making the switch myself. And maybe its a PHP people thing, I dont like being boxed in and have for that reason taken to Flask. Django is still really neat though and CherryPy… well… But I am not done with PHP yet 😀

  14. Dave Ross Cuerrier says:

    Wow, sincerely the most verbose and well explained introduction to Python for a PHP coder like me. Thanks for that, I’ll give a chance to Python for sure 😉

  15. Sunita Soni says:

    Thanks for sharing the descriptive information on python course. It’s really helpful to me since I’m taking python training. Keep doing the good work and if you are interested to know more on python, do check this python tutorial.

  16. Hey,

    This is Hadiya Barakah from Sharjah,

    I’m new in digital marketing field so Here i got some confusion that PHP is better or Python recently I hired website development dubai team they created my site
    using php but then i reliazed which one can be better and secure for website development according to 2018 purspective ? Afrer reading your article now I got my answer that which
    one can be better for my next websit so I will hire a better web developer for my next client site.


Leave a Reply

Your email address will not be published. Required fields are marked *