Here's a list of every function beginning with the letter "A" in the PHP function index:
This is a companion discussion topic for the original blog entry at: http://www.codinghorror.com/blog/2008/05/php-sucks-but-it-doesnt-matter.html
Here's a list of every function beginning with the letter "A" in the PHP function index:
PHP sucks is incredible misinformed. Any language can be considered to suck if itâs being written by a programmer who sucks. Yes, the functions are doubled in cases and yes, the parameter lists are annoying at times, but PHP can be just as elegant as any other language, if not more, if a good programmer is writing the code.
Furthermore, compare its execution speed with any of its competitors and Iâd bet for PHP more often than not.
I used to be a C# programmer and I have found that with PHP, I am far more productive, I enjoy my programming time significantly more, and my applications are more elegant. Obviously this is subjective, but isnât part of the point of programming to enjoy it, to create elegant solutions, and be productive?
Anyway, thatâs my 2 cents.
Donât mix-up bad programmers with a bad language, most PHP code out the looks crappy and ugly because of bad programmers. It is totally possible to make good working beautiful coded applications where code, data and context is separated.
PHP is as good as C and almost as forgiving, this means that the programmer needs to put more discipline into short, readable and good commented code.
Iâm surprised that the dollar sign thing in PHP doesnât get critique. Every single time Python is mentioned to an audience, who likely have no idea what it is, the use of white space is mentioned as if some kind of original sin that makes whole language impure. I honestly canât understand how anyone with experience from any other language can stand PHPâs requirement to use dollar signs to tell the interpreter that the next thing is a variable.
Couldnât the original language designer bother to read a book about compilers and just threw something together?
No offense meant to PHP users. I know that after a while things like typing $ becomes automatic and there is something to be said about having absolutely no restrictions (types, include files, namespaces etc.). If you are really good programmer, you can do good code without any boilerplate. Unfortunately most programmers are not that good.
Jeff, did you let Reg write this entry without telling us? Next thing youâll be all âblurb thisâ and âblurb thatâ.
At least you got one thing right â⌠But It Doesnât Matterâ. Iâd like to let everyone know that at least 70% of the web related programming jobs out there will have you working with PHP, most likely using a LAMP stack. If youâd like job security, knowing PHP is pretty handy as it is the standard for web application development.
The PHP Team understands the problems with the language, the advances being made in frameworks, unit testing and the mass conversion from the bastardized OO in 4 to mostly better OO in 5 are mitigating those issues.
The article completely missing the point of PHP: ease of exploratory web development and deployment.
With mod_php, which is widely available even in most basic ISP hosting plans, developing php is like writing html pages, no additional set up necessary, unlike fastcgi/scgi/app servers required by other languages. Deployment is simple as well, just copy the code directory over and youâre done. Rails is simple to development but a bitch to deploy with various additional required components to choose/setup. The mod_php model also ensures no memory leaks due to PHP scripts. PHP scales because apache/mod_php scales.
The flat namespace and ill thought out libraries of php are ugly, but with the search function of php.net and the helpful comments, nothing canât be worked around quickly.
Until language elitists figure this out. PHP will be the dominant webapp language for a very long time.
Yada, yada, yada, all words. Since PHP is considered by some easier less verbose than C# then put your money where your mouth is by solving the problem below cleanly elegantly:
For this XML:
( http://today.java.net/pub/a/today/2004/08/12/groovyxml.html )
I want to get totals for accounts âaâ and âbâ and then store everything into a strongly-typed collection or list of objects (or failing that hashtable / dictionary). So basically I want:
id = âaâ, total = 1700
id = âbâ total = 3400
In C# the solution comprises one line, try to replicate that in 1 line or less:
from account in xDoc.Descendants(âaccountâ)
group account by account.Attribute(âidâ) into accountGroup
select new
{
id = accountGroup.Key.Value,
total = accountGroup.Elements(âtransactionâ).Sum(t = (int)t.Attribute(âamountâ))
};
Anybody up for a challenge ?
@Bloodboiler
The â$â prefix on PHP variables actually does have a purpose. It allows the developer to embed variables directly in strings rather than by using a substitution function (either explicitly or implicitly) such that rather than having:
print(âYou are running {0}, on {1}.â, sApp, sOS);
or
echo 'You are running â . $App . ', on â . $OS . â.â;
you can just have:
echo âYou are running $App, on $OS.â;
Which one is the easiest to read?
Was it not the great Bjarne Stroustrup that said:
"There are only two types of programming language:
The type everyone complains about.
The type nobody uses or cares about."
I think that you can judge for yourself, based on the amount of b*thcing about PHP, into which of these PHP falls.
âThis article is offensive in its naivety. Your gripe here isnât that PHP sucks, but rather that you suck at PHP. They are vastly different concepts.â
Hehe⌠good one dude. What I got from the blog is more like âeverybody sucks at PHP and itâs ruining the language because the sucky features that sucky programmers seem to like (and good programmers hate) is all being rolled into the core language.â
This can happen to any language: VB being the prime example. There is nothing fundamentally wrong with VB depending on who you ask. For the most part it is just a programming language. The preponderance of bad VB being set up as âexample codeâ and the developers who arenât good enough to see that the example is bad code, and used it in droves all over the place, caused VB to evolve into a bad code space to be working in.
That is the problem with PHP - not that itâs a bad language, or that itâs hard to learn or anything. Itâs that when you adopt PHP, you also get itâs whole extended family of crap code, and the crap code that survives long enough seems to be happily folded into the main project as a new function. This is a bad ecosystem to be living in. Survival of the fittest may not be working correctly in the PHP world - and that makes it a bad environment to work in - IF you choose to use the built-in stuff. And if you choose not to use the built-in stuff, then you might as well not use PHP, because itâs not much of a language by itself - itâs the built-in framework that makes it useful on web sites. And Iâm sure there is considerable disagreement over whether functions like a special regex-based substring should be folded into the main project or not.
Thereâs a bunch of reasons why I think those functions should NOT be part of PHP - the main one being what someone else touched on - that it gives me an incentive to not write my own version of the function, and there is no way to choose a different library for that function, or eliminate libraries to make it leaner. You get all the weird functions or you get nothing - not even the language itself.
Let us just start with the old âits got to many functionsâ - they may have thrown everything into the toolbox without thinking if it should be in there, but the fact is you do not need to use them, and I probably only use less than 5% of them in a normal day.
One of PHPâs greatest advantages and disadvantages is itâs simplicity. It allows any old newbie to knock something together which is great, but it also means a lot of very bad code gets written.
Within a well structured team following strict guidelines it can be a beautiful language, coded badly it can be an absolute mess.
I have been programming since the days of BASIC + Assembler (6502,65186) and I have tried most things over the years and always strive for simplicity + the ability to build structured complexity. PHP is the most fit-for-purpose language in the web 2.0 space giving a fine balance between quick to build and scalable given time (and lots of extraâs)
Whoah, so many comments.
I liked php when I did it. It was way better than (classic) ASP being far more expressive and easy to use framework. It also had a wicked searchable online reference with decent examples to help you get up and running. The quality of MSDN still isnât always on par for how good that online help was.
Sure the name of some methods suck, but really, if they wanted to change that, they could. You get used to these things.
I think the benefit of compiled languages like C# are the fact that they work better in large teams. Thereâs also a lot of benefit to catching errors at compile time. Stuff like ASP.Net does integrate better into a windows infrastructure. Letâs face it, thereâs a lot of windows infrastructure out there.
Popularity doesnât mean it was done well at the start, but popularity means everyone knows it (and probably hate it to a degree). But it gets the job done in the end, and no methodology gaurantees that, no matter how pretty or perfect it is. Like windows, itâs not the best, but it sure is popular.
Seriously, C# is great, but sometimes I get the feeling that there are too many teams in MS pushing too many technologies. My brain canât keep up. I should become a manager I guess.
All languages are collections of arbitrary stuff borrowed from other languages. And arguing about how pretty one language vs. another one is like arguing about which language you should use to write a recipe for a cake.
PHP is an interpreted language. That alone should make you want to use another language.
Well, really, PHP 4 sucks, and PHP 5 isnât all that bad. The PHP 5 object system is pretty decent, and PDO (which is available for PHP 5 and standard with PHP 5.1) is a decent way of accessing a database. The problem is that almost all PHP code in existence is PHP 4, and the PHP developers I know are hardly aware of PHP 5 features, mostly because their hosting companies havenât upgraded yet.
-Max
Like others have said, crappy code can be written in any language. PHP just has such an unusually low barrier-to-entry for new programmers that you end up with a lot of people slinging around crappy code.
Iâve seen some absolutely brilliant engineering done in PHP. Thereâs plenty of modern software constructs available in the language, and plenty of frameworks are available if you really want to make your solutions clean.
Iâve heard all the arguments before, and like you say Jeff, they really donât matter. When I started coding in C I was constantly looking up library function names and parameter lists, even though they were all logically consistent. Even though you can argue that PHPâs function names arenât consistent, thatâs relatively unimportant to experienced programmers who have most of the commonly used functions and their parameter lists memorized. Not to mention that the manual is fantastic.
âno sensible framework baked into overall productâ
Why on earth should a framework be baked into a language and thrust upon you? Separating your framework from your language should be a language designerâs primary goal, not something to be avoidedâŚ
i couldnât disagree with you more Jeff. php, as a language is easy and sensible. there are a LOT of library functions, but youâre making the wrong comparison. if you put php side-by-side with VB + .NET, youâll find that php does what a web developer needs and is simpler and more efficient. iâve used both, and will use both again (though i lean more towards c# in the M$ world), but my preference is for php.
Also, it might be interesting to do an article on how almost every âX Language Sucksâ article or comment in the world is written by people who have never used X Language extensively, or by people who donât have a good understanding of the features of X Language, or by people who have only used one language and think that any language that works differently automatically sucks.
When I was discussing alternatives to Perl with people, the defenders of Perl were uniformly people who didnât have extensive experience with any other language. Defenders of PHP 4 are often the sameâthey donât know anything about any other language because they donât have toâPHP is so popular that they could program in it for the rest of their lives and never see another language. Iâm not saying that either of those languages suckâthey have their uses. Iâm just pointing out that itâs interesting that most of the arguers in this fieldâon either sideâare uninformed.
-Max
Very good article!.. I agree, PHP may have its downfalls, but all can be resolved with good coding practices, and future releases. The same thing has happened with dozens of other ânon-professionalâ languages. Also, PHP is easy to configure and install, regardless of the machine it is on, and all of its weaknesses are well-documented, with work-arounds readily available to everyone. Also, I think an environment where you can make mistakes will teach you not to make them more effectively than one where mistakes are impossible, or unlikely.
To use an analogy:
Fancy running shoes wonât make you a sprinter, the best ingredients in the world wonât make you a chef and world-class paints and paintbrushes wonât make you an artist⌠only hard work, practice, patience and some talent can.
Iâve always thought that learning how to program is more important than learning a particular language, or how to use a particular editor.