Is there a good reason to still use php when you can use hacklang (https://hacklang.org/) which has much stronger type system. Some would even call it php++.
A lot of what Hack introduced to the PHP community has become available in suitably forward-thinking ways to allow for a sensible amount of backwards compatibility and are opt-in.
For example, you can set strict typing on a per-file basis.
`declare(strict_types=1);`
I believe that the performance difference between the two is negligible now too. So it really just comes down to personal preference/platform legacy.
But Hack is on a different path which is potentially going to make it harder to share code between PHP and Hack.
the only thing that sucks about strict typing is that there's no way to toggle it globally. so if you want to transition a codebase that's simultaneously actively being developed in other ways, you have to mess around with scripts that append it to the start of all php files/remove it again
Hack isn’t still commonly used outside of FB, and for the right reasons - the PHP community is much bigger. Very few projects test for Hack compatibility, and the performance gains aren’t worth it these days (they were 5 years ago, but not so much these days)
Having "much stronger" type system cannot be anyone's definitive reason for deciding to go with Hacklang instead of PHP.
Type system doesn't guarantee that the programmer will utilize it properly, produce optimal code or even figure out the problem that is being solved by writing an algorithm.
You also need to pay attention to the ecosystem, problems that come with HHVM, the fact you're undoubtedly tying yourself with Facebook and what you're gaining / losing with the decision to go with a fork of PHP.
Hacklang diverged from PHP proper a while ago, but I haven't validated what this actually means. I know interoperability wasn't guaranteed, but with Hack at your work are you able to use composer packages - i.e. Symfony components? The ecosystem around pure Hack packages or frameworks appears quite small/niche.
simonhamp|5 years ago
For example, you can set strict typing on a per-file basis.
`declare(strict_types=1);`
I believe that the performance difference between the two is negligible now too. So it really just comes down to personal preference/platform legacy.
But Hack is on a different path which is potentially going to make it harder to share code between PHP and Hack.
PHP still has by far the larger community.
Given the choice today, I’d run with PHP.
asddubs|5 years ago
captn3m0|5 years ago
fraktl|5 years ago
Type system doesn't guarantee that the programmer will utilize it properly, produce optimal code or even figure out the problem that is being solved by writing an algorithm.
You also need to pay attention to the ecosystem, problems that come with HHVM, the fact you're undoubtedly tying yourself with Facebook and what you're gaining / losing with the decision to go with a fork of PHP.
Shish2k|5 years ago
(Sad because I use Hack in my day job and PHP for my open source projects, and find Hack way more pleasant and productive)
thepratt|5 years ago