PHP or ..., CakePHP/Symfony/ZF versus ...

Should you develop Web applications using PHP or something else? Should you develop Web applications using a framework such as CakePHP, Symfony, Zend Framework or something else? Both common questions. Occasionally someone with experience provides there viewpoint and frequently those viewpoints are quoted as justification for something that is not comparable. Take a closer look at some of the logic.

Availability of staff

Dharmesh Shah is the CTO at HubSpot and chose PHP then argued python is a better choice. One of his reasons for selecting PHP was availability of staff. Our Universities, and it appears to be similar in many countries overseas, churn out ten Java programmers for every one PHP programmers but there are more PHP programmers available. Why is it easier to hire a PHP programmer than a Java programmer.

Based on observation of Web oriented projects, Java based projects require five times more programmers than PHP based projects and for four times as long. You need twenty times more Java programmers to accomplish the same thing. Java may be a good choice outside the Web but not on the web.

Many programmers suffer through Java classes at college and learn PHP on the side for their own projects. Some of those programmers switch to PHP as soon as they leave college. The number of Java programmers steadily shrinks after college while the number of PHP programmers increases plus a lot of non programmers add some PHP to their Web projects and are soon programming.

The major technology job focused Web sites are always looking for people with experience in Java followed by .NET followed by PHP. The PHP jobs never ask for .NET or Java experience because the PHP oriented projects do not need the other languages. The .NET and Java jobs almost always ask for PHP experience because they all use PHP for something, a Web interface, a project manager, a Wiki, something, and often a few important applications.

You rarely read about a PHP based Web application switching to Java. You read about lots of Java sites switching to PHP. I switched several of them.

With all that extra PHP activity and the rapid expansion of PHP usage, the supply of PHP programmers is greater than the need because PHP is so easy to learn.

PHP, Python, TCL, ..., is easy to learn

Several languages are promoted as easy to learn. PHP and Python lead the way based on actual results. PHP beats Python about ten to one then Python beats the rest by one hundred to one. Ruby was popular for a while but almost always among people with formal training in a similar language. Python's success outside the Web is better than Python in the Web and a big use for Python is replacing the ancient Perl language outside the Web.

In the Web client area, down in the Web browser, Javascript is the only language going and very few people are successful with anything complicated in Javascript. jQuery is almost a macro language for Javascript and a lot of people with no formal programming training are successful with jQuery. The reason is jQuery looks a lot like the selectors in CSS and a lot of non programmers learn CSS. You can take someone experienced with CSS then step them easily into jQuery. By comparison, Javascript is a black art suitable only for masochists.

... is good for the easy stuff by not for complex applications

A common complaint about about programming languages is the difficulty of building complex applications in a given language. Someone says language A is easy to use for the easy stuff then difficult to use for the complex stuff and you should switch to B. In kicks another person with a story about a failure with B then a success with A. Rarely is there enough detail to work out the true reason for a failure but when there is, it is often a wrong choice about how to develop, not the language.

Take the example of the simple choice between Java and .NET. .NET started as the Microsoft name for their version of Java then Microsoft dumped a whole lot of other things in .NET. The first years of .NET were as painful and wasteful as the first years of Java. Nothing worked. Documentation was missing, wrong, or out of date. .NET crashed operating systems the instant you applied the most trivial update. Exactly like the first ten years of Java. Java was more than ten years ahead of .NET and there was a few years when Java was a better choice based purely on the maturity of Java. Anyone choosing a language should choose something that is either mature or easy to change. Java is not easy to change. .NET is not easy to change. They are the wrong choices when you need flexibility, the wrong choices for the web, and both were, for a long time, the wrong choices for maturity.

Frameworks help you deliver an application faster than writing the whole application from the start. If you are starting a big complicated project in raw code, the decision to not use a framework is far more damaging than the choice of language or of framework. Most of the languages have only one framework or only one Web oriented framework. PHP gives you a choice of frameworks. The number of frameworks indicates how easy it is to develop in PHP then share parts of your development. For a Web based application, you choose PHP then argue about which framework you should use.

Symfony is the most progressive framework for PHP and has reached the second generation with serious performance improvements, something that should be easy to achieve considering how slow it was in version one. Symfony is a good example of almost all the arguments you read. Symfony version one made code writing easier but was slow to execute and almost everyone recommended a different framework. Almost everything you read today about Symfony is based on version one. Version two is faster. Version two might be slower than the code I write but is is up there with the speed of the average programmer and the speed of execution is not a big issue. Some of the frameworks are creating their second generation but are still working on it. If you had to choose today, you would probably choose Symfony. In a few months time one of the other frameworks could be the better choice. Update October, 2011. CakePHP version 2 has a stable release.

I personally like the freedom of some other frameworks, the freedom to use parts of the framework without using the whole framework. On a couple of occasions, I added components from frameworks into existing projects then run up against an endless chain of prerequisites and ripped the code out.

For learning a framework, I like the frameworks with small starter Web applications so you can see it working. You install the Apache Web server then view the Apache verification page in your Web browser. You install PHP and verify PHP works by using a web page containing a line of PHP code. Then you install the framework and visit a page that proves the framework is working. You keep that basic demo working to verify the framework when adding additional components.

One of the frameworks I chose in the past is headed in a new direction featuring complexity far exceeding the requirements of a Web oriented framework. Some frameworks hit the point where design decisions are political, not practical, and you may have to jump ship. Changing frameworks can be difficult because they are inside the skin of your application. Some of the version 2 frameworks look like they are suitable only for very large applications where you commit to using the framework exclusively.

Content management

A content management system can give you far greater productivity gains than a framework and be far easier to replace when you decide to change. A good CMS keeps the data separate from the code and you should be able to move your data to a fifferent CMS far easier than moving your code to a different framework.

As a comparison, a framework might supply from 20% up to 60% of your code while a CMS supplies from 90% up to 98% of your code. Replacing 50% is a pain compared to replacing 98%. Lots of people switch their web sites between Wordpress, Joomla, and Drupal. Few people switch their sites from Symfony to Zend Framework or between any other combination of frameworks.

Javascript of the server

Lots of people recommend using Javascript as the development language on the Web server. Javascript is a marketing name for Actionscript. Actionscript was renamed Javascript to cash in on the media attention lavished on Java many years ago. Actionscript failed on the server for several good reasons.

Javascript in the client is close to dead due to jQuery and is used only to add the occasional logic decision or array processing. Smartphone applications were killing Javascript for a while but now everyone is over the fashion for iPhones, nearly over the fashion for Android and iPads, and has gone back to accessing the Web through Web browsers because all those hand held devices can now use real Web browsers.

The semantic Web

The semantic Web, the thing all good Web developers work towards, separates content from decoration. Most programming languages separate content from decoration. Python and a small number of other languages break the semantic approach by giving special meaning to spacing.

Python actually depends on indentation. The very first time you edit or change Python code, the indentation is exposed to change and the whole program logic is destroyed. Python developers battle on because they think their code looks pretty or clean. People working on Python code from other developers often report major loss of functionality. Suddenly you have to use exactly the same editor with exactly the same settings.

.NET

Based on comments by people leading projects and the people paying the bills for development, .NET is a consistently bad choice. Because .NET is a jumble of many different things, I though .NET would sort itself out and some of the many components would be useful for something. People using .NET are saying there is always at least one part spoiling .NET for everyone else. If you a meal at a restaurant and one of the ingredients makes you sick, do you care which ingredient caused the problem? No, in most cases you just stop eating at that restaurant. A lot of people and companies are moving away from .NET because of the bad meals.

To Web or not to Web?

Some applications are best developed outside the Web. Variations of the C language are good for use outside the Web. Perl/Python/... might be good for one off quick utilities. PHP rules the Web server. jQuery is the new ruler of the Web browser. Web developers then have to choose a framework or jump ten years ahead and use a CMS. Of all the decisions, the choice between building your application as a Web application or as a non web application is the most significant. In many cases a non Web application is best served by a Web based service and only a small amount of code is written outside the Web.

Replacing people

Half the development projects require a replacement person during the project due to time overruns, pregnancy, health, holidays, or a conflicting contract. Half of the people you replace are critical developers with specific training and experience. You will have problems replacing some experts at short notice. Choose technologies where there are a good supply of replacements.

In Australia today, you would start with PHP instead of Java or .NET based purely on availability of staff. If it is a Web based application, PHP is a double winner as the clear leader on the Web. Outside of the Web, there are a lot of choices with Java and .NET being the main ones to avoid.

There are also shortages of people experienced with security and databases. Security is usually handled outside the application by using a VPN or operating system options. The database expert shortage is more of a problem in the application development area. Should you be choosing a database, Oracle can be a difficult database and Oracle experts are always in short supply.

MVC

MVC is the Model View Controller approach. Nobody agrees on exactly how you implement or use MVC, they just agree it is a good idea. The View part is the presentation layer and everyone agrees there should be no data conversions or business logic in the View. They then put logic into the View layer to

Ruby on Rails

Ruby is a language with some interesting ideas and some strange ideas. Ruby on Rails (RoR) is a Web development framework for Ruby. RoR appears to be more popular than Ruby. Some PHP based frameworks have a similar approach, or a similar structure, to RoR. Codeigniter is the best known PHP framework with similarities to RoR. Kohana was developed from Codeigniter and shares the RoR similarities. Yii Framework is also similar to RoR.

Read all about it!

CakePHP 2.0.0
Codeigniter
Kohana

Symfony
Zend Framework 2.0 requirements as an example of code architecture
Zend Framework 2.0 Requirements

Conclusion

The language is not important. Work from the type of application you want to build through to how you will develop the application and the availability of people. Choose the most complete set of base code for the project from those free open languages where you can easily hire people. In most cases you will end up with one easy choice for that type of application.