Facebook Open- sources Hack Codegen Library to Prevent Undesired Modifications
FREMONT, CA: In order to automatically generate Hack code, Facebook has open-sourced it’s Hack Codegen library, a library for easily generating Hack code and writing it into signed files that prevent undesired modifications. It has open-sourced it for the external community to use, reports Joab Jackson for IDG News Service.
By using the library, the user gives the needed details about the particular implementation and the software does the rest. It can generate classes, methods, variables, functions, interfaces, files and other commonly needed blocks of code.
“Being able to generate code through automated code generation allows programmers to increase the level of abstraction by making frameworks that are declarative and that are translated into high-quality Hack code. We’ve been using Hack Codegen at Facebook for a while. After seeing so much internal success, we open-sourced this library so that more people could take advantage of it,” says Alejandro Marcu, Software Engineer working on Hack, Facebook.
Frameworks are valuable in software development as they save time in developing a new application by streamlining many of the low-level implementation chores. Also, they are declarative as they allow the developer to “write what they want instead of how they want it done,” explains Marcu.
Hack is a programming language, which is developed by Facebook for its HipHop Virtual Machine (HHVM) and interoperates with PHP- an open source general-purpose scripting language, suited especially for web development. While adding many features, it resolves the fast development cycle of PHP with the discipline provided by static typing.
In addition, Hack also provides immediate type checking by incrementally checking a developer’s files as they edit. It runs in less than 200 milliseconds, making it easy for developers to integrate it into their development workflow without introducing a noticeable delay.
Facebook has developed Hack to help developers' avoid many of the pitfalls of PHP development and is useful for any developer who routinely needs to make changes across multiple parts of a code base, like creating a class, or adding a constant. “Codegen will allow you to automatically do that with one change,” adds Marcu.