We use a few languages to serve client requests, but by far the biggest codebase is written in Hack, which runs inside an interpreter called HHVM that’s also used at Facebook.
> PHP makes it really easy to make a dynamically-rendered website. PHP also makes it really easy to create an utterly insecure dynamically-rendered website.
Thanks for Psalm!
Curious, if Slack was built today from ground up - what tech stack do you think should/would be used?
A slightly different question that’s a bit easier to answer: “if I could wave a magic wand and X million lines of code were instantly rewritten and all developers were instantly trained on that language”.
There the choice would be limited to languages that have similar or faster perf characteristics to Hack, without sacrificing developer productivity.
Rust is out of the question (compile times for hundreds of devs would instantly sap productivity). PHP, Ruby, Node and Python are too slow — for the moment at least.
So it would be either Hack or Go. I don’t know enough about JVM languages to know whether they would be a good fit.
Some follow-up …
A. isn’t PHP on par perf wise to Hack these days? Re: “PHP is too slow” comment.
B. have you ever looked into PHP-NGX? It’s perf looks impressive, though you lose the benefit of stateless
No. But I don't have any numbers, because it's been years since the two languages were directly comparable on anything but a teeny tiny example program.
Facebook gets big cost savings from a 1% improvement in performance, so they make sure that performance is as good as it can possibly be. They have a team of engineers working on the problem.
PHP doesn't have any engineers working on performance full-time — it's impossible for the language to compete there. Hack has also removed a bunch of PHP constructs (e.g. magic methods) that are a drain on performance, so there's no way to close the gap.
But that should in no way make you choose Hack over PHP. Apart from anything else, the delta won't matter for 99.9% of websites.
Other alternatives are Apache, Caddy, and more…
As a related thought, a lot of the modern serverless stuff feels like it's reinventing the ideas of Apache + PHP, or perhaps CGI?
Plus, it seems telling that Threads was developed in Python - not Hack.
(I’m aware IG is Python & it’s the same team)
>Slack does not share a common codebase or even runtime; services in the user-facing request path are written in Hack, Go, Java, and C++.
… but it’s probably JSON and some JSON-Schema-based “now you have two problems” junk instead of what I described. In which case, yeah, ew, gross. Unless they’ve made some unusually good choices.