I know very little about the Hack programming language. I don't intend to go far with this language. This document will go over all of my knowledge of the Hack programming language.
This is how you make a Hello World program in Hack:
<<__EntryPoint>>
function main(): void {
echo 'Hello, World!';
}
Comments in Hack are the same as in PHP.
Single line comments in Hack are written like so:
<<__EntryPoint>>
// This is a single line comment
Multi-line comments in Hack are written like so:
<<__EntryPoint>>
/* This is a
* multi-line
* comment */
/* This is
also a
multi-line
comment
*/
break;
To this day, I am still not entirely sure what the break
keyword does, but most languages support it.
I am not sure if Hack supports the break
keyword
/!\ This example has not been tested yet, and may not work
Hack has a shebang line that differentiates it from PHP.
<<__EntryPoint>>
Hack supports functions similarly to PHP. An important thing to note is that a function name has to be unique. You cannot use the same function name across multiple files in the same program.
<<__EntryPoint>>
function function2(): void {
echo 'This is a function.';
}
Returning a function in Hack is done like so
<<__EntryPoint>>
function function3(): void {
echo 'This is a function. It will be returned.';
}
return function3();
-
Hack is a language by Facebook
-
Hack is a semicolon and curly bracket language
-
Hack uses the
*.php
file extension by default, but also uses the*.hh
*.hck
and*.hack
file extensions -
Hack is a functional programming language
-
Hack is heavily based on PHP, and works on Facebooks HipHop virtual machine
-
Hack is not one of the top 50 programming languages (as of 2022)
-
Hack was first created in the year 2014
-
No other knowledge of the Hack programming language
-
I don't recognize Facebook (the company) by their 2022 name Meta/Meta platforms, as the name is too generic, and doesn't deserve to be used by them
-
The
*.hh
file extension can be mistaken for a C++ program file, as they both use this extension -
The
*.php
file extension can be mistaken for a PHP program file, as they both use this extension -
No other additional comments available
File type: Markdown document (*.md *.mkd *.mdown *.markdown)
File version: 2 (2022, Monday, August 1st at 4:35 pm PST)
Line count (including blank lines and compiler line): 190
Click/tap here to expand/collapse the history for this file
Version 1 (2022, Monday, August 1st at 4:26 pm PST)
Changes:
- Started the file
- Added the
title
section
- Added the
Hello World in Hack
section
- Added the
Comments in Hack
section
- Added the
Single line comments
subsection
- Added the
Multi-line comments
subsection
- Added the
break keyword in Hack
section
- Added the
Shebangs in Hack
section
- Added the
Functions in Hack
section
- Added the
Return Keyword in Hack
section
- Added the
other knowledge of the Hack programming language
section
- Added the
Additional comments
section
- Added the
file info
section
- Added the
file history
section
- No other changes in version 1
Version 2 (2022, Monday, August 1st at 4:35 pm PST)
Changes:
- Removed remaining references to LOLCode, which this document was based on
- Updated the
file info
section
- Updated the
file history
section
- No other changes in version 2