Wednesday, February 02, 2011

php to python: Why PHP is now dead to me

PHP started in 1995 and was a well-known web language by the time I was getting into web development around 2001.  At that time I had just picked up perl--yes, perl, which at the time seemed like the end-all, be-all sexiest language ever.  The only thing I liked about PHP, which I admit was a very big draw was the seemless fusion of content and code.  With PHP's delimiters, one could easily blend between the content and wiring.  Almost ten years later, though, PHP is starting to show serious age to the point of being a deprecated tool in the toolbox (like no one making Phillips screws anymore). 

PHP as a web language
My first grudge against PHP is it's not a very generic language.  People have successfully written non-web-based PHP applications, but this seems to be more of a PHP programmer, who doesn't want to learn a more robust language. After a brief scan of various PHP support sites, PHP development outside the realm of web development is basically negligible.  I see no reason, in fact, besides some amazing library I might not be aware of, for me to use PHP for a non-web-based application. 

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.  -

The syntax is ugly, in my opinion: requred semi-colons, arrows instead of periods to reference data, global functions to manage things like arrays instead of a more object-oriented approach, etc.  After several iterations of the language, features seem tacked on to the early implementations.  With python being faster and providing a larger development community, what motivates me to use PHP? 

The MVC architecture
The MVC architecture is a design philosophy of separating the application into three sections: the models, which manage the data of the application; the views, which typically represent the user interface of the application; and the controllers, which handle a lot of the management between the views and models.  While this design can be strictly conceptual to a programmer separating out functionality, various frameworks like Qt and CodeIgniter strictly separate these entities.  Here's where I believe php has lost it's magic.

The main allure of PHP that stole a lot of perl's magic was putting the controller elements doing the processing directly into the html.  Instead of managing large perl files mixed with html, people could make a mostly html-based file with a little PHP, which was much cleaner to read.  In that sense, all the view implementation was usually separated from the model and controller.  This seemed great at the time, but as MVC has gotten more prevalent, more and more PHP frameworks remove model/controller components from the html leaving small bits and pieces in its place.  In my experience, and what seems to be the practice now in PHP, large controllers and models are created completely separate to the actual html.  This creates a more coherent architecture, but it raises the question: now that we've moved so much PHP code away from html, why are we still using PHP?

The rise of templates
Templating libraries have been around for many, many years-even before PHP was popular.  However, since some programming language had to drive the application anyway, I believe, there was no reason to use one if one had to do his/her coding in C/C++ or perl still.  Now, however, many new languages have emerged such as ruby and python that provide a very small and more robust scripting experience.  Because they are so general purpose, many more examples exist outside of web development.  This is important as web applications have continually provided more and more functionality than just serving up semi-static web pages.  The little bits of php code that was once in my html files are now easily replaced with some templating library like mako or genshi, and I can program in a more general-purpose language, whose techniques will apply to non-web-development tasks as well.  Again, now that PHP has been moved outside of html, why should I use it over python or ruby? 

Things I'll miss
Alas, PHP, I hardly knew thee.  One thing I'll slightly miss, though, is the startup time in PHP.  Almost every apache configuration on Linux typically comes with PHP configured.  After opening up a .php file and typing a few lines, I can access the file directly in my web browser and I'm immediately seeing the results.  With python, I have to do a little bit more typically to get things running via apache.  This requires setting up a cgi-bin, creating a proper script alias, etc.  Newer python frameworks like and turbogears now come with a mini-web-server included, however, so I can hold off on configurations until I'm farther in to production.

I'll also miss PHP's documentation, which I believe is generally more accessible than python's.  Many of PHP's functions get an entire page dedicated to them like explode().  The page features the basics you'd expect from an API doc--parameters, description, and return value--but includes a huge swath of examples of how to use the function.  It's like an entire programming cookbook dedicated to that function.  I find a lot of python docs to be a little too wordy (ex. datetime and difficult to browse to a particular function--especially if I'm searching by functionality and not name.  If I'm unfamiliar with a language, I'd like to know what functions are available for a given class before treading through each and every description.  The function name should typically provide sufficient description to investigate it further.  Anyway, the PHP wiki/comment style of documentation is something I hope more languages adopt.  Wikis are already prevalent on many projects, but it seems people are much more willing to contribute through a brief comment box instead of stepping into an entire editing mode.  Is it fear?  Laziness?  Regardless, it seems more accessible to contribute something beneficial to the doc.

Anyway, PHP.  Thanks for everything.  It was fun while it lasted.


jONy KaLaVeRa said...

I used to really like php. i can't belive how boring it seems now that i've moved to python.

blog said...

PHP misses you to ;) I haven't tried Python, but now I will. That good, huh?

Dan said...

I think one of the main reasons developers are finding PHP "boring" is because it seems to be stagnating at the moment.

When was PHP 6 meant to be released? 2006? said...

I had to make adjustments to a application written in Python, so I had to learn it. Man, Python is probably the ugliest language I ever saw.

Lacisoft said...

"With python being faster and providing a larger development community"

Could you present some evidence that the python development community is larger then PHP development community ? When you present your opinion as a fact you are manipulating your readers. To my knowledge the PHP development community is at least as large as python's if not significantly bigger.

its.yousuf said...

Guys! I am learning php. But you all are saying, php is somewhat dead! What do i do now then? Please recommend something.

Dan said...

@its.yousuf PHP is far from dead! It's better than it's ever been in fact.

Don't be put off by developers saying it's boring. The fact is they're getting bored of it rather than the language itself being boring.

You'll usually see that the people who have gotten bored with PHP have been doing it for 10 years and basically just fancy a change (use whatever excuses you want).

I've been coding in PHP for about 5 years and am still love it.

mario said...

None of the PHP frameworks actually implements MVC. It's used as buzzword.

Chrelad said...

Totally subjective, but as someone that's been programming with PHP for 10+ years, I would absolutely jump at the opportunity to work full time in a node.js or python shop. PHP just doesn't cut it for me anymore. I need a language that was built from the ground up with modern development paradigms in mind; and a development community that is keyed into the future of the web. Python and node.js are exactly what I need :) Nice article!

Alessandro Pellizzari said...

I am sorry, but I can't agree with you.

I developed in C, Java, Python, Javascript, a little Pascal and Bash.
And PHP. And I simply love it.

You can hack 10 lines of code together or use a very-high-level framework to code a 1000-files web application.

You can use good-old procedural code or wrap it all with OOP.

It is fast, it can be cached easily, it is integrated in nearly every webserver, it has libraries for everything, it has a huge community (much bigger than that of python, I assure you, but python-users are more "zealotic" :).

Try python, it is a great experience and a good language (though I HATE its space-based indentation), and it can teach you many things. Also try Ruby, Java and Javascript.

But I think you will, sooner or later, get back to PHP. :)


gorlok said...

Every language has cons and pros. PHP is dirty, fast, easy, and cheapest to host. And cheapest to host is a very strong reason to use it. Very.

Python is lovely and beatiful. But you can't found so easy hosting from ISP like with PHP. PHP is a know beast by ISPs. There are no many issues with security for ISPs. Python is not so esasy for them. Always has been some issues in security between Python and Apache.

Today I use mainly Java at server and android. But I have used for years C, C++, PHP, Pascal (Delphi), VB, Clipper, Python, Groovy, Bash, Awk, ... you name it.

I like more Python than PHP, but I have used a lot more PHP than Python over the years. I love Python. Anyways, I prefer static-type languages over dynamic-languages (but I use both time to time). And I prefer languages over JVM. I will try Scala this year, I think. software said...

Php, Perl, Python, Ruby all are great languages. We need to learn to use languages as just tools. In the end the solution which we deliver to the client matters the most.

php developers

kbos2hm said...

what is the best way to learn php and html or xhtml we have all these programs that do 90% of the work but you can never get them to do exacly what you want i want to actualy learn to fully program in these ive got a pretty mutch good idear of php and i just take bits that i need

droope said...


I am a php coder, and I think PHP kicks ass.

I don't mean to be rude, or imply anything... but I have been coding PHP for more than two years and haven't run into a single bug. Rock solid. :)

Besides, how could you even think of doing something kinda decent without mvc? o.o


Sandeep said...

Thanks for this article!!

matthew said...

this is the only way i could get back to you. thanks for the openGL tutorial am new to it and that was a perfect spring board

fpauser said...

Besides looking at Python (a powerfull language) I would suggest ruby for webdevelopment.

Ruby on Rails is the Gold-Standard in webframeworks. Development in the ruby/rails space happens really fast! Have a look at!

I was a PHP webprogrammer before and learning ruby/rails was like diving into a new, rich & beautiful world I could not imagine before!

Take a day and have deeper look:


fpauser said...

@droope: Its not about finding bugs in a programming language - its about the programming language itself. Its about the concepts and the syntax in a programming language. Example:

In Ruby everthing is an object. Examples:

1 + 1
=> 1 calls the instance-method '+' with the argument 1 and returns a new Integer, 2
[1,2] << 3
=> Array '[1,2]'s instance-method '<<' gets called with the argument 3 and returns itself, [1,2,3]

In the end ruby gives you much more flexibility and clarity as the language is very powerfull and its syntax very clean and lean.

Muhammad Azeem said...

This is a nice article..
Its very easy to understand ..
And this article is using to learn something about it..
c#,, php tutorial
Thanks a lot..!

cybercrypt13 said...

I'd really like to get hold of the whole python is faster than php argument. Where do you get these facts? I've duplicated every test I've found where one argued that python was faster and so far I've not seen a single case where this was true. I'd say maybe I wasn't writing good python but I'm duplicating the code from those making the arguments.

We also write php code to do all sorts of scripting that is not at all web based so that whole argument makes very little since to me either. I'd love to see a strong example where python did something php could not.


strattonbrazil said...


There's going to be examples where one language is faster than the other such as the following, where python is faster in the majority of cases.

Having said that, I don't feel there is any credible reason why performance considerations would make me choose one language or the other considering the more important differences between them.

madhuri said...

Web developers made their programming easy only due to the best moderation of the PHP and its tools as Ieveryone hope.
Cheers !
web design company

Greivin López said...
This comment has been removed by the author.
Greivin López said...

There are some really good options for you PHP guys looking for more beauty on your code: Python, Ruby, Clojure, Scala.

Someone already tried Scala?

What about using Google App Engine or some other PaaS like OpenShift from Red Hat or Heroku?

Keep looking the horizon for some cooler ways to develop instead of focusing on PHP.. it worth it, trust me!

Kush said...

This was a fantastic article. Really loved reading your we blog post. The information was very informative and helpful.Cake PHP Programmers

Lia said...

Interesting blog and I think now a day PHP Developers are in-demand because I could see a lot of hiring for them. They are also a big help for any website business. Thanks and keep it up.

InnomaxMediaLLP said...

PHP to python you can know why php is dead now and move to

InnomaxMediaLLP said...

PHP to python you can know why php is dead now and move to
Web developer

Mike Quiney said...

Well, I am using PHP language for my projects and I don't think so it is dead. It is pretty good and useful language.
hire a ASP.NET developer | hire a PHP developer

Olya Olegovna said...

Pretty interesting post! Thanks it was interesting. into a link

Xudu Technologies said...

php web development,web design and development,web and mobile application development,cms development,web site maintenance

Olive Arnold said...

I really like php,, great post

development Services

ananya roy said...

Nice way of providing information i wish you will be continue this referring to of information with your visitors later on also for their enhancement.
Website Design Companies Bangalore

Andrew Rout said...

Why is it that the people who know the least about PHP complain about it the most?

First you complain that PHP is a web focused language, not a general purpose one. Well no kidding. That's like me creating a web page in C and complaining that it isn't web oriented. Use the right tool for the job, and you won't have these silly complaints.

Next you go on about MVC negating one of the main perks of PHP, which is embedding it directly into HTML.
First of all, nearly every website / framework that claims to be MVC is NOT true MVC, it is typically PAC or another variation.
Secondly, you are not forced to follow the "MVC" pattern. You are free to write your code however you wish. However, if you adopt the PAC / MVC philosophy, you should be applauded for writing cleaner and more well structured code. MVC is an asset in PHP programming, not a self defeating concept.

And templates? Php offers incredible flexibility.

I'll say this....

I am employed as a C programmer, and have extensive knowledge of Python as well as PHP.
Of those three languages, PHP is by far my favorite. To be fair, my knowledge of C allows me to create awesome tools like porting PHP scripts as a PHP extension, among other things, so I see a side of PHP few are familiar with.
I don't think anything can top PHP when it comes to web development -- as long as you are aware of some of the pitfalls and gotchas of the language and know how to code around it.

John Mathews said...

I really love to PHP. This programming language is very easy to understand and implement. Being open source platform, i can get code from various site for free.
PHP Institutes in Chennai

Raj Solanki said...

Thanks for sharing wonderful information about PHP. The post was really interesting to read.
PHP Web Development Company in Indore

christina jeni said...

It was really a wonderful article and I was really impressed by reading this blog. We are giving all software Course Online Training. The HTML5 Training Institutes in Chennai is one of the reputed Training institute in Chennai. They give professional and real time training for all students.

Roshini RS said...

It’s too informative blog and I am getting conglomerations of info’s about PHP. Thanks for sharing; I would like to see your updates regularly so keep blogging.
PHP Training in Chennai

Andria BZ said...

Thanks for sharing your view to our knowledge’s, its helps me plenty keep sharing…
Web design training in Chennai