Live data from Hacker News

Hack: a new programming language for HHVM

code.facebook.com

31–40 of 422 posts

Re: Hack: a new programming language for HHVM

#32
post #15
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.

whats the state of the type system like? Here[1] it suggests that it may have bugs, is this a 'covering backside' thing or is it currently unsound? [1] - http://hacklang.org/manual/en/hack.annotations.summary.php

Engineer working on Hack here.

It's complicated.

If you use partial mode, which doesn't enforce that every function is fully typed, then it's trivial to break the type system by just using an untyped function. In order to ease conversion, we just assume the programmer knows what they are doing with untyped functions and let anything pass.

If all of your code is in strict mode, then we believe the type system to be sound. We haven't done any formal proof of this of course, and there have been plenty of bugs in the past. But that's the goal.

Some types are enforced at runtime -- just like PHP5 enforces class type annotations on parameters. However, at least for now, the runtime doesn't do a lot of the clever things with the type system that the static typechecker does. It's much more conservative with using the type information, and doesn't do things like check generics at all. (At least right now! We probably will change this in the future.) This means that we can play a little more fast and loose with the type system in the static parts; we want it to be sound, but it doesn't have to be right now; it's not going to cause a JIT crash or anything.

There are more details on the modes here: http://hacklang.org/manual/en/hack.modes.php

Re: Hack: a new programming language for HHVM

#33
post #25
post #21

"Hack provides instantaneous type checking via a local server that watches the filesystem." What does this mean?

On Linux, we use the inotify subsystem to be informed every time you save a source file or switch branches. The hh_server process can then update its data structures immediately, without being explicitly asked.

I don't really get why this is the second paragraph on the page of a language though. It's like touting the jar command in an overview of Java.

Re: Hack: a new programming language for HHVM

#34
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.

My impression is that Facebook mostly write their stand-alone services in Java or C++, and are using PHP only where they're "stuck" with it due to a large existing code base.

Do you think Hack is a good language to start a new project in, compared to non-PHP languages? Are you using Hack for things besides the main web page?

Re: Hack: a new programming language for HHVM

#35
post #18

Naming a language hack ... very poor choice. Searching for Go, C, C++ is already bad, now you can add hack to the list.

I'm not sure what to think of the language (other than the fact that it looks very similar to Typescript); but, as for your comment, suffix the word lang and you're golden : golang, dartlang, hacklang.

Re: Hack: a new programming language for HHVM

#36
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.

Generics, lambdas, type annotations. This looks awesome, seems like the next generation for PHP programming.

Can I embed it? Or extend it via compiled binaries written in C/C++?

Re: Hack: a new programming language for HHVM

#37
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.

Thanks for taking the questions! How extensively is Facebook using Hack at this point? Is it in production? What has been the biggest learning/unlearning you've needed to do going from PHP to Hack?

100% of our web front end developers use Hack now. This has been an organic process of growth over the past year, by which I mean our engineers are using it because they like it and see value in it, not because there's someone standing over them with a big stick :-)

The biggest learning step for our engineering teams was to treat type errors from Hack as actual logic errors. We have a collection of "linters" that provide advice on code style and other nice-to-have factors. Some people (quite reasonably) initially thought of Hack errors as lint-like stuff that it was safe to ignore, when in fact they indicate real logical inconsistencies in code.

Re: Hack: a new programming language for HHVM

#39
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.

Could the same techniques you applied to PHP be applied to other dynamic languages like Ruby or Python?

Yes, definitely.

Re: Hack: a new programming language for HHVM

#40
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.

Say I'm starting out with an entirely new project and want to leave the legacy of dynamic typing behind. Is there a flag available to enforce the use of type signatures, causing Hack to throw a compilation error when they're omitted?
Post reply on HN