DEV Community

Cover image for What is a Programming Language?
Jeremy Grifski
Jeremy Grifski

Posted on • Originally published at therenegadecoder.com on

What is a Programming Language?

When most of us think about programming languages, we think about popular languages like Python, C#, and JavaScript, but where do we draw the line? In this article, I want to push the boundaries on conventional wisdom by challenging a few common arguments like the one that inspired this article: "HTML and CSS are not programming languages."

Inspiration

To be honest, I hadn’t really put any thought into what makes a programming language in the past. After all, we just write code, and that can take many forms. Who is to say what is and isn’t a programming language?

As it turns out, there’s quite a heated debate in the web development world about whether or not HTML and CSS are programming languages. In fact, I stumbled upon this debate over on dev.to where Desi kicked off a discussion on the topic.

Thankfully, that platform rarely breaks out into a flame war, so you can find a lot of gold nuggets in a discussion like that. Of course, I figured I’d chime in:

Personally, I would say yes [that HTML and CSS are programming languages], but my definition of a programming language is more fluid. For instance, you could ask a similar question for esoteric languages like brainf*ck or data languages like yml or json. As long as the content of the text is being interpreted/compiled by a computer, it’s a programming language.

Now, there are definitely levels to this as some languages can accomplish a lot more than others, but that’s a different discussion.

In terms of experience, I’ve taken a few classes and even written a compiler for a toy language as well as a Lisp interpreter. Now, I just maintain the Sample Programs repository (shameless plug) which contains 106 languages at the time of writing.

After making that comment, I got to thinking more about what makes something a programming language, so I decided to share some of my thoughts.

Programming Language Definitions

If you search the internet for the definition of a programming language, you’ll find a lot of word soup. For instance, Wikipedia states that “a programming language is a formal language, which comprises a set of instructions that produce various kinds of output.” Meanwhile, TechTerms describes a programming language as “a set of commands, instructions, and other syntax use to create a software program.” Hell, here are a few more definitions:

  • Computer Hope: “A programming language is a special language programmers use to develop software programs, scripts, or other sets of instructions for computers to execute.”
  • Merriam Webster: “any of various high-level languages used for computer programs”
  • Webopedia: “A programming language is a vocabulary and set of grammatical rules for instructing a computer or computing device to perform specific tasks.”

Is there any sort of unified thread that we can extract from these definitions? In other words, can we come up with any sort of criteria for language categorization based on these definitions? To me, it seems like we just need a couple things to be able to call something a programming language:

  • Syntax (i.e. a grammar composed of instructions, commands, etc.)
  • Semantics (i.e. some meaning given to that grammar)

Oh, and we should probably be able to run that language on a computer. Now, let’s see just how far we can stretch that definition.

Examining Various Languages

When considering whether or not something is a programming language, it doesn’t do us a lot of good to look at languages that typically fit the bill. Instead, I want to look at languages that are on or just beyond the edge like CSS and HTML.

MATLAB

To be honest, MATLAB probably seems like a weird place to start when challenging ideas of what is and isn’t a programming language. After all, it’s obviously a programming language, right?

If you’ve never heard of MATLAB, it’s essentially a tool used by engineers and data scientists to run simulations and make visualizations. And like most programming languages, it has a very clear syntax and semantics:

sum1 = 0;
sum2 = 0;
N = 27
for k = 1:N 
  sum1 = sum1 + k; 
  if (mod(k, 7) == 0) 
    sum2 = sum2 + k; 
  end
end
Enter fullscreen mode Exit fullscreen mode

To the casual observer, this looks like programming—and it is! Yet, a lot of programming purists look down on MATLAB. Since it’s not used to create applications, it’s not a real programming language.

Of course, MATLAB is absolutely a programming language based on our agreed definition above, and it bothers me that there’s a very vocal minority excluding MATLAB programmers from being real programmers. For instance, some of my mechanical engineering friends use MATLAB all the time to simulate their designs. Are they not programmers at least in some capacity?

HTML

If you’re not familiar with HTML, it’s a markup language which is usually used to specify the structure of a web page. Specifically, it’s a tree-like language where the document has a root node (i.e. <html>) which can contain any number of child nodes (i.e. <head>, <body>, etc.). Naturally, these children may have children and so on.

<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head> 
    <title>Hello, World!</title> 
  </head> 
  <body> 
    <h1>Check Out This Heading</h1> 
  </body>
</html>
Enter fullscreen mode Exit fullscreen mode

Now, HTML usually hits a snag in the programming language debate because it doesn’t perform any action; it’s static. In other words, there is no flow control. Instead, HTML relies on the browser to interpret and display it.

That said, there is still quite a bit of logic that goes into constructing an HTML document. Understanding how a browser is going to render the HTML is no different than understanding how the JVM is going to run a Java program. In both cases, the developer is programming.

If you don’t buy that logic, at the very least, HTML hits all the hallmarks of our definition. In particular, it has a clearly defined syntax, and that syntax has a clearly defined meaning to a browser (which happens to be on a computer).

CSS

Along with HTML, you’ll often find an interesting language called CSS. To the best of my knowledge, CSS is used to style HTML by applying properties to nodes.

h1 { 
  display: block; 
  font-weight: bold; 
  background-color: red;
}
Enter fullscreen mode Exit fullscreen mode

In combination with HTML, CSS can actually be used to drive logic from user interaction. In other words, buttons can be used to change the state of the web page using only HTML and CSS. To me, that sounds like a programming language.

Of course, CSS hits a snag because of its dependency on HTML. Alone, it doesn’t really do much. That said, I think that’s sort of a silly comparison because that’s true for all programming languages (i.e. Java is nothing without the JVM). All languages require other software—or at least hardware—to give it meaning.

As a result, I think CSS fits nicely within the bounds of our programming language definition. After all, it has clear syntax and semantics (per browser), and it happily runs on a computer.

SVG

Now, we start to get into some serious gray area: data formats. In this case, I want to talk about formats like JSON, XML, SVG, and even CSV and Markdown. Are these programming languages? I’m going to argue yes.

Let me start by asking a question: have you ever tried to write an SVG? If you have, then you know how challenging that can be:

<svg height="210" width="500"> 
  <polygon points="200,10 200,190 120,210" style="fill:purple;stroke:aqua;stroke-width:2" />
</svg>
Enter fullscreen mode Exit fullscreen mode

In this case, we’ve drawn a triangle which can be interpreted and drawn by any number of tools that can understand the SVG format (i.e. the browser). In other words, SVG is a programming language since it has a clearly defined syntax that gains meaning from certain environments like the browser.

XML

If HTML and SVG are programming languages, then surely XML is a programming language. Well, that’s a bit harder to prove.

<CATALOG> 
  <CD> 
    <TITLE>Empire Burlesque</TITLE> 
    <ARTIST>Bob Dylan</ARTIST> 
    <COUNTRY>USA</COUNTRY> 
    <COMPANY>Columbia</COMPANY> 
    <PRICE>10.90</PRICE> 
    <YEAR>1985</YEAR> 
  </CD> 
  <CD> 
    <TITLE>Hide your heart</TITLE> 
    <ARTIST>Bonnie Tyler</ARTIST> 
    <COUNTRY>UK</COUNTRY> 
    <COMPANY>CBS Records</COMPANY> 
    <PRICE>9.90</PRICE> 
    <YEAR>1988</YEAR> 
  </CD>
</CATELOG>
Enter fullscreen mode Exit fullscreen mode

While XML has a clearly defined syntax, its meaning is a lot less clear. After all, XML, like JSON, is largely used to carry data, so it only derives meaning under certain circumstances like as an SVG.

However, because so many tools depend on XML as a configuration format (see Maven), XML should be considered a programming language by extension. In other words, XML derives meaning only with context, but that doesn’t make it any less of a programming language. After all, Python doesn’t make any sense to GCC, but we still consider it a programming language.

JSON, CSV, etc.

Since we’re on the subject of data formats, how about JSON, CSV, and Markdown? All of them have a clearly defined syntax, but can we derive any meaning from them? Naturally, the answer is yes:

{ 
  "menu": { 
    "id":"file", 
    "value":"File", 
    "popup": { 
      "menuitem": [
        { 
          "value":"New", 
          "onclick":"CreateNewDoc()" 
        }, 
        { 
          "value":"Open", 
          "onclick":"OpenDoc()" 
        }, 
        { 
          "value":"Close", 
          "onclick":"CloseDoc()" 
        }
      ] 
    } 
  }
}
Enter fullscreen mode Exit fullscreen mode

In this case, I’ve chosen to share a sample JSON which should be reminiscent of XML (implying that JSON is indeed a programming language). Of course, like XML, JSON derives meaning from context. For example, JSON might also be used for configuration files. In fact, I’ve seen a similar language, YAML, used exactly for that when setting up continuous integration platforms like Travis CI. Is that configuration file not a form of programming?

Similarly, CSV is a data format that doesn’t have any meaning on its own. Like XML, JSON, YAML, and even HTML, CSV relies on a program to interpret it. Is that not what Microsoft does with Excel? How about Google Sheets? These are programs that interpret and display CSV data which gives that data meaning.

Finally, Markdown is a text formatting language which is often used to generate HTML for web pages. Does that make it less of a language because it simplifies a process? I’m sure this is the same argument that was made about higher-level languages like Python and Java by folks who refused to move on from COBOL and FORTRAN. In other words, the art of gatekeeping.

Sheet Music

Now, we’re starting to get into muddy water, but hear me out: sheet music may as well be a programming language.

Handwritten Sheet Music

When I decided to write this article, I was actually sitting in a rehearsal. At the time, I was thinking about how some of the ways that we annotate music are ambiguous. For example, the director stated that we should play one of the quarter notes short like an eighth note which prompted one of the sax players to question what the director meant by that. Did he want an eighth note followed by an eighth rest? How about a staccato quarter note?

At any rate, that’s when I got to thinking: is sheet music a programming language? After all, a composer is really just a programmer trying to get the right combination of sounds out of an ensemble through a language with a certain syntax (like Common Music Notation) and semantics.

In fact, Common Music Notation has all sorts of mechanisms that mirror control flow in popular programming languages. For example, there are repeat signs which work similar to loops, double bars which tell the musicians when to stop, and measure numbers which are reminiscent of line numbers.

Of course, we sort of hit a snag in our original definition. After all, sheet music is interpreted and ran by musicians, not computers. Also, I don’t think musicians would appreciate being called computers, but I don’t think the comparison is that far off.

Classification of Programming Languages

At this point, we’ve looked at a lot of languages and tried to come up with some argument over whether or not they are a programming language. Due to the overwhelming lack of a concrete definition of a programming language, I’m willing to argue that just about anything that has a formal syntax and a derived meaning can be considered a programming language. However, not all programming languages are the same.

In general, there are a handful of programming language categories: imperative, functional, structural, declarative, etc. Today, we’ve sort of blurred the lines between these categories thanks to multi-paradigm languages. That said, I still think these categories serve an important purpose in at least proving the case that languages like HTML, XML, and JSON are truly programming languages.

Most of the languages that people tend to describe as not programming languages—HTML, CSS, XML, etc.—are really declarative programming languages. In other words, we use these languages to declare what we want our system to do, not how.

To rub a little salt in the wound, Wikipedia actually lists quite a few declarative programming languages including Make, SQL, HTML, and Prolog. In fact, regular expressions are considered a declarative programming language. How’s that for stretching the bounds of the definition of a programming language?

What is a Programming Language?

If I can make the argument that sheet music is a programming language, then why are we even still debating what is and isn’t a programming language?

Now, that’s not to say that programming languages don’t deserve to be categorized. After all, there’s some merit in that. However, it bothers me when we try to put each other down by saying things like “you’re not a real programmer because you code in x.”

At the end of the day, who cares what someone else codes in? We’re talking about tools here, and I don’t think I’ve ever heard anyone put down for using any of the following tools:

  • Pencil (Wow, I can’t believe you’re using a #2 pencil.)
  • Hammer (DeWalt? Really?)
  • Calculator (TI-84? Try TI-86, loser!)

See how silly all that sounds? Just let people code, will ya?

As always, thanks for taking some time out of your busy lives to support my work. In addition to coding, I love to write, and I hope content like this helps someone out. If you like this article, make sure to give it a share. Also, consider becoming a member or at least hop on the mailing list, so we can stay in touch. While you’re here, why not take a look at some of these other articles:

Well, that’s it for now! Thanks again.

The post What is a Programming Language? appeared first on The Renegade Coder.

Top comments (15)

Collapse
 
cout970 profile image
cout970

This article really makes you think. In my opinion, what we are trying to do it's separate languages into 2 categories:

  • What people call programming languages: a set of instructions that a computer can run.
  • What we call markup languages or storage formats: a way to represent data that can be interpreted by a program.

It's hard to classify languages, but I think that there are a few requisites for a language to be considered a programming language:

  • It must be Turing complete.
  • It should allow to transform data, a.k.a do computations.
  • Allow abstraction (functions. methods, lambdas, subroutines, subqueries, etc.)

With this criteria we can say that HTML is not a programming language. HTML is not Turing complete, it doesn't have the ability to make decisions. HTML cannot do computations, it just stores constants. And finally lacks a mechanism to do abstractions.

I may be wrong but this is my way to differentiate programming languages from other kinds of languages. I would love to hear some counterexamples if someone wants to prove me wrong.

Nice article btw.

Collapse
 
renegadecoder94 profile image
Jeremy Grifski

Honestly, I don’t know that I agree, but I like that you lay out some criteria in the same way that I did.

Currently, I don’t feel like there is a set of checkboxes that can be used to decide what is and isn’t a programming language. As a result, I choose to leave things more nebulous. In other words, if a machine can derive meaning from some data, that data is a programming language.

That said, I think you raise a good question. What does it mean to program? If flow control (or Turing completeness) is the criteria you use, then you can start to draw some lines.

Ultimately, I guess my issue with these arbitrary distinctions is that they can be used to marginalize people (not just languages). In other words, suddenly engineers aren’t real programmers because they use a language that isn’t general purpose.

Collapse
 
anpos231 profile image
anpos231

CSS and HTML are not programming languages. They have some basic grammar, but they are unable give computer instructions, just because we write HTML to produce output does not mean that the HTML is the language producing this output, it's simply a structured data that browsers use to create output.

There are esoteric interpreters that can interpret images and create output. Does that mean the image is a programming language? Nope, it was never meant to be a "programming language", it's still an image and just because the interpreter exists does not make an image a language.

I know this is a hard topic that people will probably continue to fight over for many years. I personally try to reason about it like this:

If (a thing) was created to become a programming language, it is a programming language. If (a thing) wasn't created to become a programming language, then it is not a programming language.

Collapse
 
iamschulz profile image
Daniel Schulz

I'm going to disagree with you there.
I don't think I can clearly defined what is and isn't a programming language, but I can program in css, in a manner of manipulating data. I can hand the computer instructions on how a thing as to behave in consideration of a number of variables, to the extent of managing the whole state of a a component. That clearly makes it a programming language, and by proxy html as well.

You're right in that css wasn't originally meant as a programming language, but your argument is pointless. Why shouldn't a language be able to evolve?

Collapse
 
renegadecoder94 profile image
Jeremy Grifski • Edited

I’m completely on board here. I think it’s really hard (and often dangerous) to start declaring some languages in and others out without some formal definition which doesn’t appear to exist. Otherwise, everyone gets to create their own definition. Then, as a consequence, elitist factions get to form around certain types of languages (i.e. only functional programming is real programming).

One example that always comes to mind is MATLAB (as mentioned in the article). One of my best friends uses it as a Mechanical Engineer, and he received a lot of elitist backlash when he was first learning to use it. To him, MATLAB is the right tool for the task, but a lot of folks in our community look down on it.

Ironically, I imagine someone in our community developed that language.

Collapse
 
renegadecoder94 profile image
Jeremy Grifski • Edited

I think you and I fundamentally disagree here. To me, the languages we typically think of as programming languages are just text (data) with some formal syntax. They derive their meaning from the interpreters or compilers that convert them into something useful for a machine. In other words, images on their own are not programming languages, but the esoteric interpreters provide the context to treat them as such.

I’m not sure why there has to be some arbitrary criteria to exclude or include different data formats from the programming language classification.

Collapse
 
elmuerte profile image
Michiel Hendriks • Edited

HTML is a markup language. Of course that does not say it is not a programming language, as TeX is both.

XML is a grammar, a more strict version of SGML. Based on XML you can create a programming language. For example: XSLT is an XML based programming language.

I think the best way to say if something is a programming language is if it is Turing complete.

HTML lacks the features to be Turing complete. CSS on its own also lacks the features.
But combined you can create a so called Rule 110 system, which is Turing complete. (Just search for "Rule 110 css" and you find plenty examples.)

So HTML+CSS is Turing complete, it can be considered as language with which you can write a program. And thus a programming language.

But I would never call it a programming language. Because that just dilutes the meaning of the word. And for what reason? Just because something is not a programming language does not make it worth any less.

SQL is Turing complete. But it is still a query language, and not a programming language. Minecraft redstone is Turing complete, but it is not a programming language. etc.

Languages or systems which are unintentional Turing complete can be considered esoteric programming languages. Their main value lies somewhere else, in a more specific domain.

Collapse
 
iamschulz profile image
Daniel Schulz

I'd say that query languages and markup languages are a subset of programming languages.

Your Minecraft example is interesting though, because it's easily translatable to graphical programming like puredata. You don't write your stuff per se, yet you're programming, with a specific set of rules, grammar, etc. If not programming language, how would you call that?

Collapse
 
elmuerte profile image
Michiel Hendriks

I think Minecraft redstone can be better qualified as a FPGA.

Collapse
 
renegadecoder94 profile image
Jeremy Grifski

I also have to challenge some of the arguments here. Why mention Turing completeness as a criteria if you ignore it in some cases? Why does designer intent matter more than practical use?

Collapse
 
elmuerte profile image
Michiel Hendriks

As I said, it dilutes definitions. Terms become meaningless if you make them to broad. If we would consider SQL a programming language, then we would also consider somebody who's main role is to write SQL a database programmer.

One of the main issues with natural language is that it is really unclear about meaning of words, and sentences, and sometimes even paragraphs. If we keep making definitions ambiguous it will only get worse, and we could literally(*) lose its purpose.

*) this is just an example where this word has been misused so often, that literally has as alternative meaning "figuratively".

ps, I would not say that SQL, HTML+CSS, Minecraft Redstone have a practical programming use; it's rather impractical to use it as programming language.

Thread Thread
 
renegadecoder94 profile image
Jeremy Grifski • Edited

I guess my point was that you don’t really further solidify a definition. You provide some arbitrary criteria (Turing Completeness) that you simultaneously violate (some Turing Complete languages aren’t programming languages).

In other words, it seems like your criteria is more of a feeling or bias rather than something that can be verified.

At any rate, I do appreciate the discussion! I think you raise a good point about diluting terminology. I’m just not sure it’s an issue in this case.

Collapse
 
jasman7799 profile image
Jarod Smith

I think if we continue down this path, then eventually you would converge on any language is a programming language because a language is inherently designed to be read, wrote, and to be interpreted. This I think is close to the truth, but the problem is that it doesn't correctly focus on the right part of the argument. All languages can be programming languages, but not all of them always are.

What makes a language a programming language is its intent. The intent of the language must be to translate from one entity to another entity a set of instructions to follow. In this way a set of colored blocks could be made into a programming language.

Beyond this there are languages which have been made with the exclusive intent to convey instructions from one entity to another i.e. a human to a machine, and these specific languages have been given the title of programming languages to express the intent of the language.

Collapse
 
renegadecoder94 profile image
Jeremy Grifski • Edited

This is really spot on!

I think the big issue with the term "programming language" is that nobody really has a concrete idea of what that means. As a result, pretty much anyone can draw a line in the sand and declare something is or is not a programming language. As consequence, an elitist can come along and use those lines to arbitrarily exclude people.

So, maybe the line is just "human to machine." That way, we can exclude other mediums like music, but keep the category broad enough as to not exclude people who use MATLAB, HTML, XML, CSV, etc.

Collapse
 
jainish06915235 profile image
Jainish Patel

Programming Language is helpful to create an innovative machine. whenever the code is used. it is a programming language.