Recently, Facebook announced their Hack Codegen library would be going open source. This is excellent news for any developers looking to get started in PHP or for those who work with it frequently.
Hack Codegen is a programming language the Facebook team created to work with their HipHop Virtual Machine (HHVM), and it’s built on PHP.
Why did the team create it?
To speed up current and future development of Facebook. Because it worked so well, they decided to open it up for everyone and make it open source.
What Is Hack Codegen?
Hack Codegen is actually two parts of a very important whole. “Hack” is the language the Facebook team created to work on their social platform, and it’s remarkably similar to PHP.
Alongside Hack, the Codegen library is essentially a framework — like Ruby on Rails — that makes the development process faster and less complicated.
Codegen simplifies working with code by allowing developers to create what are called schemas, which work like a template or a piece of code that can be called upon multiple times. In addition, Codegen can facilitate the functionality and commands that are necessary to support a particular snippet of code. This is done through a connection to the database and a data loader.
Long story short, Codegen offers a form of short-code that developers can call upon when working with the library.
Other things Hack Codegen can do include generating and handling methods, classes, functions, variables, files, interfaces and more.
The Benefits of Hack Codegen
As you’d expect, Codegen can even handle adding extra functionality to existing code without overwriting anything. Even better, when another developer or teammate comes in and changes a section of code, the software can help identify what’s been changed and ensure the original handwritten code is not replaced or wiped. This makes it easier for developers to check their work and that of teammates.
A scary number to think about is that 98 percent of applications have security holes — including web apps — that often come from changes in code or edits to existing functionality. Sure, vulnerabilities can always exist in native code segments, but constant editing can lead to even more weaknesses. Using a framework like Hack Codegen, for instance, will allow developers to better secure their apps and software through efficient monitoring.
What Does This Mean for Developers Outside of Facebook?
The Facebook team uses Hack Codegen for many things, obviously, but the most important feature is that it allows them to make routine changes — multiple times — to an existing codebase without breaking anything. Creating new classes, defining new methods or adding new constants can be done quickly and efficiently without overwriting existing code. For a platform like Facebook — which remains active even while developers are working on it behind-the-scenes — it’s incredibly important you don’t break anything.Alejandro Marcu, a software engineer at Facebook discusses why Hack Codegen going open source is so… Click To Tweet
In an email to ComputerWorld, Alejandro Marcu, a software engineer at Facebook discusses why Hack Codegen going open source is so beneficial:
“Developers outside of Facebook can use Hack Codegen tool to raise the level of abstraction in their code and build more powerful frameworks.”
He also explains the framework allows developers to “write what they want instead of how they want it done.”
Marcu elaborates further in a blog post announcing the Hack Codegen release:
“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.”
Automated code generation used to be a thing of the past, but now it’s come full circle, and rightfully so. It simplifies and streamlines the development process, and when it’s used properly, it helps make teams much more productive. Perhaps you should consider the language and framework for your next project?
Image by Pawel Kadysz
Latest posts by Kayla Matthews (see all)
- What You Need to Know About Hack Codegen - September 10, 2015
- Creating a Tech Startup? Here Are 5 Things to Consider - August 19, 2015