13 ms·
I'm a PHP "hater", so take this for what it's worth. You are very close to implying that the language doesn't matter if you can hire developers and there are a
by ragnese 6y ago
I'm a PHP "hater", so take this for what it's worth.
You are very close to implying that the language doesn't matter if you can hire developers and there are a lot of good packages in the ecosystem.
Having worked on several PHP projects (Most being version 7.0+ and zero of them being older than 5.3), the languages is STILL full of gotchas, and it's a huge drag on productivity. I assert that this DOES matter. Even basic stuff like trying to use the default "array" as a dictionary has absolutely ridiculous issues like if you try to use a string as a key, but it is a string of digits. It will automagically convert your string to an int and totally F-up your dictionary.
I've actually been bitten by that one. And it showed up in production, because I didn't know or care what the string keys might be. Who the hell would've guessed that behavior after working with non-broken languages before?
Inb4 "That just means you're dumb. Just use SPL. You can write bad code in any language."
I've used Symfony. It's good. I haven't used Laravel. I assume it's also good. I still don't know why you'd choose to start a project in PHP today when there are great libraries in many other languages that are not as broken as PHP.
Honestly, PHP 7+ is not horrible, but it's also not better than anything else... In fact, the very best PHP code you can write today looks basically the same as the best Java code you could've written a decade ago.
- dubcanada 6y agoWhat are "string keys"?
- chewmieser 6y agoAssociative array or hashmap. Arrays indexed by strings instead of numbers.
- dubcanada 6y agoOhhhh I've never heard them called string keys before. Thanks.
- ragnese 6y agoPHP arrays can be indexed by ints or strings (at the same time).
- weego 6y agoFor a huge, huge potion of all work done by web developers day to day around the globe the language doesn't matter if the framework is productive and secure by default. Most of it won't survive a handful of years at best and most companies won't ever benefit from the attitude of some developers that ever developer on ever task should be writing FAANG level code. What 3nds yo happening it matter what you do is the next agency / person comes along and claims its not fit for purpose any more and redoes it 'better' and the cycle continues of low value
- macinjosh 6y ago> if you try to use a string as a key, but it is a string of digits. It will automagically(sic) convert your string to an int and totally F-up your dictionary I've been a PHP programmer for over 15 years and I cannot think of a single time this has been an actual problem. It sounds like you were embarrassed by a bug in your code and have just decided to blame it on the tools.
- paulryanrogers 6y agoI've run into that numeric reindexing confusion. PHP arrays in general are so feature rich it's also easy to overuse them. The proliferation of Collection classes may be one side-effect of how poweful-yet-awkward they are.
- ragnese 6y agoIs "powerful" really even the right description? I can't even do a map + filter without looping through the array twice. Ew. I guess I'll just stick with the primitive foreach loop (which leaves a dangling allocated object after you use it... sigh).
- jrumbut 6y agoMy guess is that the numeric indexing thing happens a lot but it's definitely rare for it to cause a visible problem and even rarer to be identified as the cause since it is unexpected. I've been bitten by it and also stuff like 800=="8E2". I've never been able to make an adequate defense of PHP, yet also have never seen another language match its success rate of getting useful software into the hands of users. I have wondered whether something about PHP, or something that it lacks, makes PHP projects easier to estimate. Ease of deployment? Batteries included standard library? Pragmatic community? Surprisingly adequate performance? It never seems like enough to overcome the obvious deficits. I can neither ignore my own experience nor convince anyone that it's actually great.
- ragnese 6y agoI'm in a similar boat. I've decided that whatever it is that makes PHP successful must be exactly the same thing that has made JavaScript successful. It's going to sound extremely condescending, but here it is, anyway: I believe that the majority of people who defend PHP (and JavaScript) are people who have ever only written code in Java (especially <=1.6), JavaScript, and PHP. Maybe C for fun or in college. In light of those immensely popular languages, I could see why someone might not think that any of the deficiencies are deal-breakers.
- unexaminedlife 6y agoI've done plenty of PHP programming (including modern) in the past. I'm excited about recent developments. Not sure about the productivity claim. I once wrote from scratch (frameworks excluded) backend and frontend (version 1) of a multi-tenant, cloud-based video-sharing platform with PHP as the backend (aws cloud) in a matter of weeks. I once wrote, from scratch (frameworks excluded), an entire backend (and front-end) of version 1 of a hybrid mobile app (backend in PHP) for a medium-size logistics company in a matter of less than 2 months. I have other examples, but life is too short trying to convince "haters" that they might not be 100% correct. I was the only developer on both of those projects. Your mileage may vary :)
- evilduck 6y agoCan you attribute that specifically to PHP making that possible? Why couldn't an equivalently capable peer use Python to do the same?
- unexaminedlife 6y agoSo the claim was that PHP "gotchas" are a drain on productivity. I'm not trying to compare with other languages, but I think my anecdata shows that, at least in my case, when you understand the tools PHP can be a very productive one.
- trey-jones 6y agoCertainly gotchas are a drain on productivity. But I don't think this applies more to PHP than any other language I've used. The fact is, if you are less familiar with the language then you won't be as productive. I personally spend a lot of time hopping among technologies and I always lean heavily on documentation. PHP has pretty good documentation, and this helps a lot in my opinion. I would guess that a lot of developers don't read the docs and just assume that something in a less-familiar language will work exactly like they expect it to, and then call this a "gotcha" when it doesn't.
- wolco 6y ago
- Apofis 6y agoSounds like a jr dev misstep... you're not really bringing up any key points.
- ragnese 6y agoIt takes 5 seconds on Google to find a myriad complaints about weird, unexpected, and downright incorrect things that PHP does. That wasn't the point of my reply. The point was that language choice CAN affect productivity. And having a bunch of gotchas is something that will negatively affect productivity. I simply gave the first example that popped into my head that actually tripped me up.
- Supermancho 6y agoUnit tests would have caught this, if you wrote them.
- MrPatan 6y ago>Unit tests would have caught this, if you wrote them. If I hadn't considered string-number-keys in my code, I would also have forgotten about them in my unit tests. Maybe you're different.
- wtetzner 6y agoAssuming you thought to test using a string that's all digits. You have to know about PHP's brokenness to even think to check that. In a sane language, it doesn't matter what the contents of the strings are, they're just strings.
- ragnese 6y agoMy unit tests did not cover all possible strings, unfortunately.
- JadoJodo 6y agoRE: string -> int, I'm not able to replicate this. https://repl.it/@JadoJodo/SelfreliantEdibleUsers https://repl.it/@JadoJodo/SelfreliantEdibleUsers edit: Not trying to discount your feelings overall, but just curious about that specific example.
- withinboredom 6y agoMost people don't use a production version of php.ini, I'm fairly certain you can turn this off and on in there. I've only run into this on my personal projects (where I don't care too much about the configuration) but never at work.
- ragnese 6y agoYou example doesn't work because you tried to access the element with a string, which was ALSO converted to an int. https://repl.it/repls/CompetentBlondInstructions https://repl.it/repls/CompetentBlondInstructions Here I changed your string index to an int and it still says success!
- romellem 6y agoThe PHP deal-breaker is that it casts[0] string keys that contain "valid decimal integers" to "the integer type"? Seems like a fairly minor language quirk (of which almost every language has) rather than a huge feature that makes one want to avoid the language at all cost. Of course, feel free to make your own choice when picking a language, but I don't think this is a compelling reason why one would always want to avoid using PHP for their web backend. [0]: https://www.php.net/manual/en/language.types.array.php https://www.php.net/manual/en/language.types.array.php
- ragnese 6y agoI'm getting quite tired of the nonsense straw men in this discussion. Do you truly believe that I articulated that there was exactly one reason that I think PHP hinders developer productivity? And of course, we brought out the old "every language has quirks" apology. Yes, you can bang a nail in with a rock. But, don't. Use a hammer. Do better, please.