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:
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 InformationRelated ArticlesGoogle Extends BigQuery For Multi-Cloud Analytics 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.
Comments
or email your comment to: comments@i-programmer.info |