tags:

views:

answers:

I made a tongue-in-cheek comment in another question thread calling PHP a terrible language and it got down-voted like crazy. Apparently there are lots of people here who love PHP.

So I'm genuinely curious. What am I missing? What makes PHP a good language?

Here are my reasons for disliking it:

PHP has inconsistent naming of built-in and library functions. Predictable naming patterns are important in any design.

PHP has inconsistent parameter ordering of built-in functions, eg array_map vs. array_filter which is annoying in the simple cases and raises all sorts of unexpected behaviour or worse.

The PHP developers constantly deprecate built-in functions and lower-level functionality. A good example is when they deprecated pass-by-reference for functions. This created a nightmare for anyone doing, say, function callbacks.

A lack of consideration in redesign. The above deprecation eliminated the ability to, in many cases, provide default keyword values for functions. They fixed this in PHP 5, but they deprecated the pass-by-reference in PHP 4!

Poor execution of name spaces (formerly no name spaces at all). Now that name spaces exist, what do we use as the dereference character? Backslash! The character used universally for escaping, even in PHP!

Overly-broad implicit type conversion leads to bugs. I have no problem with implicit conversions of, say, float to integer or back again. But PHP (last I checked) will happily attempt to magically convert an array to an integer.

Poor recursion performance. Recursion is a fundamentally important tool for writing in any language; it can make complex algorithms far simpler. Poor support is inexcusable.

Functions are case insensitive. I have no idea what they were thinking on this one. A programming language is a way to specify behavior to both a computer and a reader of the code without ambiguity. Case insensitivity introduces much ambiguity.

PHP encourages (practically requires) a coupling of processing with presentation. Yes, you can write PHP that doesn't do so, but it's actually easier to write code in the incorrect (from a sound design perspective) manner.

PHP performance is abysmal without caching. Does anyone sell a commercial caching product for PHP? Oh, look, the designers of PHP do.

Worst of all, PHP convinces people that designing web applications is easy. And it does indeed make much of the effort involved much easier. But the fact is, designing a web application that is both secure and efficient is a very difficult task.

By convincing so many to take up programming, PHP has taught an entire subgroup of programmers bad habits and bad design. It's given them access to capabilities that they lack the understanding to use safely. This has led to PHP's reputation as being insecure.

(However, I will readily admit that PHP is no more or less secure than any other web programming language.)

What is it that I'm missing about PHP? I'm seeing an organically-grown, poorly-managed mess of a language that's spawning poor programmers.

@Christopher: in college you learn what "good code" is. Granted, there are other ways, but when a nonprogrammer learns PHP as her first language, I doubt she will write programs following accepted standards in other languages later on.

@Willi: I'll define good code for you then: gets the job done, and gets the money into the business. plenty of php code does that. Doesn't follow "Approved Standards"? Many people only care about the money. Academia vs MainStreet.

Also, this is why I got so annoyed with the inconsistent library/built-in names. Consistent naming patterns are an important, though subtle, aspect of good coding style. Ideally, a programmer in a given language will adopt the same naming style as the standard library, to ensure that all code is consistent in this regard, including library and built-in calls. But if the library and built-in calls are inconsistent, you've literally been barred from adhering to a properly consistent naming style.

ROFL. so true. when someone writes something in php and it gets to me. for the life of me i cant figure out what the hell the guy was thinking. but one problem i have is i cant find anyone nearby who knows php rather than the forums. all i can find is asp.net people. and anything made by microsoft that is forced to operate on a windows i am against.

Every PHP developer has a different way of doing things. I think this is a good thing and a bad thing. The problem is that very bad developers can get something to work as well as a very good programmer from the perspective of a client, who doesn't see code but the front end works fine. I often get work to update existing PHP project and I'm astounded at how bad the code is. The client ends up paying double since half my time is spent fixing old code.

Here's what I think: ok, it's not perfect, but if you want to put something together reasonably quickly which is not hugely complex, then PHP is (in my opinion) the best way to do it, particularly if it's a web application with a database back-end. I guess the real point is that for people who know how to program but don't want to get into the complexities of Django etc., PHP is very handy.

Well, there I agree with you. I've built a pretty large project in PHP, and while it was successful, it was a bit of a nightmare, and I wouldn't choose to go down that route again for a large project. I guess the reason people use it in those situations is familiarity and simplicity.

All your criticisms (and some more) are valid. You are allowed and even expected to hate PHP.

But, then again, it has some benefits:

Ubiquitous

Fast (especially using opcode caches)

Huge community (and great documentation)

Works

Finally, you can overcome many if not all the downsides by writing good code you'd write in any other language. You can write solid, secure and good smelling code in PHP, which many times will run faster and be easier to host and to scale than many alternatives.

I can agree with you on all but fast. If you mean fast to develop, sure. If you mean performance, to get good performance out of PHP on a large project you HAVE to use caching, and that makes things rather complex.

Yup, it is what it is. You get some benefits and get some awful cons. There's a reason why most well trained programmers do hate PHP, you know :-) In any case, your complaints that cannot be solved by coding practices are just annoyances, you can ignore them or work around them.

"are just annoyances, you can ignore them or work around them." I would class them as more than annoyances. One of the corner stones of good software is consistency. If your language of choice is an inconsistent mess like PHP, then the chances of consistent apps being developed on it are lower.

Sometimes there is no choice, but you are forced to work on a language. And in that case, you can work around the inconsistencies. Seems like I must make clear my language of choice is _ANYTHING BUT PHP_, well, anything no. I still prefer PHP to Brainfuck or INTERCAL, sorry.

"Fast" - Yes, typically computers do run fast. As opposed to manually processing information with pen and paper. As for fast compared to native machine code - no. Fast enough? For some cases, but not all.

I don't think any of those are specific to PHP, though. I can say the same thing about .NET, too. Granted, there aren't as many open source projects, but there are quite a few. As for the jobs aspect, the lack of competitive pay is the reason I changed platforms when .NET came out.

Any tool, in the hands of an amateur, can become dangerous. So I wouldn't blame PHP for what people do or don't do with it, despite its apparent flaws.

PHP can be used to develop secure and robust web apps that are just as well designed as anything written in .NET, as long as you know what you're doing.

Perhaps the equally relevant question to ask is what language would you consider superior?

In my office we use PHP because of the low overhead in getting started with it because we use a LAMPP stack where everything FOSS. Running on a Microsoft platform would run my company into the ground. So I guess one valid reason that companies go with PHP is because its FOSS.

The other reason that I've seen others point out is that it gets used by many individuals for their own personal projects, and as a way for them to enter the world of web programming. I personally don't see anything wrong this. Everyone has to start somewhere, and no one is born writing beautiful code. Its something that we all grow into.

I think that other languages discourage what you might classify as bad practices by their very nature which is something that PHP doesn't do very well, but I wouldn't discount the language out of hand.

Full disclosure: my language of choices for web apps is Python, using Django. It has its own flaws, but a lot to recommend it. But to directly address your answer, 7 out of 10 of my complaints cannot be resolved by good coding practice. Do you consider those 7 complaints irrelevant?

No, PHP is definitely a red-headed, ugly step-child of a language. I don't know there's any justification for its eminence in the web development considering that Python and Java are also used for web development are probably both more elegant than PHP.

I work with PHP (Symfony), Django and Java (Echo2) and, for a basic content driven user facing site Symfony is the easiest. Django is more powerful but time consuming. Java is great for web apps but tricky for the basics. For some things, and despite it's flaws, PHP "just works".

@Andrei: I was under the impression that the VS Express products where only good for non-commercial use. If we could use .NET products for free in our office then the biggest downer would just be retraining staff and the fact that I personally despise anything Microsoft.

@gabriel1836: A license for Server 2003 Web Edition (the last one I bought) costs roughly $500. It comes with everything you need. If you don't have that kind of money to spend on web server software, then your company has other problems that it needs to fix first.

Alright, that's an answer I can get behind. The docs are good. But I'm curious; what about the class system is better? I recall it being rather short on features. Functions aren't first-class, IIRC, and you can't inherit from built-in data types, just to name a couple of shortcomings.

@Dana: PEAR is essentially an officially-hosted library repository. If they added "requires complete documentation" to the requirements for releasing there you might find it picks up but submissions would drop right down.

Really? My biggest complaint about PHP was the documentation. I found that the examples were often using so many shortcuts and tricks that to understand one example, I'd need to look up 5 more functions. The documentation is well-organized, and there's plenty of it, I just dont find quality in it.

I agree with nerdabilly - The documentation is not just poor but in some cases plain wrong: http://www.php.net/manual/en/function.date.php you can't call date() multiple times in one function - the date changes at midnight and many of these examples would come up with a wrong date/time combo, and when I posted that observation they deleted my posting!

Probably the same reason people like VB. It looks easy for a newbie to jump into. Then, once you learn a little bit about it, you want to protect the time investment you spent to learn it, which can translate into refusing to learn another language, or flaming people on the internet who disagree with you

The comparison between VB and PHP is a valid comparison, both languages I consider 'entry level' languages that let you get things done and learn about programming. I'm not saying that you cannot do anything useful with them, they just tend to be considered 'easy'. You gotta start somewhere.

Every point you make about PHP is correct, but the alternatives aren't silver bullets either.

In strongly typed languages, such as C#, you spend a lot of time casting your data types for use in various objects. In 99.999% of apps written, the efficiency that strict data typing offers doesn't matter. Most of us are writing CRUD apps, and the only bottleneck is poorly written SQL code.

PHP has it's merits for the some of the reasons why VB6 was so popular (well without the stellar IDE), anybody with a head on their shoulders can attempt to write an application, and do it fairly quickly. Good devs can write good apps, bad devs write bad apps, but at least they still work.

You need to spend less time worrying about camel case vs underscore separated functions and provide solutions to your customers (or company). Excuse the lure of a car analogy, but I really don't want my mechanic telling me how my Nissan values are coated in iodized aluminum or plated alumnium. In the grand scene of things, PHP is far from a bad language. It fills a very important niche that fuels a large part of the web. And somebody who is focusing on trivial things to decide their platform are worrying about unimportant things.

I code in both C# ASP.NET and PHP, but when I start personal projects, I almost always choose PHP because the ROI of my time is much greater. The only time I prefer C# is for desktop applications (for obvious reasons).

I'm not worried about Camel case versus underscored. I'm worried about a language that thinks a reference to MyToken and a reference to mytoken are equivalent. I'm worried about a language where half the built-ins are Camel case and the other half are underscored.

Sure, I don't want to be concerned with the coating of my car's valves. **But my car's engineer sure as hell should be.** And you'd better believe that your mechanic cares too. I'm not debating PHP with my employers, I'm trying to discuss it on a discussion forum. Why are you so dismissive?

Bzzt, wrong. Strongly typed has nothing to do with casting. Python has a strong type system and it has no cast operator at all! Also, using a statically typed language doesn't mean that you have to spend a lot of time casting. Haskell is a statically typed language but the compiler does type inference for you and typecasts automatically. Even C# has generics, which eliminate 99% of all the places I would use casts in my code, and the `var` keyword, which eliminates most of your type declarations too.

Just wanted to say I voted you up. You were voted down and I don't see why. My first thought is that you were the only one to actually offer your own arguments for php, and some "php only!" jerk voted you down.It's a shame when people misuse the system like that.

"PHP has functions in C which are fast if you know how to use them. Used correctly they can do many things faster than python and perl."Both Perl and Python have functions implemented in C, so I rally don't understand this statement.

@OIS I don't think that's accurate, see http://docs.python.org/library/ "The library contains built-in modules (written in C) that provide access to system functionality such as file I/O that would otherwise be inaccessible to Python programmers" Not a trivial addition to the stdlib.

PHP has inconsistent naming of
built-in and library functions.
Predictable naming patterns are
important in any design.

I both love and hate this topic. Because at its core, this issue is correct. Why are some bi-word function split with an underscore, and some aren't? Why do needle and haystack parameters swap positions in the argument signature sometimes? It's ridiculous. But at the end of the day... does this really matter? My IDE with intellisense and php.net just a browser click away, this is just plain not that big of a deal. Is it a negative against PHP as a language? Yes. Does it hinder my ability to be an effective programmer? No.

The PHP developers constantly
deprecate built-in functions and
lower-level functionality. A good
example is when they deprecated
pass-by-reference for functions. This
created a nightmare for anyone doing,
say, function callbacks.

Personally, I think this is not a good point. Deprecation is necessary to the evolution of a language, especially one that has as much kruft as PHP does. PHP gets a lot of flak for "making it easy to be a bad programmer*" but at the same time, the PHP group also gets in trouble when they try to remove stupid constructs from the language, such as call-time pass-by-reference. Eliminating call-time pass-by-reference was one of the best moves they ever made. There was no easier way for a novice developer to shoot themselves in the foot than with this "feature".

A lack of consideration in redesign.
The above deprecation eliminated the
ability to, in many cases, provide
default keyword values for functions.
They fixed this in PHP 5, but they
deprecated the pass-by-reference in
PHP 4!

I don't think there's a general lack of consideration at all, I think you just got stung by this particular change and have been left with a sour taste in your mouth. Language changes are often known months if not years ahead of time. A migration guide was provided for the move from 4 to 5, and the version differences are documented in the manual. Call-time pass-by-reference was a horrible "feature" and doesn't give the developer any expressive power they can't get by other means. I'm glad it is gone (along with other crap like magic quotes)

Poor execution of name spaces
(formerly no name spaces at all). Now
that name spaces exist, what do we use
as the dereference character?
Backslash! The character used
universally for escaping, even in PHP!

I have mixed feelings about this. Part of me thinks "who cares, character escaping has no meaning outside of a string anyway", and part of me thinks "surely they could use something better". But could they? I don't know, I'm not a developer for the Zend parser. Is it a huge oversight that until 5.3 PHP never had namespaces at all? Yes, absolutely.

Overly-broad implicit type conversion
leads to bugs. I have no problem with
implicit conversions of, say, float to
integer or back again. But PHP (last I
checked) will happily attempt to
magically convert an array to an
integer.

I think it's ok to disagree with how PHP does this, but disagree that it makes the language "bad". But ask me how much I want to sit in this topic and argue about dynamic vs static typing. (P.S. I don't, at all) For the record: PHP will issue an E_WARNING level error when the type of an argument matters and cannot by solved by coercion.

Poor recursion performance. Recursion
is a fundamentally important tool for
writing in any language; it can make
complex algorithms far simpler. Poor
support is inexcusable.

PHP is a DSL for the web. I've been doing it full-time for 8 years and have maybe used recursion 4 or 5 times, usually for some type of annoying directory or XML traversal. It's just not a pattern that is needed for web development that often. I'm not excusing the slow performance, but this is an academic issue far more than it is a production issue. If you need really powerful recursive performance, PHP is already the wrong language for you.

Functions are case insensitive. I have
no idea what they were thinking on
this one. A programming language is a
way to specify behavior to both a
computer and a reader of the code
without ambiguity. Case insensitivity
introduces much ambiguity.

I totally 100% agree with this.

PHP encourages (practically requires)
a coupling of processing with
presentation. Yes, you can write PHP
that doesn't do so, but it's actually
easier to write code in the incorrect
(from a sound design perspective)
manner.

*Hmmm, this topic sounds desperately familiar...

But seriously, I find it remarkable that people will complain about a language that will absolutely 100% let you implement any output system you want (the sheer volume and style of PHP templating systems alone speaks to this) - OR - skip all that overhead and just output directly. This does not make PHP bad at all. It's part of what makes PHP good.

PHP performance is abysmal without
caching. Does anyone sell a commercial
caching product for PHP? Oh, look, the
designers of PHP do.

Do you mean bytecode caching (like an accelerator), or output caching?

If the former, then I don't really know how much I care about this topic. Accelerators are free and easy to run. We could argue about why it isn't part of the language but in the end, I don't think it matters much.

If you are talking about output caching then I don't know what to say to you. ANY web project with significant traffic needs caching (seed podcast #27, for example). This is not a PHP-specific issue at all.

In summary, I think you consider PHP a "bad" language in a very academic fashion. And in your previous post you were probably voted down by people like me who use PHP to "get things done".

I've seen too many PHP applications being drop and rewritten because they are unmaintainable. I don't know if this trend says something (other than it is actually easy to get a PHP application built and running... ;-)

The whole point is, being it a bad language in an academic fashion, there are plenty of good languages in both academic and practical fashion, and that irritates the hell out of many people. That, and the awful amount of lousy PHP around (which is just a matter of scale, I think.)

The irritation is fine as long as people understand why PHP is popular: 1) low barrier of entry for new developers 2) came out at right time. PHP's popularity has nothing to do with it a good language in an academic sense.

I'm not complaining about implicit type conversion at all, when it's sensible. I guess my complaint there is that often, PHP (at least in the past) will attempt to make implicit conversions that *don't* make sense.

Care to highlight a situation where the type conversion really caused a probably, or does it just bug you on principle. Because, as I said, something like array_key_exists( 'key', 1 ) WILL throw an error.

I suppose it's the magical implementation that bugs me on principle. In python there are exposed "private" functions for every single type conversion, which can be read, overwritten, or specified on any custom object class. I guess under-the-hood "magic" just unnerves me.

Actually, I can also state this: I prefer implicit conversion only when it's used to take a value and render it to a valid subclass of the same superset. For example, a real number to a complex number.

"the implicit type conversion is not a static vs. dynamic typing issue. this can be done in both kinds of languages." Then what is the definition f "static typing"? Or are you saying "static typing != strong typing/dynamic typing != weak typing" (which I agree with)?

Currently, Zend Studio 5.5. I've been with the Zend IDE for about 3 years now. I'm testing their next version (Zend Studio 6 aka Zend Studio for Eclipse) but still use 5.5 for all my production work. I think once I become a bit more used to 6 I'll port all my projects over.

There's too much freedom in PHP. And too much freedom never leads to good things. That's why I've seen dozens of php sites get re-written several times wasting money and time. Ofcourse if they were written carefully (IN PHP) they would have been ok today but having the freedom to write crap..

I'm in much of the same boat as you are. PHP is around and it's likely to be here for several more years to come. It's quite irritating when going through reddit/SO/etc the amount of flack that PHP gets by people who don't understand the language. **All languages have quirks,** and those who use it often come to enjoy and even rely on them (from time to time). Personally, I enjoy PHP because it allows me to get stuff done AND get paid

Unpredictable parameter order may not matter while you're writing code in an IDE, but it does matter for code reviews. And reading code you're not familiar with (which includes your own code after a couple of months). And even for reviewing your diffs before you commit. "Use the IDE" really doesn't cut it.

I would say being relient on your IDE does hinder your ability to be an effective programmer, or at least I found that to be the case. Hearing the argument that an IDE's intellisense is so good that it makes up for the language's inadequacies is not a credit to the language. PHP.net is a wonderful website, but I found myself referencing it way too much. I programed PHP for 5 years and I would constantly find myself looking up some of the most basic functions because I could not remember the argument order or what the function would return because of inconsistency.

@Sean "I would say being relient on your IDE does hinder your ability to be an effective programmer, or at least I found that to be the case." How exactly does that hinder one's effectiveness? Spell it out for me like I'm a 4 year old. Are you saying you *weren't* using an IDE therefore had to look up functions all the time? I don't like that argument either. Name me one professional Java or .NET developer that doesn't use an IDE.

While people may argue that by scale alone any language will have shit (look at java) it is not the argument. The argument about PHP's coding crap is in the fact that if you are selling a web framework/language you better be selling a good one. If ruby on rails/django was a big heap of crap out-of-the-box that is only useful if you replace everything and the kitchen sink before it becomes decent for building fairly well structured, well performing, fairly secure applications, would they be so loved?

@Dmitriy while I respect the point you're making, in doing so you are completely ignoring the individual histories of the tools/language involved. PHP didn't set out to be what people used it for when it was launched - quite dissimilar to RoR. And really I'm of the opinion that this topic is about how PHP is as a standalone entity, not as it compares to parallel technologies, be them older or younger.

@Peter Bailey: We are not being sold Toyota Camry '89 edition today, because it is crap comparably. If PHP is the same we should stop it as well. As standalone PHP does not come out-of-the-box with tools like sql paramater substitutions, you gota roll your own (yes there are some out there) but things being shipped this way today compared to what frameworks like RoR and Django offer is quite inferior. My info may be a year or 2 out-of-date :(

Yes, PHP is inferior to other techologies out there. But this topic was *never* about that. Besides, any car analogy (or any analogy where you refer to a physical good) is doomed to fail. Software just can't be compared to white goods like that.

@killown - Stack Overflow is a place for mature, informed, and collaborative, and friendly discussion on programming and programming topics - not flame wars. Please consider exactly what you're contributing to the community or conversation before making comments like this.

"PHP is a DSL for the web. I've been doing it full-time for 8 years and have maybe used recursion 4 or 5 times... It's just not a pattern that is needed for web development that often." I've been using PHP to build websites for 10 years, of which 6 have been full-time work, rather than hobby-jobs. In that time, I have used for and while loops recursion almost daily. You must be using a library or frame work that does the recursion for you ...

@phalacee - You write recursive algorithms nearly daily? I seriously, *seriously* doubt that. Either you don't understand recursion, you work in some crazy niche part of the industry where it's common to need it, or you're using it where you shouldn't be.

@Peter: I never said I write them daily, only that I use them daily. I re-use code I've already written. The code is for traversing a directory and all sub-directories creating thumb-nails of all the images it finds.

Ok, so what did you say that contradicts my point? First of all, you're doing directory traveresal which I specified in my answer. Secondly, that's clearly an offline task, so super high performance isn't critical. And thirdly, that's not really a web task. Sure, PHP can do it, and do as part of a web process, but another language could do it just as well - which I *also* said in my answer. And really, when I said "used", I meant "wrote".

What is it that I'm missing about PHP?
I'm seeing an organically-grown,
poorly-managed mess of a language
that's spawning poor programmers.

Simple. The fact that poor programmers get very defensive about their language. ;)
PHP is easy to learn, much easier than the alternatives, and once you've learned it, it's not exactly obvious 1) what's wrong with PHP, 2) how the alternatives are better, and 3) how to switch to, and learn, one of the alternatives.

And perhaps the fact that, well, what alternatives do people have? ASP? That has plenty of problems on its own, from being unable to run on the majority of webservers (Apache), to some ridiculous and overengineered design choices on its own (webforms? Viewstate? AJAX where your asynchronous" requests are intercepted and run sequentially?)
Ruby on Rails? Well, perhaps, except how many webservers support it again? It's not exactly easily approachable at the moment. And it's slow.
So perhaps PHP's "strength" is really that no good alternative exists.
At least this is why I stay away from all web programming when at all possible. PHP sucks, and I'm not too keen on any of the alternatives either.

PHP has so many fundamental problems that it's not even funny. From the lack of unicode support, to the many implicit type conversions which often lead to unexpected security holes, to the complete mixing of presentation and... everything else, or to the default database module which doesn't (last I checked) use parametrized queries. We're talking about a language made for two things, database access and generating HTML, and which is terrible at both.

It's just a nasty mess, a language designed by people who aren't qualified, or able, to design a language. ;)

Additionally, there are many fine programmers working in PHP but you can generally recognize them because they'll stand up and agree that PHP is an ugly language. However, what it does do, it does pretty well in the right hands.

gabriel: That's one problem solved then, but it's symptomatic that it took them what, a decade to get there? Now, wake me up when they get proper, consistent and correct unicode handling, will you? In the right hands, a overripe banana can be used to hammer nails. That doesn't justify its use.

@Jalf: Show me how you drive nails in with an overripe banana. I agree PHP has a lot of flaws, but for all its flaws, it is also a very simple and effective scripting language that will let the general public get things done.

It is not simple. You just only stumble across the complexities by accident, usually without noticing. There are other simple and effective scripting languages that lets the general public get things done. PHP is a messy, inconsistent language which lets the general public create problems.

What about it? Does it run on your average $5/month Apache webhost? If not, it's not an option for the vast majority of web development.And @Fire Crow, thank you for proving that ignorance is still flourishing among PHP developers. Presumably you actually code your websites in assembler then?

"to the complete mixing of presentation and... everything else..." As we've already established, PHP doesn't impose mixing concerns. If mixing is an issue, it's because the developer didn't understand separation of concerns. And PHP includes a variety of libraries for properly parameterizing queries. While I agree PHP has it's faults, your tone is poor and outside of your point on Unicode (which is coming in PHP6) your facts...well, aren't.

However, I would argue that a major reason it is so popular, so useful, is precisely because it doesn't have those features.

An example: How many times have you seen a loop over database results several times in a web app? Loop to fetch from the database, loop to convert it to application objects, loop to apply special formatting, loop for a few hacks, loop to display. And in php, you're probably copying the array for each loop.

Thats a lot of looping. If you use generators, you can preserver all that looping and eliminate all of it. But now you've introduced a fairly complicated concept, one that needs to be understood fully (much like threading must be).

While I don't mean to speak ill of web developers, the majority of them aren't the cream of the crop. Introducing complexity like a generator will at best make no difference, at worst, do more harm than good.

With that said, it has some good reasons for sticking around: its very easy to understand, its pretty much everywhere, and it has strong library support. Those mean a lot when you need to make something and make it fast, which almost webapps need to do.

While you say that it promotes bad design and coding, I would say thats more the nature of web development. Too many times I've seen something simple have crazy, from a software perspective, requests made of it. To the clients, these request aren't crazy. They want VP's to not require validation, or anonymous access to be moderated, or a certain use case to display a special message, or some strange integration for a specific use-case.

My point is, a web app is custom glue code. It glues everything together, just how you want it, and its going to be ugly after a few iterations.

Anyways, my flight is about to board, so in a nutshell: PHP isn't a bad language, but its impoverishing when you need to do some really neat things the right way.

Wow, as if all the people trashing PHP wasn't bad enough, you decide to go after an entire group of programmers. Elitism doesn't serve anybody. Yes, PHP is easy to learn, and doesn't look very pretty. It can also create excellent applications with a decent programmer behind it, like any language.

But that doesn't invalidate his point. If a language's main feature is that it's simplistic at the expense of power and "correctness" (from a design perspective), it's valid to point out that its supporters are going to *tend* to be "lesser" programmers in terms of knowledge and talent.

PHP gets a bad rap because of its availability and shallow learning curve. Yes, a good programmer can make some incredible, secure, fast applications with PHP, but a novice with minimal skills can figure out the PHP basics within a few days. It also helps PHP is offered by 99% of hosting providers for $4.99 a month.

Visually, PHP is the most beautiful language. It's short, concise, and readable. Plus the dollar signs stand out so it's easy to skim through and find variables. The same couldn't be said of wall-of-verbose-text Java.

Like so many other things in this world, being the most popular, most widely used, and most readily available does not mean that a product is of the highest quality.

A big part of the lure of PHP is its availability and ubiquitousness.

as I posted in a comment above, my biggest complaint with PHP was its documentation. The organization and quantity was fine, but I found that things were not explained well, in a way that a newbie or non-programmer would understand, and that the examples would only add to the confusion by using shortcuts, trickery, and esoteric functions.

I'm in a similar spot, and while there's a lot I don't like about it, I'll probably switch to using PHP as my primary development language because its one of the few that lets me not worry about if its a Widows Server or if its a Linux server etc.

PHP has inconsistent naming of built-in and library functions. Predictable naming patterns are important in any design.

Yes, this is annoying. However, anyone who's doing serious development in PHP is going to have them memorised quickly, and what's not memorised is very easily found in PHP's online documentation. I don't feel that this inconsistency slows me down at all.

The PHP developers constantly deprecate built-in functions and lower-level functionality. A good example is when they deprecated pass-by-reference for functions. This created a nightmare for anyone doing, say, function callbacks.

Only if they upgrade unwisely. PHP4 didn't end-of-lifed until three years after PHP*5* was released. Three years to transition to a new version is plenty of time to fix things like that, and deprecating crappy ways of doing things is important to the rational evolution of a language.

Poor execution of name spaces (formerly no name spaces at all). Now that name spaces exist, what do we use as the dereference character? Backslash! The character used universally for escaping, even in PHP!

Backslash is used universally for escaping within strings. It has no meaning outside of one. Again, this is the sort of criticism that is meaningless after a few days using the language.

Overly-broad implicit type conversion leads to bugs. I have no problem with implicit conversions of, say, float to integer or back again. But PHP (last I checked) will happily attempt to magically convert an array to an integer.

I can state categorically that I have never, ever had a problem caused by accidentally turning an array into an integer.

Poor recursion performance. Recursion is a fundamentally important tool for writing in any language; it can make complex algorithms far simpler. Poor support is inexcusable.

Can't personally speak to that - I haven't seen or performed benchmarks. I don't use recursion much at all, though.

Functions are case insensitive. I have no idea what they were thinking on this one. A programming language is a way to specify behavior to both a computer and a reader of the code without ambiguity. Case insensitivity introduces much ambiguity.

PHP'll throw an error if you try to redefine an existing function, so what's the risk here? What ambiguity is introduced here - can you offer any concrete examples?

PHP encourages (practically requires) a coupling of processing with presentation. Yes, you can write PHP that doesn't do so, but it's actually easier to write code in the incorrect (from a sound design perspective) manner.

One can write crappy code in C++ or Java, too. I find the ability to do this a positive feature of PHP, too - if I were to choose a programming language to teach a six year old basic programming, it'd probably be PHP. Yes, the ability for anyone to pick up some PHP has led to a lot of bad code out there, but I consider more people having the opportunity to learn to code a good thing.

PHP performance is abysmal without caching. Does anyone sell a commercial caching product for PHP? Oh, look, the designers of PHP do.

Your last, and least compelling. So what? There are a variety of non-commercial caching products for PHP. You have options, and there's no reason the maintainers of PHP shouldn't be allowed to try to profit off their expertise. You're best off paying for a Windows and Visual Studio license to develop in .NET, but no one rational bashes the platform based on that.

These are not your reasons for disliking PHP. These are your excuses for not even giving it a chance.

Sure, here's an example. It's fairly common in object-oriented languages to have a class definition be title-cased (e.g., Thread) and an instance be lower-cased (thread). In expressive languages, function factories follow the same convention (e.g., tostring = ToString(...)).

Also, regarding the "not giving it a chance", I programmed in PHP for years. Granted, this was several years ago, but I walked into the experience thinking, "Awesome, a cool new web language!" and left that experience vowing to never use it again unless I was *starving* and only PHP was paying.

Dot was already taken for concatenation, so that wasn't an option. Since php, js, and java came out the same year, there wasn't a consensus yet. I'm sure if they decided to start from scratch, they would follow the current norms.

You can find a php job very easily, even if you are not competent, thanks to its ubiquity.
Your non-programmer employer most likely expect you to be replaceable in case. But you can thwart their expectations by writing tricky and horrible code (as in type coercion) which you get to maintain longer than they would keep you otherwise. Few languages helps you write as bad code better than php.

A couple of people at my university were talking about how bad PHP is recently.

My opinion is that anyone with any knowledge of other programming languages shouldn't even be wasting their time talking about how bad PHP is, they just should use something better and forget about it.

However, I also take slight issue with completely writing off PHP as I only entered my programming career through PHP.

This may sound absolutely mad, but to me PHP almost fits into the same category as C and Lisp as being a language that more or less nails what it is trying to do in a fairly in a fairly fundamental way.

My explanation to them was simply: "PHP went down the simplicity road from C and I think it stopped at more or less the right place."

Edit:
When you look at the bad code from PHP programmers, you are looking at the code from people who didn't graduate to bigger things, is it really surprising that they write poorer code? Even for the people who did move on, you are still looking at their first programs, before they learned better programming ideas. I can tell you, my PHP code written after learning Lisp is indistinguishable from the code I wrote a year ago in PHP.

The problem is that PHP does not nail what it was meant to do. It was meant to access a database, and produce HTML. And it sucks at both. Database access typically without parametrized queries, and (x)html in a language which doesn't support Unicode? And where you manually have to escape everything

The existence of mysql_real_escape_string speaks volumes not only about the security of PHP, but also about the joys of having completely different APIs for accessing different databases. Thank god for PDO.

@mabwi: Wrong. A language that advertises itself as being simple for new programmers to use should be protecting that user from the most glaring mistakes of usage. I would assume this is why PHP doesn't, for example, require memory management or expose pointers.

This whole answer is plain stupid. I'm sorry but I prefer to say it directly rather than lying. What's wrong with MS Word? At least the author of this question said what he thinks is wrong with PHP. You didn't. (regarding MS Word).

Only call-time pass by reference is deprecated. So you can function f(& $var) and when you call f($a) then $var and $a are the same in the symbol table. But you can't take function h($var) and f(& $a) without getting the warning. But even if it where, you can always use an object since they're always passed-by-reference.

I'm not sure how call-time pass-by-reference being deprecated causes problems for function callbacks: perhaps you are thinking of callbacks from a C++ perspective. In PHP you can call a global function by it's name such as $fname = 'func_name'; $fname(). There's also call_user_func_array() and the reflection classes to call functions and methods.

The inconsistent function naming and argument order is a pain, but an IDE can mitigate much of that unpleasantness. That said, I still get my $needle and $haystack out of order more often than I care to admit.

As for performance, let me say that I've never used PHP without the APC extension for caching. Even then, function calls and some of the language magic can really start to add up and bog down performance. But 99.9% of the projects I do in PHP are very thin layers on top of a database. When we have projects that require more complex logic and processing, we do that in C or Java. With the PHP-Java bridge or Quercus you can easily interface Java and PHP. You can also write an extension in C or C++ for PHP.

To your point of ambiguity, case insensitivity is not ambiguous, I bet you know exactly what will happen if you call my_func() versus my_Func(). Honestly, I don't see why you'd want there to be different behaviors for functions based on their case. Variables, I can see, especially for people using a lot of linear algebra or statistics, but PHP isn't really the language for those types of algorithms since it's slow.

One feature that I enjoy about PHP is that it is not strictly typed. I wish its type hinting were more robust, but if you compare the number of times I’ve made errors where type checking would have caught it in PHP versus the number of times I’ve had to go through typecasting hell, well, let’s just say I like this about PHP.

As for separating display from logic, you should check out Code Igniter or Kohana, or any of the n PHP frameworks that pride themselves on doing that.

Sorry, but case insensitivity IS ambiguous. A computer language is not a speaking language. It is a mathematical language. If you try and argue otherwise, I'd like to remind you that your computer is nothing more than an exceedingly complex adding machine.

Now, to directly reply to your own post, you point out that functions can be used as arguments. That they can be treated as values. Then you also say you can understand it being ambiguous for variable names. *If you can treat a function as a value then it IS a variable.*

A name token, be it for a variable, a function, etc, is a stand-in name for a memory reference. If I tell PHP to make a function "my_funct", then allowing a reference to "my_Funct" to access my function is a case of the compiler disregarding my specification. How can I trust such a compiler?

"If you can treat a function as a value then it is a variable." Then values are variables, so 1 and 2.3 are variables... you live in a frighteningly variable world. Math, mind you, uses font and case to differentiate variables as well. You wanna make italics part of your language?

Nobody cares if you think PHP is horrible. Comparing programming languages is like comparing tools: Convince me hammers aren't horrible! The truth is, you aren't limited to just using one language, use many languages. Choose the ones you think will best accomplish your goals.

A factory some decades ago created high-quality watches with glow-in-the-dark faces. Great product, fashionable and durable. Also, most of the factory workers got cancer due to the production methods which exposed them to radiation. The quality of the end-product doesn't obviate concern re:tools.

An extreme comparison, but it makes the logical point that the end product excuses nothing. Maybe PHP is the best production language for the web. So what? Slavery is the best crop production and factory production method. Does that excuse the valid arguments against slavery?

It's not an irrational perspective. The language you express yourself in does effect your thinking, down to the lowest levels. I'm not sure if you're bilingual, but even natural human languages have that effect.

I don't think the comparison was to slavery... perhaps it was a comparison to wrongful death? Every php project I've seen has "Important security vulerabilities" every two weeks. I can understand some vulnerabilities are not straightforward but php, as a language, positively fosters poor programming practices and vulnerable coding techniques. There are so many other languages out there that are more efficient, safer AND easier to use.

When I wrote this answer two years ago I was a PHP developer. I have since then contracted a serious mental illness from too many paamayim nekudotayim errors and unset variable notices. My company has also gone bankrupt and I am homeless. Thanks a lot, PHP.

There is a simple reason why PHP is popular. Most people developing software these days are self-taught programmers and frankly, nearly 80% of them are better off pouring concrete. So what's the best language to pick up and make easy money doing some contract work w/o actually having a degree? PHP! Any 14-year-old who dabbles in server-side scripting knows it. It's 3 times easier to find a PHP dev than Java, .NET and etc. Unfortunately the outcome is piles and piles of shitty unmaintainable code. Yes it is horrible, but its benefits (mainly maintenance costs), outweigh its cons.

FastCGI is available for IIS and Apache and it has some very cool features.
Do a Google search for "FastCGI — The Forgotten Treasure" for a detailed description of the context switching and multiplexing benefits of this technology.

You can write an application for it with any language including C, VB and FreeBasic.
(.BLOAT have their own 120MB run time module "solutions")

2008-11-22 16:01:13

of course you could write a web app with C. the question is why would you want to? string handling is atrocious in C. web programming IS string handling and lots of it. why make your life harder? I could never understand why anyone would write a web app in C.

I like PHP. It's comfortably similar to C and fairly easy to follow, depending on the way it's combined with HTML. I recently started using it for command line utilities too, and use it on almost all my website projects.

For comparison, last time I saw perl code I got a headache :(

As for "spawning poor programmers", I'd like to refer to the comfortable similarity to C and note that until quite recently I was a Basic nut. Many people told me to stop using Basic, and PHP really helped getting used to the idea of using C, so it can't be that bad ;)

What is it that I'm missing about PHP? I'm seeing an organically-grown, poorly-managed mess of a language that's spawning poor programmers.

Unfortunatelly i can't answer your question, because you're totally right in your post.

IMO the problem is that PHP isn't actually a formal programming language but something like a toolbox for developing html "templates". It was great 10 years ago, but today they are several best choices.

In fact PHP didn't make any futher progress since PHP3 appeared. Ok, ok they have added something similar as o.o. to Php4 and 5 ... but sorry guys this is not actually a Oriented Programming language.

As you i have several reasons to not consider it a formal programing language as Python or Ruby or Put-here-your-prefered-programming-language does.

Why isn't it OO language? Most OO patterns can be implemented in PHP5 just fine, and it made huuuge progress since PHP3. PHP3 was lousy template language. PHP5 is a decent language with lousy legacy templating syntax (which IMHO shouldn't be used).

Google 'PHP' and PHP related stuff: one will find results more than that of any programming language

PHP is open source and light weight

If one uses PHP for its core purpose i.e. scripting then, one won't find any significant side-effect in the language

Now from PHP 5, PHP can be considered as a pure Object Oriented language. There is interface, reflection, PHP Data Object (PDO) as kinda native data access layer or much like ADO.NET, type hinting and the list goes on.

please don't compare PHP with C# and/or Java. It's just not fair. If one only compares scripting part of these languages with PHP, it's far more easier to code in PHP.

And finally, rather than comparing languages it would be rather better to focus on using design patterns, test driven approach, object oriented doctrines and modularization concepts. Anyone can learn languages in a matter of time but once one have ideas about agile development, one can implement it in any language with ease.

I think before you can be convinced that PHP is a language worth keeping around, you need to recognise that the objections you have to it are just not obstacles to people who use it everyday.

At it's core, you have a language that provides an execution environment that is easy to setup and easy to begin to use. The language itself is highly orthogonal, which makes learning it easy. It does not come with a framework That You Must Use, or and IDE that is essential. It does not have a separate compile step. All this means you have a language that does what it does and gets out of the way. For programmers, this provides an almost blank sheet of paper to go off in whatever direction they choose to build what they need to build. The language is flexible enough that there is often a variety of ways to achieve the end-result, some better than others, but others are just one amongst equals. PHP makes things like strings and hash-tables first-class objects and provides a generous array of tools to manipulate them. There is a wide-range of built-in libraries and there is a wealth of third-party code to supplement this. In addition, it has all the tools and features to scale to massive massive websites on huge databases.

Some of its current problems are as a result of the language being forced to "grow up" as thousands (if not millions) of developers make it do things the designers never even thought of, let alone thought possible. Fixing these requires a slow and careful migration so that you pull along the bulk of the developers. Notice that it took some effort to get people off PHP v3 in the last two years - and v6 is just around the corner!

It is possible to write high quality code in PHP, with clean interfaces, good separation of logic and so on. The problem is that the average quality of PHP programmer does not reach that high. And you can't force them to be better -- because that simply doesn't work. They have to learn how themselves. If they are capable of learning. I've seen PHP programmers who are just incapable of getting beyond their current mediocre level.

PHP has a lot of warts, but it is effective and widespread. Just don't get hung up on what it does 'wrong' -- most PHP programmers don't and don't need to.

Yah, I said "PHP programmers" partly because that was the context of the question, but also because the ones I was thinking of knew *only* PHP. But yes, there are many programmers who will never be more than mediocre, and not just in web programming. I've met some in other areas.

Sure, PHP has warts and it lacks fancy meta-programming and syntactic sugar. But so what? It's more than capable for most web applications, it's relatively fast, its flaws are well understood and it has virtually universal support.

The bottom line is that PHP is (like every other language) nothing but a tool. Every job has a tool that suits it. PHP is greatly suited for quick, agile tasks that need to be done NOW.

In the real world, unfortunately, managers run the show. If a client needs a contact form, I can bang that out in 30 minutes using PHP (and even design it "properly" using an MVC architecture). Or, if I was a novice (and I say that in a loving way), I could wite the same form using ugly code, that works just as well.

Now, I started hating PHP after using it for several years for a few of the reasons listed above. Mostly, I disliked it's OOP implementation and hated the fact it was case insensitive.

As I look back on it though, I think the major problem isn't the language, but inexperienced programmers who are hired to write in it. It's the "cleaning up spilt milk" problem. About 90% of the legacy PHP code I've had to alter or maintain has been TERRIBLY written. It's not the languages fault, it's the inexperienced (or lazy) coder's fault. They took the hammer (PHP), and instead of simply driving a nail into a wall with it, they cooked spaghetti with it (successfully).

These days, I have been writing code in VBScript and Perl (NOT by choice, but gotta make a living). After working with those two nonsensical and disheveled languages, it really put PHP into perspective for me. I MISS PHP. I didn't realize what I had till I lost it.
Ever try to get the size of an array stored in a hash reference in Perl? I did. Took 2 hours and I didn't solve the problem. I was forced to do a hack. In PHP, I'd simply use count() and TA DAH! There is the size of the array (which is actually a hash in PHP but that's out of the scope of what I'm trying to say).

Does the language need improvements? Yes. Does the language have a poor governing body? Yes. But what are it's strong points? It's pretty simple:

EXCELLENT documentation

Quick turn-around time for development

A familiar, C style syntax

So in reality, It's not the language itself that's absolutely terrible, but the ironic fact that it was designed to be so quick and dirty to develop with, that it attracts poor programmers with poor programming practices.

It's ease of use is a double edged sword. It allows you to quickly write good code, just as easily as it allows you to quickly write bad code. So don't blame the gun, blame the guy who pulled the trigger.

But I'll tell ya one thing, If I had a choice between writing a web app in Perl through CGI, or using PHP; I'd use PHP in a HEARTBEAT.

2008-11-27 18:05:37

I agree with you in comparing Perl/CGI with PHP. However, regarding "don't blame the gun, blame the guy who pulled the trigger" if there are triggers all over the place you must be uber-careful where you step..

While I admit that Perl is neither pretty nor "easy", I would hardly call it nonsensical.I thought to myself "Hmm, that sounds interesting, the size of an array in a hash reference. Well, you deference the hash pointer with -> to get to the array (Simple enough, any undergrad should get that), then use it in a scalar context, which is the common way to get the length of an array. Well it must be more complicated after all his complaining..." So I tried it, and guess what: $hashRef->{"MyArray"} yielded "5" just like it was supposed to. Simple? No. Logical? Absolutely.

Other people have given a point by point rebuttal, but to take just one of your points -weak typing. Strong typing is taught as the one true way, but weakly typed languages tend to succeed in the market place - C vs Pascal etc. Java and its knock-offs are the only strongly typed languages that have succeeded.

Type checking just isn't that useful in practice, and it gets in the way more often than it actually helps.

Developers like PHP because it's sloppy and forgiving, Computer Scientists hate it for the same reason.

Strong typing is when you must declare ahead of use the type of a variable (integer, string, floating point). You don't do this in PHP but are required to in Java. To change the type in a strict environment you need to cast it.

PHP has inconsistent naming of
built-in and library functions.
Predictable naming patterns are
important in any design.

I heard Rasmus explain this at a conference. In the beginning he simply choose to use the same function names and parameters as the underlying C libraries. If you know the underlying libraries then you know what something probably will be in PHP.

i like php, using one of the many available mvc frameworks addresses most of issues pertaining to poor programming practices. you can use zend framework or one of my personal favorites the kohana framework written exclusively for php5.

I'll start by saying "a great developer can build quality software in any language", and "there are a lot of not-great php developers"...

PHP has inconsistent naming of
built-in and library functions.
Predictable naming patterns are
important in any design.

Sure, but any language that evolves runs into these kinds of issues. They're easily resolved by using an IDE such as "Zend Studio for Eclipse", which will auto-complete things for you, and hint at the right order for parameters.

The PHP developers constantly
deprecate built-in functions and
lower-level functionality. A good
example is when they deprecated
pass-by-reference for functions. This
created a nightmare for anyone doing,
say, function callbacks.

Python just launched version 3 of itself, totally breaking backward compatibility. At least PHP took a long time to do it, and they still support the 4.x branch that does it the old way.

Poor execution of name spaces
(formerly no name spaces at all). Now
that name spaces exist, what do we use
as the dereference character?
Backslash! The character used
universally for escaping, even in PHP!

I agree that backslash was a WTF moment.

Overly-broad implicit type conversion
leads to bugs. I have no problem with
implicit conversions of, say, float to
integer or back again. But PHP (last I
checked) will happily attempt to
magically convert an array to an
integer.

It can be very handy sometimes, and it can bit you in the butt at other times. The key is to validate or typecast your data before you use it.

Poor recursion performance. Recursion
is a fundamentally important tool for
writing in any language; it can make
complex algorithms far simpler. Poor
support is inexcusable.

I've never had a problem with it... of course, I've probably only used it once a year over the past 10 years. Most small-to-medium sized web apps just aren't complicated enough to require it.

Functions are case insensitive. I have
no idea what they were thinking on
this one. A programming language is a
way to specify behavior to both a
computer and a reader of the code
without ambiguity. Case insensitivity
introduces much ambiguity.

Most people I know are case insensitive, too. They can parse ALL CAPS and all lowers, and MixEd.

PHP encourages (practically requires)
a coupling of processing with
presentation. Yes, you can write PHP
that doesn't do so, but it's actually
easier to write code in the incorrect
(from a sound design perspective)
manner.

I totally disagree, and I'm sure everyone at www.smarty.net would disagree, too.
There are lots of templating systems written in/for PHP... BUT you have to have discipline when you use them. I would argue that being a good PHP developer requires more discipline than it does in many other languages specifically because PHP affords you so many opportunities to "do it your way".

PHP performance is abysmal without
caching. Does anyone sell a commercial
caching product for PHP? Oh, look, the
designers of PHP do.

PHP runs a lot of sites, and most of them don't use caching. I don't think it's as 'abysmal' as you say it is.

Worst of all, PHP convinces people
that designing web applications is
easy.

That's your "worst of all" ?? I think that's a great thing. It gets more people interested in computers & programming in general. It's a great "gateway language" that could lead to more hardcore languages in the future ;)

designing a web application that is
both secure and efficient is a very
difficult task.

It's a difficult task in any language.

By convincing so many to take up
programming, PHP has taught an entire
subgroup of programmers bad habits and
bad design

Your premise is flawed, good sir.
Convincing people to take up programming is entirely different from teaching bad habits & bad design. Either of those things can and does happen with any language.

It's given them access to capabilities
that they lack the understanding to
use safely.

How many Americans own guns?
How many of them have had "firearm safety" training?
How many of them think it's their right to own a gun, regardless?
It's up to the person to understand the safety requirements of the tools they choose to use.
It's also up to their employers to hire people who are trained & certified.

This has led to PHP's reputation as
being insecure.

The sheer volume of "php programmers" has helped that, too. I'm sure the percentage of python & ruby programmers who "suck" is similar to the percentage of php programmers who suck... it's just that there are so many more php programmers, that the same percentage yields a much higher volume. Of course, it also means there are more awesome php programmers... they're just harder to find floating around in a sea of n00bz.

What is it that I'm missing about PHP?
I'm seeing an organically-grown,
poorly-managed mess of a language

Ahhh, organically-grown. So ripe. So tasty. I think you've hit the nail on the head right there. As soon as a fad hits the net, there are 10 PHP classes for accessing it, modifying it, and remixing it into your own monkey. Some suck, some are great. Either way they're there for you to play with, on Day Zero, and that's fun and exciting. PHP is nothing if not all about Fun & Exciting.

"Python just launched version 3 of itself, totally breaking backward compatibility. At least PHP took a long time to do it, and they still support the 4.x branch that does it the old way." Bad example as Python 2.5 is not deprecated and there aren't plans to do so.

It does a good job making it easy to create dynamic markup. I'd rather read naive PHP rendering code than something where all the markup is locked up in non-syntax-highlighted strings in print statements.

It performs well in a default install, in contrast to most other things.

2008-12-16 03:40:03

+1 A:

I'm not at all a trained programmer. I took Java classes and code regularly in AS 2,3 and PHP.

I did, however, program lots of things in Basic 20 years ago so i'm at least somewhat a veteran.

PHP was easy to learn and feel like I did something useful.

PHP has a huge community that helped me grow as a programmer.

After building x number of apps, I no longer cared about "doing something useful" I cared about doing the same useful things "better" and more "elegantly" and PHP gave me enough rope to hang myself or validate my feelings of being a decent programmer.

I don't prefer PHP to anything else as I only have a limited knowledge of other items. But I do like PHP because I now know the difference between a good programmer and a bad programmer and I wouldn't have this experience or knowledge if I wasn't allowed to be a bad programmer first.

PHP has inconsistent naming of
built-in and library functions.
Predictable naming patterns are
important in any design.

PHP exposes the function signatures of all the low-level libraries that it uses. Do you make this same complaint about C or C++? You should because those are the same function calls and libraries. You have the freedom to develop whatever abstractions you want over top of these low-level calls -- you aren't limited a specific high-level toolkit.

The PHP developers constantly
deprecate built-in functions and
lower-level functionality. A good
example is when they deprecated
pass-by-reference for functions.

They depreciated call time pass-by-reference which no other language has ever had. Regular pass-by-reference still exists and always will. I feel bad for the PHP developers, they try and improve the language and still get dumped on because some people don't know how to read.

Poor execution of name spaces
(formerly no name spaces at all). Now
that name spaces exist, what do we use
as the dereference character?
Backslash! The character used
universally for escaping, even in PHP!

Agreed. But that pain hasn't even been released yet. Lets hope they change their mind. If anything, this particular issue has got me looking into alternative languages. But I have a lot good object-oriented code written in PHP that it's hard to change.

Overly-broad implicit type conversion
leads to bugs. I have no problem with
implicit conversions of, say, float to
integer or back again. But PHP (last I
checked) will happily attempt to
magically convert an array to an
integer.

I've got hundreds of thousands of lines of code in PHP and I don't find the implicit conversions to be a problem. It will not happily attempt to magically convert an array to an integer (unless you explicitly cast it).

Poor recursion performance. Recursion
is a fundamentally important tool for
writing in any language; it can make
complex algorithms far simpler. Poor
support is inexcusable.

I'll give you this one; but if you're written complex algorithms in PHP then you're using the wrong tool -- plain and simple. PHP scripts aren't designed to run for long periods (in fact, the shorter the better for responsiveness). This is like complaining that you SUV uses to much gas or your Smartcar doesn't have enough room for 2x4's.

Functions are case insensitive. I have
no idea what they were thinking on
this one. A programming language is a
way to specify behavior to both a
computer and a reader of the code
without ambiguity. Case insensitivity
introduces much ambiguity.

They are case-insensitive because HTML tags were, at one time, case-insensitive. But your argument is stupid. If functions are case-sensitive, you're still introducing ambiguity: now you have a function named bob() and Bob() that do two entirely different things. In PHP, that sort of madness isn't allowed. If you want consistency in naming, be consistent. PHP doesn't stop you.

PHP encourages (practically requires)
a coupling of processing with
presentation. Yes, you can write PHP
that doesn't do so, but it's actually
easier to write code in the incorrect
(from a sound design perspective)
manner.

This is entirely wrong. It does not practically require coupling processing and presentation. I've been coding in PHP for decades and while I did start by making them together (everybody did -- I came from classic ASP which does the same thing).

I think of PHP's functionality in this regard as the same as Python's immediate mode. You can fire up Python in a shell and just start typing commands and getting results. PHP is a web based languages, so this is it's equivalent of that functionality. When I need to quickly test something, I can bang out a quick script instantly and don't require bringing in a big framework (as I would with any other language) to get a result.

PHP performance is abysmal without
caching. Does anyone sell a commercial
caching product for PHP? Oh, look, the
designers of PHP do.

Abysmal? Please. Take your exaggerations elsewhere. PHP is plenty fast enough without caching for 99% of what it's used for. For that remaining 1%, there are plenty of free code caches available (I use e-accelerator) and it will be included as standard in PHP6.

Are we done with this tired topic now?

2008-12-31 05:20:40

"They depreciated call time pass-by-reference which no other language has ever had." VB has it! x = foo(ByRef bar) passes bar by reference even if declared as ByVal in the function.

I was aware of these and used it anyway for some projects. In practice, problems don't actually prevent the writing of good code, they simply make it very slightly harder. And there are a lot of workarounds.

I don't get your issue about function references; PHP does not support anonymous functions therefore function references are irrelevant, just call functions by name which a callback can do (No, really, create_function just creates a named function with a dynamic name. Last time I checked there was no way to deallocate these).

PHP is, by and large, so stupid that it forces you to think about how things are actually going to be done rather than relying on some underlying magic (e.g. all the voodoo from ASPNET) to "just work", e.g. sessions aren't automatic and implicitly available, you need to start them.

This can be a good thing as it means that all of the things you want to do, you have to actually do.

PHP's one of the biggest problems are novices who can't take the time to do validation etc and this leads to security problems which causes bad imago for PHP in the long run. It's a bit too easy. In one forum there were same time topics titled "Python: How I can handle errors?" and "PHP: How I can hide errors?". Pretty much sums it up. People just glue PHP apps together and then go with it.

As a PHP programmer and hosting provider myself for 8+ years I'd say PHP's good points are it's vast collection of libraries and classes and that it's fast. I can run hundreds of small pretty busy sites compared to Java based memory and CPU hogs. I've looked into Django and Ruby on Rails but libraries what you need just aren't there.

I've also seen that PHP is fading but frameworks like Symphony and Zend Framework may be these future saviours of PHP.

This is what is said in the book XSS attacks (syngress) by :
Jeremiah Grossman -
Robert “RSnake” Hansen -
Petko “pdp” D. Petkov -
Anton Rager

Another nasty thing that can be
performed by CSRF is Hypertext
Preprocessor (PHP) include attacks.
PHP is a programming language that has
increased in popularity over the last
several years. Still, while it is an
extremely useful and widely used
programming language, it also tends to
be adopted by people who have little
or no knowledge of security

so if php is that simple, it would be a big problem since everyone will just mess up with things on the wild!

Every point in your post is about how PHP will not organize your code for you.

I'm proactive, and I need a level of organization no code will give me out of the box. I'd rather a language that stays out of my way and let's me enforce good program design with actual design, like pencil and paper planning design.

And as for teaching beginners bad habbits. you can't prevent bad habits from the language level nor can you implement good design from the language level.

Something that needs to be remembered, and was briefly mentioned beforehand, is that you cannot compare PHP to just any language. People tend to use the term "programming language" loosely without giving it much thought sometimes I think. While all languages could be grouped as a "programming language" in a broad sense, not all "programming languages" are equal (Yes - an owl and a ostrich are both birds,but they certainly are very different for different environments).

A language is designed to solve a particular problem: Basic was created to program hobby computers back in the day, PHP was created to make web pages,JavaScript to help with Java Applets in the Netscape Browser. Each one was created with a different purpose in mind, and so has different characteristics to meet that problem, and operates in a different environment.

Remember, PHP was designed in the beginning to be a simple language for making web pages, nothing else. So it is not going to have the same features of a language such as C++ or Basic that was designed for computer programming, or JavaScript for client side web scripting. Yes, compare PHP to Ruby on Rails, Python, ASP/ASP.NET, but don't compare it broadly to all the other languages when they all were not created for the same purpose.

i love it because the code is updated very frequently by the general public rather than employees of a company (who can care less).

one language i really hate is asp,asp.net etc.. anything made by microsoft is garbage. the code that visual studio generates is a mess of blob. and since it forcefully operates on a windows makes it even more insecure and crappy.

$foo has not been garbage-collected—for chrissake it's still available after inner(), within outer(). It's technically still available withininner() if calling inner() triggers an error! Why should it need to be explicitly passed as an argument, or worse part of the global scope, to be accessible within inner()?

You think that's a problem with PHP?! There's a truckload of trouble waiting for you if you'd work in a language that *would* support it -- information hiding would be gone, creating a huge tangled mess of interdependencies, e.g. library code could (unknowingly) change the way your methods work. Good luck debugging that.By putting variables in arguments, at least you know that the function only works on globals and those arguments (and only if passed by reference).

Lennaert,Most of my work is with a language that does allow it. What you're describing as a danger—which it is, in an environment where you unwittingly use outside code that hasn't been reviewed—is also a powerful tool in the right hands, sometimes described as "monkey coding". ECMAScript (Javascript, Actionscript) supports the scoping model I described, and particularly when combined with anonymous functions/closures, it provides a powerful environment for highly dynamic, flexible code. There are plenty of valid use cases, in which code could be simplified quite a lot if it were available.

@kirk, you must not read much SO. Anyway, what does nested scopes have to do with global variables? Did you read my previous comment specifying a perfectly capable modern language which implements nested scopes? Or do you think ECMAScript is like BASIC and a nightmare of global-scope conflicts by design?

@eyelid Every single time you use a variable, you'd have to worry about clobbering things in the parent scope. Every single function would have to start decorating its variables with unique prefixes. This is an astonishingly bad idea.

@meagar, this is why languages with nested scope differentiate variable *declaration* from variable *assignment*. ECMAScript, not being strictly typed, has one such prefix: `var`. Other languages will require more verbose prefixes *anyway*. Explicitly declaring a variable is not only more clear to a parser, it's more clear to a reader. I don't see that as a bad thing.

@eyelid PHP doesn't have variable declaration, so nested scope is, as has been said *repeatedly*, a *very bad idea*. You can continue to gripe about PHP not supporting features which are completely inappropriate and anti-thematic, but I don't really see the point.

@meagar, you're begging the question. Twice in one sentence, which is impressive. PHP can't safely implement nested scope without variable declaration; but PHP's lack of variable declaration is already a liability, and I don't think it serves as a positive reason to limit the functionality of scope in the language. The language already has variable declaration in certain contexts (member properties, not strictly enforced; static and non-public properties, strictly enforced), and that should be extended to the rest of the language and strictly enforced, because it will improve PHP applications.

@meagar, I have only continued to gripe because I keep receiving responses to this answer that offer (with little exception) no practical reasoning that nested scope is a "bad idea". Believe me, I don't lose sleep over PHP's scope system. But I also don't like leaving misinformation unaddressed under my "name".

I don't object to the statement that PHP is horrible. It has a lot of problems which were all mentioned in the question...

...BUT

has all the features you'd expect from a C/C++ heritage (it's very familiar)

it's free

very easy to learn

lets you quickly produce results

is extremely well documented

has a HUGE fanbase and

got a good amount of WTFs that keep you on your toes ;-)

So if you like to program something with quick results (and if your code is clean and you plan ahead you won't get into trouble), don't have a lot of money for software licences, (and/or are inexperienced with or still learning PHP) you can't go wrong.

PS. I really like PHP and have used it succesfully for 10+ years. Sometimes you just don't want to solve a problem with the overhead of some languages like Java etc.

I think PHP gets some rabid, fanatical defense for the same reason most languages get this treatment. It is often the first language learned by a new programmer, and this opinion is held as long as that programmer still hasn't been forced to learn more languages.

PHP really is good enough for what these programmers are using it for, to put up a website and give it some brains. It supports enough kinds of programming that it doesn't really hinder them from expressing their code. And significantly, it doesn't look anything like the languages other folks are telling them to learn instead.

The converse of this also applies equally. PHP is strongly hated by folks that learned several other languages first. It lacks the purity of lisp. It lacks the clarity of Python. It lacks the ecosystem of Java. It lacks the performance of C++. And so on. It doesn't really offer much over these languages, for the general tasks these languages are often used. Of course, while correct, they are missing a key point. It's very easy to get free web-app hosting for your favorite language, so long as your favorite language is PHP.

Yes, those may be all drawbacks for PHP and I can't wave all of them away, but in choosing a web programming language, here's some of the pros that put PHP ahead of the pack in my book that haven't been mentioned yet:

Direct access to GD image manipulation from the source code. ASP could pull in ActiveX components to manipulate/output graphics, but PHP allows native manipulation of image canvasses, and can create image output rather than text/HTML.

One programming language usable in CLI/shell scripting and web-based scripting. If you're a new programmer, learning this one language gives you a leg up on both dynamic website creation and shell script automation.

Smarty Template engine: Yes, PHP lends itself to combine the display of a page with the processing code, but the same company that designed PHP designed a template system to go with it. Plus having the ability to combine the 'View' with the 'Controller' allows for rapid prototyping/debugging in certain situations.

It's not so much that the language is terrible, but that it has a tendency to attract those people who want to learn language "X" in 24 hours. What happens then is that you have people who (mostly) read a (intro) book on PHP programming and think they've completely mastered all the ins and outs of the language. Consequently, I think you have more of a glut of bad PHP programmers than anything else.

From a personal point of view... If it weren't for PHP, and its forgiving nature, I wouldn't be a developer at all. I never studied comp-sci or development, I didn't think I'd ever become a developer, but I'm a designer, the web became what it is and development was a skill I needed to learn in order to survive.

It's quick, dirty, easy and I love it. I now know my way around a few different languages, but I owe everything to PHP for teaching me the basics.

Ok, let's use a nice car analogy to understand the complete pointlessness of this discussion:

Title: Defend cars, prove me they aren't horrible.

Cars kill more people than any other means of transport.

Car's engines are very old technology, we haven't even got 100% outta them yet.

Not even 70% for that sake.

Cars have been on the list of the most harmful things to the environment.

Cars have been the victims of poor design, only a few years ago did they invent the seat belt, and don't get me started on the air bag...

Cars have a loony behind the design process, they don't agree on the shape, the colour, the braking system, the transmission (rear/front/both), the gear system, the fuel they use and I could go on and on and on...

The guy that invented the 3 pedals for the controls deprecated loads of other more "sensible" ways of control, like mind reading.

Cars have this thing called extras that most vendors seam to make profit on, what's that?!?!?

Cars have so low security that almost anyone can jump start one. That's very bad for the beginners. I think....

If you sleep behind the wheel of a car it will crash. How did this creep into the design of this tool?

If you don't buy one of those extras that the salesman was offering, the car will not fulfil it's intended goal, take you from point A to point B. You could find yourself on point P.

Most of the users of a car are very lacking in skills. They drive like maniacs and think the road belongs to themselves. That makes for very poor usage of the car.

Ok, I think you get it.

So... with all this against them, all this long, harmful, unattended, stupid and nonsensicle development in this tool, how the heck is it so popular?

Probably because you wouldn't use a bathtub to get you from point A to point B. (The point is having a tool for each job)
Probably because, even if quite full of problems, it's easy to use and is the one with the most support. (Repair shop at every corner, wide spread means of refuelling)
Probably because there is a very low entry barrier to hop on board.

In the analogy does PHP represent cars or do cars represent all programming languages? Is this a defense for PHP because both it and cars are popular? If PHP was a car, it would be a very strange amalgamation of many cars without much thought for consistency.

I wouldn't say it's horrible. Is PHP perfect? No. But is any language perfect?

The reason it isn't horrible: ease of use, availability and libraries make it a good language for any programmer to start with. This is probably the reason why many programs are coded with it.

It's also easy to bang out a site and scale. Someone mentioned caching earlier stating that this was a reason why it was a poor language. But again, can you scale any site efficiently and cost effectively without caching? No.

In regards to security, PHP is no different than any other language. I think all web languages have security issues when not implemented correctly.

PHP is as bad as you make it. If you are just programming an application without thinking it through you can't expect a good program from any language.

I think the devteam of PHP did a really good job creating a language that people without any initial programming experience can understand. Isn't that our goal? Having a programming language that is easy to understand for everyone?

Now lets see why PHP isn't as bad as you think. First PHP is not slow as long as you program it not to be slow. Most of the time it isn't PHP that is slow but the database engine that can't get the data faster. That is why we cache the data.

It doesn't have structure:
Not true. Look at all those frameworks out to give php structure. Kohana, Yui, Zend, Symfony (i leave CodeIgniter out because its supporting PHP4 and doesn't use full OOP). These Frameworks even make the PHP language better than some other languages in my opinion.

In my opinion PHP is a great language as long as you think before writing anything. And with the use of a Framework it becomes a bit more of a programming language than a scripting language. For now only databases and data structure are the real bottlenecks for speed.

Would you be content if you had to pay to type in English? With most other programming languages, developers have to pay for client licenses to use and produce. Conversely, PHP is Open Source, so a developer does not pay.

In the above example, I have shown in PHP, it is quite true that the money developers pay to corporations compared to what they pay to Open Source projects to going to be greater. A variety of moral issues could be derived from this. For me, personally, I am a creator. I am an artist. Thus, this is a point to ponder.

Of course one could argue an artist has to pay for the materials to do one's work... or not. This is a personal choice. This could also be a requirement.

So for me, personally, when I can - I choose the green option.

True, PHP may be a product with design flaws, bugs, and/or issues to work out. Weigh in all the factors of its shortcomings, its capabilities, and everything else. Then compare that to what is found in designed, or sold development software; it does about as much and it gets the job done.

---edit below due to downvotes LOL---

The real reasons why I LOVE PHP.

PHP lets you bend the rules.. or make new ones.

Insertion of code in HTML anywhere.

Super-fast installation using LAMP/WAMP.

Ability to access and manipulate $_SERVER variables.

Can be used to generate ANY type of file.

Can be used as a web page script or an app.

There is a function/library for just about everything imaginable.

Thousands of APIs for use with thousands of web services.

Error reporting makes it easy to debug and trace code.

Built-in support for almost every kind of database.

Built-in support for almost every kind of image type.

When there is no built-in support, see #7 and #8.

Project files are managed in text and do not need to be compiled into executables.

Full object-oriented language ability.

Can help you get 100/100 on a google page-speed rank.

Can mold to your own programming style.

It can be the language you want it to be with the right classes/functions.

Quirks in the language eventually get depreciated.

Full reg_ex support, and easier to use than PERL. (for me anyhow)

It has enough nuances to keep me learning every day.

There is not much I can think of that is cannot do. (w/ .js and .css of course)

It can handle a database of 1,000,000 records on my laptop and not crash.

Scripts written with it are only as bad as the programmer who wrote it.

The acronym of PHP is self-recursion. which is cool

I find less wrong with PHP than with javascript, which has no alternatives.

um... have you seen what most companies charge for compilers, when *not free*?? `http://software.intel.com/en-us/articles/intel-academic-developer-program/` perhaps this is getting downvoted, because it has been forgotten how expensive this really is if your company isn't buying your software for you...???

There are tons of high quality projects based on PHP. No matter what you want to build, you'll probably find some quality open source project to assist you. Think of Drupal, Joomla, Wordpress, just to name a few. I think efficency and not reinventing the wheel should be the top priorities of a developer. And here, PHP wins by far.

Given all the reasons that it's not, there is one reason we keep going back to using it in almost every solution we provide to our clients.

It's very cost efficient! It's breadth of available programmers, it's ability to work on any OS, it's interoperability with all the major opensource data storage engines and it's ease at which you can go from quickly developed prototype to a full out robust application.

I like PHP! Fast, simple, C-like (sorta). I have so many resources and toolkits at my disposal.

So how does it 'promote poor programming.' What? Was there a sign I didn't see? Everyone starts programming poorly. Should the language be so strict as to force the programmer into submission? I can write bad code in many languages! It's up to the coder to train and discipline himself, not the language. I come from a background of C and Assembly programming. I can write nicely in any of these languages, because I keep training myself, and I keep practicing, and I know my life will be easier if I code cleanly.

Yes, it's a life choice!

And let's be honest, web programming is a huge, sloppy mess. I use 4 different languages for a web page - PHP, SQL, JavaScript, and HTML. PHP generates HTML, JavaScript, and SQL - or only HTML; or not. There is a server side (PHP and MySQL) to consider, security within the forms, the server itself, the SQL script, and a client side (HTML/JavaScript). Programming for the web is no small feat, and the language should not be under the same scrutiny as the posh desktop C++ or Java, where you can enforce coding zealotry with the compiler!

Recursive performance? Why the hell would I use recursion unless I had to? I have programmed recursion in i8086 assembly, and in Pascal, but I have never had an occasion to use recursion outside of school! What are you thinking?

Bottom line: I like it, I use it, and that's it. Fast, easy, free, plenty of free code, plenty of free advice, and plenty of books to choose from. I can design, code neatly, and document via comments (again, free!).

I don't have those problems with the language. I think I should also learn Perl. And Ruby. I don't like C# or VB, but if you do, that's okay.

Get it?

2010-05-26 22:17:20

+2 A:

The one reason that I started with PHP and still like using it is that the documentation is there. The manual has every core function documented (sure, camel case, weird underscoring and argument order). If I want to know how to use something, I can find out in a manner of seconds. I've been working a bit with Perl lately, and I find it very frustrating at times because the documentation is less... easy. Not to bash Perl, because it is awesome when you know what you are doing, but PHP is the best documentation that I have found in any language I have tried to pick up.

There are ways to mitigate most of the things that can be perceived as problems, and there are some very awesome projects out there that can make even the worst code better (Zend Framework being one).

Bottom line. If it weren't for PHP a lot of developers wouldn't have jobs right now. PHP pays bills. It didn't say it would change the world & it didn't say that you need to use it. Period. You can code bad in any language. If you desire to code well because you value your work, then by all means code to the best of your abilities.

Many other languages have documentation available. The difference is how frequently you have to go to PHP's documentation for the order of arguments or to find out whether it's 'get_class' or 'getclass'.

Language wars are idiotic. This question can't be answered, unless you just like to be swayed by popular opinion or the most shrewd linguist. Failure to learn any language only means you can't communicate in that language. Any loss for choosing not to learn any language is personal. Opportunities will be missed and group association will be further limited, but their importance is subjective.

I'm sure you could rig Brainfuck to be an efficient disk management tool. I'm sure you could design a robotic surgical tool in javascript. Though each language is more or less intended to be specialized (as any human language is more or less adapted to the current, localized environment), most overlap in capability. In fact, I dare say PHP has a mix between several popular scripting or compiled languages. Hell, they even have features of BASIC in there (re: goto), if that's your thing.

If any language doesn't appeal to you, even after reading the manual for deeper insight into it's hidden or unintended capabilities, and even after looking at market share if choice involves a career path, simply move on. Here's a list of the more wellknown programming languages. I'm sure most require just a simple parser or compiler app, and a dictionary/manual handy.

Short answer: if PHP doesn't appeal to you, simply move on to try the next. Or, open a support case with the language's primary dev team to ask them to implement features of other languages you favor.

But with that said, I think more important questions would be financially motivated: "1) Is it worth becoming certified; 2) Is it worth being stuck on a corporate dev team if you hate the language". But you didn't ask that.

I consider this debate to be summed up by whether you think a good compiler/interpreter can replace a good software engineer.

The bourgeois academic route (i.e. Java) is that the compiler should be smart enough and require so much verbose explicit-ness that it will make up for mediocre programmers who tend to make the kind of errors that a compiler can catch. That's why it's great to use on enterprise applications where you tend to have hundreds of disconnected, middle-of-the-bell-curve programmers all trying to turn out a working piece of software. All the verbosity leads to more lines of code, which tends to mean more lines to debug and larger maintenance headaches.

The PHP route is to make a language that is much less verbose and explicit, which can therefore be used for great good by good programmers or great evil by mediocre programmers. My experience has been that PHP requires significantly less lines of code than most counterparts, which means less lines of potential bugs and simpler code maintenance, especially for web-based code.

For example, PHP's double dollar sign is a beautiful piece of programming art which, when used properly, can reduce code size very significantly. When used improperly, it can create bugs that are very difficult to track down.

However, PHP code without a programmer-specified coherent structure and framework is to programming what atonal composition is to music: easy to write and impossible to enjoy.

The only important factor, in my opinion, as to the "horrible-ness" or "great-ness" of a programming language is does it make your programming team and their projects more or less productive and/or buggy. Usually the answer depends on your team and/or project.

This remind me of Galileo saying : You know what guys? Maybe I'm just drunk, but what if the Earth was actually rotating around the Sun? Its the same thing. New ideas, new technologies sounds crazy and not relevant.

How old is .NET?? What about PHP? ASP was a shame...the current version of PHP will maybe turn into something really awesome..AND OPEN SOURCE.

I know that most banks, government and bunker-ish websites uses .NET
But!!

The biggest problem with PHP as I see it: Complex applications tend to become very slow very fast due to application design, which boils down to initializing the complete app and conf for each and every request while other great frameworks (in other languages), albeit the parser is slower, are much faster due to the fact spawning from a preinitialized application which handles more than one request in sequence (eg Rails, Django, ...). Is there an php equiv of that?

BTW, in PHP there are almost no new ideas nor new technologies, there are mostly reimplementation of existing features (of various qualities). Pardon, I forgot safe_mode, magic quotes and register_globals;)

PHP was the first language that I used at all seriously. I agree, there are better languages out there for experienced programmers, but I don't regret learning on it. It's an incredibly simple language that makes it extremely easy to write more-or-less working code even if you know nothing about design. The quality of the documentation is something I would kill for in every other language I used. I managed to write programs that did useful things without even understanding what a class was. I basically just used PHP's insanely powerful associative arrays to structure all my data.

The bottom line is that the value of PHP is that it makes it very easy to get off the ground and just Make Something Work (TM). The same can be said about a few other languages, like Visual Basic. These languages seem "horrible" to more hardcore programmers because they're not designed for hardcore programmers.

PHP was the first language that I used at all seriously. I agree, there are better languages out there for experienced/hardcore programmers, but I don't regret learning on PHP. It's an incredibly simple language that makes it extremely easy to write more-or-less working code even if you know nothing about design. The quality of the documentation is something I would kill for in every other language I used. I managed to write programs that did useful things without even understanding what a class was. I basically just used PHP's insanely powerful associative arrays to structure all my data.

The bottom line is that the value of PHP is that it makes it very easy to get off the ground and just Make Something Work (TM). The same can be said about a few other languages, like Visual Basic. These languages seem "horrible" to more hardcore programmers because they're not designed for hardcore programmers.

@meager: No, I'm saying it allows you to turn out **good enough** software very quickly and with no training. Some things don't need to be elegant or efficient. They just need to work, but they need to work quickly and even in the hands of non-gurus. This is where PHP excels.

@meager which is better, overly-complex languages that result in **experienced programmers** creating poor software, or easier languages that result in **poor programmers** creating poor software and **experienced programmers** creating awesome software?

PHP is not a bad language. It just simply does not have a large barrier to entry. Anyone can copy and paste code into an HTML page if PHP is supported, and that alone starts them down a slippery path of hacky modifications that help no one in the long run. Compare that to say, C#, and your average joe will not be able to even comprehend how to accomplish the same task.

Given that is is no wonder that when finding PHP code around the web, most of it tends to be terrible as it's easy to propagate. Case in point at my current work I have to support around 1 million lines of PHP code. 80% of it is garbage, redundant etc... written by people with no experience or teams in India. Just as with any other language a developer can conceptually understand concepts like OOP but in practice, without a lot of experience, it will always be implemented in the worst possible manner. Unlike most other languages, however, debugging this monstrosity and re-write sections of terrible code is breeze in PHP

I've written terrible PHP code before, for sure, just as everyone else has. But I've written god awful C# code before as well and in the long run, PHP was a hell of a lot easier to maintain and fix. It can be an elegant language despite its quirks. But I'll tell you what, for some reason no other language is as easy for me to implement basic things. When I want to simply query a database and display results, I can accomplish this very quickly and easily, and since I don't have to care what type the resulting array is, displaying and using this content is a breeze.

For MVC style web applications, nothing beats PHP. It can be very fast and efficient if you actually understand what is happening on a server level and know how to tweak settings. Combining APC, Memcache and an efficient database, it really can be a beautiful thing.

We're all in consensus that people can write bad code in any language. This has been argued a dozen times in other answers. Your answer doesn't address any of the points the question makes about *language itself*.

Language design idea: Function calls are the given name of a function, in reverse, with the arguments following in a bulleted list. Each function call will execute the given function 95% of the time, and execute a different, randomly-selected function 5% of the time.Would this be a horrible language? Yes.(Potentially amusing, but horrible.)If a horrible language can be created, it follows that your answer is incorrect.

I agree with most of your points; PHP as a whole is a mess! What I don't agree on is your view on the case insensitive functions.

"Case insensitivity introduces much ambiguity."

Not as such: only if the language isn't consistent in this. Case sensitive variables combined with case insensitive functions are a sick idea.
However, I've worked for some time with the totally and completely case insensitive Delphi and I've never had a feeling of ambiguity. So I write FooBar which was fooBar on the previous line. Big deal. It's just like this other case insensitive language, English: you just know they mean the same thing. IMO there's much more ambiguity if you (in case sensitive languages) define two different variables fooBar and FOOBAR. Now that's asking for trouble!
Bottom line: the case insensitive functions in PHP are crazy, but not just because they're case insensitive.

`Capitalization is the difference between "I had to help my uncle Jack off a horse.." and "I had to help my uncle jack off a horse.."` - (found it on bash.org but may have originated somewhere else). Inconsistent capitalization when the language allows it is as bad as having two different variables just differ by case.

OK, English doesn't seem to be case insensitive :-). OTOH, I don't agree with your comparison: in the former case no harm is done, while in the latter the system reports errors or, worse, behaves erroneously. I see Delphi programs where the programmer writes `WHILE` and others where another programmer writes `while`. If this confuses you you definitely need to learn to focus.

This issue ultimately extends from a root question: is a programming language a form of mathematical notation, a natural language, or something new? I lean toward mathematical notation, which is why I prefer case sensitivity. However, the debate will likely never be settled.

Also, you're right. Case insensitivity isn't an issue as long as it's universal. The case insensitivity of most SQL dialects never creates problems for me. However, even in those cases, I tend to write in a case-sensitive manner out of habit.

Actually, on further reflection, I take it back. Case sensitivity is important because it enforces consistency in coding style. Why does it matter? The human brain iconifies based on word shape; its a neurological short-cut. People with dyslexia struggle to read because this short-cut is effectively broken for them.

So the problem with allowing "If", "IF", and "if" is that while they're identical in spelling, and logically they're the same word, to our brain those are three distinct words which happen to mean the same thing. Code is complex enough, and hard enough to read efficiently, without forcing our brain's background threads to do additional work. ;)

Is it a huge hurdle? Of course not, but we have style guidelines for code for the same reason we have them for natural languages. Code is best when it's clear. YOU CAN TELL WHEN I END A SENTENCE THROUGH PUNCTUATION ALONE, BUT THE PROPER USE OF CAPITAL AND lower-case letters still provides valuable visual guidance that your bran uses to more EFFECTIVELY ABSORB INFORMATION.

But I've worked as PHP programmer for 7 years and I've come up with my own style of designing and coding PHP programs. By strictly following this style, inside my own "frame", subset of PHP, I wrote secure and well-organized programs.

Now I am C++ programmer. This language is die-hard as hell, but I'm happy.

I don't understand why paradigms from another language are used to evaluate how things should be done in PHP. The very same example can be used against JavaScript (I mean literally the same - when you DO NOT have scope btw any curly braces, but have function/object/namespace scope). So, while PHP has a lot of deficiencies, this particular example is shooting the wrong target imo.