Used PHP in a Hackathon was made fun of and it made me feel really shitty
reddit.com
reddit.com
Yes, there are still a lot o people out there that hack some very questionable code together in PHP but we shouldn't dismiss it like this. I've tried multiple languages (C#, Java, javascript) and I have to say PHP is my favourite so far (you guys can comment on this as much as you like, I still like it a lot).
It's disheartening to hear that in a hackathon people got "bullied" for using a programming language. You would never pick upon a mechanic for using a screwdriver instead of a chisel or something similar, as long as he can achieve the same thing.
Also, I can't help to notice a trend of ..."brogramming", where if you don't use the newest and coolest tech you're treated as an outcast, bullied and made fun of; it's quite sad if you ask me.
I used it then (3.x, 4.x) and I recognize many of the terrible warts are still front and center.
PHP isn’t bad because it’s not new and shiny, it’s bad because it does opaque and wrong things and demands a user of the language know all sorts of inconsistent PHP-specific nonsense that does not benefit the language authors, the language users, or serve the solving of the problem of the language user. It’s not prejudice or signaling, it’s objectively deficient in ways that haven’t been acceptable in decades.
I much prefer PHP, also the warts are serverside which makes a huge difference.
I don't want to start a useless debate or anything like that, so don't take this in the wrong way, but I am genuinely curious of what specific problems you see in PHP and what are the specific issues with the language.
I can't think of many things that are so bad with it, except the inconsistency in function naming and parameter orders (stuff like `str_pos`, `substr`) and a relatively unreliable SoapClient implementation; I am genuinely interested in seeing what other people think are deficiencies in PHP.
Again, I have to stress I am not being defensive nor offensive, I am just curious on other perspectives in regards to the shortcomings of PHP.
Much of my own work has been javascript, and I could probably write a similar comment about how much has improved and yet how much is still fundamentally unpleasant because of the initial design (and the need for backwards compatibility). Of course, enough has probably been said about that...
Off the top of my head, the awfully inconsistent "standard library" (and kitchen sink) is a true nightmare (array_map vs. array_walk, wtf?) the absolutely hamfisted and counterintuitive autocasting (and no way to do strict comparisons besides equality), the disaster that is its "type system", leaking implementation details of the parser into (language) user space (T_PAAMAYIM_NEKUDOTAYIM anyone?) the absolutely intransparent difference between built-in functions, keywords, expressions, etc (can I use empty() here, or was did I have to use is_null, or any of the other half a dozen ways to express "does this exist?"), the list goes on…
PHP's design is anti-intellectual (on purpose) [1] and so PHP didn't even have an AST until version 7. It just emitted opcodes after lexing. Yes. It truly, amazingly did that, I couldn't believe it either, but there you go. This lead (directly or indirectly) to many faults in the language. It's also the core reason why PHP 7 is about 2× faster than PHP 5.x. Who knew you could optimize a parse tree before executing it?
If you want to find faults with any language, you can. With PHP, you can find more faults, and more easily. But the real problem is that those faults do kill productivity. I use PHP in my day job, but recently we've moved to doing more client-side programming in React. I get to use flow's type system which isn't perfect, but believe me, it's a breath of fresh air after coming from PHP. I'm not a fan of the JS ecosystem, but it's still better than PHP.
The community has made huge strides with PHP 7, and it's finally getting into some OK shape. The reason PHP is huge is because it made the right decisions at the right time. The threading model is dead-simple (there just isn't one) and requests are automatically isolated at a process level. No recompilation, no fuss (but then you forget to flush your opcache after deploying to production and everything explodes…) It's easy to get started with, and it's easy to make a simple thing with. It may even be the "correct" choice for a Hackaton. It most certainly is, if PHP is the language you're most comfortable with.
I'm too old to lead language flame wars. You can do great stuff with it, as you can with almost anything. It's not impossible to write good PHP code, it's very possible! But not because of PHP itself. PHP is an objectively bad language
Given the choice, I'd rather code in Java, or C#, or even TypeScript+Node.js. But I'm not, so I code PHP every day, and it's not like that's the worst thing in the world. It just feels like I'm fighting the language, instead of the language helping me.
[0] https://duckduckgo.com/?q=php+sucks
[1] "I was really, really bad at writing parsers. I still am really bad at writing parsers. We have things like protected properties. We have abstract methods. We have all this stuff that your computer science teacher told you you should be using. I don't care about this crap at all. " ~ Rasmus Lerdorf (yeah, sure, taken out of context, but the point still stands, and there is no dearth of interviews and quotes of his documenting the same general attitude.)
There are so, so many. Here are some good references:
https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
Disclaimer: I earn my income from a project largely written in PHP.
But for an hackaton? 36 hours to get something done? It may be totally be the best tool for the job.
It has been a long time since "throw away the prototype" also meant switch languages, databases, production OSes, version control systems, and library code. Modern languages are flexible enough to let you prototype rapidly with sturdy languages, front end and back.
All programming languages have short comings. The once you mention here even more so I believe :)
Picking a favorite out of a very small subset is mainly personal choice. If you are happy with the toolset and the programs you create, I think you made the right call.
> "brogramming", where if you don't use the newest and coolest tech you're treated as an outcast, bullied and made fun of
I see this too, but I believe it's more specific to web development. A lot of people program C and they are generally not bullied for that.
I fell into this exact trap - Moved my org from PHP to what was "New and Shiny" -- and while it worked out, our prototyping / proof of concept speed isn't nearly as fast as it was with PHP.
But it's just a language. Good software is made in bad languages all the time. And making fun of PHP is not the same thing as making fun of someone who is using PHP. I'm sure Rasmus Lerdorf will happily tell you PHP is full of expedient design choices that would be different in hindsight, but that doesn't make it OK to poke fun at people trying to get work done.
Obviously it does suffer from some design issues due to backwards compatibility but is moving in the right direction.
Some practices are bad. PHP was my first working language and I used it for years. I’ve since used a dozen other stacks in the intervening fifteen years. PHP is objectively a poor choice, an impediment to its user.
Someone who is told this, who doubles down on ignorance of better, more efficient, more predictable, consistent, safe, and useful languages, is worthy of ridicule—not because of their ignorance, but because of their will to remain ignorant.
By an authority such as yourself? Sure aren't we the lucky fellas to have somebody like you to tell us what's what
Those functions have been deprecated in PHP for years, and they were just wrappers around existing C libraries to begin with/
And other languages have that as well. I've seen it done in C# and C++.
Using PHP is the same thing.
The story about FizzBuzz is not literally asking you to implement FizzBuzz. It’s an illustration.
My comment could be rephrased: just because many people like doing things that are bad does not mean that those things aren’t bad. It just means that many people are ignorant.
I might agree that PHP is a poor choice in many ways, and that in many situations there's a much better alternative. But it's quite another thing to claim it's "objectively" a poor choice.
I have clients on small budgets who run on shared hosting, and the fact that these support PHP is enough reason to use it. I have clients whose needs are met almost perfectly by Wordpress, and using it requires using PHP. I know developers who have fairly successful small businesses on PHP and for them it would be "objectively" a bad idea to just drop all their knowledge and everything they've built so far in favor of an "objectively" better language.
Even just the fact that in some places or for some use cases it's significantly easier and cheaper to get an decent PHP developer than anything else is a reason to use PHP for some things.
The ironing is delicious.
Fanatics of any kind always remind of this fragment of Zen and the Art of Motorcycle Maintenance:
> You are never dedicated to something you have complete confidence in. No one is fanatically shouting that the sun is going to rise tomorrow. They know it's going to rise tomorrow. When people are fanatically dedicated to political or religious faiths or any other kinds of dogmas or goals, it's always because these dogmas or goals are in doubt.
I find mocking X (for any X) to be occasionally educational https://www.youtube.com/watch?v=RGkIsUBfanQ
I agree with this, but only as a conversation starter, not a rebuttal-killer.
When I was a PHP dev I had a colleage who liked to say "the only tool nobody complains about is the one that nobody uses", as if that somehow makes all tools equal. Yes, all languages have flaws; no, not all languages will set the font colour to 33200000000000 because they guess that the string "332e11" should actually be treated as an integer written in exponential notation. Looking back, I guess it's a form whataboutism (although without any specific examples).
PS: I absolutely agree with (almost) everyone that personal attacks are absolutely unjustified.
Sounds ironic, I say from my self-satisfied position of detached superiority.
People are going to use what makes them money, and what makes the most sense for the project.
Thankfully when using the right frameworks modern PHP feels more like a real OO language instead of the clusterfuck it used to be.
-- the old comment --
Particularly ironic is PHP ranking high for ``This language is likely to be a passing fad''. Given its 17 years of history and recent the recent progress with versions 5.3 and newer... whoever voted on this position either wasn't aware of PHP's actual situation and outlook, or was just being thinking wishful.
> Why does almost everyone know the language?
If anything, it is that almost everyone can dabble in PHP and ^C^V some code. IMHO real knowledge of PHP and its ecosystem seem to be quite rare -- judging by reading some published code, which was as generic and un-PHP as possible, and by [many clueless] comments [posted on] the official docs.
-- the old comment --
[0] https://news.ycombinator.com/item?id=4929143 [1] http://hammerprinciple.com:80/therighttool/items/php [2] https://web.archive.org/web/20170913184701/http://hammerprin...
The snapshot you linked in from September 2017...
Do what you want (and what makes you most productive) and don't care about others :-)
BTW: What I especially love about PHP is its documentation, or sort of integrated stackoverflow. I can't remember any other platform having "recipes" integrated directly in the documentation (which in my opinion, is brilliant idea)
This has good sides and bad sides unfortunately. There are some really questionable ideas in those comments and they're not always downvoted to death. Presenting them to the beginners on the same page as the official docs makes them trust and copy-paste solutions sometimes.
Take java spring or ruby on rails for example, those are opinionated ways of doing SW but they are also big pile of complexity and sometimes you really need just read a file, transform it a little and output the result. I think those awkward examples and hacks are valuable too because you get involved in internals and you know then how the entire thing works under the hood.
Did you realize the V8 engine is single-threaded?
I think using PHP warrants extra points for style.
No, the point of a hackathon is to condition the Workers that unpaid overtime is not only normal and expected but also fun!
Especially if literally everyone else is just using node + MongoDB.
There's definitely a "narccissism of small differences" going on in programming languages.
PHP, JS, Python, Ruby, Perl are all basically the same (dynamically typed, imperative, interpreted, optional class-based-OOP, etc.). If a decision's been made to use one of these, then things like library availability and developer experience are probably much more important than particular language features or quality. Yet there's a whole bunch of fighting and in-group/out-group between these.
Likewise Java and C# are essentially the same thing (I think the lawsuit banning Microsoft from bundling Java had a big influence on their push for C#, rather than actual features of the language).
There also seems to be a certain level of incests among languages. I remember PHP had an RFC (request for comments) for adding generators to the language, seemingly because Python has them. I commented that it would be better to go with delimited continuations, since they're more powerful and could also use the same implementation as exception handling. My comment was not well received, presumably because delimited continuations would actually make PHP different from its kin, rather than even closer.
> I think using PHP warrants extra points for style.
I always feel like a "real" programming language debate should throw in the occasional curveball, like a Prolog interpreter embedded in Smalltalk or something. At least it would break the monotony. On a related note, why shouldn't a mars rover be programmed in TeX? http://sdh33b.blogspot.co.uk/2008/07/icfp-contest-2008.html
But I think this is the same mindset that makes people think that they need to use ML to solve every problem, when actually you can solve it without it just fine. As has been discussed in an earlier post.
Your knowledge and the requirements of the job should dictate the tools you use - not what's hot. If it works, scales to the extent you need it to, and can be secured, then great!
It's not because everyone gets crazy about those new Nike shoes that you should wear them too, just enjoy running.
I guess building quicker is more important than building better, especially in hackathons or in startups where you are testing the product-market-fit. That means, one can use whatever language/tool they are most productive with. Of course, if you are lucky and if you gain momentum, then you will have the resources to re-engineer it with the right language/tool.
These particular people truly do lack self-awareness, to criticise PHP as JS users.
and as JS users using MongoDB as a data store.
function ($arg) use ($capturedVariable) {
return 1;
}
I rest my case.Lots of world-changing projects were written in FORTRAN or APL but that doesn’t make them suitable for new apps today.
Also, many world-changing projects that did succeed would have been rendered total failures had they chosen this pathological language early on.
Your examples do not support your point.
The best tool for a job is the simplest one that gets the job done and the one you know best.
Would I start a startup in PHP tomorrow? Probably not (not least because I don’t know PHP). But that doesn’t make it unsuitable for everything.
I'm not liking this new reddit, I can't even fold comments.
Edit:
WOW I can't believe this, I opened it up in Chrome and it works / shows the comment folding option. It astounds me how much Chrome is becoming the new IE in regards to functioning websites where I wont be surprised to see (or not see) more cross-browser issues when using Firefox instead of Chrome.
Can I have the web where everyone wanted to be backward compatible with all browsers back?
Edit 2:
Also wondering how this got published by Reddit and nobody noticed some basic site functionality missing?
I've never identified with a particular technology so strongly as to feel attacked when its flaws are pointed out, and vice versa, I have never felt the need to attack anyone personally based on the technologies they use. Some might be better for some tasks but not others, and that's the only thing that matters.
Experience shows that people who lack broad knowledge of several programming languages tend to identify as "language X developers" instead of developers as such. This enhances tribalism and creates pointless language wars. Any time somebody says that some particular language is the best choice for everything, or some other language is never the best choice for anything, they're just inexperienced and are trying to mask it with fake confidence. Except for Java of course, it's the worst.
The truth is that today PHP is a pretty good language. CakePHP, Laravel and Symphony have been pretty good frameworks from a SW engineering point of view. I haven't written PHP code in the last 5 years but I miss the development experience. Everything is by default stateless. Accessing a page always starts from a blank state. You edit and save a file and you can reload instantly the page with the new code. Of course "re-execute everything" can become quite expensive at runtime...
In general I think the modern PHP is hated without a reason. Its bad rep will be hard to overcome.