Hacker News new | past | comments | ask | show | jobs | submit login

The setup time issue is an advantage of PHP over many languages. But, I will let you in on a little secret, once you know how to do it 'setup' time is a drop in the bucket on all platforms. And in the rare case where it might otherwise be hard, people setup a shell environment they can use as the template on any project and it just works.

That said, there are popular languages worse than PHP for most web development tasks, Java for example.




PHP will always have an edge. If you want to do something stupidly simple, no other language can match.

    <?php
    $hackernews=file_get_contents("http://news.ycombinator.com);
    $hackernews =str_replace('Hacker','Interwebz',$hackernews);
    echo $hackernews; 
    ?>
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 overhead in using a Real Language. It has nothing to do with "knowing how to do it," doing things properly takes time, a half-assed but mostly functional solution can be whipped up in minutes.


> 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.


  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.


And to Jeff Atwood's original point, you cannot copy-paste the file onto basically any http webhost on earth and have it run out of the box. I don't think that's appreciated in the threads thus far, is that web hosting companies have really done a lot of work for you for PHP and Perl that you have to do yourself with other web programming platforms. They might be better, but they aren't as universally available and supported. (For some value of "supported" which is usually "enough")


That was one point in favor of PHP, and it was a small one. I'm competent enough to set up any environment if the project required it. However, some hosting companies won't even let you do that. A client might have purchased a small package that won't even let you ssh in to do anything. That's a real life scenario that you have to consider. PHP works there.


Bash is another example! I've always wanted to create a web app using Bash on Balls [1]

[1] https://github.com/jayferd/balls/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: