Hacker News new | ask | show | jobs
by jszymborski 4095 days ago
I guess the question I've been having is that if I want to begin a new project with performance as a main priority, should I use HHVM+PHP or HHVM+Hack over something like Java or Go, or is it more for making existing PHP codebases more performant.
5 comments

I'm a little surprised that HHVM would make or break anyone's decision to use PHP, since I'd think that there are more important language design concerns and features that ought to figure before it came down to that... at least in a PHP-vs-Java sort of fight, anyway. Big questions like your preferred form of typing (strong/weak, dynamic/static/Hindley-Miller inference, etc), threading, ease of writing list comprehensions, whether you need to have functions as first-class objects, et cetera et cetera. Or the ability to hire developers who use that language.
For me I guess it's choosing the right weapon for the right enemy. If my greatest priority is shipping something tomorrow, I'll choose PHP or Python because I can code that in a blink.

However, if I'm able to hang back and take some time to develop something, priorities like being able to handle X I/O writes or, as you point out, threading becomes more relevant.

Depends on what you're building, honestly.

I think that it's easy enough to get a site running entirely on PHP--well tested, well supported, architecturally sound, and rewrite services into <noninterpreted-language-of-choice> as you hit performance bottlenecks.

If performance is absolutely critical to your app, then you may consider writing everything in Java/Go/C++, but it's pretty brutal for doing templating and whatnot. Besides, once you generate the page, there's a good chance you're going to cache a good part of it anyhow!

IMHO: HHVM/Hacklang are cool and i appreciate Facebooks contributions to building a better PHP enviroment... but at the end of the day, it feels like someone trying to put a V12 engine in a golf cart. It's cool if you are already driving a golf cart, otherwise it's weird.

So if you have the chance to start fresh: choose Java or Go. Or anything else... (define "performance"?)

The development cycle with PHP/Hack is fast. You code, then press F5 in the browser and see result instantaneous. With other languages, a static compilation time of even just a few seconds is very contra productive and annoying. Writing less (redundant) code helps a lot with prototyping too (dynamic typing, optional static types). The documentation on php.net with comments on each page (from the community) is very good.

Node/IO.js and Go have their advantages, especially if one wants to use WebSocket.

Nowadays, half of the code is client side anyway (be it HTML5 JS (maybe with React/Angular) or mobile apps) - in such cases the server output and receives a lot of JSON. And then Node.js/Go/HHVM are about equal as good in benchmarks, at least in my personal benchmarks (10.000 -100.000 requests/s with Apache AB tool).

Go or Java is still faster than HHVM/PHP7. I'm writing my new project (Magento Go (wordplay) ;-) ) in GoLang.
I work with Magento a lot lately. Very interested in hearing about this!