Slack launched in 2014 with a PHP 5 backend. Along with several other companies, we switched to HHVM in 2016 because it ran our PHP code faster. We stayed with HHVM because it offers an entirely new language: Hack (searchable as Hacklang). Hack makes our developers faster by improving productivity through better tooling. Hack began as a superset of PHP, retaining its best…
Overview
The article discusses Slack's migration from PHP to Hack, a language designed to enhance PHP's capabilities. It outlines the benefits of Hack, including static type checking, gradual typing, and improved productivity for developers.
What You'll Learn
How to leverage static type checking to catch bugs early
Why gradual typing can facilitate migration from PHP to Hack
How to use shapes to represent complex data structures effectively
When to implement async/await for better concurrency management
Prerequisites & Requirements
- Understanding of PHP and its limitations
- Familiarity with Hack and HHVM(optional)
Key Questions Answered
What are the benefits of migrating from PHP to Hack?
How does Hack's static type checking improve development speed?
What is the role of shapes in Hack?
How does async/await simplify concurrency in Hack?
Technologies & Tools
Key Actionable Insights
1Implement static type checking in your codebase to catch errors early.By using Hack's static type checker, you can identify type-related bugs before running your code, which saves time and resources during development.
2Adopt gradual typing to facilitate the migration process.Starting with partial mode in Hack allows you to incrementally add types to your existing PHP code, making the transition smoother and less disruptive.
3Utilize shapes for defining complex data structures.Shapes provide a clear contract for data structures, improving code readability and reducing the likelihood of errors due to typos or incorrect types.
4Leverage async/await for better performance in I/O operations.Using async/await can significantly enhance the responsiveness of your applications by allowing concurrent operations without complicating the code structure.