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 have seen many python programmers that are PHP haters, are you one of them? just curious, no offence. I like both Python and PHP, but use PHP for commercial applications.
Hack: a new programming language for HHVM
261–270 of 422 posts
Re: Hack: a new programming language for HHVM
#262I 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…
(Disclaimer: FB employee.) Do you also argue that C++ is built on top of a crumbling foundation, because it's based on C, a ancient language with almost no type-safety?
I do not think C is a "crumbling foundation". I would not suggest that C be used for large scale engineering efforts, but it's a relatively well-defined language with semantics dictated by a formal standard. A lot of research has gone into C compilers, which are state-of-the-art.
With that said, one of the biggest complaints I hear about C++ is that it still has the legacy of C embedded in it.
Re: Hack: a new programming language for HHVM
#263Earlier quoted context omitted.
Not Bryan, but I am an engineer who works on Hack :) We don't (statically) protect against type errors when you cross from untyped into typed code. If you call an untyped function, we assume the programmer knows what they are doing -- just like PHP does. You might get a runtime exception if you are calling a method on null, for example. This is actually a pretty important part of the conversion process. You don't hav…
Oh I see, so there's no change in code generation for typed code, then?
Re: Hack: a new programming language for HHVM
#264Earlier quoted context omitted.
> Congratulations for admitting your ignorance, and lending open ears to experts as to why they made certain engineering decisions. Yes, they made certain engineering decisions now because the decisions they made back then were stupid, and they have to dig themselves out.
What was the stupid decision "made back then"? That Zuck wrote the first version of thefacebook.com in PHP, the language he was the most productive at? That the initial team didn't rewrite Facebook in Python/Perl/Ruby/Haskell during the fast growth phase? If you have ever experienced the growth phase, you understand how ludicrous the idea of rewrite would be. I've personally experienced and heard only horror stories…
Re: Hack: a new programming language for HHVM
#265Congrats to Facebook on taking PHP forward. It powers a vast amount of the web and it's great to see that it's getting some engineering love!
Re: Hack: a new programming language for HHVM
#266I'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'm a little confused as to the need for Hack unless you have a code base in PHP and need to ship tighter code (which is a problem Facebook has and my team probably has as well). Adding lambdas makes PHP more Ruby-like and generics and type checking are straight out of Java. I'm still unconvinced in how this makes programming websites more efficient or bug-free than existing languages. Can you please elaborate on tha…
Re: Hack: a new programming language for HHVM
#267Earlier quoted context omitted.
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 so…
> 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. When I look at this from the docs, it seems unsound: "Hack treats traits as a stand-alone entity during the type checking process. In other words, it ensures type consistency within the trait (i.e., as a black box…
Feel free to play around with the type system in the interactive code editor on http://hacklang.org/.
Re: Hack: a new programming language for HHVM
#268Earlier quoted context omitted.
Engineer working on Hack here. Yeah, I think Hack is a good language to start a new project in. For as much flak as PHP gets, there are actually a lot of good things about the language. The fast development cycle -- edit php script, refresh -- is something amazing that you don't get in a lot of statically typed languages, which usually have a compilation step. The crazy dynamic things you can do also occasionally hav…
>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.
Re: Hack: a new programming language for HHVM
#269Earlier quoted context omitted.
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.
TypeScript added classes, interfaces, modules, and arrow functions.
Re: Hack: a new programming language for HHVM
#270I 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…
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…