Live data from Hacker News

Coding Horror: The PHP Singularity

codinghorror.com

271–280 of 341 posts

Re: Coding Horror: The PHP Singularity

#271
post #48

I seriously groaned when I saw this post (title). I was expecting an elitist diatribe about PHP (because this is perennially popular amongst particular programmers) but that's not what this post is intended to be. Interestingly Jeff does take the usual potshots at PHP almost like he thinks he'll lose street cred if he doesn't but the basic message I agree with: if you want someone to stop doing something you consider…

There's a simple adage that a good tool makes simple things easy and difficult things possible. By that measure, PHP is a pretty good tool. Yes, other tools are better in various ways, but ease of deployment is a non-trivial quality.

(I did like the quote suggesting AppleScript is "even worse" than PHP. I'd say it's far worse, since AppleScript makes easy things difficult.)

Re: Coding Horror: The PHP Singularity

#272
I guess I'll chip in here.

The handful of advantages that make PHP popular are also some of its worst liabilities. Yes, you can deploy with just FTP... but then you have upload security to worry about, and have to protect all your library files, and yadda yadda. Yes, you can do SQL right off the bat... but you have to take care of SQL injection yourself. Yes, you can stick your code right in your HTML... as hard to read as that may be. Yes, there's no resource leakage... but every request has to recompile the code and reconnect to your database.

None of these things are problems at first, but they become problems quickly once your software expands beyond two pages or a hundred hits a day. Some of them may not even be obvious problems, but you'll pay the cost anyway when some kid steals your database.

Other platforms, meanwhile, tend to have fairly simple solutions to all of these problems, for the price of a minor increase in upfront learning. But since the problems are all things that happen later on, newcomers will just see that language X is harder.

This poses something of a difficulty. How can other languages introduce the ease of PHP that everyone's demanding? We can't just port exactly the same features over, or we'll have exactly the same problems. mod_python was a bad enough idea that it's dead now. Heroku is a neat thing, but still requires writing configuration files, and nobody enjoys doing that. Nothing is really well-suited for single-page fire-and-forget, either.

I have been thinking about this since writing that damned fractal post, but I'm not clever enough to have thought up a solution yet. So, you know, it would be useful if we could brainstorm on how to fix the learning curve and deployment instead of "just turn everything else into PHP!"

Re: Coding Horror: The PHP Singularity

#273

Earlier quoted context omitted.

> What other popular languages silently convert strings to floats and then do math or floating-point comparisons on them? JavaScript. Most of the "issues" around comparisons/conversions/etc equally applies to JavaScript as it does to PHP. But PHP does some very stupid casts but it's really just one problem. In the lists of "failures" tend to show that same problem 15 different ways to show how screwed up things are.…

Yes, JavaScript has the same string comparison problems as PHP. And it gets a ton of criticism for it. JS doesn't have all these other problems, though. For the unit tests, it looks like there are still 100 unexpected failures in the latest release: http://gcov.php.net/viewer.php?version=PHP_5_4&func=test... Am I misinterpreting that? Yes, no platform is free of security problems. But the way a security problem happe…

I actually clicked on several of those failed tests and there doesn't seem to be anything critical there. Looks like some access problems (test setup) and at least one needed the test to be updated.

I'm not sure when these where run but it would be easy for someone went through all of them and give them a pass. A failed test doesn't necessarily mean that deployment should be held up. 700 failed tests is a different story.

> JS doesn't have all these other problems, though.

JavaScript has plenty of it's own problems. It has legacy things you should never do. PHP has different problems (not necessarily worse ones) and things you should never do. Lists of the horrors of PHP generally include all things you shouldn't ever do mixed together to make it look much worse than it really is.

I've seen similar lists made for JavaScript (you can get some really crazy results) but that doesn't mean shit for day to day use.

Re: Coding Horror: The PHP Singularity

#274
post #256

Earlier quoted context omitted.

Sorry to respond twice to your post, but I realized this was a great opportunity to learn something. Given my basic example in my post, what language would you recommend I try to accomplish this task? I like to stay away from frameworks so basically I'm asking you to not suggest Rails, however don't be afraid to suggest ruby. If you feel like typing something out, let me know why you suggest it and what advantages it…

Ruby. It's the cleanest language with the most sensible standard library I've come across to date. Ruby doesn't necessarily mean Rails, and in fact I'm not a fan of Rails' overly prescriptive paradigm. (As an aside, any time you hear Rails is an MVC framework, discount it because it's really an MVA framework.) One of the things you'll find coming from the world of PHP is Ruby has consistent method signatures. For thi…

Thank you for taking the time to write this. You have sufficiently peaked my interest. My next personal project will be done in Ruby.

Re: Coding Horror: The PHP Singularity

#275
My favourite part was when Jeff said that his article wasn't another post getting on the PHP hate wagon and then he takes pot-shots at the language, classy. I'd equate Jeff's article to that of squirting a water pistol into the ocean. Everyone knows PHP has some downsides, but it also has its upsides. PHP does have its positives, but of course pointing out the negatives of anything is a sure fire way of getting a response opposed to writing positive things. You can fault every major language, no language is perfect regardless of what anyone else says, JavaScript even has downsides but you'll be hard pressed to find as many hating articles on JavaScript as you would on PHP.

PHP is simple to configure and deploy, I can get a client Wordpress site migrated from my local environment to their server all setup and ready to go in less than 5 minutes. I'm tired of the argument of: "Well, I just use Heroku to push my Python and RoR projects live so your argument is invalid" the real issue here is that the only argument haters of PHP have against it being easy to deploy, is using a third party deployment app like Heroku which costs you money as opposed to being able to push a Wordpress site live via SCP or FTP without paying a cent.

I think when people hate on PHP they're confusing applications like Wordpress or PHP frameworks with the language itself. Wordpress is not PHP, it's an application built on PHP and we all know WP is poorly written but works this isn't the fault of PHP.

Don't like the language? Improve it or shut up. It's like being who complain about the war, but keep voting for the same political party..

Re: Coding Horror: The PHP Singularity

#276

Earlier quoted context omitted.

PHP will always have an edge. If you want to do something stupidly simple, no other language can match. Now that's horrible code, it has a dozen bugs aside from the security issues, but I would go so far as to say when I need to do something stupid like that quickly, nothing matches the simplicity of PHP. It's downright elegant. Not to say you should write a webapp in it, but I think you're wrong; there's intrinsic o…

require 'net/http' puts Net::HTTP.get(URI.parse('http://news.ycombinator.com')).gsub('Hacker', 'Interwebz') I'm confused. Where's the edge? Or, even simpler, require 'open-uri' puts open('http://news.ycombinator.com').read.gsub('Hacker', 'Interwebz')

I knew I was going to get some code golf responses.

Simple and short are two different things. I value PHP over Ruby here because it's much clearer to the layman what's going on. To explain the PHP, all I have to explain is functions, variables, and the echo statement.

To explain the Ruby, I have to explain functions, variables, Objects (everything is an object), Libraries, I/O, and method invocations.

Also, in classic code golf form, your code eliminates a couple things that will make it do exactly the same thing as the PHP - you're missing your #! line, and you're not actually writing a CGI script, which is a second library you need to include and explain to your hapless newbie. And honestly, it's not just a newbie thing. I've written Ruby similar to that (with good error handling, etc.) Ruby only makes sense if you're going to do the job properly and put in error handling, etc.

Re: Coding Horror: The PHP Singularity

#277
post #48

I seriously groaned when I saw this post (title). I was expecting an elitist diatribe about PHP (because this is perennially popular amongst particular programmers) but that's not what this post is intended to be. Interestingly Jeff does take the usual potshots at PHP almost like he thinks he'll lose street cred if he doesn't but the basic message I agree with: if you want someone to stop doing something you consider…

The funny thing about #4 is that php has been making a lot of progress on that exact front. Register globals has not only been deprecated but removed. Mysqli is now the default means of talking to dbs. Meanwhile, you see very fundamentally similar issues in, say, rails not getting the attention they deserve because everyone assumes rails is well engineered.

I don't mean to defend php overly much. However, it can't be ignored that progress is being made at making php better.

Re: Coding Horror: The PHP Singularity

#278

Earlier quoted context omitted.

PHP will always have an edge. If you want to do something stupidly simple, no other language can match. Now that's horrible code, it has a dozen bugs aside from the security issues, but I would go so far as to say when I need to do something stupid like that quickly, nothing matches the simplicity of PHP. It's downright elegant. Not to say you should write a webapp in it, but I think you're wrong; there's intrinsic o…

> Now that's horrible code, it has a dozen bugs aside from the security issues, but I would go so far as to say when I need to do something stupid like that quickly, nothing matches the simplicity of PHP. It's downright elegant. So: * It's horrible code * It has bugs * It's not secure ... * It's downright elegant See the discord there? It's not elegant at all. It's easy, but easy != elegant. It's just easy.

It depends on the problem domain. I've seen PHP pretty similar to what I just wrote that worked without complaint. In some circumstances, great, bug-free, secure code is over-engineered and inelegant.

Re: Coding Horror: The PHP Singularity

#279

I wish bloggers would stop quoting that fractal article. At least 50% of what's written in there is totally wrong/false. Other information is terribly out of date. And even more information is merely half-truths and lack of understanding of the language. The article author clearly scanned through PHP bashing articles and took material from them verbatim; mistakes and all. I'm not going to argue that PHP is a great la…

I stopped reading the blog article when I read the complaints around "private" and "static". The behavior is exactly what they were intended to. If he doesn't want that, he shouldn't use them. It also implies that he doesn't have much experience with languages like C#, Java or C++. Otherwise he would have learned this already.

Re: Coding Horror: The PHP Singularity

#280
post #274

Earlier quoted context omitted.

Ruby. It's the cleanest language with the most sensible standard library I've come across to date. Ruby doesn't necessarily mean Rails, and in fact I'm not a fan of Rails' overly prescriptive paradigm. (As an aside, any time you hear Rails is an MVC framework, discount it because it's really an MVA framework.) One of the things you'll find coming from the world of PHP is Ruby has consistent method signatures. For thi…

Thank you for taking the time to write this. You have sufficiently peaked my interest. My next personal project will be done in Ruby.

Good luck! One of the best books I found for Ruby was The Well Grounded Rubyist by Manning Publications.

Also, s/peaked/piqued ;-)

Post reply on HN