Data / Development / Open Source

Facebook’s Golang Object Relational Mapper Moves to the Linux Foundation

8 Sep 2021 11:11am, by

Ent, the Go entity framework originally created at Facebook and open sourced in 2019, has joined the Linux Foundation. Ent helps developers work on complicated back-end applications, where they might have to deal with a large number of entity types, as well as the relationships between them.

Ariel Mashraki, Ent’s creator and lead maintainer, said that when he was on the Facebook Connectivity team, which works to bring internet connectivity to the world, the team needed an object-relational mapping (ORM) tool that could handle mapping the network topologies they were dealing with, but couldn’t find one that fit the bill, and so they created Ent. After a couple of years of being open source and seeing increased adoption and participation in the community, Facebook has decided to move the Ent project under the Linux Foundation’s governance, where it will find a vendor-neutral home for the future.

With the move to the Linux Foundation, which Mashraki said allowed him to leave Facebook to co-found data graph startup Ariga while still working on Ent, the project is looking for even more participation from other companies that wish to be involved.

Traditional ORMs map objects in object-oriented programming to databases. Ent provides this basic ORM functionality while also layering on some additional features, which is what makes it an “entity framework,” explained Mashraki. According to a blog post, Ent “uses graph concepts to model an application’s schema and employs advanced code-generation techniques to create type-safe, efficient code that greatly simplifies working with databases compared to other approaches.”

Breaking this down, Mashraki further explained that Ent was created with three specific design principles in mind. First, it uses Graph concepts, such as nodes and edges, for modeling and querying data, which means the database can be either relational or graph-based. Second, Ent’s code-generation engine analyzes the application schema and generates a type-safe, explicit API for developers to interact with the database (e.g. MySQL, PostgreSQL, or AWS Neptune). And finally, Ent expresses all logic (including authorization rules and side-effects) related to an entity in Go code, which provides Ent’s built-in support for automatically generating GraphQL, REST, or gRPC servers directly from the schema definition. All of this not only helps with handling these large datasets, but also delivers a better developer experience while doing so, said Mashraki.

“This means that, for every entity a developer defines in their Ent schema, explicit, type-safe code is generated for the developer to efficiently interact with their data. Type-safe code provides a superior development experience because IDE’s understand the API very well and can provide very accurate code-completion suggestions, in addition, with this approach many classes of errors are caught during compilation, which means faster feedback loops and higher quality software,” Mashraki wrote in an email. “In addition, network topologies are much easier to model and query in graph concepts. Trying to maintain code and queries that traverse hundreds of types of entities in relational terms was just too error-prone and slow and Ent was created directly from that pain.”

With Ent both written in Go and generating code in Go, Mashraki says that the framework has found a natural home in the cloud native community, with many Cloud Native Computing Foundation (CNCF) projects using the framework. While Go was a natural choice, Mashraki says that they are also looking at adding other languages, such as TypeScript due to its popularity with frontend developers, in the near future.

As for Go, Mashraki said of the upcoming addition of generics that the move is “going to reduce the amount of generated code and will make it possible to create generic extensions without using code generation. We’re already experimenting with it.”

Looking forward, Mashraki said that the Ent project currently has two major initiatives in the works. First, a migration API that is “designed to integrate seamlessly with cloud-native technologies such as Kubernetes and Terraform.” Next, Ent will be getting a new query engine that will allow for defining multiple storage types on the same Ent schema, which will allow developers to query SQL, blob, and document databases with the same Ent client, for example.

“We invite more companies to join this effort and be part of it,” Mashraki added.

A newsletter digest of the week’s most important stories & analyses.