What is Syntaxlessness? How to Write More Expressive Code
C-style languages invisibly impose a syntax, whereas Lisps do not. This makes Lisps more expressive and easier to grasp.
Syntaxlessness#
There is no such word as "syntaxlessness". We had to make it up to showcase that Lisps don't have a syntax.
You might be wondering, "But Shivek, we just studied Clojure's syntax in the last lesson, and now you say that Lisps don't have a syntax!?" We know that our statement sounds a little odd, but it will make sense by the end of this lesson.
In a C-family language like JavaScript, the following conditional is common:
if (a > b) {
console.log(a)
} else {
console.log(b)
}
The equivalent Clojure version of this conditional will look something like:
(if (> a b)
(prn a)
(prn b))
The if
function expects three elements in a list: the condition, the truthy block, and the falsy block.
Notice how if
and >
are just functions, unlike in C-style languages, where if
, else
and >
are a part of the syntax.
Expressiveness#
Since Clojure is a functional language and there is no syntax in the sense of C-style languages, Clojure code is more expressive and concise.
The example that we started with can be re-written as:
(prn (if (> a b) a b))
This page is a preview of Tinycanva: Clojure for React Developers