intro to hack language

15
Intro to Hack Kyle Ferguson @kylegferg docs.hhvm.com

Upload: kyle-ferguson

Post on 28-Aug-2014

996 views

Category:

Software


2 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Intro to Hack Language

Intro to Hack

Kyle Ferguson @kylegferg

docs.hhvm.com

Page 2: Intro to Hack Language

Hack

- Programming language for HHVM

- Evolved from PHP

Page 3: Intro to Hack Language

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

Page 4: Intro to Hack Language

PHP (dynamic)

- Rapid development cycle

- Easily deployed

- Highly available

Java/C++ (static)

- Disciplined

- Scales better

Goals for Hack

Page 5: Intro to Hack Language

Introducing Hack

Page 6: Intro to Hack Language

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)

Page 7: Intro to Hack Language

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

Page 8: Intro to Hack Language

Unpredictable code is DANGEROUSHack provides a *more* predictable PHP

Page 9: Intro to Hack Language

Migrating

Page 10: Intro to Hack Language

Migrating

Page 11: Intro to Hack Language

Migrating

Page 12: Intro to Hack Language

Migrating

Page 13: Intro to Hack Language

Migrating

Page 14: Intro to Hack Language

Migrating

Page 15: Intro to Hack Language

Tools / Help

Documentation docs.hhvm.com

Editor plugins: Vim, Emacs

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

Dev Environment: github.com/senary/harbor