Generated by GPT-5-mini| Hack (programming language) | |
|---|---|
| Name | Hack |
| Paradigm | Multi-paradigm: imperative, functional, object-oriented |
| Developer | Facebook, Meta Platforms |
| First appeared | 2014 |
| Typing | Gradual, static and dynamic |
| Influenced by | PHP, Haskell, ML (programming language), OCaml, TypeScript |
| License | PHP License (original), later permissive contributions |
Hack (programming language) Hack is a programming language developed by engineers at Facebook (now Meta Platforms) to evolve server-side PHP codebases with static typing and runtime performance improvements. It integrates gradually typed features and asynchronous programming constructs to support large-scale services such as those operated by Facebook, Instagram, WhatsApp, and other products within Meta Platforms. Hack was introduced alongside toolchains and runtime components to interoperate with existing PHP ecosystems and emphasize developer productivity for massive web applications.
Hack emerged from an engineering effort at Facebook to address pain points in maintaining sprawling PHP code used by services like Facebook and Messenger. The language’s development traces to projects at Facebook's engineering organization and research groups influenced by static typing work at Microsoft Research and language design in Haskell and OCaml. Hack was publicly announced around 2014 as part of a move toward stronger tooling, alongside a custom virtual machine that evolved from runtime work tied to the HipHop Virtual Machine (HHVM). Over time, Hack’s open-source releases and community engagement involved collaborations with entities familiar with large-scale software such as Apache Software Foundation projects and contributors from companies like Dropbox and Slack who maintain PHP-adjacent stacks.
Hack’s design balances familiar PHP syntax with novel constructs inspired by languages such as Haskell and TypeScript. It introduces async/await-style concurrency influenced by patterns used in C# and JavaScript engines developed by teams at Google and Mozilla. Key features include nullable types, collections, lambdas and closures, generics, and collections drawn from ideas in Java and C++. Hack also offers attributes and shape types influenced by OCaml and ML (programming language), enabling structured records and typed arrays used in web backends at scale by organizations like Twitter and LinkedIn.
Hack implements a gradual type system that allows mixing statically typed and dynamically typed code, following trends popularized by TypeScript and earlier research from Gradual typing initiatives at universities such as Brown University and University of Cambridge. Its type checker, the Hack typechecker, enforces optional static types, type aliases, and generics, and supports advanced features such as nullable types and soft typing attributes reminiscent of work at Microsoft Research. The system provides checking modes for strictness levels that mirror practices found in large engineering efforts at Google and Amazon to manage technical debt across massive repositories.
Hack programs typically run on the HipHop Virtual Machine (HHVM), a runtime originally created at Facebook to replace standard PHP interpreters for production workloads. HHVM implements a just-in-time compilation strategy similar in spirit to techniques used in the V8 engine and the HotSpot JVM from Oracle. The runtime integrates a JIT compiler, bytecode formats, and garbage collection strategies comparable to those used by PyPy and other high-performance language runtimes. HHVM and Hack are implemented in C++ and have attracted contributions from engineers experienced with large C++ codebases at institutions such as Mozilla Foundation and Google.
Tooling around Hack includes a typechecker, code formatters, linters, and language server support for editors and IDEs commonly used in industry such as Visual Studio Code, PHPStorm, and Emacs. The ecosystem interoperates with popular package managers and deployment tools analogous to Composer (software), containerization technologies like Docker, and continuous integration systems used by teams at Travis CI and GitHub Actions. Community-contributed libraries and frameworks enable integration with databases and services similar to those used by MySQL and PostgreSQL deployments, message queues akin to RabbitMQ, and caching layers like Memcached.
Hack is primarily used within Meta Platforms for backend services powering platforms including Facebook, Instagram, and internal tooling. Some external companies with large PHP heritage evaluated or adopted Hack and HHVM for performance and type-safety gains, drawing comparisons to migrations to Java or Go in other organizations. Academic and industry interest has been shown in talks at conferences such as ACM events and language engineering workshops at USENIX and OOPSLA, where Hack’s approach to gradual typing and runtime innovation has been discussed alongside systems from Google and Microsoft.
Critics note that Hack’s close coupling with HHVM and departure from standard PHP behavior introduced compatibility challenges for the broader PHP ecosystem maintained by the PHP Foundation. Migration costs, tooling fragmentation, and the learning curve for advanced type features have been cited by engineers at companies such as Shopify and WordPress-adjacent projects as barriers. Additionally, some performance comparisons with languages like Go and Rust emphasize trade-offs in concurrency models and runtime overhead, prompting debate at industry forums including Stack Overflow and conference panels at QCon.