PHP's Bad Reputation

  • (9 Pages)
  • +
  • « First
  • 5
  • 6
  • 7
  • 8
  • 9

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

#91 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3796
  • View blog
  • Posts: 13,742
  • Joined: 08-August 08

Re: PHP's Bad Reputation

Posted 13 January 2013 - 07:35 PM

View Postjon.kiparsky, on 13 January 2013 - 10:27 PM, said:

I think what you're not addressing is that the issue is not this language feature or that one. It's an overall failure to give a shit in the design of the language that makes programmers mental.

Well, there's giving a shit, and then there's being anal about things. If I'm going to be anal retentive about PHP's quirks then I'll need to be anal about C/C++ quirks, shell scripting quirks, and any other language I might use. That's a bit tiring.

This post has been edited by CTphpnwb: 13 January 2013 - 07:36 PM

Was This Post Helpful? 0
  • +
  • -

#92 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11092
  • View blog
  • Posts: 18,980
  • Joined: 19-March 11

Re: PHP's Bad Reputation

Posted 13 January 2013 - 07:58 PM

Nobody's telling you to be anal about PHP's quirks. You like it - go ahead and use it. No big deal.
Someone was asking about why PHP has such a bad reputation, and this is my answer: the people who made it really didn't give a damn about making a good language, and it turns out you don't get good design by accident.

Case in point: some languages require their strongly-typed variables to be declared and initialized before they can be used. Some languages will weaken one of those requirements. For example, in Java, you have to declare a variable before you can use it, and variables are pretty strongly typed (numerics can be promoted, so there's a little wiggle room, but not much). But once a local variable is declared, it can be used without explicit initialization. The compiler can handle that for you. Or in python, you don't need to explicitly declare a variable, but you have to assign to it before you can read from it - python won't try to make a value for it, even if it can infer the type from context.

Only PHP, that I know of, flops on all of those points, and allows its weakly-typed variables to be read without declaration or initialization, and tries to guess what you probably must have meant.

This is what I mean by a failure to give a shit. I'm not talking about array overruns. I'm talking about the language seems to have been designed while high and implemented while drunk, and the rest of us get the hangover.
Was This Post Helpful? 0
  • +
  • -

#93 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3796
  • View blog
  • Posts: 13,742
  • Joined: 08-August 08

Re: PHP's Bad Reputation

Posted 13 January 2013 - 08:25 PM

View Postjon.kiparsky, on 13 January 2013 - 10:58 PM, said:

Only PHP, that I know of, flops on all of those points, and allows its weakly-typed variables to be read without declaration or initialization, and tries to guess what you probably must have meant.

This is what I mean by a failure to give a shit. I'm not talking about array overruns. I'm talking about the language seems to have been designed while high and implemented while drunk, and the rest of us get the hangover.

Honestly, that's one of the things I like about PHP. I find it annoying and tedious to declare variables and even functions in C. Why shouldn't the compiler handle that for me if I don't want to be explicit? I think this is just asinine:
#include <iostream>

using namespace std;

void foo() {
	cout << "This works."<< endl;
}

int main()
{
	foo();
	bar();
	return 0;
}

void bar() {
	cout << "This doesn't work." << endl;
}

Was This Post Helpful? 0
  • +
  • -

#94 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: PHP's Bad Reputation

Posted 13 January 2013 - 08:31 PM

View Postjon.kiparsky, on 14 January 2013 - 02:58 AM, said:

Someone was asking about why PHP has Someone was asking about why PHP has such a bad reputation, and this is my answer: the people who made it really didn't give a damn about making a good language, and it turns out you don't get good design by accident.
[...]
This is what I mean by a failure to give a shit. I'm not talking about array overruns. I'm talking about the language seems to have been designed while high and implemented while drunk, and the rest of us get the hangover.

OK, now you're just being an ass. We get that you don't like PHP, but there is no need for that kind of crap.

Don't assume that just because you would have done things differently, that the people who did it this way are somehow less able or less dedicated.

I don't doubt for a second that the developers were fully aware of all of of these arguments against their chosen designs, but chose to do it this way for a reason. It wasn't designed like this out of ignorance or negligence, but because this is how they wanted the language to work. - More than that, the language became hugely popular with those core designs as they are now. Why would they change it, when the people using the language clearly seemed to like it the way it always was?
Was This Post Helpful? 1
  • +
  • -

#95 xclite   User is offline

  • I wrote you an code
  • member icon


Reputation: 1281
  • View blog
  • Posts: 4,090
  • Joined: 12-May 09

Re: PHP's Bad Reputation

Posted 13 January 2013 - 08:36 PM

I'd honestly LOVE the power of static typing with the succinctness of a dynamically typed language. Type inferencing systems help with that, but I haven't found a language with type inference that makes me happy yet.

This is dumb, for example.
ClassName varName = new ClassName();



Additionally, it's possible to infer the return type of a method in some designs/cases.

View PostAtli, on 13 January 2013 - 10:31 PM, said:

I don't doubt for a second that the developers were fully aware of all of of these arguments against their chosen designs, but chose to do it this way for a reason. It wasn't designed like this out of ignorance or negligence, but because this is how they wanted the language to work. - More than that, the language became hugely popular with those core designs as they are now. Why would they change it, when the people using the language clearly seemed to like it the way it always was?


Actually, that's exactly not the case in php:

Quote

I'm not a real programmer. I throw together things until it works then I move on. The real programmers will say "Yeah it works but you're leaking memory everywhere. Perhaps we should fix that." I’ll just restart Apache every 10 requests.

-Rasmus Lerdorf, creator of PHP.

And I think your line about changing it is presumptuous - people use php because it was the first complete, works out of the box solution for its domain. It's obviously *powerful*. People still use it because they know it and it's available everywhere and everything is written in it.

You can't change it now because people rely on the broken behavior - so even if a majority of users hated a behavior, a majority probably wouldn't be willing to change it because it would break existing functionality.

This post has been edited by xclite: 13 January 2013 - 08:37 PM

Was This Post Helpful? 1
  • +
  • -

#96 ishkabible   User is offline

  • spelling expret
  • member icon





Reputation: 1747
  • View blog
  • Posts: 5,898
  • Joined: 03-August 09

Re: PHP's Bad Reputation

Posted 13 January 2013 - 08:41 PM

I don't think PHP's poor design came from not giving a shit, I think it came from initial lack of expertise (they were in college and hadn't designed a language yet) and unguided growth/evolution from many people that were not talking the way they would've been. They started out with a decent design for writing simple things, then it grew to make bigger more complex things but not in a very consistent or thought out way. PHP is the result of natural selection rather than intelligent design. As it turns out I don't like the result of that in the case of PHP.
Was This Post Helpful? 1
  • +
  • -

#97 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11092
  • View blog
  • Posts: 18,980
  • Joined: 19-March 11

Re: PHP's Bad Reputation

Posted 13 January 2013 - 08:45 PM

Quote

Don't assume that just because you would have done things differently, that the people who did it this way are somehow less able or less dedicated.

I don't doubt for a second that the developers were fully aware of all of of these arguments against their chosen designs, but chose to do it this way for a reason.


What might that reason have been? I can't think of one. If you can think of one, that would be interesting. "I'm sure they had a reason" sounds more like faith in a higher power than a reasoned argument about a language design.
Was This Post Helpful? 0
  • +
  • -

#98 xclite   User is offline

  • I wrote you an code
  • member icon


Reputation: 1281
  • View blog
  • Posts: 4,090
  • Joined: 12-May 09

Re: PHP's Bad Reputation

Posted 13 January 2013 - 08:47 PM

In my software development experience, "They had a reason" is almost always code for "They didn't have time, didn't know, or didn't care."

It's never "it was the best design."

This post has been edited by xclite: 13 January 2013 - 08:48 PM

Was This Post Helpful? 1
  • +
  • -

#99 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3796
  • View blog
  • Posts: 13,742
  • Joined: 08-August 08

Re: PHP's Bad Reputation

Posted 13 January 2013 - 09:28 PM

View Postjon.kiparsky, on 13 January 2013 - 11:45 PM, said:

Quote

Don't assume that just because you would have done things differently, that the people who did it this way are somehow less able or less dedicated.

I don't doubt for a second that the developers were fully aware of all of of these arguments against their chosen designs, but chose to do it this way for a reason.


What might that reason have been? I can't think of one. If you can think of one, that would be interesting. "I'm sure they had a reason" sounds more like faith in a higher power than a reasoned argument about a language design.

I gave the reason in post 84: convenience for the PHP coder. Everything submitted by the user is a string but there are many times when you will need to treat it as a numeric. Not forcing you to convert things manually is a legitimate design choice.
Was This Post Helpful? 0
  • +
  • -

#100 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11092
  • View blog
  • Posts: 18,980
  • Joined: 19-March 11

Re: PHP's Bad Reputation

Posted 13 January 2013 - 09:35 PM

Legitimate, yes. Also, bad.

This design decision prioritizes dumping bits into the machine over making sure those bits are the ones you actually want. Consider that for any piece of code, either it's useful or it isn't. If it's useful - serves its purpose well, etc. - then it will continue to exist. If it continues to exist, people will need to fix it, and they will want to extend it. This will continue as long as the code is useful: if you are no longer maintaining code, it's probably not being used. Therefore, the important thing is not the convenience of the person writing the code, but the person maintaining it. The only exception, of course, is if the code is not useful, in which case it should not be written in the first place.

Prioritizing the developer over the maintainer is a pure amateur mistake.
Was This Post Helpful? 0
  • +
  • -

#101 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: PHP's Bad Reputation

Posted 13 January 2013 - 09:37 PM

View Postxclite, on 14 January 2013 - 03:36 AM, said:

Actually, that's exactly not the case in php:

Quote

I'm not a real programmer. I throw together things until it works then I move on. The real programmers will say "Yeah it works but you're leaking memory everywhere. Perhaps we should fix that." Iíll just restart Apache every 10 requests.

-Rasmus Lerdorf, creator of PHP.

Lerdorf was actually only "the creator" of the first two version, which weren't all that popular. The first version that became popular was actually a complete rewrite, written by two others. You can only really credit Lerdorf as "the creator" of the idea of PHP, not as the "designer" of the language as it exists today.

It's true though, that the two developers who did design PHP 3 were pretty young. But they weren't ignorant or negligent either, though I suppose their lack of experience may have contributed to their decisions, like†ishkabible says. That much I'll yield :)/>

Quote

What might that reason have been? I can't think of one. If you can think of one, that would be interesting. "I'm sure they had a reason" sounds more like faith in a higher power than a reasoned argument about a language design.

The reason is no big mystery, and we've mentioned it several times already. PHP was meant to be simple to use. That's pretty much what they were aiming for. Dynamic and weak typing serves that purpose perfectly, as there are no declarations needed nor any explicit initializations. So does PHP's forgiving, implicit type-casting.

This concept is not entirely lost on the designers of other languages either, come to think about it. Don't both Java and C# implicitly call object's "toString()" method when the VMs detect they are being used as strings? PHP just kind of takes that though a few steps further.

Nobody here is claiming PHP is perfect. In fact, some of us have already (a few pages earlier, in fact) conceded that PHP is not, and never was meant to be, the equal of languages like C++ or Java. It wasn't meant to be used in the same way. It does what it was meant to do pretty well though, even though some of the robustness of those "superior" languages are lost in the process.

That's where it's bad reputation comes from. I think we can all agree on that much.
Was This Post Helpful? 2
  • +
  • -

#102 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3796
  • View blog
  • Posts: 13,742
  • Joined: 08-August 08

Re: PHP's Bad Reputation

Posted 13 January 2013 - 09:47 PM

View Postjon.kiparsky, on 14 January 2013 - 12:35 AM, said:

This design decision prioritizes dumping bits into the machine over making sure those bits are the ones you actually want.

No it doesn't. Making sure those bits are the ones you want is up to you, the developer, and this choice doesn't prevent you from doing that. All it does is allow you to not do it if you so choose.
Was This Post Helpful? 0
  • +
  • -

#103 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11092
  • View blog
  • Posts: 18,980
  • Joined: 19-March 11

Re: PHP's Bad Reputation

Posted 13 January 2013 - 09:50 PM

Quote

That's where it's bad reputation comes from. I think we can all agree on that much.


Yes: its manifold imperfections are the main source of its bad reputation among programmers.
This sounds like consensus to me: if anyone asks, why does PHP have such a bad reputation among programmers, we can all agree to answer, because of the langauge's design.

I think there's a derivative source as well, though. Because the language is easy to get started in, you have a lot of users of the language who come from, shall we say, a weaker starting place as far as programming goes, and who commit what we might call "howlers" a little more often. And because the language is designed to trundle along as best it can, the code will run despite their best efforts, and then we come across these things in the wild, and they make us want to claw out our eyes, and we blame the language for that.

So to some extent we can blame poor programmers as well.

This post has been edited by jon.kiparsky: 13 January 2013 - 09:51 PM

Was This Post Helpful? 0
  • +
  • -

#104 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11092
  • View blog
  • Posts: 18,980
  • Joined: 19-March 11

Re: PHP's Bad Reputation

Posted 13 January 2013 - 09:56 PM

Quote

No it doesn't. Making sure those bits are the ones you want is up to you, the developer, and this choice doesn't prevent you from doing that. All it does is allow you to not do it if you so choose.


This seems like what it means is probably not what you meant to say. A language is a tool for generating code, by which we presumably mean correct code.
Under what circumstances would we not want to generate correct code?
And how is it anything but a failure if your language encourages you to get it wrong?

"We get 10% more bugs per hundred lines, but we can write more lines, faster" is a losing proposition, don't you think?

This post has been edited by jon.kiparsky: 13 January 2013 - 10:19 PM

Was This Post Helpful? 0
  • +
  • -

#105 e_i_pi   User is offline

  • = -1
  • member icon

Reputation: 879
  • View blog
  • Posts: 1,893
  • Joined: 30-January 09

Re: PHP's Bad Reputation

Posted 13 January 2013 - 10:13 PM

Ah crap on a stick, I just edited jons post instead of replying to it :( I'm so sorry jon, mea culpa
Was This Post Helpful? 0
  • +
  • -

  • (9 Pages)
  • +
  • « First
  • 5
  • 6
  • 7
  • 8
  • 9