A while ago I participated in an online live event where Uncle Bob announced the language he thinks will be the most popular in the future: The Future of Programming Languages at the Confluence of Paradigms.
He made a walkthrough of the history of programming languages and then announced the winner for the future: Clojure (or a similar future language).
Here is shortly what he said about the requirements of the future languages:
They should..
..enable writing code that is object oriented or functional. All in one single language.
..be dynamically typed with runtime type checking.
..be homoiconic, i.e. execute out of its own data structures.
..have light grammar.
Pros with light grammar:
* High density of expression
* Short learning curve
* Easy DSL (Domain Specific Language). Manipulate the language itself to be the domain language. Invent your own language.
* Capabilities are added by libraries
Clojure meets all requirements
Clojure is the only current language that fulfils all all the four requirements. The result is not surprising. Uncle Bob has promoted Clojure for several years now, and in 2019 he said:
It is just simpler, and easier, and less occluding to write expressive code in Clojure. It requires fewer lines. It requires fewer characters. It requires fewer hours. It requires fewer mental gymnastics. Why should this be so? The answer is very simple. Indeed the answer is: Very simple. The language has almost no syntax or grammar. – Uncle Bob
Are the requirements of a future language carved out by using and liking Clojure for many years? Or, do the requirements set from a larger perspective, based on what the development community requires? I don’t know.
What is Clojure?
If you wonder what Clojure looks like, here is a simple example taken from Tutorials point:
Based on those principles the code looks like this, defining a function “Example” that prints out the result of 1+2 and Hello world concatenated:
This is very much it; a function with parameters. Println is also a function, that takes one parameter. Defn is a function as well, that is used to define a function. By this, the whole language is built up, making it having a very light grammar. Due to its simple structure, it is also very easy (not sure about that…) to manipulate by macros.
Since you write the code in the form of pure functions it is usually quite easy to run each function separately, and this is done in something called REPL (Read-Eval-Print Loop). REPL allows you to run your code statement by statement and is described very well here: https://clojure.org/guides/repl/introduction
Many Clojure programmers consider the REPL, and the tight feedback loop it provides, to be the most compelling reason to use Clojure
In what way does Clojure fulfil the requirements of a future language?
Object oriented and functional
Even though Clojure is a functional language, it can also be used in an object oriented. Here you can read more about how to use Clojure as a functional OR objected oriented language:
- Functional: clojure.org/about/rationale(opens in a new tab)
- Object oriented: https://cognitect.com/blog/2009/8/12/rifle-oriented-programming-with-clojure-2
Dynamically typed with runtime type checking
Clojure is LISP that runs on JVM on the server side. Clojurescript is a Javascript library where you write Clojure that compiles to Javascript. To enforce type checking at run-time clojure-spec can be used. This makes it easy to declare the structure of the data and enforce it in runtime.
Light grammar
Many languages are heavy on grammar e.g. C++, C# and Java. There is a lot of syntax and keywords that you need to know about to use the language effetively. After adding Linq, Lambda and Generics the languages grew even more.
Most languages are heavy on grammar. But there are two languages that have almost no grammar: Smalltalk and Lisp/Clojure. So Clojure fulfils the requirement of light grammar.
Homoiconic
Lisp is not a program, it’s a data structure. This data structure can be manipulated by another Lisp program before it executes. That is what is called macros in the Clojure world.
How hard is it to learn Clojure?
Three years ago, I thought that I would get a contract in a project where the main programming language would be Clojure. I spent some time trying to learn the basics just to be prepared and I must say it was not easy. It was the first functional language I tried to adapt, which might make it even more difficult. In the end, we did not use Clojure in the project, so I never learned it, but I am still interested in its advantages and dynamics.
Conclusion
Many companies try to identify the best programming language for the future. Looking back on the tools that have gained a lot of success during my career, they have been shipped with something more than the language itself. Visual Basic for example, came with several easy-to-use products like Access and SQLServer, and ready-to-go web server: IIS. Java came with the open source era as an almost political force against the big dominating companies such as IBM, Oracle and Microsoft. It was also possible to run on many platforms, which was a huge advantage. Javascript provided a completely new world when it suddenly worked better in the browsers allowing developers all over the globe write small libraries which stacked upon each other became an incredibly innovative environment.
Clojure is a very interesting language that comes with a lot of potential. Several of the best programmers I know really like it. But, is this enough to make it the next generation of languages? I’m still waiting to see a wider range of developers showing their interest, especially the young ones. Whether this will happen or not, is still to be learned!
Learn more
I highly recommend this session! Both to understand why you should use Clojure, and to get a wider understanding of how to tackle complexity: https://www.infoq.com/presentations/Simple-Made-Easy
More links if you want to learn more about Clojure (thanks to http://fooheads.com/):
https://pragprog.com/book/roclojure/getting-clojure
https://github.com/functional-koans/clojure-koans
purelyfunctional.tv
https://www.youtube.com/user/ClojureTV