facebook launched a new programming language for HHVM

| Last Updated: | In: Facebook


Hack is a programming language for the HipHop Virtual Machine (HHVM) invented by Facebook.Hack can be seen as a new version of PHP that also runs on the HHVM, but it allows programmers to use both dynamic typing and static typing.

This is what is called gradual typing, which has been mostly seen as an academic exercise; as described by Facebook, it is the first to bring gradual typing to a “real, industrial strength” language.

hack

Hack Features

Hack interoperates seamlessly with PHP, which is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. Majority of scripts that are valid in PHP are also valid in Hack.[4] Hack’s type system allows types to be specified for function arguments, function return values, and class properties; types of local variables cannot be specified.

Syntax and Example

The basic file structure of a Hack script is similar to a PHP script with a few changes. A Hack file starts with < ?hh as opposed to &lt;?hh
function increment(int $x): int {
return $x + 1;
}

function average(float $x, float $y): float {
return ($x + $y) / 2;
}

function say_hello(string $name): string {
return “Hello “.$name;
}

function invert(bool $b): bool {
if ($b) {
return false;
} else {
return true;
}
}

function sort(array $arr): array {
sort($arr);
return $arr;
}

// A piece of code that computes the average of three numbers
function avg(int $n1, int $n2, int $n3): float {
$s = $n1 + $n2 + $n3;
return $s / 3.0;
}

?&gt;

Acknowledgements

There are many people who have contributed to the development of Hack.

The core Hack team consists of Julien Verlaguet, Joel Beales, Eugene Letuchy, Gabriel Levi, Joel Marcey, Erik Meijer, Alok Menghrajani, Bryan O’Sullivan, Drew Paroski, James Pearce, Joel Pobar, and Joshua Van Dyke Watzman.

A special thanks goes to our early community adopters for providing valuable feedback to make the language better: James Miller, Simon Welsh, Nils Adermann, Fabien Potencier, and Alexander Mols.

Hack is written primarily in OCaml. We would like to thank the Gallium team (INRIA) for the development of the OCaml language, and the Ocsigen team (CNRS – University of Paris Diderot – INRIA) for the development of the js_of_ocaml part of Ocsigen.

And, of course, thank you to everyone else who has helped make Hack the language it is today. The list is too exhaustive for a blog post, but you know who you are.

Tags: , , , , ,


About: Prem Tiwari

Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby.


You may also like:

Follow us!

Get Free Access of 400+ Scripts

Don't worry you'll not be spammed!

Featured eBook

WordPress Security Guide

Free Guide: Learn how to implement security guideline in your WordPress site...

DOWNLOAD

Pincode Finder

pincode-finder tool

Online Pincode Finder

Best tool to locate post Office address and pincodes of all india...

SEARCH NOW