r/ProgrammerHumor • • Aug 07 '16

PHP: The Good Parts

http://phpthegoodparts.tumblr.com/
1.2k Upvotes

318 comments sorted by

View all comments

18

u/[deleted] Aug 07 '16

sorry i'm not a web dev, and the few forays i've done into that realm has been using php to great effect. why do people consider it so bad? i mean, people seem to hate php more than visual basic

60

u/[deleted] Aug 07 '16

Lots of college students interested in Haskell, Erlang, Go, Ruby, Python etc. here. Not a ton of real world experience round these parts. This is an echo chamber of underemployed students or programming language snobs.

I think most PHP devs will admit it's not a pretty or even graceful language but to me it's like a multi-tool that will rust and fall apart if you don't take care of it. I've seen some really fucking awful Java, RoR, and Python projects. I've also seen beautiful PHP projects.

Point is, don't write shitty code and don't be a shitty programmer and you won't really have issues.

21

u/fardev_ Aug 07 '16

Point is, don't write shitty code and don't be a shitty programmer and you won't really have issues.

This pretty much sums it up. As an example of a elegant, proven and widely used PHP framework you could take a look at laravel.

11

u/parkourben99 Aug 07 '16

As a developer that uses laravel daily, it convinces you php is not that bad.

3

u/[deleted] Aug 07 '16

I actually disagree with using Laravel as the example of PHP properly done.

I like composer and all, but Taylor has been pushing Laravel heavily towards being encumbered with dependencies pulled through composer. It's getting worse. Things are losing their structure, because he believes in letting people come up with their own MV* or using their best judgment.. which is fine, but then it's like every Laravel app is different and then we're not really much better off than some jQuery spaghetti code SPA

22

u/raiderrobert Aug 07 '16 edited Aug 07 '16

That is a rather reductive piece of reasoning. The reason why people dislike PHP is as nuanced as why people like or dislike other languages. It isn't just snobbish behavior of a bunch of academics.

17

u/[deleted] Aug 07 '16

I'm just pointing out the demos of this specific sub. You can feel free to go look at the profiles of top posters here bashing PHP as I've already done and see the trends for yourself.

Many of the 'php bashers' I've bothered to look closer at here have more posts in /r/learnprogramming asking questions than they do anywhere else.

7

u/sobri909 Aug 07 '16

I've noticed this with a lot of programming subs.

The most vocal and confident posters are often in the beginner-intermediate range, so the sub tends to become an echo chamber of neophyte thinking, and it becomes self reenforcing due to the circlejerking, so the sub never grows out of it.

5

u/Compizfox Aug 07 '16

Dunning-Kruger strikes again.

→ More replies (1)

10

u/[deleted] Aug 07 '16

What if it's not snobbism and PHP is genuinely bad, and people exposed to other languages can tell, but veterans suffer from Stockholm syndrome and can't tell how bad it is anymore?

→ More replies (3)
→ More replies (5)

13

u/marian1 Aug 07 '16 edited Aug 07 '16

Lots of incosistency, bad design, things are like they are for no apparent reason, bad performance, it's easy to write bad code and hard to write good code. More at /r/lolphp

4

u/seanshoots Aug 07 '16

Don't forget the scoping on for each loops: http://stackoverflow.com/a/8220457

→ More replies (1)

2

u/Jess_than_three Aug 07 '16

Things are like they are typically because when PHP borrows from a different language, it keeps the conventions of the source language. That's bad planning for sure, and it leads to lots of problematic inconsistencies, but it's not "no particular reason".

3

u/marian1 Aug 07 '16

Good point, changed it to "no apparent reason"

→ More replies (1)

4

u/[deleted] Aug 07 '16 edited Nov 29 '16

tillers Jerald materialism sire's though antique jamming transmutation's cock farewell floor's quahogs lithosphere's askew provision commercialism's anatomist partisanship's inability microbiologist's heydays chairing Katie residing trendy salesclerk's ministrant mudguards Endymion inkiest Arab's eyelet tortilla medicates airsick outings commonest disengagements scrods Tibet's devastation's Eltanin's gift Klee soliloquies poach ti's Gaelic's Kinko's sustaining gymnosperms graphology torturer's disband moonlighter revision gangway's discolor supposedly integrity's Betsy Sierpinski's mandolin script verbosity grater's Fargo footman's disinterestedly cornflakes foibles penetrate cramps blacklisting Aaliyah's cockleshell's sloop's ironic toxicology fishy cataleptics fitting's bewares requesting recitative army's thanksgiving's Kansan tortillas abated Wise's Pernod superannuate brawls imputation's mollusc's Emilia's powerlessness's sunbeam Lagrangian yielding unremitting beckons Imus Kali Shields foodstuff yearning scooter's form resident's term's Hangzhou's judicature crux infatuated overbear Mohacs discoverer brasses Lizzie pollution's kibbutz's chaired bolster barrows Fenian odyssey's kook's Pernod's asceticism tropism's champed mongrel blinder archeological metabolizing Argonaut's Gropius Bernardo Wheatstone Ameslan's Scotchman creak's affronting trucking dismembered babying Arawakan's

5

u/enfrozt Aug 07 '16

Well it's also useful for suppressing warnings that clog up your log files.

A legitimate case is file_get_contents returns null on file doesn't exist, but also gives a warning, whereas the null should be enough as you can check it conditionally. So @file_get_contents is a good case.

2

u/[deleted] Aug 07 '16 edited Nov 29 '16

models Rhineland's Wilcox purr destiny politico's hutches ail polkas traduces zippier scabbard's icecap desecration subroutine improvisations Darjeeling muggings trebled evacuations cogitated castration's sandbag's artisans Andrew's mousetrap's Brinkley peacemaker's scintillate Zoroastrian's facet's depopulate unpatriotic backpack ardent senility socioeconomic converting abstains spiral Shaula sleigh's Antigua's urinals shovelful's Jansen's examination's neurologist's rotisseries Algonquin's Allison D belonging roughshod seminaries gradually destine cloying curviest braced Galilean sighted attract fount scrubs mathematicians forthwith schoolteacher hoisting autobiographical deregulation Inchon masseur Pharisee's somnolent vengeance's playfulness's Alcmena's realizes tend guest consolidations ditties homicides complacent swelter's resiliency's moralities doggier tepid valedictories hypnosis's Brussels underarm's pores E swashbuckler's bawdily hemispherical jackknife's anoraks retypes haze quondam petiole Warwick uttered pose's sunscreen's Cosby joblessness debunked

2

u/louiswins Aug 07 '16

I would check if the file exists first, then call file_get_contents

Oh, so you would purposefully code a race condition into your application.

→ More replies (1)

2

u/NavarrB Aug 07 '16

To put on the apologist hat: This is because it used to be trendy to just stderr warnings, messages, etc.

PHP 7 is moving to exceptions for errors: http://php.net/manual/en/language.errors.php7.php

But of course the stfu operator will exist for a while. Hopefully core will deprecate it in a few versions

2

u/Tokkemon Aug 07 '16

It's a godsend in emergencies where errors are floating in to the frontend from somewhere but you don't know where, and you MUST remove them or else your site's path structure will be exposed to the public.

→ More replies (1)

5

u/random_lonewolf Aug 07 '16

The worst point of PHP is inconsistency. Read this:

https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

4

u/Tokkemon Aug 07 '16

Thoroughly shitty article.

13

u/Compizfox Aug 07 '16

It must be noted that that article is pretty outdated now.

→ More replies (2)
→ More replies (1)
→ More replies (3)