1. Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as:

    All that and more! Registration is quick, simple and absolutely free. Join our community today!

Facebook dev released new programming language for HHVM

Discussion in 'Coding, Programming' started by Battery Operated Bot, Mar 26, 2014.

  1. [​IMG]
    What is hack?
    Hack is a programming language based on PHP just announced by Facebook. The syntax is basically the same but it adds several new features to help improving the quality of the code that you write, as well take advantage of HHVM (HipHop Virtual Machine) to execute the code faster.

    What Are the Great New Features of Hack?

    Hack introduced many new features relatively to the current PHP version. Some of those features were proposed to PHP over time but they were never accepted.

    Hack code can be mixed with regular PHP code. The way to distinguish which code is to be processed as PHP or Hack is that PHP sections start with <?php and Hack sections start with <?hh. This allows smooth migration between PHP and Hack code, so you can take advantage of Hack features.

    Hack is meant to be run with HHVM. There is a type checking phase that verifies the consistency of code according to Hack new rules.

    When mixing PHP with Hack code, the PHP code sections are not checked against the new Hack rules, but regular PHP code can call Hack code and vice-versa because it is all part of the same program.

    Some Hack features are for different purposes. Let me highlight some of the features that seem more important. I am grouping the features according to their purposes. Some features are meant for multiple purposes, so they are listed here in different purpose sections.

    Notice that this article is being written based on Hack documentation. I wanted to try these features in practice but I was not able to compile it on OpenSuSE 13.1 Linux distribution. Any misunderstandings about the described features may be fixed later if necessary.
    Bug Prevention
    These are features that when used can allow that buggy code be detected before it is executed.

    Type Annotations

    Type annotations are like type declarations, except they are optional. If you use the wrong types of values, you will be able to detect when you make a mistake.
    PHP:

       Sorry you need to Register / Login to see this Content !    


    Nullable Types
    Nullable types is an extension of type annotations using a question mark to specify that a value maybe of a certain type or NULL.
    PHP:

       Sorry you need to Register / Login to see this Content !    


    Collections
    Collections are objects like array but their elements may be set to be of a specific type, thus allowing to detect attempts to set values to incorrect types due to application bugs.
    PHP:

       Sorry you need to Register / Login to see this Content !    

    Hack is definitely a somewhat unexpected and great development of PHP. It is an alternative version of PHP that provides new features that many PHP developers wanted.

    ---
    for more info visit the following links:
    official website: Please or Register to view links
    facebook announcement: Please or Register to view links
    info source: Please or Register to view links
     
    Draft likes this.
  2. Draft

    Draft Administrator Staff Member Administrator

    Not recommended to use in a production sites :)
     
    Battery Operated Bot likes this.
  3. Yeah right! konting info lang ito sa mga hindi aware sa latest news. hehe. :LOL:

    medyo nalito ako kung saan ba dapat ilalagay yung thread na ito feeling ko sa current news events yata ito. if wrong section. pa move nalang po. (y)
     
    Draft likes this.
Tags / Keywords: