4 ms·
Isn't Hack the PHP of the future, aviable today? For me it seems with hack there are no excuses anymore to still use php. I'd be glad if someone tell me some do
by 1ris 12y ago
Isn't Hack the PHP of the future, aviable today? For me it seems with hack there are no excuses anymore to still use php. I'd be glad if someone tell me some downsides of hack, it seems to good to be true. And how do the JITs compare?
- MAGZine 12y agoFacebook moves fast. I'm not saying that they're going to abandon Hack or give it away to Apache or something, but if I were a corporation, sticking with vanilla PHP is attractive because it has a large developing body, and it's future isn't dependent on the whim of one company. Otherwise, yeah, Hack is an improved PHP. To be clear, it adds additional functionality to PHP, but is still entirely backwards compatible. PHP >= 5.4 still has solid bones.
- jkoudys 12y agoHack also works really nicely with PHP - I think a lot of PMs hear about hack and think it's a workalike but completely separate language, not realizing that you can (and almost always will) have hacklang running alongside php. You're capable of declaring a class in hack (with strict-typing, method return types, better collection objects than just having 'Array' everywhere), with that class directly extending a PHP class. 80% of the reason I use hacklang is just so I can extend whatever base PHP classes my CMS provides, but implement my methods without having to add the piles of manual type-checking that PHP requires.
- girvo 12y agoI've not tried this yet, though my boss has given me the go-ahead. What editor do you use to find out how it's going? I struggle a little bit with it because I'm yet to vim-hack running. Do you just stick to the "code save refresh" cycle? Does Hack give you type checking error messages in the web page? Can you run a "check types" command on code from the terminal?
- anaphor 12y agoStatically typed usually means the compiler checks types during compilation and throws away information about them after generating the target code (usually, there are exceptions like Java). So I doubt it will be able to tell you anything about types in the ouput (the web page) unless you do something with runtime contracts.
- girvo 12y agoHack doesn't get compiled, heh, it's interpreted so it's quite a bit different to what I'm used to. It's more like TypeScript in that regard, but TypeScript is still compiled... I've never used an interpreted typed language before, hence the question!
- anaphor 12y agoWell HHVM is a JIT compiler isn't it? Also it applies just as well to an intermediate representation (like bytecode, or some simpler language that gets evaluated).
- jwatzman 12y agoHHVM enforces the checks purely dynamically as it actually executes code. There's a totally separate tool that does the full static type analysis. See my sibling comment for details: https://news.ycombinator.com/item?id=7808586 https://news.ycombinator.com/item?id=7808586
- chriswarbo 12y ago> there are exceptions like Java Actually Java works in the same way; the confusion stems from imprecise use of jargon. Java tends to use the word "type" for things which would more precisely be called "tags". Tags are the run-time information which distinguish different values of the same type, and can't be erased in general. Java adds a bunch of rules about handling tags, for example object values have a "class" tag; class tags must be statically specified (AKA "type signatures"); class tags can be pattern-matched automatically (AKA dynamic dispatch, method overloading and inheritance), allowing functions to be defined in separate chunks (AKA methods); functions can only be applied to arguments which will match a pattern (AKA "type checking"), etc. These rules are checked at compile time as well as the types. Unfortunately all these different concepts tend to be grouped under the umbrella term "type checking", which makes fine-grained discussion and comparisons to other languages more difficult.
- jackbravo 12y agoHack is nice. But right now is only backed by Facebook. PHP is backed by a bigger community.
- jkoudys 12y agoHack's backed by its own open-source community too, and in its own way, is also backed by the PHP community. Laravel, symfony, cakephp, doctrine, etc. are often run on HHVM and support hacklang applications. What makes PHP better makes hack better, and hack has a growing community of developers making hack better too.
- acomjean 12y agoI guess hack is not backward compatible with some older php code. Particularly code that mingles php and html together. For a lot of us this doesn't matter (frameworks and templating engines), but a lot of tutorials mix the html and php. Most frameworks work with hack now, so your right it would be easier if there where just 1 version of "php".
- Gigablah 12y agoHack has incompatibilities with some current PHP code too. Particularly the different syntax for generators (PHP 5.5) and the upcoming syntax for variadic functions (PHP 5.6).
- jwatzman 12y agoCan you elaborate on these incompatibilities, particularly generators? I work on the project and the only generator incompatibility I know of is that what PHP5 calls "Generator" we call "Continuation", but only since we haven't gotten around to renaming ours yet :) I'm also pretty sure HHVM supports 5.6 variadic functions in PHP code, or will very soon; the Hack typechecker currently does not, but that is strictly a missing feature, and something we do want to support.
- Gigablah 12y agoThere's already open issues in GitHub regarding the differences in generator syntax -- I commented in one: https://github.com/facebook/hhvm/issues/1787 https://github.com/facebook/hhvm/issues/1787 I guess the class has been renamed in trunk, but according to this, the syntax differences still remain: https://github.com/facebook/hhvm/issues/1871 https://github.com/facebook/hhvm/issues/1871 And while we're at it, might as well point out the missing Closure::bind and Closure::bindTo from PHP 5.4: https://github.com/facebook/hhvm/issues/1203 https://github.com/facebook/hhvm/issues/1203
- anonymoushn 12y agoSure, if you only want to run code on 64-bit linux.
- chc 12y agoThat does not sound like a very burdensome limitation for serious PHP applications.
- stusmall 12y agoPHP isn't just for the big iron in the sky. I've used it for a web portal on networking equipment and it was a perfect fit.
- castis 12y agoWhatever the future is, it will most likely have ports available in most platforms.
- rafekett 12y agoyou're probably interested in the downsides of HHVM, not Hack. Hack is really just a PHP frontend built on top of HHVM. HHVM is the JIT. - it runs really well on expensive, FB hardware. there's no consideration given to anything else (performance-wise) in development. that's not to say it's slow, but it works best on 64GB servers with fat SSDs. - it's a huge moving target when it comes to php5 compatibility -- there are a few intentional inconsistencies and a lot of unintentional ones. fixes for zend incompatibilities have a whack-a-mole effect: the typical patch fixes one inconsistency and introduces a few more. - bad documentation and bad code quality - it is open-source, but only in the most superficial sense. it's really an FB internal project, so good luck making any changes that help you but don't help FB it's still better than zend PHP, and, to be fair, most of the incompatibilities are in cases where zend behaves stupidly. source: i was an HHVM contributor. (edited to space out my ascii list)
- mtanski 12y agoFrom the github page it looks like external folks are submitting pull requests. It looks like they require external people to sign the CLA, but it doesn't look like it's a case of "good luck making any changes that help you but don't help FB" per your comment.
- jkoudys 12y agoI've found the same as you - people are getting their PRs when needed. In the earlier days of the project, it may have been true that they were less accepting of any non-critical changes (as they were still getting the core together), but in my experience they're open and eager to get feedback from the public.
- rafekett 12y agomy language was too harsh. see my edit in response to ptarjan.
- ptarjan 12y agoI'm sorry to hear about your experience contributing to HHVM. Which commit(s) were you talking about? I'd rather stop doing whatever got in your way so others don't have the same experience.
- ZeroGravitas 12y agoThe problem I see is that Hack runs on HHVM rather than the standard PHP runtime, which is ubiquitous (some would argue that's its primary or only virtue). So Facebook or any other company running code on their own server can shift to HHVM with (relative) ease but open source projects (like WordPress) and libraries can only switch once everyone else switches, Which leaves us in a catch-22, so Hack remains forever in a symbiotic/parasitic relationship with PHP.