Live data from Hacker News

Ask HN: State of PHP at Facebook?

news.ycombinator.com

31–40 of 88 posts

Re: Ask HN: State of PHP at Facebook?

#31

Are there any large Hack codebases I can explore? I am interested to see how different from straight PHP it is. Does anyone know if FB tracks changes to PHP so Hack is "up to date"?

Hack features have actually driven a lot of the additions into recent PHP versions. So the more relevant question might be the other way around

Re: Ask HN: State of PHP at Facebook?

#32
post #23
post #20

Migrating to Hack from PHP was huge undertaking requiring years to conclude, and that almost kept the same syntax and semantics where possible. What would the benefit of spending thousands of engineer years (read: billions of dollars) on a rewrite be? Especially when it would nearly certainly come with a huge performance regression compared to continuing to use HHVM which has come with years of optimization for worki…

Do you know if Facebook uses Composer to manage PHP dependencies?

Facebook uses a monorepo, similar to the way Google does it. Dependencies are vendored and checked into the repo. Facebook has released a tool for migrating software between repos, which is much like Google's Copybara:

Facebook's fbshipit: https://github.com/facebook/fbshipit

Google's copybara: https://github.com/google/copybara

With these tools, you can make fairly sophisticated choices about how you do vendoring. You can make the internal version look just like the public version, in terms of commit history. And you can export internal commits to public commits, stripping out confidential information along the way (or integrations with internal systems and tooling).

Re: Ask HN: State of PHP at Facebook?

#33
post #26

Ex-Facebooker here. Hack isn't going away. Ever. It's actually quite pleasant to develop in. The tooling now revolves around VS Code, which I personally don't like. I wish they'd based this on a Jetbrains core. One thing I learned to love with the Hack type system is that nullability is a distinct type (eg you can assign a T to a ?T but not a ?T to a T; ? here means "nullable"). The static type checking is smart enou…

Wow, that's almost the same thing that Typescript is to Javascript. Is all of that openly available to outsiders? If it is, I think I might to rethink my stance of php that I had for the last 15 years.

I don't know why people dislike PHP. It's a lot like React (which is so popular and beloved).

I mean, React was developed at Facebook...

Re: Ask HN: State of PHP at Facebook?

#34
post #29
post #24

Has anyone used both Hack and the modern React workflow of Typescript and a mixture of client and server-side rendering? Interested to know how they compare

I haven't seen a huge emphasis on SSI + client other than projects like Next (which is ok but kind of clunky). My experience with Hack was that it was just server-side ... is there some front-end aspect to Hack?

There is: it's called XHP (https://docs.hhvm.com/hack/XHP/introduction).

That said, I'm not sure how you'd go about server-side rendering React from Hacklang, as it seems that the open-source solution to do so is no longer supported (https://github.com/hhvm/xhp-js).

Re: Ask HN: State of PHP at Facebook?

#35
post #23

Earlier quoted context omitted.

Do you know if Facebook uses Composer to manage PHP dependencies?

Facebook uses a monorepo, similar to the way Google does it. Dependencies are vendored and checked into the repo. Facebook has released a tool for migrating software between repos, which is much like Google's Copybara: Facebook's fbshipit: https://github.com/facebook/fbshipit Google's copybara: https://github.com/google/copybara With these tools, you can make fairly sophisticated choices about how you do vendoring. Y…

Thanks for the infos!

What does "Dependencies are vendored and checked into the repo" mean?

Re: Ask HN: State of PHP at Facebook?

#36
post #26

Ex-Facebooker here. Hack isn't going away. Ever. It's actually quite pleasant to develop in. The tooling now revolves around VS Code, which I personally don't like. I wish they'd based this on a Jetbrains core. One thing I learned to love with the Hack type system is that nullability is a distinct type (eg you can assign a T to a ?T but not a ?T to a T; ? here means "nullable"). The static type checking is smart enou…

Wow, that's almost the same thing that Typescript is to Javascript. Is all of that openly available to outsiders? If it is, I think I might to rethink my stance of php that I had for the last 15 years.

All of the language features in ES6 / Flow / JSX that Facebook has been pushing through as part of the React ecosystem have been pioneered by Hack/HHVM at Facebook and then ported very closely to the JavaScript ecosystem.

Re: Ask HN: State of PHP at Facebook?

#37

Are there any large Hack codebases I can explore? I am interested to see how different from straight PHP it is. Does anyone know if FB tracks changes to PHP so Hack is "up to date"?

Not quite an answer to your question but slack engineering wrote a paper [1] on migrating their code base from PHP proper to Hack.

Specifically they used [2] 'partial mode' since "this loosens several restrictions to ease migration"

[1] https://slack.engineering/hacklang-at-slack-a-better-php/

[2] https://docs.hhvm.com/hack/source-code-fundamentals/program-...

EDIT: This would indicate that Hack may perhaps support standard PHP syntax but not the other way around.

EDIT: According to this [3] they are very compatible.

[3] https://www.oreilly.com/library/view/hack-and-hhvm/978149192...

Re: Ask HN: State of PHP at Facebook?

#38
post #23
post #20

Migrating to Hack from PHP was huge undertaking requiring years to conclude, and that almost kept the same syntax and semantics where possible. What would the benefit of spending thousands of engineer years (read: billions of dollars) on a rewrite be? Especially when it would nearly certainly come with a huge performance regression compared to continuing to use HHVM which has come with years of optimization for worki…

Do you know if Facebook uses Composer to manage PHP dependencies?

[deleted]

Re: Ask HN: State of PHP at Facebook?

#39
post #26

Ex-Facebooker here. Hack isn't going away. Ever. It's actually quite pleasant to develop in. The tooling now revolves around VS Code, which I personally don't like. I wish they'd based this on a Jetbrains core. One thing I learned to love with the Hack type system is that nullability is a distinct type (eg you can assign a T to a ?T but not a ?T to a T; ? here means "nullable"). The static type checking is smart enou…

Wow, that's almost the same thing that Typescript is to Javascript. Is all of that openly available to outsiders? If it is, I think I might to rethink my stance of php that I had for the last 15 years.

It is available. My understanding is that, unlike PHP, it really only has first-class support on Linux. You can run it on macOS, but you may have to fix some issues yourself.

I've been tempted to use it for things like static website generation, since it has the "XHP" stuff, which is like JavaScript's JSX... and I'd undoubtedly prefer writing code in Hack to writing code in JavaScript.

https://docs.hhvm.com/hack/XHP/introduction

JSX is based on XHP, of course, not the other way around.

Post reply on HN