What is a Programming Language?

What Is a Programming Language? Featured Image

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.

Table of Contents

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 topicOpens in a new tab..

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 statesOpens in a new tab. that “a programming language is a formal language, which comprises a set of instructions that produce various kinds of output.” Meanwhile, TechTerms describesOpens in a new tab. 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 HopeOpens in a new tab.: “A programming language is a special language programmers use to develop software programs, scripts, or other sets of instructions for computers to execute.”
  • Merriam WebsterOpens in a new tab.: “any of various high-level languages used for computer programs”
  • WebopediaOpens in a new tab.: “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

To the casual observer, this looks like programming—and it is! Yet, a lot of programming purists look down on MATLABOpens in a new tab.. 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>

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;
}

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>

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>

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 MavenOpens in a new tab.), 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()"
            }
         ]
      }
   }
}

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 dotted 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 languagesOpens in a new tab. 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 memberOpens in a new tab. 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.

Jeremy Grifski

Jeremy grew up in a small town where he enjoyed playing soccer and video games, practicing taekwondo, and trading Pokémon cards. Once out of the nest, he pursued a Bachelors in Computer Engineering with a minor in Game Design. After college, he spent about two years writing software for a major engineering company. Then, he earned a master's in Computer Science and Engineering. Today, he pursues a PhD in Engineering Education in order to ultimately land a teaching gig. In his spare time, Jeremy enjoys spending time with his wife and kid, playing Overwatch 2, Lethal Company, and Baldur's Gate 3, reading manga, watching Penguins hockey, and traveling the world.

Recent Posts