2

Recently, Facebook released a new language called Hacklang, which is compiled to machine code by HHVM.

So I just wonder, is Hacklang a merely stateful language?

Thanks.

Claudiu
  • 3,261
  • 1
  • 15
  • 27
Tiep Doan
  • 105
  • 6
  • 2
    This question was closed for no good reason, it's a legit question. So I'll answer here. PHP is stateless unless you use some mechanism to store state (think memcache, sessions, database, etc), but you can't use global variables or some language-specific features to do so. Hacklang is a layer on top of PHP which adds static typing as well as a bunch of other things, but it's still a stateless language. – Claudiu Mar 28 '14 at 02:38
  • 1
    No worries. Note that the language itself doesn't compile code to machine code, HHVM (the runtime) does. And it does so for PHP as well. Hacklang is primarily the typechecker which statically checks your code for type errors, with some additions to the runtime (async functions, collections as a couple of examples) – Claudiu Mar 28 '14 at 02:47

1 Answers1

7

PHP is stateless unless you use some mechanism to store state (think memcache, sessions, database, etc), but you can't use global variables or some language-specific features to do so. Hacklang is a layer on top of PHP which adds static typing as well as a bunch of other things, but it's still stateless.

Since this is now an answer and I have more space, the lack of state is actually one of the things that PHP got right, every request starts on a clean slate which avoids a lot of bugs that appear between requests, each one of them is isolated from the rest. So Hack did well to keep that the same way. There's an extra cost associated to starting each request, but what you lose there you win back with HHVM's performance increase.

Claudiu
  • 3,261
  • 1
  • 15
  • 27