-2

Does anyone know the file extension for Hack? I've looked pretty much everywhere, and can't seem to find it. Thanks

William Lee
  • 93
  • 1
  • 10

4 Answers4

2

HHVM supports 4 file extension for hack .hh, .hck and .hack.

starting from hhvm 4, hack now uses the .hack file extension by default which doesn't require the <?hh opening tag.

We now recommend using the .hack file extension if your editor/IDE support it; files with this extension are always strict, and do not require or allow a <?hh header line.

For example, this is a complete .hack file:

#!/usr/bin/env hhvm
<<__EntryPoint>>
function main(): noreturn {
 print("Hello, world!\n");
 exit(0);
}

example.hh / example.hck / example.php :

<?hh // strict

<<__EntryPoint>>
async function main(): Awaitable<void> {
  print 'hello, world';
}

example.hack :

<<__EntryPoint>>
async function main(): Awaitable<void> {
  print 'hello, world';
}
azjezz
  • 3,827
  • 1
  • 14
  • 35
0

I have read something about it in wikipedia: https://en.wikipedia.org/wiki/Hack_(programming_language)

and I think that you can use .php because it should be similar to php. Hope it will help you :)

0ndre_
  • 3,577
  • 6
  • 26
  • 44
0

The vim plugin for hack uses the extension .hh for hack files

vim-hack github

alexriedl
  • 5,916
  • 3
  • 21
  • 17
-1

Hack was created by Facebook as a dialect of PHP. They use .php files for their projects write in hack.

** -- UPDATE 2020 -- ** Today on their hite Hack recomendo use .hack as extension https://docs.hhvm.com/hack/getting-started/tools

vscode Hack languae extension continue to use .php as extension on their examples https://marketplace.visualstudio.com/items?itemName=pranayagarwal.vscode-hack

chefjuanpi
  • 1,570
  • 15
  • 27