Does anyone know the file extension for Hack? I've looked pretty much everywhere, and can't seem to find it. Thanks
-
Did you do a google search? – Sam Orozco Sep 28 '16 at 19:41
-
@SamOrozco I did, still didn't find an answer – William Lee Sep 29 '16 at 18:29
-
The accepted answer was the first result on google. William Lee.. – Sam Orozco Sep 29 '16 at 19:01
-
@SamOrozco Do realise that the accepted answer says "I think". The Wikipedia article did not explicitly say that the extension is `.php`. – William Lee Sep 29 '16 at 19:05
4 Answers
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';
}

- 3,827
- 1
- 14
- 35
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 :)

- 3,577
- 6
- 26
- 44
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

- 1,570
- 15
- 27