intro to hack language

Post on 28-Aug-2014

984 Views

Category:

Software

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

What is Hack, why should you care, and how to get started.

TRANSCRIPT

Intro to Hack

Kyle Ferguson @kylegferg

docs.hhvm.com

Hack

- Programming language for HHVM

- Evolved from PHP

Benefits

- Created by Facebook, open source

- If you know PHP, you know Hack

- Easy to adopt (even w/ existing code base)

- Language additions (generics, collections, etc.)

PHP (dynamic)

- Rapid development cycle

- Easily deployed

- Highly available

Java/C++ (static)

- Disciplined

- Scales better

Goals for Hack

Introducing Hack

What gets “typed”

Members

Parameters

Returns

Types

Primitive: string, int, bool, array

Nullable: ?string, ?FooInterface

Classes: Validator, FooInterface

Other: mixed, void, this

Also see: closures, collections, generics, constraints

Tuples: (string, int)

Modes

Partial (default)!!- Nothing is *required* to have types defined - Allows for incremental adoption

Strict!!- EVERYTHING must be typed

Decl!!- Allows “Strict” code to work with legacy code - Always avoid this mode if possible

Unpredictable code is DANGEROUSHack provides a *more* predictable PHP

Migrating

Migrating

Migrating

Migrating

Migrating

Migrating

Tools / Help

Documentation docs.hhvm.com

Editor plugins: Vim, Emacs

Example Site: github.com/hhvm/hack-example-site

Dev Environment: github.com/senary/harbor

top related