Live data from Hacker News

Hack: a new programming language for HHVM

code.facebook.com

291–300 of 422 posts

Re: Hack: a new programming language for HHVM

#291
post #102
post #59

Earlier quoted context omitted.

As far as I can tell they are using local inference, which is basically just unification. The set of possible types seems pretty narrow[1] as well so I don't see much room to go wrong. You're right that there is a lot of mathematical theory about type systems and that inference can easily go wrong (be undecidable) but that is mostly for type systems that try to do inference for higher rank polymorphism and other thin…

Local inference isn't just unification. In particular, most local inference algorithms are designed to work with subtyping, which doesn't work in ML-like type systems.

I assume that "local inference" means, in practice, "no let-polymorphism". That's what causes most of the headaches with extensions to Hindley-Milner (including the undecidability of subtyping).

Re: Hack: a new programming language for HHVM

#292

Earlier quoted context omitted.

C, simple and predictable? You've got to be kidding me: http://lwn.net/Articles/586838/

It can definitely be simple, but if you're writing C you're compiling directly on hardware. If you change the hardware, your program will not run. That is literally the definition of unreliable.

It's not, actually. The Mars Exploration Rover won't work underwater. That doesn't mean it's unreliable.

When your compiled C program sometimes runs on x86 and sometimes doesn't, that is the definition of reliable.

Re: Hack: a new programming language for HHVM

#293
post #225

Earlier quoted context omitted.

Yes and the OP is criticizing the decisions being made now as "yak shaving." Could it perhaps be that the "yak shavers" made a conscious and well-reasoned decision to go in the direction of "extend PHP" vs "throw it all out and rewrite everything in language-of-the-month?"

I'm sure it was conscious and well-reasoned, but the OP's point still stands. Trying to build a reasonable forward-looking high-performance managed language runtime platform is hard . Trying to build it atop of PHP is harder . The only way I could see this as being a smart long-term strategy is if the eventual goal is to isolate and retire PHP projects entirely (and PHP usage itself) over time. However, even then, wi…

Maintaining your own VM is no big deal. Compared to Facebook, HHVM is a tiny codebase. A team made of relatively small number of people (high quality, but low quantity) can and do maintain VMs like HotSpot and V8. LuaJIT is maintained by a single person.

Re: Hack: a new programming language for HHVM

#294

I am baffled as to why you'd build your castle atop a crumbling foundation. I have wondered why FB didn't use a proper language with proper typing to begin with. I mean, I "understand" logistically: they already had a giant codebase in PHP, migrating a codebase is expensive, and it's difficult to hire and train 1000s of hackers in e.g., OCaml. (They do have some OCaml people, but they are outliers. OCaml was my favor…

What if you could build a castle on top of a highway?

Re: Hack: a new programming language for HHVM

#295

Earlier quoted context omitted.

Yes, but unlike Facebook, they are largely submerged in seawater.

Facebook is literally 60% water, whence they came. Pretty wild when you think about it.

That 60% figure pertains to average humans. Those skinny hipsters are mostly calcium :)

Re: Hack: a new programming language for HHVM

#296
post #87

Earlier quoted context omitted.

The HN crowd seems to dislike (or despise perhaps?) PHP, but it's really not that bad. Yes it has a lot of warts, but it has a lot of things that make it nice for web development. a) try your new code by saving in your editor, and hitting reload in your web browser. b) it's very approachable. People who only know HTML and CSS can be expected to do a little bit of PHP work to integrate their changes. If you setup the…

Has anyone tried to copy these good parts of PHP, except with a not shitty language? Is there anything about PHP, the language, that lends itself to this style of development, or could you get these same benefits with, say, Ruby or Python?

Yes, someone has indeed tried this. It's called "Hack".

Re: Hack: a new programming language for HHVM

#297
post #3

I'm the manager of the team that developed Hack, and I'm sitting here with some of the language designers. Happy to answer your questions.

Have you guys looked at the new Truffle/Graal back end in Java 8? It has seen some impressive numbers in other languages, did you explore this as a possibility?

Re: Hack: a new programming language for HHVM

#298

Earlier quoted context omitted.

>The fast development cycle -- edit php script, refresh -- is something amazing that you don't get in a lot of statically typed languages You seriously think that? That's how we do haskell web development. Both yesod and snap do this out of the box. That's how every java developer I know works.

How do you do it in java? Compile (takes time) -> hotswap (takes time), or can't hotswap since changes to signature, will need to restart server (takes lot of time).

http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin

Re: Hack: a new programming language for HHVM

#299

I am baffled as to why you'd build your castle atop a crumbling foundation. I have wondered why FB didn't use a proper language with proper typing to begin with. I mean, I "understand" logistically: they already had a giant codebase in PHP, migrating a codebase is expensive, and it's difficult to hire and train 1000s of hackers in e.g., OCaml. (They do have some OCaml people, but they are outliers. OCaml was my favor…

Because your perfect OCaml, ML, Haskell, and any other fancy, magical, fabulous, eternal, fantastical, simplest, elegant ... languages are all atop crumbling foundations implemented in ugly, stupid, out-dated, evil, chaffy ... C, C++, and assembly running on inefficient, silly and fragile digital logical CPUs.

And when Facebook uses this stupid technique to build the world's largest social network for more than one billion users, those elegant and perfect solutions are serving ... how many?

Re: Hack: a new programming language for HHVM

#300
post #276
post #239

Earlier quoted context omitted.

Is there a statically typed variant of Python that would work with existing web servers, etc..? I am aware that there's Cython and I know that py3k technically permits type annotations (which Jetbrain's Python IDE uses quite effectively), but that isn't true static type checking in the same way as Hack does this.

Statically-typed Python would ruin a great number of Python libraries you'd probably want to be using. It'd be a very different language. Once you have type annotations, it wouldn't be too much of a stretch to enforce them statically with a separate tool. You could even go as far as rejecting first-party code if you can't statically determine every single value's type. Pylint's underlying astroid library has a bunch…

Such a tool would be no less difficult to build than hack itself, though. Hack's "gradual typing" solves the problem of re-using existing code that you've mentioned.

FB already had a PyLint-like tool earlier that could do some static analysis, namely pfff (also open source and written in OCaml), but it did not provide a full-on static type system like Hack. (Background: I used pfff when I was in bootcamp at FB itself. This was however prior to hack, I worked solely on C++, Java, and a bit of Python at FB after bootcamp).

I am sure if FB started off with Python, a similar solution could have been found, but if you're looking for a tool that exists _right_ now, Hack is actually quite decent.

Creating a static type system, implement local type inference, as well as working out "gradual typing" and associated problems (all while being able to do type-checking at speeds developer _expect_) is not a trivial problem.

Post reply on HN