amuck-landowner

Hack

MannDude

Just a dude
vpsBoard Founder
Moderator
What does it do that other languages can not do, or rather, what does it do better than other languages?
 

devonblzx

New Member
Verified Provider
This appears to be part of Facebook's PHP enhancements with HHVM.  Looks interesting.  <goes to read some more>

After going through the tutorial, I like some things and can definitely see them getting merged into PHP in the future.  The type enforcement features would ensure better code and the Vectors may be useful for some.

Looks to be mostly compatible with PHP as is, you can take advantage of the Hack features if you open your code with <?hh instead of <?php (when using HHVM).

PHP has started to address type enforcement with type casting but nowhere near the extent of Hack, especially with return values.  PHP has always been pretty loose on variable types.
 
Last edited by a moderator:

devonblzx

New Member
Verified Provider
Just downloaded PHPStorm EAP, still no Hack support, so that's a disappointment.  It looks like Facebook is releasing their own IDE soon named Nuclide.

Guess I'll hold off on diving in until one of these is available.
 

splitice

Just a little bit crazy...
Verified Provider
Peronally I like hack, good PHP code has been enforcing documented types (i.e PHPDoc) for a while now. PHPStorm then does a great job infering for code completion. I imagine they will do an even better job with Hack. This and the features of Hack make will make it very popular in my opinion, however until PHPStorm (or a comparable IDE) supports it its a solid non-start in my books.
 

devonblzx

New Member
Verified Provider
After I originally posted, I saw that Hack also includes async support.  I haven't tested it yet, but that is a major change from PHP, I could see that as being very useful in the future assuming it works well (it looks like they just implemented it in 3.5).

As some may know, PHP is a synchronous language, each line of code is executed and it waits to finish execution before moving on to the next line.  This makes it simple to use, but somewhat inefficient if you have something like a remote CURL request, SSH/FTP login, or a long database transaction.  PHP could be doing other things while it waits for a response. 

So from my understanding, you use the async keyword on the function, run it, perform other code, then when you get to the point when you need the response from the async function, you can use await.
 
Last edited by a moderator:
Top
amuck-landowner