Skip to content

seanpm2001/Learn-Hack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

/Hack_(programming_language)_logo.svg

Learning Hack (programming language)

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.

Hello World in Hack

This is how you make a Hello World program in Hack:

<<__EntryPoint>>
function main(): void {
  echo 'Hello, World!';
}

Comments in Hack

Comments in Hack are the same as in PHP.

Single line comments

Single line comments in Hack are written like so:

<<__EntryPoint>>
// This is a single line comment
Multi-line comments

Multi-line comments in Hack are written like so:

<<__EntryPoint>>
/* This is a
* multi-line
* comment */
/* This is 
also a
multi-line
comment
*/

Break keyword in Hack

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

Shebangs in Hack

Hack has a shebang line that differentiates it from PHP.

<<__EntryPoint>>

Functions in Hack

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.';
}

Return keyword in Hack

Returning a function in Hack is done like so

<<__EntryPoint>>
function function3(): void {
  echo 'This is a function. It will be returned.';
}
return function3();

Other knowledge of the Hack programming language

  1. Hack is a language by Facebook

  2. Hack is a semicolon and curly bracket language

  3. Hack uses the *.php file extension by default, but also uses the *.hh *.hck and *.hack file extensions

  4. Hack is a functional programming language

  5. Hack is heavily based on PHP, and works on Facebooks HipHop virtual machine

  6. Hack is not one of the top 50 programming languages (as of 2022)

  7. Hack was first created in the year 2014

  8. No other knowledge of the Hack programming language

Additional comments

  1. 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

  2. The *.hh file extension can be mistaken for a C++ program file, as they both use this extension

  3. The *.php file extension can be mistaken for a PHP program file, as they both use this extension

  4. No other additional comments available


File info

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


File history

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