What is Hack?


Some programming languages are general purpose e.g. Java,C++ and C#, some are very specific like PHP and Hack is one of those. It’s an open source “improvement” on PHP developed by Facebook engineers. One big difference is that in runs on HVVM.

What is HVVM?

HHVM is an open source Virtual Machine that runs programs written in Hack and PHP. Originally Facebook developed a PHP compiler called HipHop which statically compiled PHP to C++ but eventually replaced it with the HipHop Virtual Machine (hence HHVM).

Virtual Machines offer several benefits over statically compiled programs; one of the biggest is that they can dynamically optimise code at runtime. The classic JVM that Java programs run on is an example of this and is how some Java applications can run as fast as or even faster than compiled C++. Ironically the JVM is written in C++ as is HHVM. You can view the HHVM code on Github.

Facebook isn’t the only site running HHVM. Add to that Wikipedia, Baidu, Box and Etsy. To ask why though, we have to go back to PHP which is now 21 years old.


Regardless of criticisms and a poor reputation, PHP is a major success story for developing server side functionality in websites and it’s estimated that over 50% of the Web uses it. That includes WordPress sites, Joomla, and many commercial quality open source packages, numbering in the hundreds.
Part of this success lies in that every Linux hosting and now most Windows Hosting includes PHP. It’s the P in LAMP and WAMP.
To become a PHP programmer does not take much effort, however It takes a lot more effort to write good PHP code. It’s not exactly a masterpiece of design, unlike say Python which is just four years older but does just about everything right. When it comes to the web though Python is the Betamax to PHP’s VHS!

The criticisms of PHP include that it’s full of surprises, is inconsistent, requires lots of checking round C API calls and is flaky in places. When developing PHP websites I spent a lot of time looking through the comments and examples on the online PHP documentation to try and get things done. Here’s an interesting blog entry about PHP’s failings.

Which brings us back to Hack.


Facebook engineers know PHP very well. Not just from developing earlier incarnations of Facebook but from writing the HipHop compiler for it.
They’ve taken that knowledge plus awareness of PHP’s deficiencies and the result is Hack = PHP + Improvements. It’s backwards compatible with PHP which means that you should be able to take an existing PHP website and run it on HHVM. This assumes that your platform can support HHVM. There are prebuilt HHVM install packages for Ubuntu 14.04+ and Debian 7+. A search for HHVM hosting finds quite a few including Heroku, DreamHost and others.

These improvements of Hack over PHP include static typing, Generics, Collections, Lambdas and Async support. Here’s an example below where variables are annotated with types (int and string). Note the <?hh which is what distinguishes Hack scripts from PHP.

class MyClass {
  const int MyConst = 0;
  private string $x = '';
  public function increment(int $x): int {
    $y = $x + 1;
    return $y;

Collections are an interesting addition and should be considered before arrays. It’s like moving from Basic to Java! PHP has a one-size-fits-all array container. Hack has arrays but they are closer to generics in that you have to specify additional type information. An int dictionary of strings is declared as array<int, string> in Hack.

There are seven collection types with both mutable and immutable versions of Vector, Map and Set plus a Tuple like Pair collection, but only good for two values.

The Typechecker

As you are editing and saving, the Hack typechecker does its magic and detects errors very rapidly. There’s an online tutorial where you do editing in the browser and can see it in action.


Hack, together with HHVM make it possible to write PHP like websites with a lot less effort than with PHP. It’s impressive what Facebook has done with it. Adding the type annotations will speed up code execution though if your application is CPU bound, moving it to HHHVM can give up to a 5x speedup according to one of the Hack team in an answer on Stackoverflow.

Of course bear in mind that Hack needs HHVM and if you are using shared hosting, then it’s not available as far as I know. For dedicated, or virtual servers, you can install HHVM.

The spec for Hack is online and can be found on Github.

Note that comparisons with PHP refer to versions before PHP 7. I haven’t used it or tried PHP 7 it, though I understand it can run programs a bit faster than PHP 5.

Comments { 0 }

Working in Technical Sales and Marketing at Intel Corporation


The world’s largest producer of transistor technology
Intel is the world’s largest and most successful producer of transistor technology in the world, but if you think PC technology is all Intel does, think again. We are innovators that are seeking to develop solutions to a broad spectrum of problems faced by all kinds of organizations the world over. Though we are in the best position to answer the needs of the rapidly evolving technology world, in order to do so we need sales professionals like you to deliver our comprehensive, end-to-end solutions to where our customers need them most.
Read more →

Comments { 0 }

What is .NET Standard?

development - .net standard

It’s all a bit confusing! In the good old days, say fifteen years ago there was just .NET for Windows. Then Mono appeared in 2004. It’s like .NET but for Linux so now you could compile and run C# programs on both Linux and Windows. Mono didn’t have everything from .NET but it was a decent implementation.

Along the way Xamarin the company appeared out of the ashes of Novell’s takeover by Attachmate and support for Mono continued. In addition they released the commercial Xamarin tools, first as MonoTouch for cross-platform mobile development in C#. By mid-2015 it had over a million developers in over 120 countries and Microsoft bought Xamarin in early 2016. Read more →

Comments { 0 }

What to study to get a Job in IT

Casual man working on laptop in library

So you want to work with computers after you graduate university? That’s great news!

This means that if you’re just about to enter university, you may think that in order to get a job in IT, you can just do an IT degree: simple right?

Not quite.

For instance, there is quite a lot of confusion about the term ‘IT’. Whilst it is used as a catch-all term for ‘working with computers’, it ALSO refers to the specific field of working in computing maintenance and repairs.  Read more →

Comments { 0 }

Mo’ Data, Mo’ Problems…


There is rarely a consensus on what ‘Big Data’ really means, either within business or academia, but if there is one point that most (if not all) companies can agree on, it’s that their voyage into big data caused unexpected problems.
Read more →

Comments { 0 }

Core Skills Needed to be an IT Manager: What you Need to Know

The 10 Most Valuable Questions to Ask Your Interviewers 11


So you want to be an IT Manager?

You’ve been in the industry for a couple of years, you know your stuff and your all clued up. Good; it’s time to make the next leap.

Management is a whole new ball game compared to a more junior roll. Not only do you need to master your own job, but you must be able to provide support and knowledge to those you manage. Now that really is a challenge.  Read more →

Comments { 0 }

Six skills every Business Analyst needs


See the six skills to help you succeed as a Business Analyst, a role that often comes with lots of autonomy, constantly evolving demands and priorities.

These six skills don’t necessarily determine whether you’ll be a competent business analyst. But if you’re aware of them, you’ll have an advantage in selling yourself as someone who will be able to work effectively in any organisation.

Read more →

Comments { 0 }

IT Sales Tips: How to Hone Your Skills

figure out your finances


Working in IT sales is not easy: by definition, your role is inherently two-fold. You are expected to be an IT expert and a successful Marketer. That’s two different sets of skills that you’re working with on a daily basis. You need knowledge of computing and how to be a good salesperson- these are both important parts of the job. We can understand that sometimes, the variety of skills you’re using on can feel like juggling a lot of things at once.

So, in order to make things easy for you, we’ve researched the best tips on the skills that are unique to an IT Salesperson and how you can improve your job.   Read more →

Comments { 0 }

Game Developer Salary

Never undersell yourself

A Game Developer can be an exciting and creative, as well as a highly technical role. With the current high demand for video games, developers are certainly in demand, making this an excellent choice of IT career for people interested in coding and Computer Science.

However, there are obviously various levels of seniority in the Game Developer business and the more relevant experience you have, the greater chance you will have of succeeding.  Read more →

Comments { 0 }

What is Elliptic Curve Cryptography?


Elliptic curve cryptography is a set of algorithms for encrypting and decrypting data and exchanging cryptographic keys. But why is it called elliptic? The word derives from ellipse, which is a mathematical curve in a plane surrounding two focal points such that the sum of the distances to the two focal points is constant for every point on the curve.  Planets in orbit round the Sun travel in an elliptic orbit, not circular.

Now while the length of part of an arc in a circle is easy to calculate, it’s a pretty complex task for an arc on an ellipse.  I’ll spare you the maths. Cryptography in general is an area where knowledge of algebra to an advanced level is required to really understand it, but you can still use it without that depth of knowledge.  Read more →

Comments { 0 }