Facebook releases software that creates more software

The Codegen tool, released as open source, provides a way to supercharge the process of creating complex Web applications.

Facebook has released as open source a library it uses to generate code, providing a way for outside programmers to automate some of the routine work they do when creating large programs.

"Developers outside of Facebook can use this tool to raise the level of abstraction in their code and build more powerful frameworks," wrote Alejandro Marcu, a software engineer at Facebook, about CodeGen, in an e-mail.

Frameworks have been immensely valuable in software development because they save a lot of time in developing a new application by streamlining many of the low-level implementation chores. For instance, the Ruby-On-Rails framework proved to be immensely popular for quickly setting up Web applications.

Frameworks are declarative, meaning that they allow the developer to "write what they want instead of how they want it done," Marcu explained.

Codegen works with Hack, a PHP-like programming language Facebook created to expedite the development of its Web site, and subsequently released as open source for others to use.

Prior to using Codegen, Facebook engineers used a patchwork of scripts and templates to generate the bits of code that perform simple but frequently executed tasks, such as fetching a user's birthday.

This cobblework approach had some limitations though, as Marcu outlined in a blog post explaining the technology. Facebook engineers couldn't tell which parts of the resulting code relied on other parts. So, making any changes could lead to unintended consequences.

Also, this old approach wouldn't allow developers to set data types for variables, which can be handy for ensuring data integrity. Setting data types would also provide a way for code editing software to autocomplete code snippets, another time saver.

And even with the templates, they still had to write many additional components by hand, such as test code, or data loader.

The Codegen library simplifies operations by allowing a developer to create a schema, which would hold a template of code that can be used multiple times, as well as a way to generate all the related functionality needed to support that code, such as a data loader and a connection to the database.

Using the library, the user provides 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.

The software also provides a way to identify when  automatically generated code is changed later by another developer, information that can be used to alert an update process not to overwrite the hand-written code. It also provides a place within the generated code to put additional functionality where it won't get overwritten.

Outside of Facebook, the Codegen library would be useful for any developer who routinely needs to make changes across multiple parts of a code base, such as creating a creating a class, or adding a constant.

"Codegen will allow you to automatically do that with one change," Marcu wrote.

Join the Good Gear Guide newsletter!

Error: Please check your email address.

Tags Facebook

Our Back to Business guide highlights the best products for you to boost your productivity at home, on the road, at the office, or in the classroom.

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Joab Jackson

IDG News Service
Show Comments

Most Popular Reviews

Latest News Articles

Resources

PCW Evaluation Team

Azadeh Williams

HP OfficeJet Pro 8730

A smarter way to print for busy small business owners, combining speedy printing with scanning and copying, making it easier to produce high quality documents and images at a touch of a button.

Andrew Grant

HP OfficeJet Pro 8730

I've had a multifunction printer in the office going on 10 years now. It was a neat bit of kit back in the day -- print, copy, scan, fax -- when printing over WiFi felt a bit like magic. It’s seen better days though and an upgrade’s well overdue. This HP OfficeJet Pro 8730 looks like it ticks all the same boxes: print, copy, scan, and fax. (Really? Does anyone fax anything any more? I guess it's good to know the facility’s there, just in case.) Printing over WiFi is more-or- less standard these days.

Ed Dawson

HP OfficeJet Pro 8730

As a freelance writer who is always on the go, I like my technology to be both efficient and effective so I can do my job well. The HP OfficeJet Pro 8730 Inkjet Printer ticks all the boxes in terms of form factor, performance and user interface.

Michael Hargreaves

Windows 10 for Business / Dell XPS 13

I’d happily recommend this touchscreen laptop and Windows 10 as a great way to get serious work done at a desk or on the road.

Aysha Strobbe

Windows 10 / HP Spectre x360

Ultimately, I think the Windows 10 environment is excellent for me as it caters for so many different uses. The inclusion of the Xbox app is also great for when you need some downtime too!

Mark Escubio

Windows 10 / Lenovo Yoga 910

For me, the Xbox Play Anywhere is a great new feature as it allows you to play your current Xbox games with higher resolutions and better graphics without forking out extra cash for another copy. Although available titles are still scarce, but I’m sure it will grow in time.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?