r/PHP • u/fred_emmott • Sep 18 '17
The Future of HHVM
http://hhvm.com/blog/2017/09/18/the-future-of-hhvm.html22
u/SaraMG Sep 18 '17
As a PHP Release Manager, I endorse the dropping of PHP 5 support. :)
14
Sep 18 '17
PR spin aside, by "dropping PHP 5 support" they basically mean "dropping PHP support", as references and destructors are not PHP 5 legacy features. They're very much core PHP features.
Cheering for HHVM to no longer align with PHP is cheering for a Zend Engine with no competition. We know what happens when Zend Engine has no competition. Stagnation, lack of meaningful innovation, and excessive bikeshedding.
9
u/fred_emmott Sep 18 '17
We'll be dropping destructors from Hack soon - references have always been banned in Hack, we're just planning to create an alternative.
Both will continue to work with PHP code on HHVM until we're at a point where "pure Hack" projects are practical
4
Sep 18 '17
I'm going to ask you the same question I asked /u/SaraMG - if you could go back would you reinvent PHP at all if the end game would be just an incompatible fork that's mostly specific to Facebook? Why not use Flow + JS?
6
u/headzoo Sep 19 '17
Why not use Flow + JS?
Some of you have lost your damn minds.
-3
Sep 19 '17
I'm proposing it as a replacement for PHP/HHVM, which isn't the entire Facebook, genius. It's just some of the server-side front-end logic. A lot of the back-end services at Facebook are C, C++, Haskell, Erlang (well, used to be), Java and so on.
5
u/headzoo Sep 19 '17
which isn't the entire Facebook
Wow, I had no idea! /s
A lot of the back-end services at Facebook are C, C++, Haskell, Erlang (well, used to be), Java and so on.
I don't see JS in that list, and I'm sure there's a good reason for that.
2
Sep 19 '17
Wow, I had no idea! /s
I can't decide which is more pathetic:
That you didn't have an idea, and that's why interpreted that I propose JS for the entire Facebook (which I haven't), or...
That you did have an idea, and you came here to just spew bullshit.
Hmm, maybe I can decide, actually.
I don't see JS in that list, and I'm sure there's a good reason for that.
The reason is they have 1M+ lines of Hack/PHP code laying around. They claim they also prefer a script language for front-end concerns as it's more flexible (hence JS would fit the bill, where C++/Java/etc, wouldn't).
I appreciate your gargantuan efforts to appear smart and snarky, but you need to first inform yourself of the context of the conversation, before you can seem witty, and not just inept.
4
u/headzoo Sep 19 '17
entire Facebook
I didn't say the entire Facebook. You did, and you're being pedantic. This is why I avoid getting involved in programming discussions on reddit, but sometimes someone says something so stupid that I have to chime in.
hence JS would fit the bill
You're moving the goalposts, since we're clearly not talking about the front-end. The "context of the conversation" as you put it, is about replacing PHP.
inept
Says the guy who doesn't understand the differences between front-end and back-end.
2
Sep 19 '17
I didn't say the entire Facebook. You did, and you're being pedantic.
You said "using JS at the core of a codebase as large and complex as Facebook's". HHVM is not at the "core" of Facebook, and isn't the most complex part of Facebook, which is in the backend services written in C++, Java, Haskell. So as a replacement for HHVM, JS also wouldn't be "at the core of a codebase as large and complex as Facebook's".
You're moving the goalposts, since we're clearly not talking about the front-end. The "context of the conversation" as you put it, is about replacing PHP.
Facebook calls PHP their "front-end" language:
"Front-end" doesn't mean "client-side", unlike what you've read on a blog somewhere.
Says the guy who doesn't understand the differences between front-end and back-end.
Oh, the irony. So thick, I can cut it with a knife.
→ More replies (0)1
u/methylenegaming Sep 19 '17
I would bet it has something to do with this announcement a couple of months ago tbh https://www.youtube.com/watch?v=AGkSHE15BSs
2
Sep 19 '17
They could've had Reflex be completely its own thing and still go for feature parity with Hack/PHP, turning HHVM into a JVM type of runtime with multiple languages. I can understand why they don't care - there's nothing in it for them to make it so. But it's a shame for the wasted effort.
BTW, Reflex sounds like something with narrow appeal. I've seen such "reactive programming" efforts a lot and they never go anywhere. Whether we like it or not, nothing beats the raw flexibility and performance of imperative code...
3
u/methylenegaming Sep 19 '17
wasted effort is subjective to a trillion dollar company, At the time PHP was too slow and they saved more than enough in server costs probably to offset the cost of developing HHVM/hack
1
Sep 19 '17
They would've saved a lot more by using one of the PHP compilers targeting JVM, as one example. I think a lot of this was they wanted to dabble in NIH practices, and their money allowed them to. It's fair, I guess. I maybe also would write my own language in that situation, although it'd be absolutely pointless.
1
u/methylenegaming Sep 19 '17
well you surely know how hack/hhvm came about? why target JVM when you can just Target C++?? and when you have a PHP to C++ compiler why allow the shittiness of php? so then you pretty up terrible practices in PHP to make them "better" and you just made HHVM and Hack
0
Sep 19 '17
well you surely know how hack/hhvm came about? why target JVM when you can just Target C++??
Well to anyone with a bit more experience it was immediately obvious that trying to compile statically a heavily dynamic script would result in very modest boost compared to a C/C++ interpreter (which is what PHP is now).
Which is why they quickly abandoned their "compiles to C++" solution and wrote HHVM, which is a more traditional language runtime. Unfortunately it takes a lot of time and a lot of smarts to make a fast, optimizing VM, so HHVM is actually a quite poor effort compared to something like the JVM or .NET (Mono) or what have you.
So instead of reinventing a PHP compiler and then reinventing a script runtime, they really could've just compiled to an existing one, like JVM, with much better results. Going "raw" with C++ compilation (or similar) only makes sense if your language is already static - no gradual/optional typing. PHP is anything but, and Hack is also anything but.
12
u/the_alias_of_andrea Sep 19 '17
PHP has had no notable competition in terms of implementations for most of its existence, yet succsssive releases have made huge improvements (2 to 3, 3 to 4, 4 to 5, the 5.x series). HHVM probably helped but PHP shouldn't stagnate without it.
6
u/Tyra3l Sep 19 '17 edited Sep 19 '17
I think having a competitor helps to counter balance the "we are a mature language, this new feature has no place in the language otherwise we would already have it", but having competent people and especially more people to review ZE specific changes matters a lot more.
1
u/SaraMG Sep 18 '17
nit; AIUI, that's part of the longer-term departure from PHP7 support.
I could be wrong though.
2
Sep 18 '17
I have a question. If Facebook could start over, wouldn't you say they'd have benefited much more by moving their code (gradually) to Node with Flow (where basically Flow:Hack = JS:PHP), instead of literally reinventing PHP with a custom runtime, type-system etc.?
12
u/SaraMG Sep 18 '17
Given that Facebook is older than Node, I'm going to presume you mean "If FB could start over today...". I doubt very much FB would jump straight into developing their own runtime today for a number of factors:
PHP 7's speed is roughly apace with HHVM, so the perf question (sort of) vanishes.
PHP 7's AST makes replacing the front-end compiler to gain HackLang features (relatively) simple (compared to a full rewrite).
LLVM is far more stable and mature than it was at the time, so there's also less need to write a custom JIT.
As to the theory of moving a very large codebase from one language to another, that always sounds simple in theory, but that also means a helluva lotta decoupling and rearchitecting along the way.
7
u/the_alias_of_andrea Sep 18 '17
RIP PHP 5. It brought PHP kicking and screaming into the early 1990s.
10
u/SaraMG Sep 19 '17
into the early 1990s.
Uh, PHP was born in the mid-90s
About the same time as you, I'll wager. ;)
4
1
9
u/MorrisonLevi Sep 18 '17 edited Sep 18 '17
The HHVM team believes that we have a clear path toward making Hack a fantastic language for web development, untethered from its PHP origins.
Good luck, and I mean that seriously. PHP is some really awful baggage for language design. May I make a few suggestions on things to change?
Unify symbol tables and allow referring to functions and classes by symbol. The fact that we have to use strings for these is a serious refactoring and code analysis pain.
Unify case sensitivity. I'd prefer case sensitive but entirely case-insensitive would be great too.
Unify behavior with regards to undefined constants, functions and class-likes.
Once the above points are done you can now do general symbol autoloading instead of autoloading for only classes, interfaces and traits.
These things would make me significantly happier with PHP, anyway. That plus generics, which Hack already has.
11
u/fred_emmott Sep 18 '17
Unify symbol tables and allow referring to functions and classes by symbol. The fact that we have to use strings for these is a serious refactoring and code analysis pain.
Array and string callables are banned in Hack; the fact that class_meth(), inst_meth(), fun() etc are backed by them is considered an unsupported implementation detail, and likely to change.
Unify case sensitivity. I'd prefer case sensitive but entirely case-insensitive would be great too.
Hack is fully case sensitive
Unify behavior with regards to undefined constants, functions and class-likes.
Banned in Hack.
Once the above points are done you can now do general symbol autoloading instead of autoloading for only classes, interfaces and traits.
https://docs.hhvm.com/hack/reference/function/HH.autoload_set_paths/ - made convenient with https://github.com/hhvm/hhvm-autoload (composer plugin)
Some of these 'banned' behaviors are still implemented in the runtime, so they'll show up on 3v4l; however, they'll fail in the typechecker, and in the default HHVM configuration: HHVM usually won't execute Hack code that the typechecker says is bad, however 3v4l explicitly allows it.
4
u/fred_emmott Sep 18 '17
Sorry, I missed a few things; we don't really have 'referring to functions by symbol', however the
fun()construct returns an appropriately typed callable (with parameter/return types).Classes by symbol: Foo::class is a subtype of string, a classname<Foo>: https://docs.hhvm.com/hack/types/type-system#type-aliases__classname
5
u/MorrisonLevi Sep 18 '17
To clarify, though: the tables aren't unified, correct? You can have
fooas a constant, function and class all simultaneously?2
u/fred_emmott Sep 18 '17
Sorry, yes, that's correct - so our autoloader interface supports providing separate maps for each symbol table, and/or a failure handler that gets passed 'type', 'function', or 'constant' in addition to the name, allowing you to implement PSR0/PSR4 or similar.
1
u/fred_emmott Sep 20 '17 edited Sep 20 '17
You might also be interested in
use namespace Foo\Bar;anduse type Foo\Bar;, effectively splittinguse Foo\Bar;in two. I've been meaning to write this up as an RFC at some point, but haven't had the time.
we went for
use typeinstead ofuse classbecause we have additional forms of types: enums and type aliases; I would suggest the same for PHP for clarity in case additional types get added in the futureWe added this because we added
vec,dict, andkeysetvalue types, and wanted the library to be in similarly named namespaces:use namespace HH\Lib\{C, Dict, Str, Vec};and$foo = Vec\map($bar, $x ==> do_stuff($x);)for example. as the runtime is still case insensitive for PHP compatibility, this wasn't possible with the standarduseconstruct - and we feel that being specific about exactly what you're importing is an improvement anyway, and more consistent withuse functionanduse const7
28
u/the_alias_of_andrea Sep 18 '17
Reposting my HN comment since I saw this there first:
Given HHVM is already being dropped from PHP packages because of its lagging compatibility, announcing that they're not targeting PHP compatibility any more might be the nail in the coffin for HHVM (and thus Hack) as a viable “upgrade” from PHP for existing codebases.
I mean, it's great that Hack will work for new Hack code and existing Hack codebases, but there aren't a lot of those. It makes sense for Facebook — why waste your efforts on maintaining part of your runtime that you don't need? — but I wonder if this will consign HHVM to irrelevance in the long term. Maybe Hack is a compelling platform for new code, but then, why use this obscure proprietary Facebook thing that's a bit better than PHP when you could use any of the numerous other languages out there that are also better than PHP but have much better ecosystems?
Personally this makes me sad because I wanted to see a standardised, multiple-implementation PHP language. Facebook did, even. They paid someone to write a spec: https://github.com/php/php-langspec
Maybe someone will write a new PHP implementation to take that idea forward. Or maybe we'll be stuck with Zend forever.
The future is strange.
11
u/Disgruntled__Goat Sep 18 '17
Pretty much my exact thoughts reading the article. The improvements in PHP7 are more than good enough for 99.99% of PHP users.
I wonder what Wikipedia will do? They moved to HHVM a while back. I guess they'd prefer to stick with PHP instead of Hack so presumably they'll move back to the PHP runtime?
5
u/the_alias_of_andrea Sep 18 '17
Wikimedia's sites run on MediaWiki, which is a very popular PHP application, so I'm sure they could switch back to PHP 7 and be fine. There might be custom extensions and stuff they'd have to sort out but it's surely a surmountable hurdle. And HHVM's performance lead is much smaller since PHP 7.
15
u/legoktm Sep 19 '17
All of MediaWiki and our custom PHP extensions are PHP 7 compatible already - we've never introduced any HHVM/Hack specific code since we still do use PHP 5 for some batch CLI jobs and special wikis. There's currently a discussion about where to go from here, but it likely will be moving to PHP 7 and dropping HHVM.
21
Sep 18 '17
Maybe Hack is a compelling platform for new code
Yes, let's bet the ship on an incompatible single-vendor fork of a language whose best asset is ubiquity. Very compelling. I become moist just at the thought of it.
5
u/rbmichael Sep 18 '17 edited Sep 19 '17
True, but Facebook is a pretty huge vendor. And I'm not sure proprietary is the right word. Sure, they're in control of merging commits, but that's different.
In any case I would be wary of using hhvm/hack unless you actually want to work at Facebook.
Edit: typo
1
u/methylenegaming Sep 19 '17
also if you have to consider this announcement https://www.youtube.com/watch?v=AGkSHE15BSs
2
1
10
2
u/jimbojsb Sep 18 '17
If only PHPStorm has first class Hack support
4
u/bmwparking Sep 19 '17
They don't and for a good reason: https://blog.jetbrains.com/phpstorm/2015/06/hack-language-support-in-phpstorm-postponed/
11
u/mnapoli Sep 18 '17
That's a surprising course of action, by splitting up from PHP I wonder if there's any future for Hack outside of Facebook. Or maybe that's the only way there could be?
Would be great to see that in PHP too tbh