Monday, 24 March 2014

Hack The New Programming Language

Posted by Amit Khomane
Hack Programming Language,  Facebook Hack Programming Language
Any Programming language have 3 main features. Performance, Productivity and Generality. We always have to give up on one of the three. People always try to create a so called super-language which meets all three features and that leads to creation and modification of languages. Some other points that lead to creation of languages are,

  • People take ideas from different languages and combine them into a new languages.
  • Some features improved, Some added and some removed of existing language.
  • Programmers start using a language in a particular way, Language designers identify some usage patterns and introduce new abstractions to support that patterns.
  • Some languages are designed to support particular domains.
  • People thinks they can improve on existing products.

Now Facebook jump into programing language creation. Google is already into it. Google have developed GO (aka golang) and Dart Web programming language. Facebook have unveiled language called Hack (nothing to have with hacking). What made them go for Hack? Lets get deep into it to understand more about it.

What is Hack?

As said earlier, its programming language invented by Facebook(introduced on March 20, 2014, that too young). Hack is for the HipHop Virtual Machine (HHVM). Now what's that? In simplest context It is PHP execution engine and improvement. The HHVM is a machine designed to execute programs written in Hack and PHP. Its main motive is to increase speed of the PHP application. Hack is, in simpler terms, new version of PHP.

Why Hack?

I think point that would attract PHP developer is, it interoperates seamlessly with PHP. The highlighting point of the Hack is static typing. Ok, I know bit about static typing but Why and how does that matter.
  • Static Typing:
Static typing languages required to carefully define your variable types. Annoying to many developers right?(specially who do scripting like PHP which is dynamically typed). But where does it benefits. It requires fewer server to run your code and it’s easier to manage your code. Since typing itself gives you documentation you need for collaborative development. You no need to explain your code to other developers for its typing.  
So Hack provide static typing? YES and still Interoperate with PHP How? The answer is  gradual typing. It is both static and dynamic typing.(Now that make a sense).

Other Point to highlight about Hack are,
  • Generics:
It allows classes and methods to be parameterized, a type associated when a class is instantiated or a method is called.

  • Collections:
It enhances the experience of working with PHP arrays. Hack implemented some collection types such as, Vector, Map, Set, Pair.
There are few more features such as, Lambdas, Shapes, Type Aliasing, Async, Continuations, Override Attribute, Method Dispatch and few more.
Tested and Proven:

So next thing comes to mind, is it tested and proven? As Facebook stated, we had already implemented the code and "battle tested" it on a large portion of Facebook's site. So we can consider it safe and tested (If we believe what they stated).

PHP to Hack:

Running your PHP project as Hack (is it possible?). Hack provide some tools that will be used to convert your code into Hack. It is automated conversion while running on HHVM so you no need to be worried about other things than your logic.

Hack is creating buzz with some of the top software developer’s appreciation. But some do question about it being new language or update to PHP.


  1. Hi Admin,
    I went through your blog and it’s totally awesome. Keep on updating your site with such informative post. If possible please include rss feed for your blog. Web designing course in Chennai

  2. Thank you for this detailed article on Web designing course. I’m aspiring to do Web designing course.