News for hackers. Stuff that matters.
Re:Facebook releases HHVM, 60 percent faster than its curren... by nupark2 on Tuesday December 13, 2011 @09:50AM (#3347618)
I find it interesting that the economics of inertia work out in favor of Facebook expending so much effort in improving the performance of a historically technologically poor language like PHP.

Jason Evans is the author of jemalloc (and more). Given all the things he would be capable of applying himself to, it's surprising to see him working on PHP runtime performance (though, the problems are interesting).

Re:Facebook releases HHVM, 60 percent faster than its curren... by hvs on Tuesday December 13, 2011 @09:57AM (#3347641)
I'm not sure that I'd refer to PHP as a "historically technologically poor language". I'm not even quite sure what that means, exactly, but PHP has proven itself over and over again to be more than capable of working in environments with heavy load and numerous simultaneous users. In fact, in comparison to something like Ruby, it historically destroys it.

Now, if you want to get into the details of syntax, naming conventions, etc.. sure, PHP is not everyone's favorite language to work with, but it is far from "technologically poor".

Re:Facebook releases HHVM, 60 percent faster than its curren... by phillmv on Tuesday December 13, 2011 @11:10AM (#3347903)
It's always hard to talk about these differences because 90% of the time we're actually just chest beating and comparing the length of our respective community's e-penises.

When people complain about PHP they often mean that in an aesthetic, and in an academic sense, the designers of PHP have, arguably, made a lot of poor choices.

What they usually mean is, due to the low barrier of entry coupled with poor aesthetic design choices the PHP community at large seems to have poor engineering standards.

These all being Turing machines though don't prevent it from having quality engineering being applied to it, as is the case of Facebook.

So, the corollary to "only a poor craftsman blames his tools" is "when you only have a hammer everything starts looking like a nail".

I wonder how many people are paid to directly hack on a Ruby implementation vs Python (yay Google) or PHP (yay Facebook).

Re:Facebook releases HHVM, 60 percent faster than its curren... by umjames on Tuesday December 13, 2011 @12:06PM (#3348171)
Isn't that what Matz is doing now at Heroku?
Re:Facebook releases HHVM, 60 percent faster than its curren... by jackowayed on Tuesday December 13, 2011 @07:23PM (#3350022)
I think Engine Yard pays 3 people to be fulltime on the JRuby core team and 2 (not sure on that, certainly one) to be fulltime on Rubinius. Microsoft was supporting IronRuby until a couple years ago.
Re:Facebook releases HHVM, 60 percent faster than its curren... by maratd on Tuesday December 13, 2011 @10:30AM (#3347763)
Absolutely. PHP just works and it's easy to make it work. That's the most important thing when choosing a platform. Asthetics are always secondary. It's certainly a pain to deal with inconsistent syntax, but fighting your toolchain is a far worse fate and with PHP, that's rarely an issue.
Re:Facebook releases HHVM, 60 percent faster than its curren... by jonknee on Tuesday December 13, 2011 @01:08PM (#3348494)
It doesn't "just work" for Facebook though, look at all the effort they have exerted to be able and use it. They don't get the main benefit of PHP, but still get all of its flaws.
Re:Facebook releases HHVM, 60 percent faster than its curren... by ry0ohki on Tuesday December 13, 2011 @04:18PM (#3349322)
Nothing out there "just works" when you are at Facebook scale.
Re:Facebook releases HHVM, 60 percent faster than its curren... by laconian on Tuesday December 13, 2011 @12:26PM (#3348279)
For a hack, maybe.

Fighting your toolchain is an upfront penalty. Once things start moving smoothly, they tend to continue to work smoothly. And that's a problem that can be solved by further development of the toolchain.

Poor aesthetics/readability? You pay that price every second you work on the code.

Re:Facebook releases HHVM, 60 percent faster than its curren... by maratd on Tuesday December 13, 2011 @12:58PM (#3348441)
> Once things start moving smoothly, they tend to continue to work smoothly.

This is flat out wrong. If you're on a language all the cool kids are using, you'll find those cool kids have an obsession with perfection. To the point where they deprecate things instantly and break everything that worked before. See NodeJS and Python for examples.

If you have 10K lines of code, not so bad. So you do a rewrite every year. When you have 100K lines of code or more, their obsession with perfection will destroy your business.

A rewrite becomes an immense undertaking. You end up running old versions. Those old versions require dependencies which require you to run old operating systems. Eventually the entire ecosystem implodes.

But guess what? Code that was written in PHP3 over 10 years ago works just as well today under PHP5. You can even mix and match. Does that make the syntax of the language ugly? Sure. It even encourages bad practices. So what? You're running a business, not an art gallery. Code should be beautiful, but not at the expensive of having a successful business and a working product.

Re:Facebook releases HHVM, 60 percent faster than its curren... by grncdr on Tuesday December 13, 2011 @05:08PM (#3349571)
> But guess what? Code that was written in PHP3 over 10 years ago works just as well today under PHP5.

Sorry, but having felt the pain of keeping legacy installs of old PHP versions around to run business-critical processes, I have to call bullshit on that one.

Re:Facebook releases HHVM, 60 percent faster than its curren... by maratd on Wednesday December 14, 2011 @09:03AM (#3351814)
> legacy installs of old PHP versions around to run business-critical processes

Why? Your code should work in the latest version. Can you give an example?

Re:Facebook releases HHVM, 60 percent faster than its curren... by laconian on Tuesday December 13, 2011 @01:06PM (#3348477)
But, I don't use the languages those cool kids are using. :) I imagine I would have to formulate a very defensive strategy to deal with breaking changes that would gobble up my productivity gains from using said cool language, just like the people that use Mongo have to DIY the checks that RDBMSes get for free.

I use Java and C++, and I don't rush update the second new libraries become available. My team has a large regression suite, too, so it's been less painful (can't say painless) to detect breakage when our dependencies need to be updated.

Re:Facebook releases HHVM, 60 percent faster than its curren... by maratd on Tuesday December 13, 2011 @01:42PM (#3348619)
> I use Java and C++

Comparing Java and C++ to PHP is the equivalent of comparing a Ford Mustang to a Mac Truck. Yes, they are both vehicles. However, they are designed to do very different functions. Java and C++ are statically typed, compiled languages. PHP is not.

Yes, if you drive a Mac Truck, you can bully and make fun of the guy driving a regular car, but if you're using your Mac Truck to commute to work, you're a lunatic.

For every problem, a proper tool.

Re:Facebook releases HHVM, 60 percent faster than its curren... by prewett on Wednesday December 14, 2011 @03:01AM (#3351061)
When you're trying to ferry boatloads of bits down the information superhighway, the Mack truck starts to look pretty good. Sure, the automatic transmission Mustang is cheap, quick to acquire, and easy to find drivers for, but you have to get 10 of them for every Mack truck's worth.

Given that FB's solution to their PHP problem was to discover the static typing, I'd say that PHP is not the proper tool for the current job.

Re:Facebook releases HHVM, 60 percent faster than its curren... by dhugiaskmak on Tuesday December 13, 2011 @04:10PM (#3349293)
Mack Truck
Re:Facebook releases HHVM, 60 percent faster than its curren... by andybak on Tuesday December 13, 2011 @10:14PM (#3350417)
"See NodeJS and Python for examples."

What's an example of the Python community doing this. Usually Python get's criticised for being overly-conservative if anything.

Re:Facebook releases HHVM, 60 percent faster than its curren... by maratd on Wednesday December 14, 2011 @08:58AM (#3351804)
Re:Facebook releases HHVM, 60 percent faster than its curren... by wwweston on Tuesday December 13, 2011 @01:53PM (#3348665)
Funny, my experience is that learning to read the idioms (and write the most convenient idioms) of the language is an upfront penalty, and once you've made the investment things start moving smoothly.

Of course, it's everyone's privilege to decide which penalty they'd prefer to pay, and that doesn't mean there aren't language features that can make put it on a new order of expressiveness.

But are we talking about those features? Or are we talking about "aesthetics/readability"? If it's the later, that's probably a different thing, and I have my doubts that it's anything objective. Particularly if it has much to do with which specific tokens indicate the beginning/ending of blocks or enclosing arguments to a function.

Re:Facebook releases HHVM, 60 percent faster than its curren... by wwweston on Tuesday December 13, 2011 @02:16PM (#3348773)
(You know, the funny thing with downvotes is that you never know if you just made someone uncomfortable, or if there's a credible argument against what you just said. Though one tends to assume that if the later were true it would have been employed along with -- perhaps even in stead of -- the downvote.)
Re:Facebook releases HHVM, 60 percent faster than its curren... by adbge on Tuesday December 13, 2011 @05:21PM (#3349627)
The best way to deal with a downvote is to assume that it was an accident.
Re:Facebook releases HHVM, 60 percent faster than its curren... by nupark2 on Tuesday December 13, 2011 @10:15AM (#3347710)
I'm referring to the quality of the implementation, its performance profile, the soundness of the type system and syntax, and -- like the original post -- measuring relative to the state of the art in JITs, including the JVM.
Re:Facebook releases HHVM, 60 percent faster than its curren... by j_col on Tuesday December 13, 2011 @11:58AM (#3348136)
If the JVM is state of the art, how many applications of the scale of Facebook are using it? A serious question, as I don't know of any.
Re:Facebook releases HHVM, 60 percent faster than its curren... by nupark2 on Tuesday December 13, 2011 @12:30PM (#3348300)
The JVM is one of the most advanced production-quality JITs available.

As for who is using it, everyone from Google to Twitter to Apple, as well a huge number of high-transaction business systems. The JVM is something that tends to get used quietly and widely.

Re:Facebook releases HHVM, 60 percent faster than its curren... by j_col on Wednesday December 14, 2011 @04:28AM (#3351209)
It's also in my experience a massive memory hog, makes deploying your web application a pain (restarts anyone?), and is much more complex to develop for. If your Facebook and you're trying to get more bang-for-your-buck from your existing hardware, do you think its a good choice to migrate everything to the JVM (including a full rewrite to Java/JRuby/Scala etc.)?
Re:Facebook releases HHVM, 60 percent faster than its curren... by nupark2 on Wednesday December 14, 2011 @01:15PM (#3352902)
> It's also in my experience a massive memory hog

It's not that Java is memory hog per se, but rather that the total VM memory allocation must be specified at launch, and the VM will not (rarely?) give that memory back to the OS.

This is largely an artifact of Sun's generational GC design+implementation, and has some interesting performance wins; namely, object allocation and deallocation are incredibly cheap, because in the fast case, all allocation requires is updating a single pointer.

The last time I profiled java object allocation, creating short-live objects turned out to be insanely cheap compared to other allocators/runtimes.

> Makes deploying your web application a pain (restarts anyone?)

This largely depends on how you structure your web application.

> If your Facebook and you're trying to get more bang-for-your-buck from your existing hardware, do you think its a good choice to migrate everything to the JVM (including a full rewrite to Java/JRuby/Scala etc.)?

That depends largely on how much they're spending on hardware and JIT/language engineers, versus how much a rewrite would cost, amortized over the reasonable lifetime of their code base.

You have to factor in the fact that they've built an entire organization around PHP, and it's not just a technological migration problem; they might also have to retrain or outright replace a large number of existing engineers.

I'm inclined to say that it was a mistake to choose PHP, and moreover, to continue to use PHP as they scale. However, funding the implementation of better PHP runtime implementation may be the most fiscally conservative decision left available to them.

Re:Facebook releases HHVM, 60 percent faster than its curren... by streptomycin on Tuesday December 13, 2011 @10:05AM (#3347675)
> the performance of a historically technologically poor language like PHP

One of the biggest reasons PHP supplanted Perl as the de facto web programming language ~10 years ago was that Perl running through CGI was incredibly slower than PHP.

Re:Facebook releases HHVM, 60 percent faster than its curren... by fallous on Wednesday December 14, 2011 @12:05AM (#3350697)
Sorry, but that's just historically inaccurate. PHP _10_ years ago was popular because it was a templating language that could be embedded in HTML, in which case it supplanted SSI and really was a competitor to ASP.

mod_perl was spanking PHP 10 years ago from a performance standpoint, but the democratization of the web meant that a lot of people that started with basic HTML layout then learned to extend it with PHP in templates, then moved on from there. Much the same as Perl became a dominant CGI language in mid/late 90s because a lot of sysadmins and hackers transitioned to back-end development due to web programming demands.

Re:Facebook releases HHVM, 60 percent faster than its curren... by streptomycin on Thursday December 15, 2011 @02:33PM (#3357546)
No, it's not historically inaccurate. mod_perl was fast, but no shared hosts offered it. So unless you wanted to shell out big bucks for a dedicated server, mod_perl wasn't much of an option. And if you wanted to write software to give away or sell to others, mod_perl certainly wasn't much of an option unless you wanted to only focus on a very small part of the market.

I personally transitioned from writing Perl CGI scripts to writing PHP scripts about (pause while I look through my records) 9 years ago, and it was exclusively for performance reasons (I still prefer Perl as a language). I was not alone in my thinking back then.

Re:Facebook releases HHVM, 60 percent faster than its curren... by sciurus on Tuesday December 13, 2011 @11:30AM (#3347990)
As an aside, there are an enormous number of ways to deploy a modern perl application. For anyone who is curious, see slides 30 through 79 of http://www.slideshare.net/miyagawa/deploying-plack-web-appli...
Re:Facebook releases HHVM, 60 percent faster than its curren... by dspillett on Tuesday December 13, 2011 @10:46AM (#3347811)
Perl had a reputation for being more complex for a beginner too and leading to code that was difficult to maintain.
Re:Facebook releases HHVM, 60 percent faster than its curren... by dmooney1 on Tuesday December 13, 2011 @11:23AM (#3347956)
I always thought it was because basic PHP was so intuitive for anyone familiar with a C-like language.
Re:Facebook releases HHVM, 60 percent faster than its curren... by pbiggar on Tuesday December 13, 2011 @01:28PM (#3348576)
There's a ton of reasons PHP took off, including off the top of my head

- cruftyness of perl

- good timing, few alternatives (C and Perl basically) at a key point in the growth of the internet and web developers.

- very easy migration from a static only site

- easy to deploy, leading to...

- wide availability of PHP shared hosting

- in depth docs

- commenting on docs (cut-and-paste programming ;))

- thousands of builtin functions: first real batteries-included language

- recognizable syntax (esp vs Perl) for Java/C programmers

- not awful performance

- builtin MySQL support from an early stage

- oh, it was free (and also Free)

- dynamic typing

- weak typing (as in, values coerced to other types easily, I know this isn't a real term)

Re:Facebook releases HHVM, 60 percent faster than its curren... by nir on Tuesday December 13, 2011 @05:21PM (#3349626)
> - commenting on docs (cut-and-paste programming ;))

Very true and rarely mentioned. PHP docs never had the fancy wiki/social/javadoc features you see in many languages, just a primitive comments system - and it was perfect.

When you were picking it up back when "PHP3" yielded 0 results in Amazon (and we had to change the oil on our desktops every week) the docs were your bible, not merely in the sense of occasionally contradicted themselves but also in having examples, Q&A and recipes for common tasks posted by your peers in the comments, much faster than doc writers could catch up with the language's growth.

Re:Facebook releases HHVM, 60 percent faster than its curren... by r00fus on Tuesday December 13, 2011 @06:48PM (#3349923)
> good timing, few alternatives (C and Perl basically) at a key point in the growth of the internet and web developers.

Two web language competitors to add here: MS .ASP and ColdFusion. PHP broke out by being both free and Free (the REPL helped too).

Re:Facebook releases HHVM, 60 percent faster than its curren... by themonk on Tuesday December 13, 2011 @12:49PM (#3348398)
mod_perl was there, it performed better but little bit extra memory footprint.

I don't know why mod_perl was known to very few and PHP become popular.

Re:Facebook releases HHVM, 60 percent faster than its curren... by fallous on Wednesday December 14, 2011 @12:09AM (#3350711)
mod_perl required real programming techniques due to the shared namespace. So many cgi scripts were written with no localization and so many programmers of that era had embraced the sloppiness of lack-of-persistence that it was hard to port existing cgi to mod_perl even assuming they bothered to try and grok the "voodoo" of persistence in a single finite process CGI world.
Re:Facebook releases HHVM, 60 percent faster than its curren... by rubashov on Tuesday December 13, 2011 @02:42PM (#3348889)
Shared hosting services offered php. You can't do shared hosting with mod_perl.
Re:Facebook releases HHVM, 60 percent faster than its curren... by fallous on Wednesday December 14, 2011 @12:17AM (#3350738)
Umm, actually you can... it just requires some skills on the apache config side.
Re:Facebook releases HHVM, 60 percent faster than its curren... by rscale on Tuesday December 13, 2011 @10:35AM (#3347774)
mod_perl also had serious performance and memory leak issues.

PHP sucked at the time too, but it sucked in ways that were easier to track down and fix.

Re:Facebook releases HHVM, 60 percent faster than its curren... by preinheimer on Tuesday December 13, 2011 @10:56AM (#3347850)
They've spoken to this directly. Facebook has tried to migrate to something else (generally with a small team leading the charge) a few times.

Let's say that there's 1M lines of PHP code right now handling Facebook's site. In the time it takes the team to re-write those million lines of code, another million have been written. So they can never catch up. Almost like Zeno's paradox, except the turtle moves faster :).

All that aside, you can teach PHP to pretty much anyone, and it's rather effective at solving web problems.

For quite a while they had some really smart people working on APC to help with performance, they've since switched horses to work on HipHop and the like to get the performance they need.

[deleted]
Re:Facebook releases HHVM, 60 percent faster than its curren... by phillmv on Tuesday December 13, 2011 @11:13AM (#3347914)
Since they're hiring so many Googlers one presumes Python would be a top choice, but if you need an opportunity to whine about Ruby/Rails go for it.