Over time SQL has become the de facto language for querying and manipulating data. It is now the most popular language for working with relational databases.
Whether SQL is a programming language and meets the various criteria is a hotly contested topic online. Arguments can be made either way regarding SQL’s status as a programming language.
Let’s explore what SQL is and then look at the different reasons surrounding its status as a programming language. Then move on to why it doesn’t matter if SQL is a programming language.
What is SQL?
SQL is shorthand for Structured Query Language and is a language used to communicate with relational databases. It was created in 1974 by Donald Chamberlin and Raymond Boyce, then was registered with the American National Standards Institute in 1986.
Today it is the most common query language used in the software development world and has been built upon with the release of Microsoft SQL Server, MySQL, and PostgreSQL.
SQL is referred to as a domain-specific programming language because its use is limited in scope, unlike general-purpose programming languages. Other domain-specific programming languages like CSS share the same characteristics as SQL of being very narrow in scope but incredibly useful to the development community.
You can’t build an app or a web page solely with SQL. However, the entire project would not function without a query language like SQL to talk with the database. Its importance can’t be overstated.
Some basic SQL commands include:
- SELECT – extracts data from a database
- UPDATE – updates data in a database
- DELETE – deletes data from a database
- INSERT INTO – inserts new data into a database
- CREATE DATABASE – creates a new database
- DROP TABLE – deletes a table
- WHERE – used to filter records
- GROUP BY – used to aggregate results
- ORDER BY – sort results by ascending or descending
The order you place these commands is incredibly important. The GROUP BY command should follow the WHERE clause but precede ORDER BY. An example SQL query includes:
SELECT column_a, column_b FROM table_one WHERE column_a = 2000 GROUP BY column_a, column_b ORDER BY column_a;
Is SQL a programming language?
SQL is a domain-specific programming language that is programmers use to manage data in a relational database. It has become the de-facto query language to interface with databases and is the most used query language in the world. With nearly 60% of professional developers using SQL in some manner, it is now the third most popular language behind JS and HTML.
The debate rages on about SQL’s status as a programming language in the purest sense of the word. Some programmers believe the lack of decision logic and looping in basic SQL means it lacks a core tenant of what makes a programming language. However, this is contested by large segments of the developer community.
Either way, SQL is virtually important to modern technology and has proved itself a robust and versatile technology.
The technical definition of a programming language is any set of rules that converts to machine code to implement algorithms. Does SQL meet this criterion?
Let’s explore some reasons why SQL is considered a programming language and why its detractors believe it isn’t.
1. General-purpose vs domain-specific
Some of SQL’s critics will use its narrow usage as a reason that it shouldn’t be considered a programming language. However, this misses the point.
When people argue against SQL as a programming language they often use its narrow use as a reason. However, it’s purpose-built to serve a small range of tasks.
SQL is not a general-purpose programming language and that is the point. It is used specifically to communicate with relational databases and it performs this task excellently. You can’t write a UI frontend with SQL or build an API but that is entirely the point.
2. No Loops
It’s argued that SQL can’t be a programming language because in its purest form it can’t perform loops or implement decision logic. It is a pretty valid point but has largely been negated by the release of SQL-based languages like PostgreSQL and MySQL. These allow you to create loops and implement logic.
Some would argue further that these are not dialects of SQL but are their own languages entirely. Whatever your view they both remain SQL compliant and add additional functionality.
3. Turing Complete
Many in the tech world like to define a programming language based on whether it is Turing complete or not. A language is said to be Turning complete when it can be used to simulate any Turing machine and can recognize or determine other data-manipulation rules. It’s based on computer theory work completed by AlanTuring.
SQL with the addition of recursive queries is Turing complete. So it’s another notch on the scoreboard for proving SQL is a programming language
Does it matter what type of language SQL is?
It doesn’t really matter whether SQL is considered a programming language or not. Its global popularity and widespread usage speak volumes about its effectiveness. Whether it’s considered a ‘real’ programming language or just a query language isn’t as important as the argument surrounding it.
People like to elevate themselves while pushing others down and this is often at the heart of the argument about whether SQL Is a programming language. The question doesn’t often come from a place of good intent.
Developers across the world are doing fantastic work in a wide range of programming languages and their work shouldn’t be devalued based on pretty subjective definitions. We shouldn’t use the discussion around programming languages to gatekeep the terms programmer or software engineer.
The reality is that most successful software engineers get things done, they can outline solutions and approaches regardless of the language. The languages you use daily aren’t the defining metric of how good a developer you are – despite what StackOverflow and Reddit threads may tell you.