Google Releases Logic Programming Language
Written by Kay Ewbank   
Wednesday, 14 April 2021

Google has announced a new open source logic programming language. Logica is a successor to Google's existing logic language, Yedalog, and is a Datalog-like programming language.

Datalog is a logical query language that fits somewhere between Prolog and the formal relational algebra that underpins SQL. It can be thought of either an unusually powerful query language or a carefully limited logic programming language. Datalog was created to give database theorists a way to use logic programming, particularly via recursive queries.


Yedalog extended Datalog to be more practical, adding support for concepts such as nested records. Yedalog lets programmers mix data-parallel pipelines and computation in a single language.

The new language, Logica, compiles to SQL and runs on Google BigQuery. Logica compiles the logic program into a SQL expression, so it can be executed on BigQuery, Google's advanced SQL engine. Logica also includes experimental support for PostgreSQL and SQLite. The Google team says it is more concise and

"supports the clean and reusable abstraction mechanisms that SQL lacks. It supports modules and imports, it can be used from an interactive Python notebook and it even makes testing your queries natural and easy."

The big advantage Logica offers over SQL is its support for abstraction. While SQL supports views and functions for saving and reusing subsets of logic, they are limited and vary between SQL implementations. The Google team says:

"This inherent resistance to decomposition of logic into bite-sized pieces is what leads into the contrived, lengthy queries, the copy-pasted chunks of code and, eventually, unmaintainable, unstructured (note the irony) SQL codebases."

Logic programming languages use the syntax of mathematical propositional logic rather than natural English language, and Logica extends classical Logic programming syntax further, most notably with aggregation, hence the name, which stands for

Logica = Logic + Aggregation.

While SQL operates with relations that equate to sets of rows. the equivalent in logic programming is a predicate. This still defines a set of rows, but is a logical condition that describes the rows of a relation. A sample of code to find prime numbers less than 30 would be:

# Define natural numbers from 1 to 29.
N(x) :- x in Range(30);
# Define primes.
Prime(prime: x) :-
  x > 1,
    y > 1,
    y != x,
    Mod(x, y) == 0

The developers say Logica brings readability and good engineering practices to database queries, making them easier to read. Logica also makes it possible to define and re-use subqueries and functions.


More Information

Logica Website

Related Articles

Database The Prolog Way

Google Extends BigQuery For Multi-Cloud Analytics

BigQuery Updated and Repriced

Google BigQuery Updated

BigQuery Now Open to All

Google BigQuery Service

Towards Objects and Functions - Computer Languages In The 1980s


To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.


Most Used and Fastest Growing Languages

Information about the popularity of computer languages isn't just of passing interest. It's important because it relates to job opportunities and also to the ability to contribute to open source softw [ ... ]

Computer Pioneer Kathleen Booth Dies At Age 100

Kathleen Booth, who died last month, had a remarkable career in which she achieved many firsts. She is credited with the first assembly language, founding and teaching in the first university computer [ ... ]

More News





or email your comment to: