Você pode ler este post em português também.
Recently a friend asked me about PHP. What you will read here is the reply that I sent to him.
Each language has its good and bad sides. It depends of “where” you will use them, and ’cause this I make the comparison as web developer. And I will do it comparing the ASP (not ASP.NET), PHP and Java languages.
The factors that I use to make a choice of a language are:
- Typing (weak, strong or dynamic. The most common is the requirement to declare a variable / type to use it);
- Portability (how it can run in heterogeneous environments);
- Scalability (how difficult is to increase / improve the environment for running the application);
- Development tools (What exists to improve the development experience);
- Readability (the learning curve of its syntax);
- OOP compliance (as provided by the OO pattern);
- Bureaucracy (How much you’re MUST to follow to use it).
Based on the topics above:
- Typing: PHP and ASP have weak typing. Java has strong typing. PHP/ASP therefore tends to give more freedom to develop. Java to be more orthodox, it’s more organized. As I prefer the freedom, point to the PHP and ASP.
- Portability: Point to PHP. For web applications, it supports more environments than Java. And if none of available binaries work for you, you can download the source code of PHP and recompile it on the freak environment that you’re building. ASP here, joke.
- Scalability: Here, less is more. Less work to scale an application, turns it to be better to scale. Ignoring the design pattern factors that should be followed to allow rise the environment, I think that PHP is the best. Unfortunately I have no facts to prove it. So, point to the three languages.
- Development tools: Point to PHP. This language has almost everything that you can imagine to help or give base for development: the Internet there are giants repositories of projects/classes/functions where you can get almost everything for not to start from scratch.
- Readability: Point to PHP. As a language with weak typing and low bureaucracy, the learning curve of the language is very low. There are several kits on the Internet ready to start developing, and indeed, many of them don’t need to be installed (running directly from a pendrive, by example). ASP in the second, and because of its complexity/bureaucracy, Java last.
- OO compliance: Point to Java, with PHP closest to him (especially after the new version 5.3, which support namespaces and other cool things). And yes, PHP is OO (1). ASP isn’t. Just to compare, namespaces are like packages in Java.
- Bureaucracy: Point to PHP. Mainly due to the items 1), 5) and 6). I say that PHP is like Delphi, which provides many OO resources, but without forcing you to use them. Java is highly bureaucratic. Search for examples on Google and you will see that the difference is obvious.
This is an excellent theme for a bar table. There are several other factors, like as maintainability, robustness, reuse, development speed. But is subject for another post.
Adding the score:
a) PHP = 6 points;
a) ASP = 2 points;
a) Java = 2 points.
Done. PHP is better. I swear that I tried to be impartial.
(1) – OOP manual at PHP site.