TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Hack: a new programming language for HHVM

576 点作者 bos大约 11 年前

47 条评论

reikonomusha大约 11 年前
I am baffled as to why you&#x27;d build your castle atop a crumbling foundation.<p>I have wondered why FB didn&#x27;t use a proper language with proper typing to begin with. I mean, I &quot;understand&quot; logistically: they already had a giant codebase in PHP, migrating a codebase is expensive, and it&#x27;s difficult to hire and train 1000s of hackers in e.g., OCaml. (They <i>do</i> have some OCaml people, but they are outliers. OCaml was my favorite thing to write there, though it didn&#x27;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.)<p>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&#x27;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&#x27;s a lot of stuff. And in the end, it&#x27;s still PHP, which is duly disliked. (Though Facebookers don&#x27;t seem to care. The prevalent attitude toward it is that &quot;PHP, as it&#x27;s coded here, is mostly like C++, and that&#x27;s OK.&quot;)<p>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&#x27;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&#x27;s standard is perhaps the most infamous; it&#x27;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&#x27;t see how the same guarantee can be made with something that is just cobbled together.
评论 #7436950 未加载
评论 #7436967 未加载
评论 #7436898 未加载
评论 #7437026 未加载
评论 #7437211 未加载
评论 #7436961 未加载
评论 #7437076 未加载
评论 #7437012 未加载
评论 #7438792 未加载
评论 #7437832 未加载
评论 #7436920 未加载
评论 #7437210 未加载
评论 #7437079 未加载
评论 #7436778 未加载
评论 #7438723 未加载
评论 #7439383 未加载
评论 #7441408 未加载
评论 #7441923 未加载
评论 #7437502 未加载
评论 #7440811 未加载
评论 #7437769 未加载
评论 #7440298 未加载
评论 #7440531 未加载
评论 #7440160 未加载
bos大约 11 年前
I&#x27;m the manager of the team that developed Hack, and I&#x27;m sitting here with some of the language designers. Happy to answer your questions.
评论 #7436719 未加载
评论 #7436667 未加载
评论 #7436557 未加载
评论 #7436654 未加载
评论 #7436577 未加载
评论 #7436615 未加载
评论 #7437278 未加载
评论 #7436912 未加载
评论 #7436890 未加载
评论 #7436705 未加载
评论 #7436803 未加载
评论 #7438161 未加载
评论 #7436627 未加载
评论 #7437542 未加载
评论 #7436659 未加载
评论 #7436750 未加载
评论 #7439973 未加载
评论 #7436567 未加载
评论 #7436831 未加载
评论 #7436776 未加载
评论 #7438241 未加载
评论 #7440609 未加载
评论 #7436594 未加载
评论 #7436664 未加载
评论 #7440236 未加载
评论 #7436606 未加载
评论 #7436548 未加载
评论 #7436571 未加载
评论 #7436512 未加载
jlebar大约 11 年前
So argue. Much armchair quarterback. Very flame. Wow.<p>It&#x27;s entirely appropriate and reasonable to say &quot;I don&#x27;t understand why Facebook would do this; please explain it to me.&quot; But it reflects a supreme lack of humility to say &quot;I don&#x27;t understand why Facebook would do this; they must be idiots, and when they, armed with inside information I don&#x27;t even know I don&#x27;t have, come to defend themselves, I will angrily try to convince them of the error of their ways.&quot;<p>If you think what Facebook has done here is stupid, why is that something to get upset over? In fact, why is it even something worth arguing about? You&#x27;re not going to convince anyone who matters, and anyway you have nothing to gain by doing so: Instead, just short Facebook stock and be smug in the knowledge that, when Facebook announces next year that they&#x27;re abandoning PHP in favor of a ménage à trois of OCaml, F#, and Clojure, you&#x27;ll be able to say &quot;I told you so&quot;.
评论 #7442661 未加载
habosa大约 11 年前
Facebook is always pushing PHP to new places. Would it be too broad to say PHP is the worst thing that ever happened to Facebook&#x27;s engineering but Facebook&#x27;s engineering is the best thing that ever happened to PHP?
评论 #7436566 未加载
评论 #7436633 未加载
jtreminio大约 11 年前
If you want to try out Hack (and HHVM) quickly, my FOSS project lets you quickly set up a VM using Vagrant and Puppet: <a href="https://puphpet.com" rel="nofollow">https:&#x2F;&#x2F;puphpet.com</a>
评论 #7437194 未加载
georgebarnett大约 11 年前
My favourite comments are the ones where some random geeks tell the guys who have built a multi-billion dollar business with hundreds of millions of daily active users how they&#x27;re doing it wrong.<p>Congrats to Facebook on taking PHP forward. It powers a vast amount of the web and it&#x27;s great to see that it&#x27;s getting some engineering love!
评论 #7440981 未加载
treblig大约 11 年前
Man, it&#x27;s going to be really hard to search the Internet to troubleshoot this.<p>Search: &quot;Hack Anonymous Function&quot; Search: &quot;Hack Background Process&quot;
评论 #7437462 未加载
评论 #7438256 未加载
octo_t大约 11 年前
See this presentation[1] from Strange Loop 2013 about some design decisions on Hack.<p>[1] - <a href="https://github.com/strangeloop/StrangeLoop2013/blob/master/slides/sessions/Adams-TakingPHPSeriously.pdf" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;strangeloop&#x2F;StrangeLoop2013&#x2F;blob&#x2F;master&#x2F;s...</a>
vanilla大约 11 年前
Naming a language hack ... very poor choice. Searching for Go, C, C++ is already bad, now you can add hack to the list.
评论 #7436634 未加载
评论 #7436658 未加载
评论 #7437491 未加载
vezzy-fnord大约 11 年前
Looks like Facebook might have inadvertently turned PHP trendy again.<p>Expect &quot;Why I migrated from Go to Hack&quot; articles soon enough.<p>Either way, the name is very fitting. I have no use for this, but good for Facebook that they&#x27;ve managed to (at least to some extent) evade some of the many PHP pitfalls.
评论 #7437147 未加载
评论 #7437227 未加载
cpeterso大约 11 年前
Is Facebook&#x27;s code so monolithic that they can&#x27;t deploy new, decoupled services written in new languages? Twitter did this with Ruby, Java, and Scala. Didn&#x27;t Facebook create Thrift RFC for exactly this purpose??
评论 #7438418 未加载
rarestblog大约 11 年前
PhpStorm support issue <a href="http://youtrack.jetbrains.com/issue/WI-21737" rel="nofollow">http:&#x2F;&#x2F;youtrack.jetbrains.com&#x2F;issue&#x2F;WI-21737</a>
wes-exp大约 11 年前
Sounds like they added optional type declarations, lambda expressions, and a few more goodies to PHP.<p>I am reminded of <a href="http://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule" rel="nofollow">http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Greenspun%27s_tenth_rule</a>.<p>Facebook is now at sufficient scale where they are reimplementing Common Lisp on top of PHP.
wambotron大约 11 年前
I haven&#x27;t looked this over too much but I&#x27;m curious as to why they did this: &lt;?hh class MyClass { const int MyConst = 0; private string $x = &#x27;&#x27;; public function increment(int $x): int { $y = $x + 1; return $y; } }<p>instead of this: &lt;?hh class MyClass { const MyConst: int = 0; private $x: string = &#x27;&#x27;; public function increment(int $x): int { $y = $x + 1; return $y; } }<p>The first seems inconsistent to me. Especially coming from AS3&#x2F;Haxe where the function return value is indicated in the same manner.
评论 #7437533 未加载
评论 #7437045 未加载
fmitchell0大约 11 年前
Very excited to play with this. While I know many poo-poo PHP, it still is a pretty decent gateway language.<p>If these type of innovations introduce hobby programmers into more professional practices and concepts, I&#x27;m all for it.
评论 #7436621 未加载
bowlofpetunias大约 11 年前
Every negativity thread on PHP on HN just serves as a reminder how poorly informed and inexperienced most developers here really are.<p>Good to keep in mind the next time you read a topic on how awesome language X&#x2F;framework Y&#x2F;method Z is.<p>It&#x27;s depressing to see how much of our profession is informed by the desire to being cool and fashionable, like kids in schoolyard.
mlubin大约 11 年前
&quot;Hack provides instantaneous type checking via a local server that watches the filesystem.&quot;<p>What does this mean?
评论 #7436618 未加载
inglor大约 11 年前
Am I the only one who finds it ironic they have the old deprecated `mysql_*` API in the sample?
paulyg大约 11 年前
Are there any plans for a Hack -&gt; PHP transpiler? Or is that impossible? It would be nice to develop on Hack, transpile back to vanilla PHP where we still have to use the PHP.net runtime (shared hosts, Google app engine, Engine Yard, etc)
评论 #7438089 未加载
yulaow大约 11 年前
As said on reddit, that is really a poor choice of name. Good luck looking something related to this language on google putting &quot;hack&quot; in the searchbox... It is even worse than &quot;Go&quot;
评论 #7440810 未加载
argimenes大约 11 年前
I don&#x27;t understand why there is so much fuss about PHP in 2014. Hasn&#x27;t most serious web development moved beyond scripting languages? Java and C# have been mature languages for statically-typed web development for years and are not difficult to achieve competence in. And for more fluid yet terse server-side languages you could always go with Ruby, or Smalltalk, or Racket, or F#, and their associated frameworks. Defending PHP in 2014 is almost as surreal as defending Classic ASP in 2014.
Touche大约 11 年前
This rubs me the wrong way.<p>&gt; Thus, Hack was born. We believe that it offers the best of both dynamically typed and statically typed languages, and that it will be valuable to projects of all sizes.<p>In which way does it offer the benefits of dynamic typing? The entire point seems to be to abandon dynamic typing, which is fine, but not what that sentence says.<p>I&#x27;m guessing, for example, you can&#x27;t really do meta-programming with Hack in the way you can with dynamic languages, is that correct?
评论 #7437124 未加载
评论 #7437123 未加载
评论 #7437586 未加载
aleem大约 11 年前
I wish these extensions came by way of the PHP core rather than a language that is superimposed on PHP. However, this is awesome.<p>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 lagging behind?
评论 #7437810 未加载
评论 #7436846 未加载
评论 #7437209 未加载
cab_codespring大约 11 年前
Odd, just two days ago I was remembering a college class where we had to create a new programming language, and I named mine &quot;Hack&quot;. The cover of the paper was a copy of K&amp;R only &quot;C&quot; was replaced by &quot;Hack&quot; and of course I was the author.
mogui大约 11 年前
It seems like a strange monster with PHP body and C++ head or the other way around you choose
评论 #7437558 未加载
lukashed大约 11 年前
Off topic: Can anyone else see a trend to name projects so that they&#x27;re impossible to google? Hack, Go, Celery, Fig, Cucumber, Lettuce, you name it.<p>E.g. the only way how I could find useful resources on how to run celery with fig was to exclude -gorgonzola.
bsaul大约 11 年前
I&#x27;m really curious to know if any <i></i>new<i></i> project will start using this language. I really wouldn&#x27;t understand why they would. I think that would be an argument to explain why some consider this whole project a loss of time in the long run ( although probably something really great from a purely CS pov)<p>Edit : i just forgot that i still haven&#x27;t found any server side language i&#x27;m satisfied with. I&#x27;m still waiting for a type-annotated variant of python to catch on.... So maybe hack would be a good choice after all. It&#x27;s such a pity they started this work based on php rather than any other cleaner language.
jdp大约 11 年前
Why a brand new language, instead of building or optimizing the PHP backend for HHVM with an existing language like Haxe? <a href="http://haxe.org/" rel="nofollow">http:&#x2F;&#x2F;haxe.org&#x2F;</a>
评论 #7436604 未加载
评论 #7440671 未加载
programminggeek大约 11 年前
I&#x27;m really intrigued by the concept of array Shapes. I actually implemented that for Obvious and use it for type checking hashes in ruby with Contracts. <a href="https://github.com/RetroMocha/obvious/blob/master/lib/obvious/contract.rb#L176" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RetroMocha&#x2F;obvious&#x2F;blob&#x2F;master&#x2F;lib&#x2F;obviou...</a><p>It&#x27;s cool to see the same idea implemented in Hack. I don&#x27;t know if anyone at FB has even heard of Obvious, but it&#x27;s cool that they had the same idea in their language.
amaks大约 11 年前
Hack to PHP is as Dart to JavaScript.
kackontent大约 11 年前
This is great and exactly what I need in my PHP. Glad to see types making sort of a come back (see also: TypeScript) as I think they&#x27;re, in one way or another, necessity in a large scale applications.<p>One note though - the success of this depends on the success of HHVM. Hopefully FB guys understand that and will push even more to make HHVM the best platform to have for running PHP on.
thinkindie大约 11 年前
everyone has it&#x27;s own &lt;opinion&gt; over the fact that facebook had to use another language rather than php. On the other side there is the fact that facebook managed to get one of the most visited website on top of php, period. This is a &lt;fact&gt; and we would never know what would be facebook if it was built on top of another language. Probably they had to shut down early just because they were not able to hire enough developers to keep pace with new stuff and scale. At the same time they haven&#x27;t suffered the same amount of issues twitter had to deal with (remember the landing whale?) with much less users and traffic just because they were using RoR and that lead them to move to something completely different with scala and a different architecture. But still, facebook has about 4x times users and much more data to deal with (more text, images, video and so on).<p>Nevertheless, let&#x27;s remember that web applications are not a one-shop monolithic anymore.
himelnagrana大约 11 年前
Firstly, Awesome! Need to traverse more in it - definitely.<p>But as the documentation says primarily &quot;HHVM can run both your PHP and Hack code, either separately or when both are part of one project.&quot; -- does that means we can imagine a framework or something like that - where parts of it is in Hacklang and parts are in old PHP?<p>or such project is somewhere there already?
elwell大约 11 年前
<i>Somewhat unrelated, but curious</i>: Does anyone know if Facebook still uses MySQL heavily?
评论 #7437694 未加载
评论 #7437924 未加载
devwebee大约 11 年前
It looks promising, I highly dislike writing PHP and this seems like it might ease the pain, but they could&#x27;ve gotten rid of the damn dollar sign in front of variables, how ugly is this? &quot;return ($y) ==&gt; { return $y + 1; }&quot;
评论 #7437583 未加载
zmanian大约 11 年前
Provides some context on the language development. <a href="http://www.wired.com/wiredenterprise/2014/03/facebook-hack/" rel="nofollow">http:&#x2F;&#x2F;www.wired.com&#x2F;wiredenterprise&#x2F;2014&#x2F;03&#x2F;facebook-hack&#x2F;</a>
sesm大约 11 年前
It&#x27;s good to see gradual typing rising!<p>2 things are not obvious from the article:<p>1. Why a new language, and not just a gradual typing tool for PHP (like Typed Racket and Typed Clojure)?<p>2. Is type information somehow passed to runtime to assist JIT compilation?
dghf大约 11 年前
&quot;You have reinvented PHP better, but that&#x27;s still no justification&quot;: <a href="http://colinm.org/language_checklist.html" rel="nofollow">http:&#x2F;&#x2F;colinm.org&#x2F;language_checklist.html</a>
srg0大约 11 年前
Any¹ sufficiently advanced social network contains an ad-hoc, statically typed² implementation of half of PHP.<p>¹ YMMV ² sometimes<p>See also:<p>KPHP (subset of PHP to C++ translator, released by Vkontankte).
thatmiddleway大约 11 年前
Looks like another way to polish the PHP turd.
nness大约 11 年前
&gt; PHP only supports a 256-character set, and hence does not offer native Unicode support<p>:(<p>This was their opportunity to to get multi-byte strings right...
TazeTSchnitzel大约 11 年前
Oh great. Now when PHP expands its type annotations, they&#x27;ll be incompatible with Hack. :(
z3phyr大约 11 年前
They have best functional programming language geeks around and they made this?
评论 #7440913 未加载
评论 #7440972 未加载
msie大约 11 年前
Wanted: Backend developer. Must have 5 years of experience with Hack.
评论 #7441792 未加载
评论 #7441252 未加载
islon大约 11 年前
It seems like the name really suits the language.
elwell大约 11 年前
I thought Hack was already released months ago?
Crito大约 11 年前
Does anybody know if Hack can correctly parse integer literals, properly rejecting malformed ones?<p>PHP cannot, so I wonder how deep the relationship goes.