Hello World in HackPublished on 07 May 2019 (Updated: 07 May 2019)
In this article, we’ll implement Hello World in Hack.
How to Implement the Solution
At long last, let’s take a stab at Hello World in Hack:
<?hh echo 'Hello, World!';
Right away, you should scream “that looks a lot like PHP!” After all, Hack is just a dialect of PHP.
That said, there is at least one obvious syntactic difference: the Hack tag. I can’t seem to figure out the formal name of the <?hh tag, so I’ve been calling it the Hack tag. At any rate, at least that’s different.
Beyond the tag, Hello World in Hack is exactly the same in Hello World in PHP. However, I will point out that you can’t mix HTML with Hack like you can with PHP, so that’s probably the biggest syntactic difference. Otherwise, both languages perform a similar function: backend web development.1
How to Run the Solution
If we want to try this code, we can use an online Hack compiler.
Alternatively, we can download the Hack Virtual Machine to run Hack code locally. From there, I recommend reading up on how to get started with Hack. Getting everything up and running is bit out of scope of this article.1
J. Grifski, “Hello World in Hack,” The Renegade Coder, 15-Apr-2018. [Online]. Available: https://therenegadecoder.com/code/hello-world-in-hack/. [Accessed: 07-May-2019]. ↩ ↩2