4 ms·
For HN, this is a majorly linkbait-ey title. Now that that's out of the way, this is a pretty spot on article. I find it very interesting that points brought u
by fein 14y ago
For HN, this is a majorly linkbait-ey title.
Now that that's out of the way, this is a pretty spot on article. I find it very interesting that points brought up against PHP (weak typing, easy to write swiss cheese security code, framework overload) are generally it's greatest strengths as well.
Let's take the weak typing issue for example: Sorry, you should be keeping track of your variables. If you can't do this, then just define your own object and use it. I do this with just about all return types now; it's pretty nice to always know what type of variable you're going to be dealing with on the other side of your MVC. The worst thing that comes from this issue (which exists in every weakly typed language) is improper use of comparison operators (!= vs. !==, == vs. ===). Again, this is up to the developer.
PHP will give you the lumber and the rope, but it's up to the developer if you hang yourself or manage to build a galleon. Personally, I love having the option of total control with the risk of total destruction.
- MichaelGG 14y agoBut improper use over something as simple as typing (at least typing as implemented by popular languages these days) _should not be a problem_. If I create a bug by multiplying by a string, I'd ideally find out immediately after writing it, as the background compiler/analyzer detects the problem. Saying "Oh, well, we'll just assume that an integer times a string is 0" is just... dumb. Seriously, if a program has a bug like that, what's the point of continuing execution? What's the real-world use case for this? The only use case I can see is "people screwing around making a home page, where nothing really matters and if they make a mistake, hey, just try to go on and maybe that last line wasn't really important anyways". It's the Visual Basic "On Error Resume Next" mindset.
- zbuc 14y agoOne of my least favorite things is the behavior of undefined constants. Use an undefined constant: Get an exception? Nope. Get an empty string? Nope. PHP will put the name of the constant in the rendered HTML. Arg.
- johnny22 14y agothere would be if an error if error_reporting(E_ALL) was used. Sadly you have to manually set an exception handler if you want it as an exception :(
- FuzzyDunlop 14y agoYou might get behaviour that is a lot more difficult to spot in production when multiplying an integer by a string that starts with an integer, too. echo 10 * "300 bananas"; // 3000 Makes total sense, doesn't it? And it could easily happen if you maintained a poorly written project with crap data stashed in the database. Even the most skilled PHP developer will have some head scratching moments when things appear to work but actually don't.
- eevee 14y agoThe language doesn't do something, so it's the developer's responsibility, and thus the developer's fault when it goes wrong. This is a strange way to judge your tools.