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

Google and Stanford early adopters of Honda Fit EV

Honda's first all-electric vehicle is hitting the streets a little early. The  Honda Fit EV  debuted at the Los Angeles Auto Show in November 2011, and it's expected to be     available for lease this summer. However,  Honda announced  that Google and Stanford University got a special early delivery of the tiny EV this week.The Honda Fit EV is equipped with a 20kWh lithium ion battery, and has an EPA estimated driving range of 76 miles. Google added the EV to its  car -sharing service for employees, dubbed the G-Fleet, in    Mountain View, Calif. The search giant maintains several electric and plug-in vehicles that it uses for research and to cart Googlers around town and between buildings on campus. Stanford University also is an early adopter of the Fit EV, but will be using it primarily for research. The university's automotive research department will study the difference in psychological and physical reactions of using battery...

Hand-manipulated objects and transparent displays - the computer desktop of tomorrow

A see-through screen, digital 3D objects manipulated by hand, perspective adjustments according to the user's viewing angle - these are the core features of a prototype computer desktop user interface created by Microsoft's Applied Sciences Group. The prototype uses a "unique" Samsung transparent OLED display through which the user can see their own hands to manipulate 3D objects which appear to be behind the screen. A demo video appears to show a working prototype of a computer markedly different from those we use today. Yes it includes a familiar keyboard and trackpad - but these are placed behind the OLED display. The user simply lifts their hands from these input devices to manipulate on-screen (or more accurately  behind -screen) objects, such as selecting a file or window. The video shows the interface in action with a series of program windows stacked behind one another, with the user selecting the desired program by hand, using the depth of the w...

Bioengineers develop smart, self-healing hydrogel

Velcro is pretty handy stuff, but imagine if there was a soft, stretchy material with the same qualities. Well, now there is. Scientists from the University of California, San Diego have created a self-healing hydrogel that binds together in seconds, essentially copying the Velcro process at a molecular level. The new material could potentially find use in medical sutures, targeted drug delivery, industrial sealants and self-healing plastics. The secret to the jello-like polymer hydrogel is its "dangling side chain" molecules, that reach out toward one another like long, spindly fingers. When developing the gel, a team led by bioengineer Shyni Varghese ran computer simulations, in order to determine the optimal length for these molecules. The resulting substance is capable of healing cuts made to itself - or of bonding with another piece of hydrogel - almost instantly. The behavior of the material can be controlled by adjusting the pH of its environment. In lab t...