Skip to main content

Facebook Unveils Hack, A New Programming Language For Bug-Free Coding

Facebook engineers Bryan O’Sullivan, Julien Verlaguet, and Alok Menghrajani spent the last few years building a programming language unlike any other.
Working alongside a handful of others inside the social networking giant, they fashioned a language that lets programmers build complex websites and other software at great speed while still ensuring that their software code is precisely organized and relatively free of flaws — a combination that few of today’s languages even approach. In typical Facebook fashion, the new language is called Hack , and it already drives almost all of the company’s website — a site that serves more than 1.2 billion people across the globe.

What is Hack?

Hack is a programming language for HHVM that interoperates seamlessly with PHP. Hack reconciles the fast development cycle of PHP with the discipline provided by static typing, while adding many features commonly found in other modern programming languages.
Hack provides instantaneous type checking via a local server that watches the filesystem. It typically runs in less than 200 milliseconds, making it easy to integrate into your development workflow without introducing a noticeable delay.

The New PHP

You can think of Hack as a new version of PHP. It too runs on the Hip Hop Virtual Machine, but it lets coders use both dynamic typing and static typing. This is what’s called gradual typing , and until now, it has mostly been an academic exercise. Facebook, O’Sullivan says, is the first to bring gradual typing to a “real, industrial strength” language.
What this means is that Facebook was able to gradually replace its existing PHP code with Hack — move from the old dynamically typed system to a statically typed arrangement. “It allows you to slide the dial yourself on the continuum between dynamic types and statics — so you can start out with dynamically typed code and then gradually add more statically typed code, benefiting from each little bit of work you do as you go along,” O’Sullivan says.
In doing so, he explains, Facebook built much more precise code — code with fewer flaws. Hack provides a kind of safety net for developers. What’s more, engineers can more easily understand code when they revisit it. Static typing acts a lot like documentation.
But the big trick is that Hack provides these benefits without slowing down the developer: Unlike other statically type languages, Hack can run without compiling. “You edit a file and you reload a webpage and you immediately get the feedback of: Here’s what the page looks like after I made that change. There is no delay,” O’Sullivan says. “You get both safety and speed.”
Nils Adermann, a software engineer and the co-founder of a company called Forumatic, has used the language, and he says he knows of nothing else quite like it. James Miller and Simon Welsh, engineers at a company called PocketRent, who have also used Hack, agree. The closest thing, they say, is Haskell, a statically typed language that provides a way of executing code relatively quickly. But Hack, they indicate, takes the idea much further.
Hack will be particularly attractive, Adermann says, to existing PHP shops. “Ironically,” he says, “its chief advantage is how little it differs from PHP.” Like Facebook, these shops can gradually move their operations from one language to the another. But Adermann also believes that some developers will adopt the language even if they’re not already using PHP. “While PHP is the most widely used language on the web, it’s unpopular in many places because of its inconsistencies,” he says. “Hack addresses these … and thereby makes the language more attractive to users of other languages.”
But the biggest endorsement for the new language is that Facebook already uses it to run its own site, the world’s most popular social network. It’s not every day that a new language debuts with such an impressive track record. Some, however, question whether Hack should really be called a new programming language. There’s a fine line here between an update to PHP and a replacement for PHP. Where does Facebook draw that line? “That,” Sullivan says, “is a good question to discuss late at night over whiskeys.”

Comments

Popular posts from this blog

AQUA TEK S – the first waterproof, ruggedized, solar-powered battery case for iPhone

If you're hoping to attract investors to get yet another iPhone case to an already crowded market, it had better do more than just protect a phone from bumps and scrapes. Snow Lizard Products is giving itself the best possible chance of raising funds for its new AQUA TEK S case for  iPhone 4  and  4S  with an offering that not only boasts ruggedized protection, but also includes a solar panel, built in battery, and is waterproof up to 20 ft (6 m). Aimed at outdoorsy types who want to stay connected when heading off the beaten track, the case features a waterproof and dirt resistant poly-carbonate ruggedized casing that packs its own built-in battery to extend the life of the the iPhone. The company is still investigating the best battery to fit the form factor so the capacity of the unit hasn't yet been finalized, but it will be able to recharge from the power of the Sun via the solar panel built into the rear of the case. The encased iPhone can also be recharg...

DoubleBack adds a sliding pod to VW's Transporter van

It was over thirty years ago that Volkswagen first started offering "pop tops" on its camper vans. In the years since, the soft-sided interior height-extenders have become a common sight on VW vans parked in campgrounds all over the world. Now, Welsh company Overlander Motorhomes is offering what it sees as the logical compliment to the pop top - it's the DoubleBack, a sliding insulated pod that extends the interior length of Volkwagen's T5 Transporter van.    The company starts with a stock 2.0TDI 140PS Long Wheelbase T5 van, then adds its patented DoubleBack pod package. When on the road, the pod stays tucked up inside the back of the vehicle. Once the driver stops and decides they'd like to settle down someplace, however, it electrically extends out of the rear in under 45 seconds, adding approximately two meters (6.5 feet) of useable interior space. Two legs also fold out from the bottom of the pod, which allow it to support up 600 kilograms (1,323 l...

Nanogenerator that harnesses energy from tires friction

Engineers from the  University of Wisconsin-Madison  along with a collaborator from China have created a new nanogenerator that harnesses energy from the friction caused by rolling tires. Xudong Wang has developed a new way to harvest energy from rolling tires (Credit: The College of Engineering) As a novel energy reusing method, the nanogenerator could be potentially used by auto-mobile manufacturers to improve the efficiency of their vehicles. The first of its kind, nanogenerator was published in the Nano Energy journal. The research was carried out by Xudong Wang, the Harvey D. Spangler fellow and an associate professor of materials science and engineering at UW-Madison, and his PhD student Yanchao Mao for about one year. Based on the triboelectric effect, the nanogenerator can harness energy resulting from the electric potential created between a vehicle's wheels and the pavement. The triboelectric effect is the electric charge generated due to the rubbing...