123 Replies - 14604 Views - Last Post: 15 January 2013 - 12:14 PM
#1
PHP's Bad Reputation
Posted 10 January 2013 - 03:13 PM
What are everyone's thoughts on the article? What good practices would you encourage for a PHP developer? Other thoughts?
Replies To: PHP's Bad Reputation
#2
Re: PHP's Bad Reputation
Posted 10 January 2013 - 03:25 PM
- 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
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.
#3
Re: PHP's Bad Reputation
Posted 10 January 2013 - 03:28 PM
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.
#4
Re: PHP's Bad Reputation
Posted 10 January 2013 - 03:28 PM
Quote
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.
#5
Re: PHP's Bad Reputation
Posted 10 January 2013 - 03:50 PM
Here are some examples of weird stuff in PHP.
Quote
#6
Re: PHP's Bad Reputation
Posted 10 January 2013 - 04:11 PM
#7
Re: PHP's Bad Reputation
Posted 10 January 2013 - 04:15 PM
Tayacan, on 10 January 2013 - 05:50 PM, said:
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.
#8
Re: PHP's Bad Reputation
Posted 10 January 2013 - 04:15 PM
#9
Re: PHP's Bad Reputation
Posted 10 January 2013 - 05:02 PM
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
#10
Re: PHP's Bad Reputation
Posted 10 January 2013 - 05:29 PM
CTphpnwb, on 10 January 2013 - 10:25 PM, said:
Quote
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.
Tayacan, on 10 January 2013 - 10:50 PM, said:
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.
#11
Re: PHP's Bad Reputation
Posted 10 January 2013 - 05:31 PM
Quote
At some point, don't a lot of little gotchas start adding up to real problems?
#12
Re: PHP's Bad Reputation
Posted 10 January 2013 - 06:30 PM
Quote
...
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
#13
Re: PHP's Bad Reputation
Posted 10 January 2013 - 06:32 PM
jon.kiparsky, on 11 January 2013 - 12:31 AM, said:
Quote
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...)
#14
Re: PHP's Bad Reputation
Posted 10 January 2013 - 06:49 PM
This post has been edited by ishkabible: 10 January 2013 - 06:53 PM
#15
Re: PHP's Bad Reputation
Posted 10 January 2013 - 06:50 PM
ishkabible, on 11 January 2013 - 01:30 AM, said:
Quote
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?
ishkabible, on 11 January 2013 - 01:30 AM, said:
Quote
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.
|
|

New Topic/Question
Reply





MultiQuote











|