---
title: "Hacklang at Slack: A Better PHP"
description: "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."
url: "https://swe.quest/articles/hacklang-at-slack-a-better-php-0c5b2d46ded07bab"
canonical: "https://slack.engineering/hacklang-at-slack-a-better-php/"
source: "Slack Engineering"
published: "2020-04-14"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["php","type-systems","static-analysis","refactoring","concurrency"]
---

# Hacklang at Slack: A Better PHP

A post on [Slack Engineering](https://swe.quest/sources/slack.md), published 2020-04-14, 7 min read, Case study. Original: [https://slack.engineering/hacklang-at-slack-a-better-php/](https://slack.engineering/hacklang-at-slack-a-better-php/)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PHP](https://swe.quest/tags/php.md) (Languages)
- [Type systems](https://swe.quest/tags/type-systems.md) (Compilers & runtimes)
- [Static analysis](https://swe.quest/tags/static-analysis.md) (Engineering practices)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Concurrency](https://swe.quest/tags/concurrency.md) (Compilers & runtimes)

## Prerequisites

- PHP basics ([easy posts on PHP](https://swe.quest/tags/php.md?difficulty=easy))
- static vs dynamic typing

## Keywords

Hack, HHVM, Shapes, XHP, HHAST, Hack SQL Fake, Hack JSON Schema

## Related posts

- [Hakana: Taking Hack Seriously](https://swe.quest/articles/hakana-taking-hack-seriously-564898cdb11987b5.md): Slack Engineering · 2023-02-08 · Medium · 5 min read · Static analysis, PHP, Application security, Rust, Open source
  Slack 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.
- [How Two Interns Are Helping Secure Millions of Lines of Code](https://swe.quest/articles/how-two-interns-are-helping-secure-millions-of-lines-of-code-daa936f3b67e08a6.md): Slack Engineering · 2021-11-04 · Medium · 6 min read · Static analysis, Application security, PHP, Functional programming, Open source
  Slack 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.
- [Redesigning the HHVM JIT compiler for better performance](https://swe.quest/articles/redesigning-the-hhvm-jit-compiler-for-better-performance-1f9d35b871d88d6a.md): Meta Engineering · 2016-09-22 · Hard · 7 min read · Compilers, Runtimes & VMs, PHP, Performance engineering
  HHVM's JIT originally compiled tracelets, maximal type-specialized bytecode sequences formed by inspecting live VM state.
- [Meta’s Full-stack HHVM optimizations for GenAI](https://swe.quest/articles/meta-s-full-stack-hhvm-optimizations-for-genai-8b3ab67200c60012.md): Meta Engineering · 2025-05-20 · Medium · 4 min read · Runtimes & VMs, Performance engineering, Multi-tenancy, PHP, LLMs
  Meta 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%.
- [Carl Sverre ruined my day. And it was glorious](https://swe.quest/articles/carl-sverre-ruined-my-day-and-it-was-glorious-66c73969df61e4c5.md): Turso · 2026-04-23 · Easy · 5 min read · Testing, SQLite, JavaScript, AI for coding
  Turso 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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
