A team of developers has introduced a new data constraint language — CUE that combines types and values into a single concept. It’s an open-source data validation language, inspired by Google’s General Configuration Language (GCL) and aims to make tasks that involve defining and using data simpler.
CUE comes with two core properties that set it apart from other configuration languages. First, it considers types as values and second, these values are ordered into a lattice, a partially ordered set. Talking about applications of CUE, it includes data validation, data templating, configuration, code generation, querying, etc.
Read: Why Rust is the Most Interesting New Programming Language
According to the developers, “CUE merges the notion of schema and data. The same CUE definition can simultaneously be used for validating data and act as a template to reduce boilerplate. “Schema definition is enriched with fine-grained value definitions and default values. At the same time, data can be simplified by removing values implied by such detailed definitions. The merging of these two concepts enables many tasks to be handled in a principled way,” they also added.
Contents
Some Major Features of CUE
Data Validation
CUE makes it quite easier to define and verify the schema using the ‘cue’ command-line tool. You can use CUE constraints to verify document-oriented databases like MongoDB.
Enhanced Readability
This new data validation improves readability by allowing the one file single definition applicable to values in many other files. If you a developer, you won’t have to open various files for verifying the validity.
Allows Normalization of Data Definitions
As it combines constraints from multiple resources, redundancy has always been an issue. With CUE, its logical inference engine will address this issue by reducing constraints automatically. Its API also allows selecting between different normal forms for optimized representation.
Code Generation and Extraction
As of now, CUE can only extract Protobuf and Go code definitions. It allows annotation of existing sources with CUE expressions and facilitates the use of existing sources or smoother transition.
Improved typing capabilities
CUE offers “expressive yet intuitive” compact typing capabilities by combining types and values. So, it’s different from others who mainly focus on reducing the number of lines of code.
Also Read: Luna: First Programming Language with Dual Syntax Representation
This open-source language got a mixed reaction on different portals. One side, the users are excited about a new data validation language. On the other, they are unsure of how things will work with this new weapon. Some developers have also compared it with Jsonnet, which a data templating language. You can read more about CUE on its official website.