PHP's Bad Reputation

  • (9 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

123 Replies - 37811 Views - Last Post: 15 January 2013 - 12:14 PM

#1 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10803
  • View blog
  • Posts: 40,262
  • Joined: 27-December 08

PHP's Bad Reputation

Post icon  Posted 10 January 2013 - 03:13 PM

I came across this article discussing why PHP has a bad reputation. A lot of it came down to developers using poor practices. This excerpt: Copying internet tutorial code and not reviewing it struck me as particularly relevant, and something I think we see a lot of in the PHP forum. Granted for any language there are the low-quality and outdated tutorials out there, but PHP seems to have an abundance of this.

What are everyone's thoughts on the article? What good practices would you encourage for a PHP developer? Other thoughts?

Is This A Good Question/Topic? 1
  • +

Replies To: PHP's Bad Reputation

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3099
  • View blog
  • Posts: 10,885
  • Joined: 08-August 08

Re: PHP's Bad Reputation

Posted 10 January 2013 - 03:25 PM

I'd add:
  • Always use prepared statements.
  • Beginners should NEVER mix languages like PHP, HTML, Javascript, and CSS. It adds to the confusion. If you ask for help nearly as much or more than you give it, you're a beginner.

I disagree with his assertion that php:

Quote

was not meant to be an all-encompassing language

It's object oriented, or at least it can be, and it can do many of the same things as any other language. I think that many people try to treat it as if it isn't a full blown language. They run into problems because they think they can do something quickly and easily without thinking as much as they might if they were writing in C or something else.
Was This Post Helpful? 4
  • +
  • -

#3 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4421
  • View blog
  • Posts: 12,286
  • Joined: 18-April 07

Re: PHP's Bad Reputation

Posted 10 January 2013 - 03:28 PM

Eh... if you know what you are doing PHP is just fine. I have developed many applications with it and find it very flexible and pretty straight forward. It has all the whistles of a scripting language like perl and yet is quite extensive like a full programming language.

I think it just gets a bad rap from the "advanced developers" because they want to move onto the latest buzz words and rehashes of everything that PHP initially helped create.

Just recently ruby on rails had a huge exploit and should we bash it for that now? It is trendy to put down PHP even if secretly you are building websites with Wordpress or Drupal.

Watch your comparisons and make sure you test everything and things should be fine. I think the haters just need to find something else to hate because PHP runs a good portion of the world's websites.
Was This Post Helpful? 2
  • +
  • -

#4 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10803
  • View blog
  • Posts: 40,262
  • Joined: 27-December 08

Re: PHP's Bad Reputation

Posted 10 January 2013 - 03:28 PM

Quote

I think that many people try to treat it as if it isn't a full blown language. They run into problems because they think they can do something quickly and easily without thinking as much as they might if they were writing in C or something else.

Certainly PHP was designed as a web language, and I think people forget as well that it has extensions that allow developers to work with other tools like GUI programming, such as with the PHP-GTK library.
Was This Post Helpful? 0
  • +
  • -

#5 Tayacan  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 145
  • View blog
  • Posts: 275
  • Joined: 18-January 11

Re: PHP's Bad Reputation

Posted 10 January 2013 - 03:50 PM

PHP works, but I would never call it a well-designed language, not even if you know what you're doing. Knowing how to avoid the pitfalls doesn't mean that they're not there.

Here are some examples of weird stuff in PHP.

Quote

Do not tell me that “good developers can write good code in any language”, or bad developers blah blah. That doesn’t mean anything. A good carpenter can drive in a nail with either a rock or a hammer, but how many carpenters do you see bashing stuff with rocks?

Was This Post Helpful? 2
  • +
  • -

#6 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 862
  • Posts: 2,651
  • Joined: 29-July 11

Re: PHP's Bad Reputation

Posted 10 January 2013 - 04:11 PM

PHP was the first language I learned years ago. I hated it then, and I hate it now. I'd rather abuse myself doing java web development than PHP.
Was This Post Helpful? 1
  • +
  • -

#7 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7999
  • View blog
  • Posts: 13,701
  • Joined: 19-March 11

Re: PHP's Bad Reputation

Posted 10 January 2013 - 04:15 PM

View PostTayacan, on 10 January 2013 - 05:50 PM, said:

PHP works, but I would never call it a well-designed language, not even if you know what you're doing. Knowing how to avoid the pitfalls doesn't mean that they're not there.


I would go along with this. Don't want to get into a personal slug-fest: if you like PHP, this is not about you, it's about the language. The language seems to me poorly designed, in that it facilitates bad code and makes good code difficult. The article Tayacan links to sums it up pretty well. Other languages have their faults - I write Java, I write perl, and I've spent time in C, all of them have got real issues - but no language that I know of combines issues to the degree that PHP does.
Was This Post Helpful? 2
  • +
  • -

#8 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1623
  • View blog
  • Posts: 5,710
  • Joined: 03-August 09

Re: PHP's Bad Reputation

Posted 10 January 2013 - 04:15 PM

PHP works, I used it at my job for 6 months exclusively. PHP is however, IMHO, horribly designed. I'm glad I'm not using it anymore. I like ruby and python better.
Was This Post Helpful? 1
  • +
  • -

#9 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3807
  • View blog
  • Posts: 13,500
  • Joined: 12-December 12

Re: PHP's Bad Reputation

Posted 10 January 2013 - 05:02 PM

My two cents:

CONS
Dollar-signs are a pain;
There are too many functions;
There are too many similar functions;
Function names are inconsisent.

PROS
It is easy to learn and easy to get up-and-running (with WAMP/LAMP);
The docs are excellent, particularly the comments.

Being easy to get up-and-running could also be a CON, as it means people use it without knowing enough about it (or studying proper practices!) - also discussed in the OP-article.

Every language has its quirks. C#, a much newer language, is horribly verbose?! IMO

This post has been edited by andrewsw: 10 January 2013 - 05:10 PM

Was This Post Helpful? 1
  • +
  • -

#10 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: PHP's Bad Reputation

Posted 10 January 2013 - 05:29 PM

View PostCTphpnwb, on 10 January 2013 - 10:25 PM, said:

I disagree with his assertion that php:

Quote

was not meant to be an all-encompassing language

But it really wasn't meant to be an all-encompassing language. And that's the core of the problem. Initially it was just a simple HTML template language with a few thing C wrapper functions. As it became more popular, people started adding their own functions, each with their own styles, and before you knew it, the core of the language was more or less inconsistent.

By the time the language had become popular and widely used, and the devs started thinking about more advanced things like OOP, that damage was already done, and they couldn't really reverse it without breaking half the internet. (Or making sure nobody would ever upgrade to the latest versions.)

PHP was not initially designed to be in the same category as languages like C# or Java. However, if you can wrap your head around that fact and live with a few inconsistent naming styles, then it can certainly hold it's own against those languages today. At lest in the web-development arena.

View PostTayacan, on 10 January 2013 - 10:50 PM, said:

Here are some examples of weird stuff in PHP.

I remember reading that article at some point and being somewhat underwhelmed by some of the things he discussed. He makes some good points, but most of the time he's making way to big a deal out of minor details that don't matter in the slightest. I mean, there are things about PHP that are worth pointing out like that, but he goes way beyond that. - It's basically a long list of things he doesn't like, explained like they are fatal mistakes.
Was This Post Helpful? 4
  • +
  • -

#11 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7999
  • View blog
  • Posts: 13,701
  • Joined: 19-March 11

Re: PHP's Bad Reputation

Posted 10 January 2013 - 05:31 PM

Quote

It's basically a long list of things he doesn't like, explained like they are fatal mistakes.


At some point, don't a lot of little gotchas start adding up to real problems?
Was This Post Helpful? 3
  • +
  • -

#12 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1623
  • View blog
  • Posts: 5,710
  • Joined: 03-August 09

Re: PHP's Bad Reputation

Posted 10 January 2013 - 06:30 PM

Quote

PHP is built to keep chugging along at all costs. When faced with either doing something nonsensical or aborting with an error, it will do something nonsensical. Anything is better than nothing.
...
Weak typing (i.e., silent automatic conversion between strings/numbers/et al) is so complex that whatever minor programmer effort is saved is by no means worth it.
...
There is a whole lot of action at a distance. Consider this code, taken from the PHP docs somewhere.
...
The language is full of global and implicit state.
...
There is no threading support whatsoever.
...
array_search, strpos, and similar functions return 0 if they find the needle at position zero, but false if they don’t find it at all.
...
or do much of anything with it except compare with ===, PHP will silently convert it to 0 for you
...
foo()[0] is a syntax error. (Fixed in PHP 5.4.)
...
(int) is obviously designed to look like C, but it’s a single token
...
include() and friends are basically C’s #include: they dump another source file into yours. There is no module system, even for PHP code.
...
There’s redundant syntax for blocks: if (...): ... endif;, etc.
...
A single shared file, php.ini, controls massive parts of PHP’s functionality and introduces complex rules regarding what overrides what and when


I stopped going though the list but these are all issues that have bit me at least once if not repeatedly. that list has a lot of good points that I very much agree with. It perhaps goes a bit overboard on somethings. the first two points I posted REALLY annoy me, also the equality operator and how certain functions abuse dynamic typing.

This post has been edited by ishkabible: 10 January 2013 - 06:31 PM

Was This Post Helpful? 0
  • +
  • -

#13 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: PHP's Bad Reputation

Posted 10 January 2013 - 06:32 PM

View Postjon.kiparsky, on 11 January 2013 - 12:31 AM, said:

Quote

It's basically a long list of things he doesn't like, explained like they are fatal mistakes.


At some point, don't a lot of little gotchas start adding up to real problems?

Sure. Depending on the "gotchas" and the problem the are adding up to, of course. - But much of what he talks about isn't "gotchas" as much as personal dislikes, or things that work differently in other languages. (And, thus, are working incorrectly in PHP...)
Was This Post Helpful? 0
  • +
  • -

#14 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1623
  • View blog
  • Posts: 5,710
  • Joined: 03-August 09

Re: PHP's Bad Reputation

Posted 10 January 2013 - 06:49 PM

I share a good portion of his "dislikes" and I would imagine many others do as well. Those are things that I think many langues try to do away with because they are of no use or they make a better trade off in the case that they don't.

This post has been edited by ishkabible: 10 January 2013 - 06:53 PM

Was This Post Helpful? 0
  • +
  • -

#15 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: PHP's Bad Reputation

Posted 10 January 2013 - 06:50 PM

I'm not going to bother arguing against everything said in that article (what would be the point?), but these two things you quoted, ishkabible, kind of bug me.

View Postishkabible, on 11 January 2013 - 01:30 AM, said:

Quote

There is no threading support whatsoever.

Why would there be? PHP's purpose in 99.99% of cases is to work as a "hit-and-run" script inside a HTTP or CGI worker thread. Why add a complex system that will hardly ever be useful?

View Postishkabible, on 11 January 2013 - 01:30 AM, said:

Quote

PHP is built to keep chugging along at all costs. When faced with either doing something nonsensical or aborting with an error, it will do something nonsensical. Anything is better than nothing.

It's never nonsensical. There are different levels of errors the code can issue, and PHP handles each of them in a clearly defined manner. A fatal error (E_ERROR) stops the script execution. Anything less (E_WARNING and E_NOTICE, for example) will not stop the script execution, but be logged and the script will continue in whatever manner it would have otherwise. - Of course, the path of the execution will differs based on return values from the functions responsible for issuing the non-fatal errors, and those are often mishandled by the developer. That, however, can hardly be attributed to PHP doing things in a nonsensical manner. PHP just does no more or less than exactly what it was told to do.
Was This Post Helpful? 2
  • +
  • -

  • (9 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »