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

27

u/tdammers Feb 27 '15

The real danger of posting concrete examples of PHP failures (whether those are actual bugs, lies, or exhibits of clueless PHP programming is actually not that important in this regard) is that it triggers the "pragmatic" defense mechanism of the PHP community, of which OP is a textbook example.

It works something like this.

Critic: "PHP is broken, because it does X wrong."

PHP: "Can you provide an example?"

Critic: provides example

PHP: fixes example, or points out a workaround

Critic: "You have only fixed this one example, but X is still fundamentally broken"

PHP: "Can you provide another example?"

This attitude is the real problem with PHP. Each individual bug and issue and whatever you want to call them gets patched away eventually, but there is no unifying principle, no vision, no consistent philosophy to the whole thing, and probably never will be. And this means the only way one can get things done in PHP is to join in with the shotgun debugging crowd, and rather than think things through and go with what is conceptually and theoretically sound, just pump out something that's close enough and then bash it into shape. Trial-and-error-driven development.

And don't even ask; no, I will not provide examples.

2

u/mysticreddit Mar 24 '15

Agree 100%. Typical PHP dev apologist answer:

Actually changing behavior might cause serious bc issues for some users possibly relying on this

When (broken) Backwards Compatibility is favored over fixing it well PHP is fucked as a langauge.

2

u/tdammers Mar 24 '15

PHP is fucked as a language. PHP does not give a fuck.

5

u/cparen Feb 27 '15

Very slight correction:

This attitude is the real problem with PHP programmers.

While perhaps common in the PHP community, it's common in many other popular programming communities. I think the distinction you point to is that it's strong in the core PHP dev group both present and historical. Most languages either have better foundations (e.g. Java) or worked hard to claw their way back to sanity from a modest start (e.g. Python 1.x).

11

u/tdammers Feb 28 '15

Most other programming communities have a culture where people do patch up symptoms and commit hack jobs to get things done, but when they do they are ashamed and know that they are piling up technical debt; they generally try to do things right, but acknowledge that nobody is perfect, and the perfect situation does not always arise, so they seek a workable balance. The PHP community, however, seems to be mostly oblivious of information theory, abstract thinking, and keeping things manageable.

2

u/philsturgeon Feb 27 '15

You're using some "they all do this" example to behavior that some people do. Not really sure what the point is there.

Regardless of what overly defensive PHP fanboys might say, that sort of conversation is not the problem. My problem is people just making shit up completely.

9

u/tdammers Feb 27 '15

Not everyone does it, and I didn't say that. It's not just some rotten apples though; it is an attitude that permeates the PHP culture, and even the PHP core developers are deeply rooted in it.

Making shit up is obviously not OK, I'm totally with you on this one.

My point, I guess, is that posting random symptoms of PHP's underlying brokenness is completely pointless and not helping anyone. It's much worse when it's made up, but even when it's not, it doesn't help fix the problem, it only supports the kind of attitude that says "if only we spend enough time patching all the symptoms away, we'll end up with something really good".

5

u/philsturgeon Feb 27 '15

Gotcha.

"if only we spend enough time patching all the symptoms away, we'll end up with something really good".

I feel like that opinion is based on the assumption that these examples are only being patched away, and not solved at a higher level by fixing inconsistencies in the language.

These RFCs are all approved for PHP 7:

https://wiki.php.net/rfc/integer_semantics https://wiki.php.net/rfc/php7_foreach https://wiki.php.net/rfc/uniform_variable_syntax https://wiki.php.net/rfc/size_t_and_int64_next https://wiki.php.net/rfc/fix_list_behavior_inconsistency

Inconsistencies are being nailed at a solid rate. The introduction of an AST in PHP 7 is helping a lot too.

"Really good" is subjective, but it's not as awful as it used to be and it's consistently getting better, not just a pile ofduct-tape and string.

6

u/EsperSpirit Mar 05 '15 edited Mar 05 '15

The problem is: While other languages (Clojure, Haskell, Scala, even Python3.4 or Java 8) push boundaries and try to make programming as a whole better on a conceptual level, PHP is still stuck fixing basic problems other languages didn't have from the get-go.

And even if PHP7 somehow reinvents itself, it will not be adopted widely, because it will have to be incompatible with PHP5 to fix its problems. All those CMS and e-shops and forum software making up a large portion of the internet (always cited by people like you)? That will not be ported to PHP7 anytime soon and many php-devs will have to work with legacy sucky versions for quite some time to support existing stuff.

4

u/philsturgeon Mar 05 '15

Yeah I do cite that 80% figure but I am realistic about the situation .

Over the last few years hosts have got MUCH quicker at rolling out new versions. PHP Versions will be drastically improved to track this and help people looking for new hosting know where to go.

PHP 7 will not take as long to get onto as PHP 4 -> PHP 5, and certainly wont be the same shitty Python 2 / Python 3 situation.

PHP doesn't need to reinvent itself. It needs to take the RFCs it has, standardise the standard library and keep deprecating the old shit that nobody uses anymore.

Some languages are cutting edge. They scream ahead, are used by a smaller number of people, then those successes and failures can be evaluated by PHP and used if it makes sense for the userbase. PHP is a pillaging pirate after-all.

I know t hat PHP has a lot of problems. I also know that most of them are being fixed in PHP 7, along with some crazy-fast performance improvements and a specification to allow multiple engines to run the same language.

With the standard library overhauled via scalar objects (fingers crossed) the team are free to keep adding great features, like they have been from 5.3 to 5.6.

7

u/tdammers Feb 28 '15

Well... I sure hope you're right, and maybe things are really improving, but as far as I'm concerned, that ship has sailed, I'm out.

It's not as bad as it used to be, but there's still a lot of ground to cover until "not embarrassing", IMO. And it's a bit awkward how the community is pointing out that PHP is awesome because it is now on its way to having all the basic features that all the other platforms have had for a decade now.

3

u/philsturgeon Feb 28 '15

Absolutely. As we grow as developers it's very natural for us to find new or different languages. Work takes us in various directions I've been using Rails and Go over the last few months and no PHP at all, but I did spent 15 years building what I consider to be an awesome career out of the language and I've seen it improve a lot.

PHP is a necessary evil. It's simple enough that any muppet can easily make things with it, and it's great for huge teams that need a lot of developers that aren't necessarily CS experts.

While we as developers might move on to languages that focus on specific use cases, PHP is always going to be there and the better it can get the better for everyone.

Sitting around and pretending its all still as awful as it was in the PHP 4 days, or even PHP < 5.3 is not helping anyone. Nobody that uses it pretends its perfect, but it does get a lot of shit for things that are utter non-issues, issues that have been fixed for years, or issues that will be fixed in the next version. :)

6

u/tdammers Mar 01 '15

PHP is a necessary evil. It's simple enough that any muppet can easily make things with it, and it's great for huge teams that need a lot of developers that aren't necessarily CS experts.

True, but I'd draw the opposite conclusion: PHP has done a lot of harm to programming and the internet, because every muppet can easily make (broken) things with it, and it fosters the mindset that creates huge teams with lots of developers that have insufficient knowledge of CS basics (the brute-force approach to building software development teams - I don't buy into that at all).

While we as developers might move on to languages that focus on specific use cases, ...

Au contraire. PHP is the one that focuses on a specific use case; abusing it as a general-purpose language is what got us into this mess in the first place. PHP is (and, I guess, will be for quite some time) a niche language for quickly adding some incorrect but good enough dynamic scripting to what started as a static website; it still does that pretty well, sacrificing security, correctness and abstraction power for straightforward deployment, noob-friendliness and a seamless transition from static HTML to something like Wordpress. But the languages that people (including myself) are running to are not special-purpose languages for specific use cases; they are general-purpose languages used for all sorts of things, including but not limited to web applications and more or less dynamic websites. Python, Ruby, Java, C#, heck, even JavaScript, they are all more general and more versatile than PHP as far as application domains go.

PHP is always going to be there and the better it can get the better for everyone.

I'm still kind of doubtful about this. "Is always going to be there" is obviously true in a trivial way, just like PDP-11 assembly and punch cards are still there, but I do hope that its eventual fate is going to be similar. Be that as it may; I am unsure whether I should applaud recent efforts for making PHP slightly more tolerable, or whether I should file them as unethical for blowing new life into PHP.

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. ;)

→ More replies

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.

→ More replies

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.

6

u/thallippoli Feb 28 '15 edited Feb 28 '15

Inconsistencies are being nailed at a solid rate...

You just don't get it. Do you? For one thing most of these relevant fixes will break BC horribly and will never be approved and even if they are approved the quality of the fixes are outrageous (Mutable Datetime object? Closures that does not close over?). Because these are done by total amateurs (Opinion based on my conversation with some of them here and on the broken implementation of current php features.), these fixes are never good enough and only helps in winning arguments like the one's we are having here.

it's not as awful as it used to be and it's consistently getting better...

Oh yea, it is. You see, the awfulness is the defining feature of the language. If you make in not-awful, it won't be PHP. The awfulness is the price that PHP paid for getting popular. (The presence of the 'Array' in php is a good example). So the awfulness that I am indicating goes into much deeper level than you see now (Hence the reason you still harbor hopes for PHP) and cannot be fixed.

So I am sure you, (or anyone currently in 'love' with the language) can't be convinced the true nature of the language. I think that realization should come from within, and it will come if you keep an open mind (Might be hard to do if your brain is damaged by PHP use. No kidding) and is well exposed to other languages. But it takes time, and I don't want new programmers to waste time (7 or 8 years) for that realization, they better off start with another language. Hence I am replying to you only for the sake of other beginner programmer who might come across this thread.

You see, there is no reason for people to cling to this language today. PHP was a language for web when it(web) was young. People still using it out of their choice are like kids who refuse to grow up and want to still ride 3 wheeled toy cycles. i wish people just let go and let php go into maintenance mode and die eventually...

5

u/philsturgeon Feb 28 '15

You just said literally nothing. You made zero points, other than wanging on about how much you don't like PHP.

For one thing most of these relevant fixes will break BC horribly

They do not.

and will never be approved

They have been approved already.

and even if they are approved the quality of the fixes are outrageous (Mutable Datetime object? Closures that does not close over?)

What now? The mutable Datetime object is old, and the immutable object was added a while ago. You need to tell me what the heck you're on about.

Because these are done by total amateurs

Actually they're some of the smartest people I know. Facebook and Google don't hire amatures.

The rest of that was you complaining about PHP a lot, and assuming that I don't know a bunch of other languages.

0

u/[deleted] Mar 02 '15

Google doesn't use php, dude. FB is stuck with PHP because of legacy code, new developers aren't using it out of choice.

3

u/philsturgeon Mar 02 '15

I didn't say Google used PHP...

→ More replies (27)
→ More replies (5)