Hacklang at Slack: A Better PHP
Slack moved its PHP 5 backend to HHVM in 2016 for speed and stayed for Hack, whose static type checker reports type errors as code is typed rather than at runtime. Gradual typing let the team migrate incrementally from partial to strict mode. Shapes, typed dicts with known and optional keys, are used for database rows, decoded JSON and functions with many options. Async/await with concurrent blocks adds I/O concurrency without threads, while dropping PHP compatibility in HHVM 4.0 improved the language at the cost of the Packagist ecosystem and constant upgrade work.
Related posts
- Hakana: Taking Hack Seriously
Slack Engineering mediumAdeptSlack has open-sourced Hakana, a Rust-based type checker and static analyzer for Hack, built on Psalm's design and reusing the Hack parser bundled with HHVM. Slack runs it in CI to catch unused code, impossible or redundant type checks, misuse of internal APIs, and security flaws. Security checks use interprocedural taint analysis similar to Facebook's internal Zoncolan, plus a literal-string type that blocks SQL injection at function boundaries. Plugin hooks support custom type inference and fast codebase-wide migrations, and on Slack's roughly 5 million lines it runs about 5x faster than Psalm and on par with the official Hack typechecker.
- How Two Interns Are Helping Secure Millions of Lines of Code
Slack Engineering mediumAdeptSlack added Hack support to Semgrep so its 5+ million lines of Hack could be scanned for security vulnerabilities, since no static analysis tools exist for the language. The work had two parts. First, a Tree-sitter grammar for Hack was extended incrementally, guided by error counts on internal repos, cutting unparsable lines from over 120,000 to 15 (a parse rate above 99.999%). Second, an OCaml parser maps the Tree-sitter CST onto Semgrep's language-agnostic AST, and the grammar was extended to recognize Semgrep pattern syntax such as ellipses. The resulting rules check for OWASP Top Ten issues on every pre-deploy change and in a daily full-codebase scan.
- Redesigning the HHVM JIT compiler for better performance
Meta Engineering hardMasterHHVM's JIT originally compiled tracelets, maximal type-specialized bytecode sequences formed by inspecting live VM state. Tracelets end at unknown types or branches, which causes repeated type guards, register/memory shuffling at boundaries, and blocks cross-tracelet optimizations such as loop-invariant hoisting. Facebook redesigned it as a multi-gear system: a profiling gear reuses the tracelet JIT with counters after type guards to gather block frequencies and types, and an optimizing gear recompiles hot paths as larger regions with arbitrary control flow. Getting there meant rewriting most optimization passes, which had relied on acyclic tracelets. Longer traces alone cut webserver CPU by about 5% in 2014, and the full redesign cut it by about 15%. Profiles also drive code layout, method dispatch, partial inlining, guard relaxation and array specialization.
- Meta’s Full-stack HHVM optimizations for GenAI
Meta Engineering mediumAdeptMeta moved GenAI inference traffic, which is long-running, I/O-heavy and latency-sensitive, onto a dedicated HHVM web tenant with its own runtime tuning, cutting latency by 30%. The isolated tier raises the usual 30-second request timeout and runs about 1,000 worker threads per host, sized by dividing host memory by the per-request memory limit, instead of a couple hundred. It also seeds the JIT cache with Jump-Start profiles from the main web tier and runs dummy warm-up requests to pre-fill config and service-discovery caches. Shadow traffic keeps the JIT cache covering code paths that open up later through real-time feature gating.
- Carl Sverre ruined my day. And it was glorious
Turso easyNoviceTurso used Antithesis's new property-based testing library Hegel to check that its two TypeScript drivers, the native @tursodatabase/database and the pure-JS @tursodatabase/serverless, expose the same API and return identical results. With Claude setting up the harness, the first run found a bug within minutes. Expanding the generated inputs, such as adding RETURNING statements that stress serialization, surfaced four more edge-case bugs. Treating driver equivalence as a testable property gave the team enough confidence to start recommending the serverless driver over libSQL.