2014年11月12日星期三

Facebook Code Blog: Announcing the Hack Transpiler


On the Facebook Hack blog there's an announcement about a new tool they've created to "reverse engineer" Hack code and turn it back into normal PHP - the Hack Transpiler. There's also more information in the Facebook announcement:




Today, we're proud to announce a first, experimental release of h2tp, or the "HH (Hack) Transpiler," a tool which allows projects that have converted from PHP to Hack to still make releases that target the PHP language.



Since the launch of Hack, many community members have asked us how to manage forward compatibility. Hack is backwards-compatible with PHP - if you're running PHP on HHVM, Hack code will seamlessly integrate with it. But the inverse is not true.




The announcement talks about the things that make Hack, well, Hack and how it's not just a simple find and replace to convert it back into PHP. Their "h2tp" tool also converts things like collections and short lambda expressions back into structured PHP. To illustrate, they include some before and after code, showing the addition and substitution of PHP for the Hack shorthand operators. The post also covers some of the hurdles they faced during the implementation of the "h2tp" tool, including error handling.


Link: https://code.facebook.com/posts/398235553660954/announcing-the-hack-transpiler/

没有评论:

发表评论