zoukankan      html  css  js  c++  java
  • 兴奋、强类型版的PHP语言

    Hack 是 Facebook 推出的一款新的编程语言。

    Hack 是由Facebook开发的,同时结合了动态类型语言(如C语言)和静态类型语言(如PHP语言)两种特点的一种编程语言。通常在使用静态类型语言编程 时,开发者会在程序被运行前就知道错误发生的位置。而在更为当前的编程环境里,动态类型语言会一直运行到直至程序出错崩溃。

    http://static.cnbetacdn.com/newsimg/2014/0321/25_1jaT3fMDO.png

    特性:

    • 该语言将能使代码的编写和测试更加高效快速,能够在程序运行前捕获到其中的错误;
    • 同时结合了动态类型语言(如PHP语言)和静态类型语言(如C语言)两种特点;
    • Hack对代码本身的运行速度并没有实质影响;
    • 基于hhvm(hiphop vm)运行

     我不知道我的系统环境如何,用下面的步骤就装好了

    hhvm --version
    HipHop VM 2.5.0-dev+2014.03.20 (rel)
    Compiler: heads/master-0-gc4b6a793b0d6bc28e63c29151ca0a5c12bbbf856
    Repo schema: 0e601f9f2c514001cbe38f215a281d34f36a9a9c

    Installing Boost 1.49

    Similarly, HHVM requires Boost 1.49, but Ubuntu 12.04 only ships with 1.48. To get a more recent version, follow these steps:

    sudo add-apt-repository ppa:mapnik/boost
    sudo apt-get update
    sudo apt-get install libboost1.49-dev libboost-regex1.49-dev 
      libboost-system1.49-dev libboost-program-options1.49-dev 
      libboost-filesystem1.49-dev libboost-thread1.49-dev

    For Ubuntu 12.04:

    wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
    echo deb http://dl.hhvm.com/ubuntu precise main | sudo tee /etc/apt/sources.list.d/hhvm.list
    sudo apt-get update
    sudo apt-get install hhvm-nightly
    装好后,创建一个文件如 first.hack,代码如下:

    <?hh
    
    // Hack functions are annotated with types.
    function my_negation(bool $x): bool {
      return !$x;
    }
    
    // FIXME: annotate this function parameter
    // and return with the type 'int'.
    function add_one(int $x): int {
      return $x+1;
    }
    
    echo add_one(5);
    在命令行运行

    hhvm first.hack
     

    安装指南

    1. https://github.com/facebook/hhvm/wiki/Building-and-installing-HHVM-on-Ubuntu-12.04

    2. http://zendframework.info/tag/hhvm-2/

  • 相关阅读:
    CSP2019 Day2T3 树的重心
    51nod1835 完全图
    [HNOI2015]亚瑟王
    [六省联考2017]分手是祝愿
    洛谷P4550 收集邮票
    06_手工负载分担(数通华为)
    05_配置交换机SSH服务(数通华为)
    04_配置交换机Telnet服务(数通华为)
    03_vlan & access & trunk 口(数通华为)
    02_搭建HTTP客户端与服务器(数通华为)
  • 原文地址:https://www.cnblogs.com/x3d/p/3615068.html
Copyright © 2011-2022 走看看