Live data from Hacker News

Hack: a new programming language for HHVM

code.facebook.com

121–130 of 422 posts

Re: Hack: a new programming language for HHVM

#121
post #74

Earlier quoted context omitted.

Why use public string $x = ''; instead of public $x:string = ''; It seems inconsistent to me, probably because I've used AS3/Haxe.

Its not just inconsistent with other languages, its consistent with their own language. Property types are declared before the property name, while function return types are declared after (and with a colon). Very strange.

If you look at the original C syntax for function types, it is also a bit weird: part of the type (the return type) is placed before, and part (the parameters) after.

That syntax in hack seems more "functional" to me. That said, I must admit that I kind of like the C syntax, because of its oddity.

Re: Hack: a new programming language for HHVM

#122
post #52

I wish these extensions came by way of the PHP core rather than a language that is superimposed on PHP. However, this is awesome. Is this a layer that is superimposed on PHP that falls back to the default interpreter for unimplemented features or is this a fresh implementation. I suppose my question is, how reliable is this. Are the core PHP bugs going to manifest here? If a bug gets fixed on core PHP, will hack be l…

>I wish these extensions came by way of the PHP core rather than a language that is superimposed on PHP

Someone has to do it, and the PHP developers have proven time and again that they aren't going to. At some point the only options are to leave PHP altogether, or make your own PHP that sucks less.

Re: Hack: a new programming language for HHVM

#123

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 http://en.wikipedia.org/wiki/Worse_is_better

Re: Hack: a new programming language for HHVM

#124

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…

"I am baffled as to why you'd build your castle atop a crumbling foundation."

Congratulations for admitting your ignorance, and lending open ears to experts as to why they made certain engineering decisions.

Oh wait, you weren't doing that, you were just warming up to go on a diatribe about how stupid Facebook engineers must be.

Re: Hack: a new programming language for HHVM

#125
post #68

Earlier quoted context omitted.

Why use public string $x = ''; instead of public $x:string = ''; It seems inconsistent to me, probably because I've used AS3/Haxe.

I too programmed for a long time in AS3/Haxe, and while I prefer variable:type as I think it's more readable, most static languages (java, C#) do it the other way.

Yeah, I'm just not sure why they have public function get_name(): string but use public string $x = '';

The incosistency drives me a bit crazy.

Re: Hack: a new programming language for HHVM

#126

Looks like Facebook might have inadvertently turned PHP trendy again. Expect "Why I migrated from Go to Hack" articles soon enough. Either way, the name is very fitting. I have no use for this, but good for Facebook that they've managed to (at least to some extent) evade some of the many PHP pitfalls.

>Expect "Why I migrated from Go to Hack" articles soon enough

Why would you expect that? Obviously the bulk of people migrating to hack will be coming from PHP.

Re: Hack: a new programming language for HHVM

#127
post #62
post #50

Earlier quoted context omitted.

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?

As you note, the team developed the typechecker in OCaml, as that's what the founding engineers were familiar with. Many of ML's cousin languages happen to be well suited to this kind of work.

Have you considered using some standard library replacement like Core?

Re: Hack: a new programming language for HHVM

#128

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…

Are not coral reefs both beautiful and built upon the dead bodies of those who came before?

People also cut themselves easily with them.

Re: Hack: a new programming language for HHVM

#129
post #108

Earlier quoted context omitted.

I don't see why not. It's possible to have done it any any mainstream language.

Which mainstream language would you have chosen in 2003 that you think would have had similar success?

> Which mainstream language would you have chosen in 2003 that you think would have had similar success?

Bingo. In 2003 PHP was the best option to get from zero to hero.

Re: Hack: a new programming language for HHVM

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

Great work!

A question about the type inference mechanism: in PHP, while it is possible to define object interfaces which classes may be defined against, by the dynamic nature of the language, functions don't necessarily need that interface specification to accept an object conforming to it, explicitely or implicitely. OCaml provides something "similar" with its object system, but much more powerful with static inference of an object (super)type from its usage. will Hack be able to infer an object interface as well from its usage in a function?

Post reply on HN