Programming is something I've done for the last 10 or so years (in various forms). It is essentially the only activity (in terms of 'work' or career) that I enjoy. The engineer in me just enjoys making things 'perfect' (where perfect is a definition perhaps only I understand, but generally its something built on solid engineering principles. Well-tested, reliable, modular, efficient, etc). When code looks 'just right', I enjoy the code regardless of whether it is bringing me any $$$. In that sense, for me, engineering is a fun activity, and not 'work'.
The hacker in me will enjoy a well built piece of software for its engineering brilliance regardless of whether the software got anything done at all.
In the last year or so I've been able to isolate these personalities and perhaps merge them. I do not scold the hacker just because he wants to try out new languages every month and is opinionated about his favorite ones. I get pissed off when this stops him from getting shit done.
I'm glad for the hacker in me who cares deeply about the tools (languages, IDEs etc) that he uses. Its this hacker that makes my job 'fun'. It is this hacker that has helped improve the quality of my code and my thought process for building good software. The 'getting shit done' would never have been enjoyment enough if it were not for the hacker.
But that's not really a problem.
I guess the problem is not that good devs can't code in PHP. And when they focus on the task at hand, they might not even notice. Because PHP has everything you need. I'd prefer coding a website in PHP than in Java, C, or C++, because PHP is dynamic, has first class functions and the kind of stuff you need to be expressive.
One of the problems is that if you think too hard about the fact that the language you use is suboptimal, it will affect the pleasure you take from doing your job.
The other problem is that a lot of PHP code is really horrible, so people have grown to associate PHP with bad code.
In practice you disable stupid options, don't use quirky parts of the language, set up your IDE to autocomplete functions, and PHP stops getting in the way.
What you're left with is a decent OO language, which recently got namespaces and closures.
It's OK speed-wise (with APC) and has got stable implementation.
Imagine buying a car where the salesmen was saying "this is a great car, it will get you where you want to go cheaper and faster than anything else out there. The only thing you have to remember is; 40% of the buttons, pedals and handles in the car will actually make it explode into a rolling fireball if used. Don't do that. You'll also need to open the hood and physically remove 2 or 3 things that are even more dangerous. Oh yea, don't ever put anyone or anything in the back seat. If you remember all that, this car will be a dream!". Would you use such a car? I wouldn't and I wouldn't use a language like that either.
There's php.ini-recommended in the distribution and it's well-commented.
Not using variable-variables, undeclared variables, globals, unsanitised variables in paths, SQL without prepared statements, etc. is common sense and applies to other languages too. PHP might just bite harder if you lack that common sense.
C++ very much applies. :)
>Not using variable-variables, undeclared variables, globals, unsanitised variables in paths, SQL without prepared statements, etc. is common sense and applies to other languages too.
This is a subset of what you have to avoid in PHP. Further, things like globals can have uses. That's the difference with a really poorly designed language: there are things in there that have no good use case. Not things that are only used in rare cases, things that should never be used.
And all of these faults in the language, even the minor ones, just contribute to the unnecessary cognitive load of using the language. So the way I see it, if I'm starting a new project then why not just pick a sane language like Perl or Ruby or Python instead and save myself all the headaches? It's not 2004 any more, we're no longer constrained to languages that have good Apache modules, and with that constraint gone there are very few reasons to pick PHP over the competition.
Yet despite these warts standard transmissions are quite popular in most of the world, and people get around just fine in them.
Compare this to Perl, which everyone hates, but which has a modular-enough core that you can override core behaviors. The community has recently added all sorts of new features -- a new metaobject protocol, hooks on opcodes, macros, etc. Every day, it keeps getting better.
I might agree that PHP's flaws, from a language design standpoint, are okay. Who cares what character you use to separate namespaces from class names? But the deep design without any hooks for extensibility is a killer. Every day, the language will get worse and worse, because the other languages can be extended in themselves. PHP is stuck as what it is forever. And that's the deep problem.
(Actually, I'm not willing to concede that the language design failures can be worked around. A lot of the language design quirks are boneheaded enough that they're a deal killer. I had to use PHP for two projects at two jobs. They were both my last project for those companies.)
Also note that mod_perl for Apache provides several really good features for efficient web applications that are missing in all other language modules (including mod_php).
Although that kind of stuff may sound complicated, it allows for great flexibility and I've been told that this actually simplifies things.
The mod_perl docs provide more information:
What's the upside? Conservation of intellectual momentum?
But hey, that's what copy-and-paste is for!
On the other hand, there's still other stupid stuff like "magic_quotes_gpc" that has only recently been deprecated.
If you have application that relies on register_globals or magic_quotes, you can assume it's vulnerable. PHP allows enabling these on per-directory basis, so at least you can somewhat isolate the legacy code.
I would say, the blogging-about-programming elite, rather than the actual programming elite. I haven't coded PHP in years, but some of the most brilliant devs I know use it when it fits the task.
People who say PHP is badly designed, however, aren't talking about the implementation; rather, they're strictly talking about the language itself—the syntax, the semantics, and the standard library. There is no advantage to the way PHP-the-language does things; it makes nonsensical choices (like the flat, disorganized, all-libraries-included function namespace, the inability to chain method calls in a single expression, the extreme amount of "weakly-typed" cruft surrounding the comparison operators, etc.) which derive no benefit.
It would be strictly beneficial to the programming ecosystem if PHP-the-language were treated as an object-code for other, better-designed languages to target, such that PHP-the-implementation could be used without needing to write in PHP.
What's good about PHP is the execution/dispatch/deployment model, which papers over massive deficiencies in the infantile implementation (much less the know-nothing language).
Care to give some proof?
Say, performance-wise, MRI is not any worse than PHP. And as far as I understand, PHP implementation is just plain horrible.
PHP was great a few years ago, and by great I mean "one of the only options". PHP is active on every shared web host around. It's the norm. Only recently have the likes of Ruby and Python become popular on shared hosts. Personally I think that's fantastic.
edit: that's not to say he didn't make up the statistic for his opinion.
* Java has a really repetitive syntax, but it's libraries might make up for that.
* C++ with all it's features has bazillion ways to shoot yourself, but it's arguably fast and the syntax is bearable.
But php has both an ugly syntax, horrendous stdlib, and fame of security issues.
Maybe COBOL or MUMPS could be worse than php... haven't used these though.
Your "worst" is probably ill-defined: C is bad for web programming, but is certainly an elegant language and pretty good in its niche.
To me, both are effective at the tasks I need them to accomplish.
Is Instapaper merely adequate, or is it better? Would it have been that much better if it was constructed in Rails?
IIRC, Instapaper's a PHP application. I could have mentioned a larger site, but Instapaper was probably a better example, since it's quite popular with HNers.
But yes, it would probably be more easily maintainable if written in a better language, and the developers would be able to add new features more quickly.
To comment based on your metaphor, the problem is not that the screwdriver/hammer is ugly. It's that the grip doesn't feel right and it's unbalanced. You can turn the screw and drive the nail, but it takes more effort and might leave your hands scraped up.
Transitioning to Ruby or Python or Scala or anything else will not make anything magically better. I recently converted a Rails project to Grails (actually, I'm in the middle of the conversion). I'd thought "it's Rails - we'll just go in and fix the current issues". It was a horrid nightmare of undocumented crap. It was started in 2006 - Rails 1, and had been added on to for nearly 4 years, and was still Rails 1 (1.2). No useful inline comments, no unit tests, undocumented magic method overrides for basic stuff that wasn't compatible with future Rails versions, and so on. It was horrid. But hey, it's Rails, right? Must be magically better than PHP!
I went back and forth on whether to rewrite in PHP or Grails, and either would have been fine. Why? Because part of the rewrite process is to use modern techniques - with a big helping of TDD tempering the process. Oh, and version control. Yeah - 4 years of a project with 0 version control is not fun to deal with.
So... I'll take PHP with a team of people using sane schedules, TDD/testing, version control, internal and external documentation, and other niceties, over Ruby for the sake of Ruby. Now, modern Ruby/Rails with all those niceties vs PHP with same niceties? Probably a more even draw, with no clear cut choice. But that doesn't seem to be brought up in these discussions.
Frankly, most of the stuff people point to as awesome about Ruby (or Groovy, in my case) in isolation can be detriment - metaprogramming in general can be confusing to someone new to the code without proper documentation as to what's being done. Whether those docs are in tests, inline or external is beside the point. Typically when I come in to a new code base in any language the documentation just doesn't exist (or, better yet, it's "self-documenting"... right...).
End of rant - PHP really is fine when used with proper development techniques. Most languages are. In my experience problems start (and get worse over time) when people rely exclusively on the language alone, rather than language + commonly accepted dev techniques.
Perhaps once a language becomes mainstream, and is adopted by many people, not just the early hacker adopters, the perception of the language as clean and elegant goes down. This isn't necessarily because the language has changed, but because the average person using it has become less skilled. Languages that are comparatively new and shiny are mostly used by the much more talented early adopters, and thus seem to be more professional and clean. (This is just speculation, so feel free to disagree if your personal experience doesn't reflect this.)
Of course some languages make it easy for inexperienced programmers to write bad code, but this doesn't mean that good code can't be written in that language.
In fact, I would go so far as to say that if you are a decent programmer you should be able to write clean, reusable, DRY, efficient code in just about any language.
So as far as your argument goes I agree. The important thing is the team doing the programming, not the language they are programming in. If they are a decent team they will be able to do good development in PHP, or any other language.
No, actually, the teams (people) could be the same. It comes down to lang X with sane processes (testing, documentation, version control, etc) vs lang Y with no (not enforced, standardized, adhered to) processes.
So if you want to succeed, and you have a choice about language, you still need to pick the best language for your circumstances. The importance of people and process doesn't invalidate that any more than the importance of Lance Armstrong invalidates the importance of bicycle engineering in the Tour.
All that being said, I agree with the last sentence of your comment. It's just that I don't meet many people who say that with the right language they don't need anything else, so I'm not sure who you're debating. For example, all of the Rubyists I know fetishizes testing. None of them have ever said to me that thanks to Ruby, they no longer need tests. What they actually say is that Ruby makes testing easier, which is your point.
So yes, process and people are important, we all agree. So who, exactly, says anything to the contrary?
The ruby community is interesting because of the testing focus, which possibly negates my point a bit. However, I meet plenty of Rubyists who are so focused on tests (which are easy to do because of the language) that they eschew documentation, of any kind.
I've talked to more than a few Rubyists who are now in the 'my code is self-documenting because Ruby is so elegant and my method names and variables are so awesome and I can metaprogram anything I need that there's 0 need to have any comments or documentation - just read my code and the awesomeness of Ruby will overtake you'.
I don't particularly care how elegant your code is, having some inline comments will not hurt. Having external documentation, and sane commit log comments, and so on, are vital in my view. I'm not picking on Rubyists here specifically, that's just the few that spring to mind.
In a way, good languages are interesting because they make good practices so easy they're invisible.
Which makes me very interested in the question of documentation. Throwing tests out the window as documentation for the purposes of this discussion, how do you feel about DSLs as one form of self-documenting code?
I've got to run now, but email me at firstname.lastname@example.org to carry on :)
I once had a Python programmer looking at the kind of stuff that I was doing with PHP and he was surprised that such things could be done in PHP.
This is an actual conversation that I had in a meetup:
Guy1: If PHP were to disappear, it would bring down a lot of the web with it, wouldn't it?
Guy2: Nah, but, that would be the case if Java or .net were to disappear.
Me: (to myself)Wtf!
Guy1: But, most of the links that I click on the web end with .php.
Me: (to myself)pwn3d!
PHP is cool. I have found (http://fatfree.sourceforge.net/) and I couldn't be happier. It's similar to Sinatra and has everything a small app needs. It's simple and make separation easier. But if I need that complicated data structure processing that can be done with python or perl, I'll just write down that script and run it through php and get the results.
Between, this statement makes no sense for me
>> This is just going to get bigger and bigger as we grow by 500% or more _every year_
echo 'No subliminal messages here...';
It doesn't mean I like it though. It's still as ugly as sin. After all these years programming it I still get thrown by ($needle, $haystack) ($haystack, $needle) and have to look up which variant this particular function uses. I'd much rather be doing it all in Ruby. Or Lisp.
There's no reason they couldn't (over the course of years) move to another language. I'm not suggesting a total rewrite, but they could start writing entirely new subsystems in a new language. It's very rare to have 100% of your code in one language anyway.
Recruiting great programmers is one of the most important things in a software startup. Why stick with PHP if it makes that far more difficult?
Language is not that important. Your engineers are. They will easily compensate for suboptimal tools.
The best hint for this is that most (>70%) of the money goes into salaries. Not software. Not hardware. Not office space. Salaries.
Great salaries is a great thing, but what if your competition offers great salaries and a less obnoxious programming environment than PHP (and better hardware, and better office space, for that matter)?
And, therefore, anything that makes your engineers more or less efficient goes directly to your bottom line.
(I agree that the comment you're replying to underestimates the cost of migration. But the problem isn't a failure to understand that salaries are the main cost; that's exactly the thing that makes moving to a better langage attractive.)
That's exactly his point: it's much harder to find great engineers who want to use PHP.
Disclosure: I'm a PHP developer who has had to hire PHP developers in the past.
At my office we use a mix of languages. PHP for the services, Ruby for one set of management panels and Python for one of our other systems.
So during interviews we're happy with anyone that knows any of these with the intention of cross training when needed. During times when there is a shortage of good PHP developers to be found there is usually a shortage of good developers period.
(Okay, they didn't actually offer me the job, but I would have turned it down anyway.)
I'm not sure what that proves, considering all the languages we're talking about are free, and the largest price you have to pay is probably for the IDE (which also tends to be free).
Great programmers can make great stuff using anything.
Just because I _can_ doesn't mean that I _want to_.
I'm willing to work in lots of environments. In the last 2 years I have done projects for pay in Perl, PHP, Java, C++, Python and various in house languages you probably haven't heard of. However I have to be paid a healthy premium for the displeasure of working with PHP. And if I was asked to do it all the time, eventually I'd leave and find a better job working in something else.
Would you rather do something boring in a beautiful language vs. something interesting in an ugly language?
Or maybe they'll bitch up to high heaven because doing that makes them slower. Engineers don't bitch about using shitty languages to be whiny Prima Donnas. They bitch because using shitty languages makes them slower.
People like to feel like they're getting things done. If they're using a language that looks like it was put together from newspaper clippings every step takes much longer than it does with proper tools. And that makes people mad. In fact, I would go so far as to say the ones who don't bitch are the absolutely terrible engineers because they must be doing it just for the billable hours.
Go find the most genius engineer you can in any other field and make him work with the crappiest tools you can find that he can still eventually get his work done with and see how well your assertion holds.
Forced to use PHP? And it's crappy and slow to build stuff in? So write some tools that compile to PHP.
What I'm saying is that great programmers work with the limitations and build the tools they need to make the limitations moot.
(unless you're the single exception where your business is just that compelling...)
Let's say he's great enough to get lots of job offers. And let's say that among those, the ones in his favorite language - the one he actually enjoys using - also tend to pay more, and his average coworker in them is more proficient.
Is he terrible to start filtering his job searches by that language?
Probably because by the time they've transitioned to the more popular language, an entirely new programming language will be the one more great programmers want to use.
I don't think I agree. The end product's possibility to be exist at all depends on the mental health of your employees, how efficient they are, and what tools they use. Someone who is unmotivated due to using a language or a tool that is horrible will work only on work morale as a resource for motivation, and it's only a matter of time before that resource runs out, and they'll start feeling miserable and perform sub-optimally.
I don't have an opinion on PHP, although I've made a few cool things with it and enjoyed coding in it, so I don't think it's necessarily that bad.
It doesn't have to be the security blackhole or spaghetti monster it's made out to be.
Back in 2004, PHP was a very sensible solution: It was the language I knew best (we had little time for the project, so going with a language I knew felt sensible), it was easy to deploy and back then, there weren't that many alternatives anyways:
That would have left me with mod_perl, but looking at where we are today, that would have been an even worse decision it seems.
Fast forward 6 years.
The application consists of over 100'000 lines of PHP code alone now. It's in production use for many customers which serve tens of thousands of end users. It's not only a traditional web application, it also serves as an API for custom-made tablet pc applications (before we had the iPad), for GPRS-connected barcode scanners and last, but not least, for native Windows Clients (all developed by our company, using various languages).
While I really hate some aspects of PHP by now and I would love to have a Ruby or Python codebase to work with instead, rewriting all of this is out of the question.
Customers depend on this to work exactly the way it works now (they panic even if a link is two pixels off - welcome to the enterprise).
While I might be able to exchange some components with something else, I don't see the benefit it would provide - it would do nothing but make maintenance harder because I'd add another dependency to keep track of.
The only thing I could do is rewrite the thing. But by now, there's more than 30 man-years of work that went into this.
Sure. Redoing it wouldn't take the same amount of time, but considering it would have to look exactly the same (probably I couldn't even get customers to accept different URLs), where's the point in that?
OTOH, despite being done in PHP and tailored to sometimes crazy customer requirements, the code base is sufficiently clean to work with and it's constantly improving. Bad parts get factored out, good parts arrive, so it's not all-bad.
We are embracing new technologies as they become available and fit our product. Our CSS is now written in SASS, we moved from pure DOM scripting to Prototype to jQuery, we make use of the latest features of PHP (now Closures and anonymous functions from 5.3) and of our database (constantly running latest Postgres).
Even though it's PHP, it can still be fun.
Considering recruitment: Granted. It might be harder to convince a good programmer to work on this "ugly" PHP project. But a) we are not just doing PHP (just mainly), b) the code base is, as I said, quite clean and c) even though the code base might be in a language you don't like, the basic concepts of our profession still apply.
You can still discuss and solve interesting problems and you can still create great solutions to these problems.
If you don't want to take part in this adventure just because you don't like the language this is done in, then, frankly, you are not the person I want to hire.
Even though programming is the coolest thing you can do on this world, it's still a job and not everything can always be unicorns and rainbows. If you can't see this, then I don't need you.
If their CTO and I traded jobs, I wouldn't rewrite everything in other languages. I'd continue to solve interesting problems and recruit the best people I could. But I wouldn't take it personally if some of the people in the marketplace chose to pass on solving interesting problems in our environment with our tool chain.
It's not personal when I pass on someone talented who isn't a fit for us, and it wouldn't be personal if someone else passed on working for us because our tool chain wasn't a fit for them. Unicorns and rainbows don't enter into it.
It's like.... Oh I don't know, perhaps it's like locating your office in Toronto instead of the Valley. Some applicants want to live and raise a family in Toronto, some want to be where the action is in the Valley.
We solve interesting problems all the time in Toronto. But no, I'm not opening an office in the Valley for those who want to live there, just as you aren't doing work in Python just because there are talented people who want to use it.
I can respect that while simultaneously respecting those programmers who give your job a pass because they don't want to work with your tool chain. Just one of those things.
"Why not transition to a different language over time? One that more great programmers want to use?" which just isn't something you'd realistically do.
And then I thought about the fun we have here in the office and I thought about the nearly two hours of discussion I had with a fellow coworker about race- and lock free storage and merging of shopping baskets and it hurt me to think that people would throw all that away just because they don't like the language even though it was the only viable option when all of this started.
I might have been carried away.
So: Sorry. I didn't mean to insult anybody. I just think it's really shortsighted to judge a project, a team and a company based on the choice of language that might have been used at one time.
The company I'm leaving solves complex, interesting problems in solid PHP code. There are developers here who are a lot smarter than I am. So my attitude is far from "you guys suck" or "I'm better than you."
But when I look out over the programming landscape, I see a lot more energy and activity right now in the Ruby community. A lot more people building new things and inventing new best practices. This is a simplification, but it seems like great ideas come from Rails and move back to PHP eventually.
PHP jobs run the gamut from high-tech and awesome to grunt work. Rails jobs tend to be more cutting-edge, because the technology is newer and there's just more stuff happening there.
So for me, the question is this: if the Ruby / Rails community is the leading edge for new ideas, and the AVERAGE (not to say all) developer in that community is better, and the AVERAGE job in that language / framework is cooler, doesn't it make sense for me to move that way? All other things being equal, isn't that a good career move?
It isn't snobbery, it seems like the most pragmatic thing to do. This is on top of the fact that I genuinely like the Ruby language a lot more than PHP.
So I don't think you have to feel slighted personally. And I'd expect this cycle to repeat someday: there will be a lot of Ruby / Rails apps that need maintaining, and a lot of developers will prefer some hotter, newer thing. Just the way it goes. But it's nothing personal.
I just have to respond to the MUMPS bit, I thought I was the only person here that actually remembers the thing, let alone worked with.
The clearest experiences from my MUMPS days are the ones where I inadvertently wiped some string containing crucial functionality.
1) What is best for my business?
The answer may well mean sticking with a flawed technology that nonetheless is serving the business well. Remember there is still lots of COBOL chugging away.
2) What is best for me?
If it's my business, but I'm sick of PHP and would like to switch to Ruby, Lisp, Haskell, whatever, it might be better to sell the business and start a new one based on the new language, rather than risk a rewrite. Isn't that part of the freedom being a founder was supposed to buy?
One last thing (to convince more PHP people to downvote me) is, if you are spending most of your time on PHP or a web-only-language, you will never see the beauty of asynchronous I/O, socket programming, threading, hooking...
Update: When I mentioned "web-only-language", I was thinking of people who use & only use Ruby with RoR for web apps. I don't know how many developers who can't distinguish between Ruby & RoR but I guess it's not a small number. And of course, what I said is toward to those who aren't willing to learn new things. They always think about web & only web.
anyways. I have some reasons for my strong dislike of Java: a) checked exceptions, b) no method pointers or something similar and c) lots of the code produced by the community out there (and in the standard library itself) is full of FactoryFactoryFactories and other typing intensive, mind-bending and ultimately useless abstractions (most of them not DRY at all either).
Back in 2004 I did strongly consider Java though, but ultimately, I didn't have time to implement this web application AND learn a new library (learning the language is easy. learning the library is what makes you slow in the beginning).
As a side note: Said web application also accesses locally connected barcode scanners over the local serial port. Unfortunately the only way to do this (aside of a locally installed client) is still using a Java Applet which I've also written back in 2004. So I do have the Java experience to know that I don't quite like it :-)
Indeed, this whole thread's reminding me of:
"Combining the sanity of threads with the robustness of web development" http://wearehugh.com/public/2010/08/html5-web-workers/
The stigma that Java has too many checked exceptions is no longer true with modern Java code. Everyone is using unchecked children of RuntimeException almost exclusively. Of course, there is still plenty of legacy code out there using outdated checked exception paradigms.
So what? Why does the code produced by others in "the community" affect your perception of the language and/or tools, if you aren't using their code?
If you're one guy off in a corner, write however you want. But if you're not, you have to take the culture into consideration. And if you are one guy in a corner, why are you using Java?
Java has a very strong culture around it. I worked in academia and startups previously and I didn't realize that there is a huge number Java programmers who do nothing but program in Java. They aren't interested in learning new languages and will only grudgingly learn a new framework. Their biggest concern making sure the lowest common denominator can still maintain the (unmaintainable) code.
An example is unit testing. Our current "unit" tests start up a JBoss instance, connect to the development databases, and take ~5 minutes to run just one test. But I've been told not to waste my time working on anything more modular and that if I'm going to put in any time working on unit tests, I should contribute to the framework everyone else is already using.
It can be quite soul crushing.
Always remember: "It's easier to ask for forgiveness than for permission."
If you want to do better than the cultural norm demands, nothing's keeping you. What's the worst that can happen?
I think that "one of the biggest financial companies in the world" would be just as conservative and anxious about the tiniest technology changes with any language: Ruby, Perl, or Fortran.
The attitude you describe sounds like it has more to do with being a large financial institution and the type of place where software development is a "cost center", not a profit maker.
Ask for forgiveness after you do something...
The other way to go about it is to 'gingerly' find the single ally, and build on that.
He tells me horror stories of code he refactors at work written by people in his own office, or worse, outsourced companies, and it's bad. It seems to me that that kind of code is more representative of the community.
When you're going to join a project, you have a better chance of encountering code not sucking if the overall culture of that language is better.
but I hate. No. HATE PHP's type conversions with its == operator.
0 == 'foobar'
true == 'foobar' && 0 == false
true == false ?
Yeah. I know === exists. But if you have to compare strings and numbers, why is the default conversion method you do the lossy one? If you compare a number to a string, why can't you convert the number into a string and compare the two strings? Why convert the string into a number which will be lossy in most cases?
It's not that hard to get your head around, and at least one other major language does it this way.
And if you know something could return 0 (which is not empty), you should know to do a type-sensitive check). You are trading off HAVING to set types with HAVING to check types when needed (I think the latter is better).
I hate this as well, but, I love dynamic typing. They aren't the same thing.
In PHP 5.3 you'd just pass the function (which of course will pass a pointer to that function) and in earlier versions you'd hack something with eval or variable-variables which, while bad, is still better than either writing half a screen full of empty methods or inheriting an inner class from some meaninglessly named class that only exists for you not to have a screenful of empty methods.
Having said that I wonder if missing the 'beauty' of async I/O etc has more to do with the projects people take than the language. Would a python or ruby developer who focuses on creating web apps have any more familiarity with those concepts than a PHP developer?
One of the reasons for this is because PHP was designed to quickly handle single HTTP requests. The scaling is ment to be done on the app-server side and that single request that your script is serving at a given time will take as long as it will take anyways.
So you don't really need the async I/O (in theory).
There async I/O becomes important.
So: PHP: concurrency by firing off another apache/fastcgi process or thread. Don't worry about blocking on I/O.
node.js and some python/ruby frameworks: concurrency by using an event based system. Because one operation blocks the whole server, they need to be quick. async I/O becomes important.
Of course the evented model has huge advantages too: You worry much less about races, you get huge performance with a simple architecture and you can potentially handle much more concurrency (because each thread/process consumes resources that your one evented process does only once).
Both paradigms are interesting, but having first-class functions certainly makes an evented model more convenient to work with.
EDIT: I don't hold that view because of the things I mentioned but I am pretty sure a lot of programmers do.
I will have to agree with you that PHP is perceived as a web language. Hopefully with more articles like these that perception will change.
They are a bad idea, in general. PHP is designed for a very specific purpose: Very quickly building web pages in a CGI or mod_php environment and spitting them out. Everything else is an afterthought, and it shows.
For example, if you try to manipulate the filesystem extensively using PHP you will eventually trip over its "stat cache". PHP caches the result of stat() calls, presumably assuming that, hey, it is more important to avoid redundantly calling stat() during the time-sensitive rendering of your web page than it is to actually return correct information about the state of the filesystem. I mean, how often do symlinks change or files get moved during the rendering of a typical web page? And how much web-page-rendering code really depends on being able to read a link, then read the link again after the link has changed on disk? You can afford to ignore that stuff at the language level, if you're PHP.
The result is that you have to learn about the stat cache and remember to call clearstatcache() all the time when manipulating the filesystem in PHP.
That's just one example of why it's better to use Ruby or Perl to write command-line scripts. These languages were designed with command-line scripting in mind. Indeed, this is the flip side of the reason why PHP eventually drove out Perl as a web development language: Perl was originally designed for command-line scripting, and PHP was originally designed for the web. Use tools for their proper purpose.
Java was originally designed for programming embedded devices. Python was originally designed as a teaching language. One anecdote suggests that Lisp's original designers always intended to add syntax to the language.
Perhaps a decade after a language's invention it's possible to discuss its current suitability and design for specific tasks more than its original design intent.
(I consider PHP's relative ease of deployment over everything else far more explanatory of its ubiquity than any original design intent.)
Things like "stat cache" and "memory leaks" are what I watch out for when I write command line scripts in PHP. Also, I do not run my scripts as a daemon and I make sure that they do not run for more than a set maximum execution time.
So yeah, it may not be the most perfect choice but, it beats : having to learn another language when I know what to look out for when I write a command line script in PHP.
If you don't like writing nested closures, you have coffeescript which makes the code pretty, and also brings in some new features viz. list comprehensions, splats, satement modifiers etc.
We (well. back then it was just me) began doing this back in 2004.
Fast forward 8 years.
the cynical part in my brain now compels me to write something along the lines of "so this is the only thing you took away from that posting?".
So I'm writing it and I'll immediately regret it.
The trollish part of my brain compels me to tell you that, while I didn't read what you wrote, you should capitalize the first letter of sentences.
But I did read it and I don't care too much about proper grammar ;-)
In 2004 you still only had cgi/erb for web development. While ruby was really cool, it just wasn't practical for web development.
What would have been so bad with mod_perl?
According to its documentation, this appears to be the most advanced language module for Apache, providing integration of Perl at all levels: http://perl.apache.org/docs/2.0/user/config/config.html
Also, Perl has a huge standard library. So what's the issue with Perl, compared to PHP?
I'm also reluctant though to introduce more dependencies for the sake of porting perfectly working code to another language I might like more.
It's not just that maintenance will be harder it's also that in some cases our customers (very traditional enterprise. IE6-on-NT4-traditional) provide the server for this to run on and I can't present them with a huge list of services to install and monitor.
Well. Maybe I could, but I my conscience can't deal with persenting them with that list just so that I potentially have more fun while programming.
One of the things I'm currently looking into though is Websockets for a specific component of the app and in that case, I SO clearly see a huge advantage in Node.js that I will certainly go node if we decide that the shortcomings in the way we are currently solving that problem warrant the change in the architecture.
Which brings me to the same conclusion as my initial post:
Rewrite for additional functionality or fixed issues: Yeah. Rewrite for the sake of having it rewritten: I'd rather not.
The fact that you made sound engineering decisions and continue to improve on what you can (while being practical) means more to me than your language choice, even if I'd rather be dancing with Django :)
The problem is not that nothing interesting can be done in PHP. Lots of interesting can be done in any Turing complete language. It would be just 'plus points' if you would use for example Scala for the kind of task you described. I just cannot see why to use a dynamic language in a task where performance is important when there is a statically typed fast language which is as good and as concise as Scala. It is not that it is impossible that I would join a company developing in PHP. We have to make compromises all the time. It is just that developers evaluate companies, and join the one with the most 'plus points'.
In terms of programming-in-the-large, at Google and elsewhere, I think that language choice is not as important as all the other choices: if you have the right overall architecture, the right team of programmers, the right development process that allows for rapid development with continuous improvement, then many languages will work for you; if you don't have those things you're in trouble regardless of your language choice.
It just is a red flag and makes me wonder about the sense of taste the developers at a PHP company have. Therefore it would take a lot to convince me that working for them is "alright". If they have bad taste, how are they supposed to write nice code?
Having to learn their proprietary solution to scaling issues only is not as tempting as it sounds. Yes, I am interested in working with scaling problems. But learning a proprietary PHP hack is not going to help my CV that much.
I worked in PHP for five years before I worked in Rails, and I think PHP is a great language for web development.
Yeah but here's the rub. You can't compare Rails with PHP. You need to compare Ruby to PHP, and ask if the switching costs will outweigh any deficiencies; and you need to compare Rails to e.g. Cake or Symfony or similar, and ask if one language provides a framework whose advantages are so compelling that they too will outweigh those switching costs. I have yet to be convinced.
(weighting factors may apply for dev experience with one or the other, legacy code, hosting/infrastructure support, etc.)
I wouldn't develop in Ruby without Rails, but I wouldn't develop in PHP with a framework.
One of the applications I maintain is a convoluted machine made of half java half php on top of Quercus, and if freaking drives me crazy. I think the only thing I hate more than that is working in ASP.
I was kind of floored since I didn't exude a fan-boy mentality, I was simply answering the questions. That was more of an inner chuckle, but I wasn't surprised by his answer at the end of the day. By the time the interviews ended, I realized that PHP might be the last thing these guys will look at.
Coincidentally, I took another offer where the core is PHP + Symfony + Doctrine. I was very impressed at how well behaved, structured and developer friendly a good source base can be, no matter the language.
People never see the same need when starting a project in rails, even if it isn't that great a fit. One advantage PHP has for me is that nothing is abstracted away in a way that I don't understand the underlying components because I'm writing my own framework. Sure certain aspects I'll grab some cade as necessary but in general everything I'm doing I've either written it or parts of it myself.
I get all the semantic language arguments against PHP and largely agree, this has become less of a problem for me though with experience.
Unfortunately for this line of thought, Facebook wanted to move away from PHP 3-4 years back, specifically to Python I believe, and realized it would be too much work to rewrite their entire front end. So, they're trapped in PHP, not using PHP because they think it's the best choice.
This was mentioned in the article announcing HipHop.
No point in being condescending about someone else's choice of language.
I find it reliable, reasonably powerful and easy to use. It's major strength is brilliant documentation on the official web site (this is a major downside to Python in my experience).
Before I jump on this bandwagon I think I'll forget all about mailchimp, and think about all the many, many, many great companies (such as Facebook) that use PHP.
a) I find it more enjoyable to program in other languages.
b) I can generally get things done more quickly in other languages (feel free to ignore this point if you're the opposite :P).
c) Aside from speed, ubiquity, and the docs on php.net (which are awesome), I don't really get anything out of using PHP.
d) People will pay me more to program in other languages.
So yeah, I suppose my first reaction on reading "PHP" in any job description is "Eww". It's not really because I think PHP is wholly unsuited for programming, though. It's just not optimal for me, personally.
PHP is popular in the same way Miller Lite is popular: it's convenient, cheap to run (on shared hosting) and adequate. However, if you're used to something finer, Miller Lite simply will not do, and people who think it's fine are not going to understand.
The submitted link requires clicking a "More" link in order to read the full entry. (And it will be out of date once they post another entry on the blog.)
It gets the job done, sometimes spectacularly, sometimes not so very much - depending on who did the work. It's a workhorse, and has been demonstrated as such millions of times so far. Performance depends a lot on deployment strategy, but it can be fast.
I really see no point in bashing PHP. It's a tool, it has tons of documentation, libraries and available helpful people. Sure, I'd like to have some tweaks here and there, but with what tool wouldn't you?
There is a saying around here, roughly translated: Rusty cock minds every(single) pube.
Based on my experience, I doubt they need their "highly sophisticated" PHP to do this -- plain old normal PHP would probably be fine so long as they choose the right out-of-the-box software to pair it with. (nginx, postfix, certain non-sql databases, and the right mysql setup)
I know PHP, and I've used it to put food on my table. Luckily that is no more. I'd consider doing PHP again only if my wife and kid were starving.
My advice to people stuck with PHP codebases - start changing the site backend first. Write everything not related to spewing HTML in a real programming language, and slowly limit PHP use as a simple template-processing tool that generates your app's HTML. Which is probably the only thing PHP is good for.
The one thing that bothered me was towards the end. In trying to justify PHP's coolness (which I am not arguing against), people continuously bring up Facebook as an example, even though they've repeatedly stated that they wanted to move away from PHP to Python years ago but realized they couldn't after having hundreds of thousands of lines in PHP.
PHP's cool. I love PHP. But, let's stop using Facebook as an example of a company "embracing PHP".
Although it feels 'dirty', the only thing I consistently read about ruby & python web apps are deployment issues and exactly the best way to deploy those apps.
With PHP it seems very straight forward and an easy way to avoid all those issues.
Your time as a human is far more valuable than the extra cost of an IIS server.
Ruby and Python actually offer some language advantages tho. Personally if I coded .NET in the day I would be looking at F# for webapps.
Thats news to me ... if anything deploying Ruby on Rails apps has become much much easier over the years with the advent of Phusion Passenger, Enterprise Ruby, cheaper VPS's, Heroku etc
Secondly, and this is my biggest bug bear, I know nothing about Python on a Mac and OS X. I am a Windows fan through and through, I love Windows 7 and I love the .NET ecosystem. Please don't assume that everyone on HN uses OS X / *nix
Yes you did ("the only thing I consistently read about ruby & python web apps are deployment issues"). That was the reason I used them as my examples.
On your second point, I never assumed anything. I used two examples of common things that where said a few years ago about both languages. It had nothing to do with what you use, more power to you if you use windows7 and .net, it had to do with the fact both where misconceptions that where later proved to be non issues.
I didn't mean to be patronizing or anything, I guess what I really wanted to say is that if you keep reading that Ruby and Python have all this massive issues, you're probably reading articles from 2008 ;)
The things I did to fix the performance problems are generally language agnostic. Improved database architecture, search indexer configuration, clustering, memcache, etc.
Damn! Are these all spammers?
He hasn't heard of Google? :-P
As for using PHP, I'm sure it is used somewhere, but it is not a popular language at Google. Most Google developers have better taste than that.
"Once you get to the scale of computing we’re at, the language you use is much less important than the platform you build on it."
It's 2010 - link the post, not the blog
Edit: never mind, http://news.ycombinator.com/item?id=1819021 already posted it.