Facebook team posted Hack language

    The new Hack language is a direct descendant of PHP, based on its syntax. Hack was created specifically for the HHVM virtual machine (Hip Hop Virtual Machine). The Facebook team has completely translated the development into a new language and calls this migration a great success. However, Facebook does not give up PHP support and plans to finalize PHP5 support in HHVM.
    Detailed language documentation is available here (in English).
    The official website for the new language is http://hacklang.org/ .
    News release language.

    Code example


    <?hh
    class MyClass {
      public function alpha(): int {
        return 1;
      }
      public function beta(): string {
        return 'hi test';
      }
    }
    function f(MyClass $my_inst): string {
      // Fix me!
      return $my_inst->alpha();
    }
    


    New language features


    The main feature of Hack was the implementation of static typing. This required disabling some features of the language, such as a variable in the $$ variable and the extract function (implicit creation of variables in a table of characters from an array).
    Many features from modern programming languages ​​were also introduced: generalized programming, type aliases, nullable types and restrictions on type parameters, collections, lambdas, as well as checking return types and parameter types at run time.
    Types are checked by a special server (service, daemon), which monitors changes in the source code files on the disk.
    How the programmer is notified is not yet clear, but along with the Hack, several tools are included.

    Thanks, Facebook, maybe this is what PHP has been missing for so long!

    Also popular now: