Live data from Hacker News

Hack: a new programming language for HHVM

code.facebook.com

41–50 of 422 posts

Re: Hack: a new programming language for HHVM

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

I like the async/await additions. Seems very similar to the .NET implementation. Was this an inspiration?

Yep, we're happy to be inspired by good ideas when they're obviously the right path to walk.

Re: Hack: a new programming language for HHVM

#42
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?

Yes, "<?hh // strict" at the top of a file will do the trick.

Re: Hack: a new programming language for HHVM

#45
post #42

Earlier quoted context omitted.

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?

Yes, "<?hh // strict" at the top of a file will do the trick.

Great! Thanks.

Re: Hack: a new programming language for HHVM

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

It looks like you've done a good job with closures, type inference, etc...

Would you consider adding even more expressive features like algebraic types or hygienic macros to the language?

Also how likely do you think it is that typical PHP will eventually be overtaken by HHVM? I'm hoping it will!

Re: Hack: a new programming language for HHVM

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

At a glance it looks like Hack is to PHP what TypeScript is to JavaScript. Is that a fair analogy?

Yes and no. Yes, because TypeScript is bringing a type-system to a dynamically typed language and so did Hack. No: because Hack is bringing some additional language features affecting the runtime. Modest changes for now, but we intend to carry on in that direction.

Re: Hack: a new programming language for HHVM

#48
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 favorite thing to write there, though it didn't afford some of the same niceties and interactivity as the PHP code they had, only because the support was down by several orders of magnitude.)

But at the same time, layering FP with a home rolled static type checking server (??) is bug prone and is certainly yak shaving (which they have time and money to do). Now they've written (1) a compiler to C++, (2) a compiler to VM byte code, (3) a corresponding runtime for each, (4) extensions to PHP, (5) a type checker, and (6) an inference engine. That's a lot of stuff. And in the end, it's still PHP, which is duly disliked. (Though Facebookers don't seem to care. The prevalent attitude toward it is that "PHP, as it's coded here, is mostly like C++, and that's OK.")

Writing correct type checkers and inference engines is kind of difficult. They seemed to take the approach of just building onto it incrementally until it just seems to work. That approach led to many bugs in many cases that just simply aren't thought of when one is trying to build inference engines by hand, as opposed according to theory. Type checking and inference is an area ripe with theory and attached formal, mathematical semantics. Standard ML's standard is perhaps the most infamous; it's a collection of mathematical statements about the language. That way, the compiler is now almost an engine to prove your code is correct. I don't see how the same guarantee can be made with something that is just cobbled together.

Re: Hack: a new programming language for HHVM

#49
post #33
post #25

Earlier quoted context omitted.

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.

Because this is tremendously important to the usability of the language.

One of the reasons that PHP has been such a success is that you can simply save a source file and reload a web page to see what's going on.

The server-based typechecker that runs instantaneously is what makes it possible for Hack to replicate this experience: you save a file and reload a web page, but you have the safety net of a typechecker that told you about your type errors as soon as you saved the file.

I can't overstate how important this instant feedback is: it's really the thing that distinguishes Hack from working in a more traditional compile-based static language.

Re: Hack: a new programming language for HHVM

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

Hi Bryan, I know most people know you from your prolific work on many great Haskell libraries ( Criterion, Attoparsec, Aeson, ...). Did Haskell have any role in the development of Hack? Looking at the code base it seems like the type system is primarily written in ML, what made the team decide to use OCaml over Haskell?
Post reply on HN