PHP Archives
Recently in PHP Category
Is PHP really that bad?
First of all, let me state that I don’t think I’m an expert programmer, but I think I’ve learned programming from some very good people (at my previous work) who were perfectionists in terms of how the code should look like.Â
When I first started programming (it has not been long, trust me), I started to work on a real-project using PHP.  I was taught to use it because PHP is considerably easy to learn.  I believed it, after all, lots of universities in Indonesia didn’t have PHP in their curriculum, yet there were so many PHP developers in Indonesia.  I thought these people must’ve been self-taught, hence the languge itself isn’t really difficult. It turned out to be true.  PHP isn’t really hard.  I’m now used to it, even though I’m still looking at other programming language to learn from.
When I worked as a developer in the past, my employer was very strict on coding style. Â Everything has to look similar from one file to another. Â We also followed (kinda) MVC where View should not interact to the Model right away. Â Instead, it will be the controller’s job. Â We also tried to maintain that there should be no PHP codes in HTML files or vice versa. Â The solution was to use Smarty, for better or worse.Â
Some of the strictness we used were:
We use: $n = count ($var); for ($i = 0; $i < $n; $i++); Instead of: for ($i = 0; $i < count ($var); $i++);
Also, spacing between characters, variable assignments, calculation, curly braces, and all that stuff are maintained. No one is allowed to write:
for($i=0;$i<$n;$i++);
Well, one line of code might not matter. Â But if you have hundreds or thousands of files, your eyes will eventually be tired to read some of these codes. To cut story short, we used K&R style as much as possible.
Now, my problem is, I resigned from my old company, and started on my own business, and I’m still doing PHP work. Â For the first few months I could work by myself. But sooner or later, I started to need some help from other developers, so the job vacancies began.
Here’s what I found out when I interviewed and tested some of the guys:
- Their codes are truly a mess. No indentation, no spaces between assignments, calculations, and etc.
- They don’t understand the concept of MVC. So, they write their codes on Dreamweaver where they can mix the HTML codes and PHP codes
- Even worse, some of them don’t even know how to write codes from scratch. One of the applicants actually asked me if I had a PHP file where he could edit and finish it.
I know that some of the problems I faced was because some of these people might “lie” on their resume, or maybe their codes was good enough for their former employer. Now, this leads me to my question:
Is PHP really that bad? Don’t people learn how to code nicely so that others can read/understand them? Is it because of the IDE? Or is it because PHP is not in our universities’ curriculum so that people practice PHP in different ways (I noticed Java people or .NET people don’t have these problems since they are taught in the University)?
The last thing is, is PHP really that easy to learn that it becomes a disadvantage, where people can just abuse the language, in terms of how it is written?