Skip to main content

Learn Rego by Comparison

info

Beta Content If you've found a problem with this documentation or would like to suggest improvements, please join us in the Styra Community Slack!

Writing policy that models authorization, admission control, and data filtering requirements isn't a new problem. Many readers will have implemented such policies as part of their applications — and some will have done so in dozens of languages and frameworks. The most common languages used today are general purpose. Engineers write business logic and policies in the same language, side by side, often with tight coupling between the two.

When considering a new model standardizing policy specification and evaluation across an organization, using a language written from the ground up for policy use cases can provide significant benefits. Rego, the policy language used by OPA, is designed specifically to express policy logic in a short, declarative manner — without sacrificing on performance or expressiveness.

In this section, we provide examples of policy code in different programming languages. Each example includes the same policy written in a general purpose programming language and the corresponding policy written in Rego. This is intended to help readers learn Rego more quickly by comparing it to languages they already know well.

Browse by Language

Please select a language that you know well to see how it compares with Rego. Over time we will add more languages based on your feedback — stop by the Styra Community Slack to ask for a new language or share any feedback you have.