Writing code that writes code — with Facebook Hack Codegen
HACK is the Facebook's own programming language designed to build complex web sites and other software quickly and without many flaws.
Open-sourcing Hack Codegen, which automatically generates hack code, Facebook's software engineer Alejandro Marcu said in a blog post
Before Hack Codegen, Facebook engineers used concatenating strings to generate code that perform simple yet frequently executed tasks, like fetching birthday of a user.
However, the social media giant later discovered that the technique was not good enough to scale up and realized that it need a good library to generate code. This results in the birth of Hack Codegen.
Code That Writes Code
Hack Codegen simplifies code generation by helping developers create a schema, which holds code for multiple times usage, and a way to generate all the related functionality required to support that code.
The library only needs a developer to provide the required details about the particular implementation, although rest of the task is done by the software, such as generation of classes, variables, methods, functions, interfaces, files, and other standard blocks of code.
The Hack Codegen library includes:
- Hack_builder to deal with the concatenation
- New lines
- Indentation
- Braces
- Hack keywords
- Collections
- Signed files to re-generate code automatically when a schema is changed
The open-source version of Hack Codegen is available on GitHub.
No comments
Post a Comment