Hack in 15 minutes (Tobias Nyholm, Happyr)

Fackebook needed a huge amount of servers to run their PHP code, so they created HHVM to execute it more efficiently – 8 times faster. Wikipedia recently switched to HHVM and increased performance by about a factor 5.

Hack is a PHP-compatible alternative language (including its deficiencies). It is slightly faster than HHVM. It is gradually typed. Not really statically typed because typing isn’t obligatory, but you can add type specifications when you want. You can also run it in strict mode, which means everything has to be annotated.

Convert php to hack:

<?hh

Add types to function arguments, returns and class members.

Syntactic sugar: you can add member declarations in the constructor instead of the class.

Syntactic sugar: lambda expression: (arg, arg) ==> expr;

Arrays cannot be typechecked, so use Map or Vector. Shape is a fixed-size array with fixed keys – a bit like a class.

Generics similar to C++: the type annotation can be delayed until class instantiation.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s