Programming Languages Are More Than Syntax

Intro

Over time, I saw different opinions on the choice of programming language. First, when you start learning, any new language is difficult, and you say that you prefer one, only because the syntax is easier.
Then, people start to fall into two categories: the people who see programming as a tool to do what they want or to earn money, and the people who like programming as an end. Don't get me wrong, this doesn't mean that the first category doesn't like programming, or that the second doesn't need a goal, but the root of their motivation is different. The first category will often limit their learning to a few very practical programming languages and have a limited scope of knowledge. The second category, however, will often dig deeper to learn uncommon and unusual technologies.

I personally fall in the second category; I love programming. I love the reasoning, I love how you start from a literally blank page and end up with a fully usable project with only ALU operations. I could probably dissect why I love programming for a few hours, but it isn't the subject of this article.
These two categories are fundamentally different in my opinion, and they will struggle to agree on a lot of subjective matters such as how good a programming language is, is Vim really useful, or if Windows really is that bad. Obviously, all these questions have correct answers that I have, but the two categories of people will struggle to agree. The root of the problem is the divergence in their values; it's like talking with different word meanings, it's a deaf debate. To be serious for two minutes, there's no one category of people that is right and the other is wrong.

What you read until now might seem like an off-topic introduction, and it is, but I'm bringing this on the table for a specific reason: the topic I'm going to talk to you about today has been urged in my mind after I talked to that first category of person, someone seeing programming as a tool only, someone who doesn't have a preference in programming language.
One day, I will take more time to talk about this differentiation between people, but for now, it is enough to understand why this topic matters to me. I want to give a glimpse of how it is on my side, the side of deep, unconditional, and stupid passion.
Today, I want to talk about a particular opinion. An opinion that triggers me: "learning a new programming language is easy, it's mostly new syntax." My first reaction to that opinion is disgust and contempt. However, as these emotions are ugly, I have to face my reaction and understand why I feel that way, and why I'm right to feel that way. Spoiler: I have to be less contemptuous because I'm a dick, but I'm still convinced that I'm right.

Example

First Example

I want to start with an example. Let's write a graph exploration algorithm. Let's say we want to find all paths between two points in a graph. If we write it in Python, this will look like this:

But in Prolog:

path(X, Y, [X,Y]) :- edge(X, Y).
path(X, Y, [X|Path]) :- edge(X, Z), path(Z, Y, Path).

I think this code requires a little bit of explanation. First, here we assume that edge(X, Y) is a predicate that already exists. We could have declared some edges before like edge(1, 2). and edge(2, 3).. In this snippet, we create the predicate path(X, Y, P) to find all paths between points X and Y, where P is the path list. The first rule says if there's a direct edge from X to Y, the path is just [X, Y]. The second rule recursively builds longer paths: if there's an edge from X to some point Z and a path from Z to Y, then we can construct a path from X to Y by starting with X and appending the path from Z to Y. This concise logic lets Prolog automatically explore all possible paths through backtracking.

In a modern language, like Python, we could have a graph exploration algorithm like this DFS:

def paths(src: int, dst: int, edges: dict[int, list[int]]) -> list[list[int]]:
  stack = [([src], set())]
  res = []
  while stack:
    path, visited = stack.pop()
    last = path[-1]

    # if we reached the dst, path validated
    if last == dst:
      res.append(path)
      continue

    # add every
    for neighbor in edges[last]:
      if neighbor in visited: continue
      stack.append((path + [neighbor], visited | {neighbor}))

  return res

As you can see, the Python logic is much longer and more complicated. It sure feels more natural and easier to most experienced developers, but the Prolog solution has an elegance that we don't find in most common languages.

What I'm trying to point out here is that a different programming language, with a very different paradigm, not only enables a new way of thinking but actually forces you to shift your way of thinking. It enforces an evolution in your capabilities to reason.

At this point, you might want to answer with two points.
First, this is useless; good old Java lets me do anything, it is Turing complete, and there's no algorithm with a better complexity that I need that requires another programming language. And you might be right, you probably are actually, and this is because our holy C (C actually, not HolyC, which is a different language) is the father of all and the perfect translation of assembly and these computer operations. But don't you ever do something to open your mind to new points of view? It is the same.
Second, this is extreme; you are taking a lost language no one cares about. And once again, you are right, damn you're pertinent. Prolog is a particular language that no one uses anymore, not even a potential child like all the Lisps. It was used in constraint-based AI, and you can quickly see how if you know a little bit about that field. However, we can find an example with much more common languages.

Second Example

Let's compare Java and Go, though this concept applies to other highly object-oriented languages like Java, paired with lower-level languages like Go, Rust, and even C to some extent. We'll examine inheritance versus composition.
In Java, inheritance is commonly demonstrated with this example:

class Animal {
  void eat() {
    System.out.println("Animal is eating");
  }
}

class Cat extends Animal {
  String name = "";
  void meow() {
    System.out.println("Cat says meow");
  }
}

This example is straightforward, but let's clarify for those unfamiliar with Java. We define two classes, or object types: Animal and Cat. The Cat class is a subclass of Animal, meaning a Cat object inherits the properties and behaviors of the Animal class.

Now, let's implement something similar in Go. Unlike Java, Go doesn't have classes but uses structs, which are similar enough for this purpose. However, there's a key difference: Go doesn't support inheritance, so we use composition instead.

type AnimalBehavior struct { }

func (a *AnimalBehavior) eat() {
  fmt.Println("Animal is eating")
}

type Cat struct {
  name string
  AnimalBehavior
}

func (c *Cat) meow() {
  fmt.Println("Cat says meow")
}

In this Go code, we define a struct AnimalBehavior with no fields but attach a method eat() to it. This is very similar to the Animal class in Java. The Cat struct includes a name field and an unnamed AnimalBehavior field. Because the AnimalBehavior field is unnamed, any method call on a Cat object will first check for a matching method in Cat. If none is found, it will look in the embedded AnimalBehavior struct.

This approach allows Go to replicate Java's inheritance behavior using composition. However, you must notice that Animal became AnimalBehavior, and this small change drastically changes how things are perceived. It doesn't make sense to have value fields in AnimalBehavior as it does in Animal. We went from a relation is-a to has-a. At the moment, it might seem like a stupid obstacle, but as it reduces your possibilities, it reduces the risk of problematic behavior such as unexpected conflicts or uncontrolled access. I'm not trying to say that composition is always better, and it is a well-discussed topic, but I'm trying to point out how the difference in paradigm affects the way you must think.

Conclusion

Through the previous example, I aimed to express how different programming languages can force you to think differently. These differences in programming languages are not syntax differences. Actually, we could make two languages with almost exactly the same syntax, but very different logic.

When the differences are big enough, we call them paradigms. I chose not to start this article by talking about paradigms because they intuitively suggest massive differences in the root of the language; they define how the whole language will be designed. But the more important reason is that a lot of modern languages are multi-paradigm, and what I just told you isn't entirely true. TypeScript has classes, which suggest an object-oriented paradigm, but also anonymous lambda first-order functions, which align with the functional programming paradigm; it was even a popular trend a few years ago to criticize object-oriented programming and focus on functional programming logic, even with these kinds of languages. At this point, talking about paradigms can be confusing and is a source of endless debate.

The differences in languages are what make their strengths, and reducing them to syntax is, at best, an insulting simplification, and at worst, proof of a deep misunderstanding of the world of programming.