LoginSignup
0
1

More than 5 years have passed since last update.

HHVMとHackを触ってみる

Posted at

概要

リリースしてからずっと興味を持っていたが、今まで触っていませんでした。
PHP7のリリースによって、HHVMとパフォーマンスに差がないことから世間的には興味が薄れつつありますが、敢えてこのタイミングでHHVMとHackを触ってみます。

はじめに

Hack言語

2014年にFacebookにより開発されたプログラミング言語です。オープンソースとして公開されており、同社が開発したPHP実行環境のHHVM で動作します。

HHVM(HipHop Virtual Machine)

PHPやHackを実行する仮想マシンです。JITコンパイルで中間言語に変換した後、コンパイルして実行する方式です。

CentOS7にHHVMをインストール

ubuntuへのインストールが推奨されていますが、自分は業務でCentOSをよく使っているので、今回はCentOSにインストールします。
本家Githubにインストール方法が載っているので、そちらを参照して進めます。

手順

まずはCentOSを更新

yum update -y

EPELリポジトリ更新

rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm

依存関係のあるライブラリ更新

yum install cpp gcc-c++ cmake git psmisc {binutils,boost,jemalloc,numactl}-devel \
{ImageMagick,sqlite,tbb,bzip2,openldap,readline,elfutils-libelf,gmp,lz4,pcre}-devel \
lib{xslt,event,yaml,vpx,png,zip,icu,mcrypt,memcached,cap,dwarf}-devel \
{unixODBC,expat,mariadb}-devel lib{edit,curl,xml2,xslt}-devel \
glog-devel oniguruma-devel ocaml gperf enca libjpeg-turbo-devel openssl-devel \
mariadb mariadb-server make libc-client -y

HHVMインストール

rpm -Uvh http://mirrors.linuxeye.com/hhvm-repo/7/x86_64/hhvm-3.15.3-1.el7.centos.x86_64.rpm

バージョン確認

$ hhvm --version

バージョンが正しく表示されれば、導入完了です。

初めてHHVMでHackを動かそうとして躓いた事

インストール後の動作検証として、世界に挨拶しようと下記コードが記載されたhello.hhを動かそうとした所、エラーが発生しました。

hello.hh
<?hh
echo "hellow hack\n";
$ hhvm hello.hh

Fatal error: hello.hh appears to be a Hack file, but you do not appear to be running the Hack typechecker. See the documentation at http://docs.hhvm.com/hack/typechecker/setup for information on getting it running. You can also set `-d hhvm.hack.lang.look_for_typechecker=0` to disable this check (not recommended).

指定されたドキュメントを確認した所、最初に .hhconfig を作成してから実行する必要が有ると記載されていました。
そのため、 .hhconfig を空で作成して再実行します。

$ hhvm hello.hh
hellow hack

無事に実行できました。
これで環境が整ったので今後も時間をみつけてHHVMとHackを触ってみようと思います。

最後まで読んで頂きありがとうございました。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1