What is so bad about PHP?

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

45 Replies - 23286 Views - Last Post: 24 August 2012 - 07:46 PM

#16 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5776
  • View blog
  • Posts: 12,587
  • Joined: 16-October 07

Re: What is so bad about PHP?

Posted 16 August 2012 - 08:14 AM

Why people like PHP: It's pretty simple and almost anyone can use it.

Why people hate PHP: See above.

I'm serious. There is nothing wrong with PHP as a language. It probably has no more or less quirks than any other language. The problem is, newbie programmers DO things with it. And, frankly, newbie programmers write crap. So, based on volume, PHP code in the wild has a very high crap quotient.

It should be noted that this is the same reason people hate Javascript. It's also a big reason for VB hate.

PHP is a huge mess of functions. It's OO system isn't great. However, you can whack together a simple web site with PHP probably faster than anything else. Not only that, deploying that website is just a copy. Try deploying an industry heavy weight like Java servlets...

One thing PHP lacks in an IDE. You're still writing script. Ok, you can use something like Eclipse for those scripts, but the GUI is hand written. Compare that to ASP.NET with drag and drop form design. But you need a lot to get an ASP.NET site up...

Story time: I'm in a Microsoft shop. We have all the MS toys. A bunch of junior programmers used ASP.NET to get an enterprise app up and running. They struggled, I guided. One of the team came to me later and told me about an update to the company website she'd made. The site had some dynamic pages that read from a database. She added a new page by copy and pasting some PHP code I'd used. She'd never seen the language before, but it was clear how to tweak it. "It was so simple," she tells me. "Can we use this for other projects?"
Was This Post Helpful? 4
  • +
  • -

#17 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6036
  • View blog
  • Posts: 23,418
  • Joined: 23-August 08

Re: What is so bad about PHP?

Posted 16 August 2012 - 08:23 AM

baavgai, with you guiding them, those Junior Programmers are going to be great Senior Programmers someday.
Was This Post Helpful? 1
  • +
  • -

#18 Elihu5991  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 06-January 12

Re: What is so bad about PHP?

Posted 17 August 2012 - 03:29 AM

So your saying that, as with any language, if used properly it's fine? What about the messy setup and it's plethora of useless (as I'm told) function and poor OO? Simple isn't always best ;)

Would ASP.NET be any good?
Was This Post Helpful? 0
  • +
  • -

#19 Cbeppe  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 31
  • View blog
  • Posts: 215
  • Joined: 16-September 09

Re: What is so bad about PHP?

Posted 17 August 2012 - 03:56 AM

View PostElihu5991, on 17 August 2012 - 04:29 AM, said:

So your saying that, as with any language, if used properly it's fine? What about the messy setup and it's plethora of useless (as I'm told) function and poor OO? Simple isn't always best ;)

Would ASP.NET be any good?


Try PHP. Seriously. The functions you don't use will not bother you in any way. To make sure you do things correctly, use MySQLi or PDO for your database stuff. If you want, you can also use OO.

The only real thing I have against PHP objects is that a class can only extend one other class.

The plethora of functions is one of the things I love about PHP. For example, if I wanted to reverse an array in Java, I would have to do something like this:
private Item[] reverseItemArray(Item[] a){
    for(int i = 0; i < a.length/2; i++){
        Item temp = a[i];
        a[i] = a[a.length - i - 1];
        a[a.length - i - 1] = temp;
    }
    return a;
}



In PHP, I could just do this:
$result = array_reverse($array);



These things speed up development time. And although I'm sure most people have reversed an array in their language before, there will be a PHP function for just about everything you want to do. This lets you develop large applications in record time. Unfortunately, the fact that it's easy means that many people who may not be the best of programmers can produce code, and put it online.

As for what's bad about PHP, Facebook uses PHP for all their websites and the only problem they've had, that I can recall seeing, is the speed. They came up with a solution that, if I remember correctly, translates PHP code into C++ and then compiles it. I'm not 100% sure about this last part, but it went something like that.

Now, while I've never seen any of FB's code, I'd like to think that they wouldn't have stuck with PHP if it was bad. They would have had the resources to change to ASP.NET, Perl, Python, etc. if they wanted to, but decided not to. With that said, I've never tried ASP, but that's because I've never felt the need to when coding websites.

Also, according to FB, PHP people are cheaper than C++ programmers ;)
Was This Post Helpful? 1
  • +
  • -

#20 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5776
  • View blog
  • Posts: 12,587
  • Joined: 16-October 07

Re: What is so bad about PHP?

Posted 17 August 2012 - 03:59 AM

*
POPULAR

It's not really the uselessness of functions, but the plethora of them. :P

PHP started from humble beginnings. The letters standing for "Personal Home Page (Tools)." Like any language, it's grown since... Not only have many functions been added since 1.0, but there seems to be an active attempt to make it more programmer friendly. Meaning more things programmers like, things like OO, safety checks, etc. It has reached a point where any given task has not just many approaches, but many standard ( often opposing ) libraries to choose from.

The same could be said of most languages with any longevity, though. If you go ASP.NET, then your function set is the .NET Framework. This framework, 1.0, is an excellent example of a well designed, well thought out code base. Now, at version 4.5, that framework supports many opposing ideologies and tools.

It's the evolutionary nature of code bases. In natural environments, supplanted entities naturally die out. In programming environments, code get depreciated, but if the user base screams loud enough, it never dies. Microsoft still supports XP, though they've tried to kill it several times. PHP supports both 4.x and 5.x; users won't let them kill 4.x.

Simple IS always best! However, simple is hard.

Edit: Lost my point... As long as you choose a methodology and stick with it, the other language resources you DON'T use don't matter.

This post has been edited by baavgai: 17 August 2012 - 04:01 AM

Was This Post Helpful? 5
  • +
  • -

#21 vectorialpx  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 28
  • Joined: 16-July 12

Re: What is so bad about PHP?

Posted 17 August 2012 - 06:38 AM

I agree with baavgai about "The problem is, newbie programmers DO things with it. And, frankly, newbie programmers write crap."

The main problem with PHP is that, because it has a simple language, everyone thinks it's easy to code a website or an application but lots of kids don't understand that programming is not just writing code, it's about having a school OR knowing some principles, gaining experience and, first of all, thinking.

BUT I have a small problem with PHP: the consistency of the language.
Simple examples
* nl2br or bin2hex VS strtopos (why? str2pos or nltobr was not taken)
* in_array($needle, $haystack) VS substr($haystack, $needle)
* strpos VS str_split (why not strsplit or str_pos?!)
and there are more. But, it's just the way it is! :)
Was This Post Helpful? 1
  • +
  • -

#22 Elihu5991  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 06-January 12

Re: What is so bad about PHP?

Posted 17 August 2012 - 06:40 AM

What is with developing sites with C++? I thought that was killed many years ago?

So then why do languages start contradicting themselves over time?
Methodologies? Like what exactly do you mean as I'm thinking of several different things with that statement.

So what exactly makes PHP so famous? The same for My SQL.

NOTE: Sorry, #21 vectorialpx, when I posted this your post wasn't there.

This post has been edited by Elihu5991: 17 August 2012 - 06:41 AM

Was This Post Helpful? 0
  • +
  • -

#23 vectorialpx  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 28
  • Joined: 16-July 12

Re: What is so bad about PHP?

Posted 17 August 2012 - 06:42 AM

View PostElihu5991, on 17 August 2012 - 06:40 AM, said:

What is with developing sites with C++? I thought that was killed many years ago?

So then why do languages start contradicting themselves over time?
Methodologies? Like what exactly do you mean as I'm thinking of several different things with that statement.

So what exactly makes PHP so famous? The same for My SQL.

Both are simple, free, reliable and light (if you understand the limit, of course).
Was This Post Helpful? 0
  • +
  • -

#24 Elihu5991  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 06-January 12

Re: What is so bad about PHP?

Posted 17 August 2012 - 06:44 AM

What do you mean by it's just how it is? So if the developer knows what they're doing and/or is willing to properly code, they can?

View Postvectorialpx, on 17 August 2012 - 09:42 PM, said:

View PostElihu5991, on 17 August 2012 - 06:40 AM, said:

What is with developing sites with C++? I thought that was killed many years ago?

So then why do languages start contradicting themselves over time?
Methodologies? Like what exactly do you mean as I'm thinking of several different things with that statement.

So what exactly makes PHP so famous? The same for My SQL.

Both are simple, free, reliable and light (if you understand the limit, of course).


What part of my post are you referring to?
Was This Post Helpful? 0
  • +
  • -

#25 vectorialpx  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 28
  • Joined: 16-July 12

Re: What is so bad about PHP?

Posted 17 August 2012 - 06:48 AM

View PostElihu5991, on 17 August 2012 - 06:44 AM, said:

What is with developing sites with C++? I thought that was killed many years ago?

So then why do languages start contradicting themselves over time?
Methodologies? Like what exactly do you mean as I'm thinking of several different things with that statement.

So what exactly makes PHP so famous? The same for My SQL.

Sorry for my ambiguity, I was talking about PHP/MySql vs C++/Others
Was This Post Helpful? 0
  • +
  • -

#26 Elihu5991  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 06-January 12

Re: What is so bad about PHP?

Posted 17 August 2012 - 06:57 AM

That's ok. Though what do you mean by the limit? I mean, I'd like a better understanding of them.

This post has been edited by Atli: 17 August 2012 - 08:07 AM

Was This Post Helpful? 0
  • +
  • -

#27 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5776
  • View blog
  • Posts: 12,587
  • Joined: 16-October 07

Re: What is so bad about PHP?

Posted 17 August 2012 - 07:02 AM

View PostElihu5991, on 17 August 2012 - 09:44 AM, said:

What do you mean by it's just how it is?


Programmers like to program. They use tools generated by other programmers, but it is still never as good as the tool they'd write. So you often get overlap in functionality as a code base grows. Particularly if a library is trying to stay self contained with few dependencies.

Every programmer feels their style is the best style; because it's theirs. Unless a programmer is forced to do so, they'll use their own bloody system, which is what everyone else should be using, anyway. Hence, vectorialpx's excellent examples of inconsistent naming.
Was This Post Helpful? 0
  • +
  • -

#28 Elihu5991  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 06-January 12

Re: What is so bad about PHP?

Posted 17 August 2012 - 07:04 AM

Are all languages like this?
Was This Post Helpful? 0
  • +
  • -

#29 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7564
  • View blog
  • Posts: 12,684
  • Joined: 19-March 11

Re: What is so bad about PHP?

Posted 17 August 2012 - 08:19 AM

View PostElihu5991, on 16 August 2012 - 08:33 AM, said:

I appreciate your thoughts, everyone; but it doesn't adequately explain the pros and cons. I still don't completely know why people gravely dislike or passionately love it php.


Some people love PHP because it allows them to do things they want to do - for example, they can quickly and easily make dynamic web pages that look pretty good.
Some people hate PHP because it facilitates grave mistakes in coding which can be subtle, dangerous, and impossible to detect by automatic means.
For a simple concrete example, consider variable declaration and use. In PHP, you don't need to declare a variable, and variables are not typed, which some people like. As a consequence, if you come to a new piece of code and you find that the previous programmer has typed
liszt.someMethod();


you have no way of knowing whether that is a typo (and what they meant was "list") or whether they're using an object called "liszt" for some reason. (this is a real example!) Some people hate this.

Should you love PHP or hate it?
No. You should learn it if you're working with web programming, because it's ubiquitous. You should know how to use it well, if it's the right tool for the job, which means knowing how to use its features and how to avoid its gotchas. If you enjoy using it, great - you still need to know where it bites you in the ass, because as a web programmer you can't let your enjoyment of the language blind you to its gotchas. If you hate using it, fine. You'll have to work with it some times, and as a web programmer you can't look down your nose at a language just because you don't enjoy it.
Was This Post Helpful? 1
  • +
  • -

#30 Cbeppe  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 31
  • View blog
  • Posts: 215
  • Joined: 16-September 09

Re: What is so bad about PHP?

Posted 17 August 2012 - 11:04 AM

View PostElihu5991, on 17 August 2012 - 07:40 AM, said:

What is with developing sites with C++? I thought that was killed many years ago?


They don't develop websites using C++, they have something like a Just-In-Time compiler that translates the written PHP code into basic C++ code, to which the compiler can further optimize. It basically gives PHP the speed benefit of a compiled language, while being interpreted. This allows Facebook to use their existing library of code and employ PHP developers instead of a specialized set of C++ developers. This of course saves them money.

The software is supposedly called HipHop and can be seen here: Facebook Developers Blog
Was This Post Helpful? 1
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4