<story><title>Hack: a new programming language for HHVM</title><url>https://code.facebook.com/posts/264544830379293/hack-a-new-programming-language-for-hhvm/</url></story><parent_chain><item><author>lectrick</author><text>Given a programming task, it will be written faster, easier, and in a more maintainable and less bug-prone fashion &lt;i&gt;if it is not PHP.&lt;/i&gt;&lt;p&gt;The opposite opinion is basically indefensible. Sure, you can still dig a trench with a spoon (and if you have enough money to wield a bunch of workers with a spoon), even if a shovel would do a better job.&lt;p&gt;Let&amp;#x27;s begin.&lt;p&gt;1) PHP autocraptastically converts strings that look like numbers, into numbers, resulting in all sorts of weirdness like this: &lt;a href=&quot;https://eval.in/111886&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;eval.in&amp;#x2F;111886&lt;/a&gt;&lt;p&gt;2) PHP 5.4&amp;#x27;s OWN TEST SUITE has 91 failures and only 70% coverage. There is NOTHING more &amp;quot;WTF&amp;quot; than that! Why even bother having a test suite?? &lt;a href=&quot;http://gcov.php.net/viewer.php?version=PHP_5_4&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;gcov.php.net&amp;#x2F;viewer.php?version=PHP_5_4&lt;/a&gt;&lt;p&gt;3) Why the fuck are all of these different things equal, and how does this NOT result in problems? &lt;a href=&quot;http://i.imgur.com/pyDTn2i.png&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;i.imgur.com&amp;#x2F;pyDTn2i.png&lt;/a&gt;&lt;p&gt;4) String increment is dumb to begin with, but why does it not even match the behavior of string decrement? &lt;a href=&quot;https://eval.in/60631&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;eval.in&amp;#x2F;60631&lt;/a&gt;&lt;p&gt;5) Why the hell can you &lt;i&gt;jump back&lt;/i&gt; into a try block from a catch block? Recipe for disaster: &lt;a href=&quot;http://phpmanualmasterpieces.tumblr.com/post/33091353115/the-documentation-clearly-says-raptors&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;phpmanualmasterpieces.tumblr.com&amp;#x2F;post&amp;#x2F;33091353115&amp;#x2F;the...&lt;/a&gt;&lt;p&gt;6) PHP comparison operators. I&amp;#x27;m sorry, but this level of complexity might make you &lt;i&gt;feel&lt;/i&gt; smart once you master all its idiotsyncrasies [sic], but it&amp;#x27;s actually &lt;i&gt;dumb&lt;/i&gt;: &lt;a href=&quot;http://stackoverflow.com/questions/15813490/php-type-juggling-and-strict-greater-lesser-than-comparisons&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;stackoverflow.com&amp;#x2F;questions&amp;#x2F;15813490&amp;#x2F;php-type-jugglin...&lt;/a&gt;&lt;p&gt;That&amp;#x27;s a &lt;i&gt;small fraction&lt;/i&gt; of not-thought-out PHP language features &lt;i&gt;that result in REAL bugs and security holes.&lt;/i&gt; Which consume large swathes of programmer time. Which, apparently, Facebook can afford to swallow.&lt;p&gt;I&amp;#x27;m sorry, but your position, as valiant as you are defending it, is literally indefensible. And I don&amp;#x27;t give a fuck how big Facebook is, they would STILL be better-served by switching SOME of their code to a different language. ANY modern programming language wouldn&amp;#x27;t suffer from this imbecilic, immature language design.</text></item><item><author>lbrandy</author><text>&amp;gt; I am baffled as to why you&amp;#x27;d build your castle atop a crumbling foundation.&lt;p&gt;Because perfect is not the enemy of the good? Because &amp;quot;build atop a crumbling foundation&amp;quot; has demonstrated time and again to be, by far, the most successful way to accomplish anything in computing? Unless you have some example of perfect, now dominant, technologies that have been created ex nihilo that I&amp;#x27;m missing? I mean we (facebook) are still using PHP and MySql, improving both. And when we need to break things out, we head into C++, the queen mother of castles on broken foundations.&lt;p&gt;&amp;gt; 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&amp;#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&amp;#x27;s a lot of stuff.&lt;p&gt;All languages, runtimes, and standard libraries (and databases, and source control, and on and on) are &amp;quot;broken&amp;quot; at sufficient scale. You&amp;#x27;re going to be spending time rebuilding things other people take for granted no matter who you are and what language and technology you are working in. The underlying assumption that a &amp;quot;proper language&amp;quot; gives you these things for free is completely false.&lt;p&gt;&amp;gt; Writing correct type checkers and inference engines is kind of difficult.&lt;p&gt;Just so we are clear, you ask why Facebook didn&amp;#x27;t rewrite 10,000 human-years of code into a mythical unnamed &amp;quot;proper&amp;quot; language, but you consider writing a type checker to be &amp;quot;difficult&amp;quot;. I think you might have vastly inaccurate pictures of what is and isn&amp;#x27;t &amp;quot;difficult&amp;quot;.&lt;p&gt;&amp;gt; That way, the compiler is now almost an engine to prove your code is correct. I don&amp;#x27;t see how the same guarantee can be made with something that is just cobbled together.&lt;p&gt;Computing history is littered with dead projects from people who believed that anything less than perfect is unworkable or non-valuable.</text></item><item><author>reikonomusha</author><text>I am baffled as to why you&amp;#x27;d build your castle atop a crumbling foundation.&lt;p&gt;I have wondered why FB didn&amp;#x27;t use a proper language with proper typing to begin with. I mean, I &amp;quot;understand&amp;quot; logistically: they already had a giant codebase in PHP, migrating a codebase is expensive, and it&amp;#x27;s difficult to hire and train 1000s of hackers in e.g., OCaml. (They &lt;i&gt;do&lt;/i&gt; have some OCaml people, but they are outliers. OCaml was my favorite thing to write there, though it didn&amp;#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.)&lt;p&gt;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&amp;#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&amp;#x27;s a lot of stuff. And in the end, it&amp;#x27;s still PHP, which is duly disliked. (Though Facebookers don&amp;#x27;t seem to care. The prevalent attitude toward it is that &amp;quot;PHP, as it&amp;#x27;s coded here, is mostly like C++, and that&amp;#x27;s OK.&amp;quot;)&lt;p&gt;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&amp;#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&amp;#x27;s standard is perhaps the most infamous; it&amp;#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&amp;#x27;t see how the same guarantee can be made with something that is just cobbled together.</text></item></parent_chain><comment><author>orblivion</author><text>You&amp;#x27;re making a mistake. The question is not whether to start a company with PHP vs language X. The company is long started. The question is not whether or not to poof into existence a port from all of FB to language X. That&amp;#x27;s not possible. The question is, given that PHP is the current language, with all its faults, will it it cost &lt;i&gt;more&lt;/i&gt; (including all definitions of cost) to make the switch? How long will it take? Does it get the job done? How bad is the damage?&lt;p&gt;The question more pertinent to your argument is, did they make a mistake years ago choosing PHP? That&amp;#x27;s when the could have conceivably gone with language X.&lt;p&gt;BTW the types of stuff you&amp;#x27;re listing are documented here. So thorough it&amp;#x27;s amusing to read: &lt;a href=&quot;http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;me.veekun.com&amp;#x2F;blog&amp;#x2F;2012&amp;#x2F;04&amp;#x2F;09&amp;#x2F;php-a-fractal-of-bad-de...&lt;/a&gt;</text></comment>
<story><title>Hack: a new programming language for HHVM</title><url>https://code.facebook.com/posts/264544830379293/hack-a-new-programming-language-for-hhvm/</url></story><parent_chain><item><author>lectrick</author><text>Given a programming task, it will be written faster, easier, and in a more maintainable and less bug-prone fashion &lt;i&gt;if it is not PHP.&lt;/i&gt;&lt;p&gt;The opposite opinion is basically indefensible. Sure, you can still dig a trench with a spoon (and if you have enough money to wield a bunch of workers with a spoon), even if a shovel would do a better job.&lt;p&gt;Let&amp;#x27;s begin.&lt;p&gt;1) PHP autocraptastically converts strings that look like numbers, into numbers, resulting in all sorts of weirdness like this: &lt;a href=&quot;https://eval.in/111886&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;eval.in&amp;#x2F;111886&lt;/a&gt;&lt;p&gt;2) PHP 5.4&amp;#x27;s OWN TEST SUITE has 91 failures and only 70% coverage. There is NOTHING more &amp;quot;WTF&amp;quot; than that! Why even bother having a test suite?? &lt;a href=&quot;http://gcov.php.net/viewer.php?version=PHP_5_4&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;gcov.php.net&amp;#x2F;viewer.php?version=PHP_5_4&lt;/a&gt;&lt;p&gt;3) Why the fuck are all of these different things equal, and how does this NOT result in problems? &lt;a href=&quot;http://i.imgur.com/pyDTn2i.png&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;i.imgur.com&amp;#x2F;pyDTn2i.png&lt;/a&gt;&lt;p&gt;4) String increment is dumb to begin with, but why does it not even match the behavior of string decrement? &lt;a href=&quot;https://eval.in/60631&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;eval.in&amp;#x2F;60631&lt;/a&gt;&lt;p&gt;5) Why the hell can you &lt;i&gt;jump back&lt;/i&gt; into a try block from a catch block? Recipe for disaster: &lt;a href=&quot;http://phpmanualmasterpieces.tumblr.com/post/33091353115/the-documentation-clearly-says-raptors&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;phpmanualmasterpieces.tumblr.com&amp;#x2F;post&amp;#x2F;33091353115&amp;#x2F;the...&lt;/a&gt;&lt;p&gt;6) PHP comparison operators. I&amp;#x27;m sorry, but this level of complexity might make you &lt;i&gt;feel&lt;/i&gt; smart once you master all its idiotsyncrasies [sic], but it&amp;#x27;s actually &lt;i&gt;dumb&lt;/i&gt;: &lt;a href=&quot;http://stackoverflow.com/questions/15813490/php-type-juggling-and-strict-greater-lesser-than-comparisons&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;stackoverflow.com&amp;#x2F;questions&amp;#x2F;15813490&amp;#x2F;php-type-jugglin...&lt;/a&gt;&lt;p&gt;That&amp;#x27;s a &lt;i&gt;small fraction&lt;/i&gt; of not-thought-out PHP language features &lt;i&gt;that result in REAL bugs and security holes.&lt;/i&gt; Which consume large swathes of programmer time. Which, apparently, Facebook can afford to swallow.&lt;p&gt;I&amp;#x27;m sorry, but your position, as valiant as you are defending it, is literally indefensible. And I don&amp;#x27;t give a fuck how big Facebook is, they would STILL be better-served by switching SOME of their code to a different language. ANY modern programming language wouldn&amp;#x27;t suffer from this imbecilic, immature language design.</text></item><item><author>lbrandy</author><text>&amp;gt; I am baffled as to why you&amp;#x27;d build your castle atop a crumbling foundation.&lt;p&gt;Because perfect is not the enemy of the good? Because &amp;quot;build atop a crumbling foundation&amp;quot; has demonstrated time and again to be, by far, the most successful way to accomplish anything in computing? Unless you have some example of perfect, now dominant, technologies that have been created ex nihilo that I&amp;#x27;m missing? I mean we (facebook) are still using PHP and MySql, improving both. And when we need to break things out, we head into C++, the queen mother of castles on broken foundations.&lt;p&gt;&amp;gt; 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&amp;#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&amp;#x27;s a lot of stuff.&lt;p&gt;All languages, runtimes, and standard libraries (and databases, and source control, and on and on) are &amp;quot;broken&amp;quot; at sufficient scale. You&amp;#x27;re going to be spending time rebuilding things other people take for granted no matter who you are and what language and technology you are working in. The underlying assumption that a &amp;quot;proper language&amp;quot; gives you these things for free is completely false.&lt;p&gt;&amp;gt; Writing correct type checkers and inference engines is kind of difficult.&lt;p&gt;Just so we are clear, you ask why Facebook didn&amp;#x27;t rewrite 10,000 human-years of code into a mythical unnamed &amp;quot;proper&amp;quot; language, but you consider writing a type checker to be &amp;quot;difficult&amp;quot;. I think you might have vastly inaccurate pictures of what is and isn&amp;#x27;t &amp;quot;difficult&amp;quot;.&lt;p&gt;&amp;gt; That way, the compiler is now almost an engine to prove your code is correct. I don&amp;#x27;t see how the same guarantee can be made with something that is just cobbled together.&lt;p&gt;Computing history is littered with dead projects from people who believed that anything less than perfect is unworkable or non-valuable.</text></item><item><author>reikonomusha</author><text>I am baffled as to why you&amp;#x27;d build your castle atop a crumbling foundation.&lt;p&gt;I have wondered why FB didn&amp;#x27;t use a proper language with proper typing to begin with. I mean, I &amp;quot;understand&amp;quot; logistically: they already had a giant codebase in PHP, migrating a codebase is expensive, and it&amp;#x27;s difficult to hire and train 1000s of hackers in e.g., OCaml. (They &lt;i&gt;do&lt;/i&gt; have some OCaml people, but they are outliers. OCaml was my favorite thing to write there, though it didn&amp;#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.)&lt;p&gt;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&amp;#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&amp;#x27;s a lot of stuff. And in the end, it&amp;#x27;s still PHP, which is duly disliked. (Though Facebookers don&amp;#x27;t seem to care. The prevalent attitude toward it is that &amp;quot;PHP, as it&amp;#x27;s coded here, is mostly like C++, and that&amp;#x27;s OK.&amp;quot;)&lt;p&gt;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&amp;#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&amp;#x27;s standard is perhaps the most infamous; it&amp;#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&amp;#x27;t see how the same guarantee can be made with something that is just cobbled together.</text></item></parent_chain><comment><author>juchem</author><text>It&amp;#x27;s interesting how most people seem to attribute the quality and longevity of a software to the language it is written in or the frameworks it uses rather than to the amount of thought that was put into its design. Sure, the former is important, but largely overrated.</text></comment>