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.

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

Table of Contents

This lesson preview is part of the Tinycanva: Clojure for React Developers course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to Tinycanva: Clojure for React Developers, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course Tinycanva: Clojure for React Developers

In the last chapter we studied about closure syntax. In this chapter, I will try to convince you that closure does not have a syntax . I know it sounds a little odd, but please bear with me for a few minutes and things will make sense. Consider this simple JavaScript if condition. The keywords if and else and the curly brackets have to be in specific positions for this code to execute properly. This constitutes the syntax of the language. The same condition enclosure can be written as follows. On the surface the two might look similar, but there are many underlying differences. In JavaScript, the positioning of the keywords if and else and the curly brackets are a part of the syntax. Other operations like defining a function, defining a tri-catch block, defining a variable will have a difference in tax in JavaScript. But in closure, if is just a function call and so is every other operation you can perform. The only rule that you need to keep in mind is that a list starts with parentheses and the first element of the list is an operation and all other elements are the arguments to that operation. In that sense closure is way more expressive than a C family language. We can rewrite the if conditional in closure as follows. Notice how we moved the function if inside the print function. Now you might be wondering that you can do the same thing in JavaScript using the ternary operator. That's a great observation, but we'd like to point out that the ternary operator is an additional piece of syntax. With closure it was just a function call, but ternary operator is an escape hook. It is not as extensible as composing functions would be. If JavaScript was as expressive as closure then something like this would have been possible, but it is not. The keywords if and else only work in certain positions, you can't compose them freely. Closure functions can be nested at multiple levels and as long as your code is a valid list, there is no other syntactical rule that you need to follow. hence, syntaxlessness.