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

Ok, so here it goes. I haven't commented on this site for over a year.

Full disclosure: I am an average programmer compared to many here. I come to this site to improve my self and read about what brilliant and amazing things you all do. Now you have a reference.

I use PHP on a daily basis, have been for years. I am a freelance developer who has been able to carve out a living with a lot of hard work and a lot of luck. I just met the right people at the right time. Over the last 7 years since I started developing professionally, I have seen nothing but people shitting on PHP constantly. I am in no way suggesting PHP is a perfect language, but I still never get the hate. It just seems so ivory tower to me sometimes. Let's look at reality.

I'm starting a small project for a client. They are keeping track of all their scheduling and doing all their reporting in excel. They want to move this to the web with basic security so the right people can see the right information with ability to access it from anywhere. That's it. You know what works for that? PHP does. It works fine and it works on almost any server in the entire world with no issues. I don't need a .vimrc file with a million special configurations, I don't need a hot new framework where my time is spent figuring out how to do basic CRUD operations, it won't matter if PHP is statically typed or not, it won't matter if... you get the idea. I just need to start developing and getting this project done so this business can start saving time and money. That's what matters most to me.

PHP works, and it works damn well for millions of situations every day. No one is suggesting you use PHP to build a super computer. If your project requires something different than use something different. PHP is not the "Nickleback" of programming. PHP is useful. PHP is practical. PHP is easy, and that's not a bad thing. Facebook, the biggest site in the world, uses PHP. Think about that.

Finally, let's use his tool analogy. PHP is a double-clawed hammer. What if your job was to remove nails from wood all day? What a wonderful tool a double-clawed hammer would be! You wouldn't have to worry about which way the hammer is facing! That would save you real time and real effort. It's the right tool for that job. Tools are about how you use them. If someone uses a tool incorrectly it's not the fault of the tool.

PHP can use improvement. Every language can. I imagine a meeting of otherwise incredibly smart people sitting around in smoking jackets and sipping fine brandy standing around with smug smiles on their face. "PHP is horrible!" One will say. "Hmmmm... Yes... Quite..." A small laughter emerges. They all pat themselves on the back and enjoy their intellectual circle-jerk. All the while countless developers are using it every day for the right reasons making real applications that help real businesses save real time and real money. Laugh at me all you want, I get Christmas cards from my clients. They like me just fine.




It's not ivory tower for all of us. In my case it all boils down to simple discomfort. Writing PHP code is painful. Reading PHP code is painful. Fixing bugs in PHP code is painful.

I don't write rants about it but that's just because I left the language behind years ago and never looked back. But if I had to write for my job? Yeah I'd write a rant every other month probably. I would need some kind of outlet for all that pain.

It looks like in Jeffs article his rant was sparked by having to take a close look at php again and all that pain just bubbled back up.


I in no way meant to suggest that any criticism of PHP should be considered 'ivory tower'. I thought I was clear in my opinion that PHP is not perfect. I disagree that writing PHP code is 'painful'. It's perfectly fine for countless developers. Also, again, don't blame the tool for people who use it properly. If you think that it is literally impossible to write good code in PHP than you are being ivory tower.


I never said it's impossible to write good code in PHP. I said it's painful. Don't conflate that with impossible. You may not feel pain when you write it but that doesn't mean other people don't.


What other languages besides PHP have you used? I think a lot of us dislike PHP because we're putting it in the context of better designed languages.


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 has over PHP.


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 this and a lot of other reasons you'll almost certainly be happier with Ruby.

Aside from happiness, there are things that make Ruby more powerful. For example, you can cleanly implement the reactor pattern (think: NodeJS) with EventMachine and with EM-Synchrony you can avoid the callback hell that comes with NodeJS.

If you want, you can look at Sinatra to provide the common functionality that the PHP framework provides. With Sinatra you're not all-but-forced to use an ORM like you are with Rails, as Sinatra doesn't include one. If you really want, you can go closer to the metal and look directly at Rack, which is middleware between web servers (Apache, Nginx, etc) and the actual application.

There's really no right way to do it, but the best thing is to learn and explore. Some people will recommend Python, and while it's a decent language, it's got some things I consider to be rough edges -- lack of useful language features, such as switch/case statements, and badly implemented parts of its standard library that handle network requests.

The next language on my learning list is Go. I've heard nothing but good things about it, but I'll reserve my judgment until I have some experience with it.


I'll second Ruby because of Sinatra and add some of my own thoughts. Sinatra is a very gentle introduction to separation of concerns. You can get a Sinatra app running on a shared Dreamhost with the same effort as a PHP site.

PHP was ok for me I spent a ton of time looking up functions in the docs but I could get stuff done. Once I had to edit/work with 3rd party code it was a nightmare.

I've developed in PHP, Ruby, C#, Java, ActionScript, and Python and Ruby's gem system is by far the easiest package management system I've used. Making your own gem is really easy.

Great ideas seem to pop up in Ruby first and then are ported to PHP, so why not use the original (see Rails, Cucumber, Bundler).


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


>My next personal project will be done in Ruby.

Here's a better idea. Take a very simple problem - say user fubar enters his name, you say "Welcome, fubar!", populate a backend database with his name because he's a new user. Otherwise you tell him "Welcome back, fubar!" and don't mess with your database.

This involves what ? Handling a GET, making a database insert, doing a select on name in a database, that's it.

Now go do this in atleast 5 frameworks, and time yourself. PHP obviously, but do try RoR, Django, Play2, JSP and ASP.NET

I actually did the above exercise and came away with a lot of valuable insight. In my case Play2 was a breeze because on Heroku its trivial to set up, and each GET xxx request mapped directly to a xxx scala method in the Controller, so no magic. The others were a little more painful, but not a whole lot. I enjoyed the exercise.


The only trouble with this is that trivial applications tend to only give a superficial feel for the framework and aren't representative of a "real" development experience. For example, I wrote a trivial application in Flask. Python's Flask, while it looks great on the surface and has fantastic documentation, rapidly becomes unwieldy in the face of more complex problems. The same is true for Ruby on Rails.

Most frameworks almost feel like they're tuned to solve these basic problems and give a fantastic first impression that doesn't sustain.

Developing a complete project in each is a better way to move forward IMHO.


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

Also, s/peaked/piqued ;-)


Just try something. I don't doubt that PHP has its good points, but how can you appreciate them without having something to measure them against?

Ruby or Python would probably be the best choices if you don't have anything else in mind.


I've played around with Python and Ruby (more specifically rails), nothing serious though. I enjoy trying new things, but never found them worth delving into for my purposes. I 100% admit this a reflection on me and not those languages. I have nothing bad to say about them. I just didn't find anything in them that was worth switching.


Unfortunately what many would define as 'better designed' doesn't always translate to useful software.


Can you give an example?


Any major websites done on Lisp, Smalltalk or Haskell?

Besides Viaweb?

Now count > 1m visits per day websites done in PHP.


You're measuring the success of a website in terms of traffic.

The number of hits a website receives isn't the product of the language it's written in, but primarily a function of its marketing (and other factors that appeal to its users).

There are also more websites with their foundations in PHP, so it's reasonable to expect a higher number of successes. You can't therefore logically conclude that the language influences success. It's like comparing the number of millionaires in the US with the number of millionaires in Canada; the US has a bigger population compared to Canada, and all things being more or less equal, it's reasonable to expect that the US would have more millionaires simply because of its shear size.


>You're measuring the success of a website in terms of traffic.

Yes, me and all Analytics and SEO guys. You either sell ads or stuff. In both cases you want as many eyeballs and wallets as possible.

>The number of hits a website receives isn't the product of the language it's written in, but primarily a function of its marketing (and other factors that appeal to its users). There are also more websites with their foundations in PHP, so it's reasonable to expect a higher number of successes.

Yes, but your logic is circular. The question is WHY are there "more websites with foundations in PHP", and not just trivial amateur personal stuff but highly successful ones too.

You seem to assume PHPs expanse as just a fact of life, totally arbitrary, and thats why you say we must not draw conclusions based on it.

>You can't therefore logically conclude that the language influences success.

Sure I can. Here are some ways:

- Php is easy for newstarters, so got more adoption. - Php is trivial to deploy, so got more adoption. - Php was there, targetting the web specifically (with libs and features), in 199x, while Haskell, CL, what have you were not yet. - Php, because of the above, had amassed a huge ecosystem of projects and engines (Nuke, Wordpress, Drupal, EE, etc). - Php, because of that, has alo got huge adoption. - Because of th adoption it built a huge ecosystem of programmers, projects, tools, books, etc.

And, putting it all together, what makes PHP more likely to power most high ranking sites, is that you can easily find components and engines to base your site on, AND you can easily find tons of programmers to employ, AND you can easily find support for it, etc. All those make it a no brainer for a lot of uses.

And all of those are interdependent, based on some initial language attributes, not arbitrary like the US vs Canada population argument (which is not that arbitrary and size based itself, but thats another story)


> You're measuring the success of a website in terms of traffic.

I wasn't disagreeing, and in fact I didn't even express an opinion regarding this. Success means a lot of different things to people; I was stating your definition of success for clarity.

The user doesn't care whether I write a website's back end in PHP, Ruby, Python, Haskell, C++, Ada, Clojure, or even Erlang. The success depends on how useful the site is and how well it's marketed. This isn't circular reasoning.

There are more websites written in PHP because PHP is an easy language for beginners and therefore more common compared to Ruby or Python, for example.

It's an absolutely untenable position to assert that the programming language itself affects how much traffic an site receives, which is what you originally defined as "success".


>I wasn't disagreeing, and in fact I didn't even express an opinion regarding this. Success means a lot of different things to people; I was stating your definition of success for clarity.

Oh, alright. Thought you meant it was not a good metric.

>The user doesn't care whether I write a website's back end in PHP, Ruby, Python, Haskell, C++, Ada, Clojure, or even Erlang. The success depends on how useful the site is and how well it's marketed. This isn't circular reasoning. There are more websites written in PHP because PHP is an easy language for beginners and therefore more common compared to Ruby or Python, for example.

Yes, that second argument is not circular reasoning because it searches for the causes.

But the argument in your previous post, I read it as: "PHP is used by more of the popular sites because PHP is used by more sites in general" Which is kinda circular, mostly repeating "PHP is popular".

>It's an absolutely untenable position to assert that the programming language itself affects how much traffic an site receives, which is what you originally defined as "success".

I did the opposite: the success of the site affects the programming language.

That is, I am a pragmatist: I see every successful site built with a programming language as one more verification that said language is good for building sites with (whatever the reasons).

If we have 200,000 high volume sites in PHP and 0 in X, as a pragmatist, I will avoid using X in my next high volume site project.

Working from that, one can also see why it is so. For example:

1) it's because X is obscure, so I wouldn't be able to get a team easily. Perhaps even no one in my city, at least without adding the overhead of teaching them X first.

2) it's because X is more expensive to host. I'll need to get a VPS whereas I can just put PHP on a $10/year server.

3) it's because PHP has more libs and stuff. This DB/service API/etc I want to use does not have X drivers (or has a semi-abandoned project).

4) it's because PHP has Drupal/Wordpress and I can have a high traffic portal/news style site in minutes, whereas X has only ho-hum solutions for that, or I would have to build one from scratch.

and so on.

Surprisingly, many so called "scientists" and "engineers" choose to argue from first principles. "X is a bona fide academic language, and has all those meta programming features, higher-order types and such, so you are crazy to use PHP over X for your project".

So, instead of reading the situation pragmatically, and finding the real pain points PHP eases and why it's used, they resort to idealistic rants about how masses are ignorant, "beating the averages", etc etc.

Well, this Zuckerberg guy, with his average PHP, beat Viaweb's Lisp by about 100x better valuation. If, according to "beating the averages", ViaWeb's success was a pro-Lisp point, why isn't that a pro-PHP point? Or does it only work when Lisp wins (as in, "ViaWeb won because of Lisp but Facebook won despite of PHP"). Talk about having it both ways!


> But the argument in your previous post, I read it as: "PHP is used by more of the popular sites because PHP is used by more sites in general" Which is kinda circular, mostly repeating "PHP is popular".

You misread what I wrote in that case. I said "There are also more websites with their foundations in PHP, so it's reasonable to expect a higher number of successes." This isn't circular reasoning, and let me show you why:

Lets pretend I'm superhuman and create 10,100 unique, high quality websites in one day. Let's assume also that my skill and experience remains constant throughout building these 10,100 websites; I'll get no better at marketing, design, etc and all my decisions are of equal quality. The only difference is the programming language I use to develop some of the sites.

For the sake of this example, let's assume that 1% of websites created, on average, end up with one million page views per month after six months.

In this fictitious example, let's say that for grins I build 100 sites in Lisp and 10,000 sites in Perl. 1% of my Lisp sites will be successful (a grand total of one successful site) and 1% of my Perl sites will be successful (100). From this data you're erroneously concluding that Perl is more likely to result in a successful site. This is wrong, because the number of sites created in each language varies wildly, but the odds of hitting "traffic gold" are still 1% with everything else being equal. The language, therefore, doesn't impact success rate.

Seeing something built in PHP doesn't make it a good choice, just a common one, just like smoking in the 1970s was a common choice, just not a good one.

Facebook, while it's mostly written in PHP, is actually transcompiled to C++ (HipHop compiler) because PHP was insufficient. They're not actually running any PHP code in production. Also I keep hearing that their codebase is an unholy mess and that the only reason it hasn't been re-written in another language is that the codebase is just now too big to rewrite. Zuckerberg wrote Facebook in PHP because it was the language he knew, not because it was the best tool for the job. Marketing and user experience made the site successful, not the language.

Don't just look at PHP and say "huh, it's common!" and conclude it's good. It just doesn't make sense and it's a logical error to do so.


Amazon.com was famously put together by mostly Lisp engineers. They more recently switched to C++ and apparently experienced a lot of growing pains as they had to learn how to scale up C++ to match what they had been doing in Lisp for years.


> Any major websites done on Lisp

Does Hacker News count?


Note the use of the word "major"


Note the use of "true" in "no true Scotsman".


Note that I specifically wrote >1m visits per day.

Note also that the mention of one site is too literal and meaningless interpretation of my question, which is more rhetorical, and should be read like: "There are TONS of high volume PHP sites and very very very few high volume Lisp sites".

That said: the "no true Scotsman" logical fallacy is only a fallacy half of the time, like most of those so-called logical fallacies.

They assume a perfectly logical world, where you have infinite information at your disposal and infinite time to check it. E.g I'd rather listen to my doctor on my medical condition over a random guy on the subway, even if that's "appeal to authority".

Similar cracks in the "no true Scotsman" fallacy. There ARE cases where a category/taxonomy is used badly, and no true member of said taxonomy would so something. That is, membership in a taxonomy is not always 100% solid, and you can have true and less true (fuzzy) membership.

E.g

- No KKK member would attend a NWA concert. - But I just saw a KKK member rocking it at a NWA concert. - Well, no _TRUE KKK member_ would ever attend one.

It's obvious that the first guy is correct: no TRUE KKK would ever attend a NWA concert.

Now, a random KKK member could possibly attend one (say, out of curiosity). The "no TRUE" argument in this case, says not so much the impossibility of an event happening, but that it is against the very concept of the taxonomy under discussion for it to happen.

Hackers shouldn't touch the "logical fallacy" stuff with a ten foot pole. They presuppose that conversations and argumentation can just go "by numbers", without examining each individual case.


Haskell


Way to talk down to people.

I use PHP as my main language for web development, but also am a frequent C user. I have done projects in C# and Python.

While I like C# and Python - actually for scripting I tend to go for Python rather than PHP, prefer the CLI modules of Python- , I found that in context of web dev PHP still get the job done faster and in a maintainable manner. As for C, I use it for writing PHP extension -or generally fucking around with PHP source code- and writing non web stuff, so not as relevant.

The difference between people like me and people like you, is I don't go around constantly mocking other language. It is pointless, I'd rather spend my time and energy delivering products, or actually doing something productive.


I'm not talking down to anybody.

Based on experience I asserted that many programmers feel that PHP is an inferior language because they've experienced "cleaner" languages such as Ruby. It's not wholly unreasonable that chez17 had only programmed using PHP, as PHP is commonly a programmer's first language. I therefore wanted to find out if chez17 had used other languages and to see what their thoughts are on PHP vs those other languages.

I also don't go around "constantly mocking" other languages. Why did you make that assumption?


Good, just the way it read.

As for constantly mocking other languages, that was not directly pointed at you, but at the constant swarm of people always going about php sucks, php this, php that... We got it, you people don't like PHP, try to see if I care.


Why shouldn't engineers "mock" the things that they think are badly designed? But by "mock" I mean criticize. In fact, as an engineer, it's one's professional duty to criticize bad design, as good design is essential to the endeavor of engineering progress.

Good engineering design vs bad engineering design is what prevents bridges from collapsing or Mars landers from crashing.

But I hear you: sure it's quite possible to do arithmetic using Roman numerals, and if that's what you're used to, you probably don't want to hear that you've been doing it suboptimally. And all these people clamoring for a change to decimal are just an unbearable nuisance.


"Finally, let's use his tool analogy. PHP is a double-clawed hammer. What if your job was to remove nails from wood all day?"

Brilliant.


>Brilliant.

Except that, if you're removing nails, there are much better tools than the claw on a hammer. [1][2] I've done demolition, and I've had to pull a lot of nails, and the claw on a hammer is about the last tool I'd use for the job. I basically only use the claw to straighten or remove a partly-hammered nail that's gone wrong.

So yes, the analogy is brilliant.

[1] For really big nails, more leverage is good, and the hole in the flat part can be used to pull longer nails out than you can pull with a hammer claw: http://refer.ly/abwW

[2] To get a nail started, something sharper with points, and that (here's the important bit) can be HAMMERED under the nail head: http://refer.ly/abw2


Not brilliant. You can use a regular hammer just fine to pull nails out of wood all day AND to nail the occasional one in should the need arise.


Pulling nails all day long with one side will quickly wear off that side - it won't be as sharp and you'll have to throw away the tool. Double claws will allow you to use the SAME tool twice as long (that's 99% of what you do, remember?), will avoid rotating the hammer 180 degrees in certain situations (constrained space, two nails - one on the left, one on the right) and you get to hammer an occasional (1%) nail with the side without changing tools.

I think the original analogy was indeed brilliant, given the context.


As someone who has been hammering nails and pulling out nails for the past 8 weeks, I can assure you that hitting them with the side of the hammer is a very, very bad idea.

Also, you never find yourself in a situation where you're just pulling out nails. A large number are too difficult to pull out, or will damage the structure you're pulling them from, so you hammer them down.


But it would take you longer because you would have to turn the hammer on occasion. You would also have to consider an additional failure scenario where turning the hammer caused you to drop it.


IOW, the double-claw "hammer" is just what you may need if your job is to pull nails out of houses that are unsafe because they were built by carpenters who used double-claw "hammer"s to hammer in the nails. Got it.

The analogy is almost perfect! Except that PHP doesn't pull out nails very well.


> It just seems so ivory tower to me sometimes.

More like a game between different sports teams. Are you going to go to the fans of the opposing team for an honest opinion about yours? Are you shocked they have nasty things to say about your team? Or that you have nasty thoughts about theirs?

What gets to me is this air of objectivity ... that part is most certainly ivory tower and is arrogant to boot.

What I want to read is a critical article on PHP by somebody who uses PHP and loves it. That would be useful.

A hit piece by somebody on a Microsoft stack is just boring!


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/


"I don't need a hot new framework where my time is spent figuring out how to do basic CRUD operations"

Definitely see what you're saying but the flip side is that in my experience once you figure out the basic CRUD operations in a good framework, the amount of time it takes to implement them decreases hugely compared to repeatedly writing boilerplate in PHP.

Being able to get something functional up and running extremely rapidly was exactly what caused me to move most of my projects away from PHP although it would be fair to say I didn't give the corresponding PHP frameworks much of a chance as I had other reasons for wanting to consolidate codebases into either python or ruby and I hear Zend, Symfony and various others have come on a long way.


"Finally, let's use his tool analogy. PHP is a double-clawed hammer. What if your job was to remove nails from wood all day?"

I agree with your metaphor relating working with PHP as "pulling nails from wood all day."


Zing!


I am willing to bet that the reason facebook uses PHP is to remain backwards compatible.




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

Search: