It seems as if everything needs to be wrapped in parenthesis in clojure. Even a simple hello world!
(println "Hello world!")
What is the benefit of that syntax decision?
They mean that there needs to be a simple way of representing a tree structure within Lisp code. The purpose of the parentheses is to enable that representation. In particular, an open parenthesis, "(", means "step down a level of the tree". And a close parenthesis, ")", means "step back up a level of the tree".
Clojure is a Lisp-1 and is not intended to be code-compatible with other dialects of Lisp, since it uses its own set of data structures incompatible with other Lisps. As a Lisp dialect, Clojure supports functions as first-class objects, a read–eval–print loop (REPL), and a macro system.
Immutable data structures Clojure has features of an object-oriented language. So, it initially includes a set of immutable (unchangeable) structures and methods for working with them. They look like common JavaScript arrays, Hash Maps. But any operation can't change their values.
Clojure is being used extensively for processing large volumes of data. It is very well suited to data mining/commercial-AI (ie: Runa) and large scale predictions (aka WeatherBill). Clojure's concurrency story really helps in these data heavy domains where parallel processing is simply the only answer.
The fundamental reason is that Clojure was designed as a homoiconic language, i.e. code is expressed in the core data structures of the language. All Lisps share this property, but few other languages do. As a result, the entire language design of Lisps is strongly influenced by this decision.
The choice was made early in the design of Lisp that lists would be used for function invocation in the form:
(function arg1 arg2 arg3) => some result
This has lots of advantages:
(cons function-symbol list-of-args)
The function name could have been put outside the parentheses:
function (arg1 arg2 arg3) => some result
But this would have many disadvantages:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With