Learn HACK with Real Code Examples
Updated Nov 20, 2025
Architecture
Runs on HHVM (HipHop Virtual Machine)
Supports both static and dynamic typing
Compiles Hack code for efficient execution
Supports asynchronous I/O
Type system integrated at runtime and compile-time
Rendering Model
Hack code executed on HHVM runtime
Static typechecking at compile time via hh_client
Dynamic execution for untyped sections
Async functions scheduled via event loop
Integration with PHP libraries where needed
Architectural Patterns
Web backend services
Async event-driven programming
Type-safe APIs
PHP-Hack mixed codebases
Large-scale modular application design
Real World Architectures
Facebook backend services
High-performance REST/GraphQL APIs
Async data processing pipelines
Large-scale web applications
PHP codebases upgraded to Hack gradually
Design Principles
Gradual typing for backward compatibility
High-performance web execution on HHVM
Async and concurrent programming support
Compatibility with PHP ecosystem
Modern language constructs for maintainable code
Scalability Guide
Use Hack collections for memory efficiency
Employ async functions for concurrent requests
Modularize code into reusable components
Leverage HHVM JIT compilation for performance
Typecheck code regularly to prevent runtime errors
Migration Guide
Gradually add type annotations to PHP code
Replace legacy PHP constructs with Hack equivalents
Adopt Hack collections for structured data
Refactor code for async/await patterns
Test with HHVM typechecker and runtime