Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Facebook 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.



Hack 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.


I'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?


Unfortunately the only way to get type errors statically right now is to run `hh_client` at the command line (see http://docs.hhvm.com/manual/en/install.hack.bootstrapping.ph...) -- this is what vim-hack will do for you. HHVM will only report type errors that it can see at runtime, which won't catch the edge cases or error cases you didn't think to test, which kind of defeats the purpose of having the static type system. For a really simple integration, you can do `watch hh_client` in a second window, which will run the checker every 3 seconds, configurable, see `man watch`.

This separation is different than many other languages, and lots of folks have found it confusing. It largely exists for technical reasons, and we should be able to have a better UX for end users; this is something I've been thinking a lot about and want to try to improve in the language going forward. (I work full-time on the Hack team.) Please do give it a shot and let us know how it goes!


Funny, I was in the IRC channel this evening having a chat to Simon and managed to work all this out! I'm actually quite excited by it, I think the type checking that's available + unit testing will catch most of the edge cases I was looking to catch, although that "doesn't check global scope" threw me for a bit when getting it all up and running!

I'm really interested to see what you end up coming up with UX wise. What sort of edge cases do you think the `hh_*` apps will miss? Running `hh_client` on save isn't a bad thing, IMO, and having it output JSON for easy integration is amazing :) But I'm curious what the type checker will miss currently?

Is there a public mailing list where these sorts of discussions happen or is it more internal to Facebook? I'm really interested in Hack (as is where I work, we push PHP to it's limits so we're keen to use something that can catch even more bugs from day 0) so thanks very much for pushing PHP even further forward!

Are the technical reasons for missing type errors that wouldn't be triggered at run-time insurmountable? Or is it more a "finding the right UX to expose it"?


It's not that the tyepchecker will miss things, it's that, for folks coming from other languages, it's not clear that there even exists a separate typechecker you have to run!

There isn't a mailing list right now. A few discussions are just in-person since we sit next to each other, but we're trying to make things as transparent as we can. Lots of stuff (and hopefully more moving forward) happen on #hhvm on Freenode or on GitHub issues -- basically the same channels as the HHVM project itself. There is also nontrivial discussion during code review, which is very unfortunately all internal right now; we hope to have that all moved external as soon as we can. (There are a lot of tricky integrations with internal tools that need to happen for that to work.)


Statically 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.


> 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.


Hack 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!


Well 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).


HHVM 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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: