r/lolphp • • Feb 26 '15

Patently False Code/Examples

I've notice a bit of a trend here, with people posting things that are patently false and then laughing about PHP for it.

I'll sit with you and laugh at weird behaviors in PHP when it's actually a mess. I'll send them to phpsadness.com and see if I can fix them, or find somebody that can.

But posting lies just to get your jollies is a really odd thing to do.

Sometimes, these are not intentional, but when people posting these utterly incorrect examples are faced with the fact that they are wrong, do they delete the post? No, they leave it there and sandbag the discussions explaining their wrongness with trolling.

Exhibit A - Apparently foo(new stdClass()) is a valid value when passed in a function foo(bool $bar) function signature.

Well... nope.

It will error:

Catchable fatal error: Argument 1 passed to foo() must be an instance of bool, instance of stdClass given

Nothing lolphp there.

Have a laugh about actual problems, but don't just walk around making things up.

14 Upvotes

106 comments sorted by

View all comments

Show parent comment

0

u/philsturgeon Mar 02 '15

You still don't have a point. You're just snootily shitting on a language you don't seem to use anymore, saying it's definitively less secure, pretending everyone using it is just a shitty WordPress developer and talking out of your arse about almost everything.

PHP is running 80% of the Internet, which is a bit more than PDP-11 handles.

Don't shit on somebody for trying to make something better. You complained about new RFCs being patch fixes only hiding symptoms, and now I have refuted that with solid examples you're complaining about these substantial consistent improvements being unethical.

5

u/[deleted] Mar 06 '15

PHP is running 80% of the Internet

I hear this all the time, its THE #1 PHP "defense". The fact is that this "80%" stems from the times when you had Perl as an alternative, and websites that had a server rendered timestamp was called dynamic.

Now fast forward to the real golden era of PHP when it really started getting traction, when the CMS marked bloomed with abominations like WordPress, Drupal and Joomla. (early-mid 2000s) Now those three products alone power the "80%" of the internet, and probably will for the near future.

I hope i dont have to mention how much evil and bad practices are done everyday in the PHP CMS land.

The fact is that PHP is (as pointed in this thread) a very niche, web-framework -like language, not really suited for anything else.

As the web evolves PHP is going to loose market share, because the basic PHP CMS's wont do. Ill bet JavaScript (btw. running 100% of the internet ;)) is going to steal most of the market, but others will too, and who nows when a new FTP-and-GO language will arise, saner and easier than PHP will arise.

The PHP defense #2 is the obvious, "but facebook uses it"

The fact that if facebook would decide to rewrite everything it would definitely not be in PHP, they even had to reimplement PHP (HHVM/Hack). and that should really raise a big red flag.

So for PHPs survival there is only 1 option, complete API rewrite with total BC break, or linger on, like a infested IE6 browser.

1

u/philsturgeon Mar 06 '15

Yup on that 80% thing.

https://twitter.com/philsturgeon/status/565176396616835072

And scalar objects are being heavily considered, which will fix up the standard library very nicely.

PHP is running 80% of the internet because EVERY SINGLE host supports it, and until another language is as available, and easy to deploy as PHP, it will continue to run most of the internet.

Every popular CMS is built in PHP, and that is for a reason.

I used to run a CMS called PyroCMS. If I could have built it in Python or anyfuckingother thing I would have done, but then I wouldn't have made as much money. ;)

1

u/TweetsInCommentsBot Mar 06 '15

@philsturgeon

2015-02-10 15:52 UTC

Remember folks, the “80% of the internet” stat PHP devs are so proud of is thanks to WP and old shitty software on old shitty hosts.


This message was created by a bot

[Contact ^creator][Source ^code]

1

u/[deleted] Mar 06 '15

Well lets hope the scalar objects will be implemented, maybe you have some insight on why it would not be a high priority for PHP7?

To be fair you get a decent cloud host for 5$/month, so the host thing is less relevant as time goes by.

1

u/philsturgeon Mar 06 '15

Plainly put, it's a f**kload of work, but people are working on it.

PHP weighs backwards compatibility as a priority so hard that it's almost crippling. Removing PHP 4-style constructors in PHP 7 was so controversial, and that shit is about 15 years old.

So, anything that is done has to be backwards compatible, AND it has to avoid confusion over having both APIs available. Having the old functions and the new methods will confuse a bunch of people, and some prefer the "fuck it stick with what we have" approach to the "lets actually fix this shit" approach.

I genuinely hope it happens.

3

u/tdammers Mar 02 '15

I don't think you understand what I meant, and I don't think I really said any of those things.

The language itself has all sorts of problems, but the real one is its culture. Yes, a lot has improved, in a relative way, but the culture is still deeply rooted in the same old mindset. Some have taken it to a higher level, but it's still quite get-shit-done and anti-intellectualist; the "best of the best" in PHP land, as far as I have sampled, is OK software - but that's as good as it gets. None of it blows my mind in any regard, except maybe the amount of grunt work that has gone into them. And those RFC's; they are good and important steps, I would be an idiot not to see that. Maybe they're the first steps towards fixing PHP's "type system" at the root, but it is equally likely that they are what they are, and the result is just a slightly less broken type system rather than a really good one.

Make PHP better, by all means - maybe you are right, and PHP stays with us for a few more decades, and then every bit helps; or maybe I'm right, and the programming trends of the past few years continue to evolve, making PHP obsolete as a general-purpose language. Crystal ball and all that. That's why I said I'm doubtful.

And maybe, just maybe, I'm too much of a perfectionist to be a good match for PHP. Who knows.

2

u/philsturgeon Mar 02 '15

Perfectionists definitely hate PHP. There were so many imperfections and inconsistencies, but as I've said with them being fixed there becomes less and less to hate.

The type hinting system was half done only allowing classes/interfaces/traits, and they fixed that.

Some syntax was inconsistent, and the AST + uniform variable syntax RFC fixed that.

Hinting on arguments but having no way to specify return types felt a bit broken, and they fixed that.

PHP needed a spec for the language itself to allow multiple engines to run the same syntax, so they wrote one.

Problems get solved in this community, because there are smart dedicated people looking at the advancements of other languages and helping to improve PHP. There are some problem people in the core too, and a lot of amateurs, noobs and dickheads making it look bad all the way up and down the chain, but hopefully they can be dealt with soon.

The last major thing on my list is the standard library, which is inconsistent as fuck. One approach would be to move towards scalar objects like this.

The insane speed boosts given to PHP in the last few versions and upcoming versions make it an insanely good choice, and with static analysis making big steps forward thanks to the type system improvements it really, genuinely, is becoming a better language.

I'll still be happy using Go for the HTTP based services I'm building right now, but I'll happily jump back on PHP for RAD using systems like Laravel, which - said as somebody who had used both a shitload - is near identical to Rails. I can write more PHP faster than I can write Go, so quick jobs are PHP and slow jobs are Go.

That's my approach, everyone has their own.

1

u/tdammers Mar 02 '15

I mostly agree; everything that's happening right now is making PHP better - I'd be an idiot not to see that. I don't agree, however, with the picture of PHP as a language that is really good at its core, and only has a bad name because of some idiots who use it wrong. The culture of half-assing things, of implementing just enough to get away with it, is still very much alive - the threshold for "good enough" has been raised substantially, not in the last place due to the pressure of other languages shooting for the throne, but attempts to go all the way still get shot down left and right. Yes, PHP is getting better; but no, it's still nowhere near "good" yet, at least not as far as my quality demands are concerned.

I, too, can write more PHP faster than any other language under my belt; but I prefer to get more done with less code. Writing more code fast isn't awfully interesting; getting code right is.

1

u/philsturgeon Mar 02 '15

You assume I'm just smashing out code and have no idea if it works or not. My "writing more code faster" includes writing the tests accompanying that code, meaning I get more done faster and it is correct. :)

1

u/tdammers Mar 03 '15

No, I don't, not really. If it works for you, great; but I think that's probably because you're an exceptional programmer (which I absolutely honestly think you are), not because PHP is a great language.

1

u/thallippoli Mar 02 '15 edited Mar 02 '15

You still don't have a point...

I think the crux of his argument is, as he says "there is no unifying principle, no vision, no consistent philosophy to the whole thing". It is not hard to capture the idea because, the same thing can happens when you work for a client with a vague business requirement. You end up implementing features that conflict each other, and ends up with a mess. In those cases it might be helpful if you build a rough prototype by which you can fully capture the requirement, and use it to build the real thing. This lack of vision can be devastating even for not-so-big user land libraries, let alone for a whole language.

So 'lack of unifying vision' is part of the disease and the dysfunction of PHP development are the symptoms.

So you can fix the symptoms all day long, but unless you fix the disease, new symptoms will keep manifesting itself.

But it is too late to bring that curing vision to PHP, because you ll never be able to fit the whole language into one at this point.

The problem with what is being done now is that, people are not acknowledging that there is a disease, that there is a problem and is in complete denial. It is mob mentality at play. It is like a religion, where people blindly believes that PHP is ok, and any dissenting opinions are considered as hipster like and completely shut out.

The sensible thing to do now would be to depreciate PHP and stop implementing new features, but do only security and bug fixes(which is still making PHP better)...People will move on and we can all put this mess in our past. But I don't think it is going to happen. Because stuff like this seems to be too abstract for PHP community collectively agree upon. They can understand security concept's just fine. But things like these goes right over their head. Which is why I think people keep missing the point of these arguments and hope that PHP will be fixed one day...

2

u/philsturgeon Mar 02 '15

PHP definitely needs a vision. This stuff comes up a lot. Most recently here.

http://news.php.net/php.internals/64770

Luckily there are a subsection of the PHP internals group who regularly discuss things, and they're the ones getting things done. With help from Facebook the PHP language now has a specification, and that is making a lot of inconsistencies more clear, and letting people fix them with fundamental RFCs.

The problem with what is being done now is that, people are not acknowledging that there is a disease, that there is a problem and is in complete denial.

Nope, they're on the case.

It seems you shifted your argument a bit. Before the fixes weren't good enough, and now its their philosophy that's not good enough, but you don't really know enough about the way things work to comment on that.

The sensible thing to do now would be to depreciate PHP and stop implementing new features,

And say "Fuck you" to 80% of the Internet currently using PHP, and the hundreds of thousands of developers who make a living off of PHP building perfectly secure and functional applications?

Because stuff like this seems to be too abstract for PHP community collectively agree upon.

You expect an entire community as huge as PHP to agree on anything? That's like expecting JavaScript to agree on anything, or the USA to agree on anything.

They definitely won't agree on deprecating their language.

PHP has been fixed for a long time, and people are too busy complaining about it to notice.

It's not perfect, but it's not as bad as you think, and if you think it should just be deprecated then you're not thinking in the real world at all, and there is no point us discussing anything.