April 14, 2020 • ☕️ 3 min read
Clojure is a
compiled, and predominantly
functional programming language from the Lisp family tree. It is completely dynamic, every feature supported by Clojure is supported during runtime.
Clojure is designed based on LISP programming language and has compilers that make it run on both
.Net runtime environment. LISP is the
second-oldest high-level programming language after Fortran. Some features make LISP really likable:
For Ex: Perform mathematical expression (4+2) in LISP :
>> USER(1) (+ 4 2)
1. Dynamic Development: Clojure is a dynamic programming language. Values have a type and their types are determined at run time. The type doesn’t have to be explicitly specified.
While writing a function, we don’t have to specify the types of the function arguments. For example,
Consider an expression that defines a function named
add-num which receives three numeric arguments and returns their sum:
(defn add-num [a b c] (+ a b c)) ;; a, b and c are the three arguments (add-num 2 5 6) ;; returns 13
Clojure program is not something that you can compile and run, but something with which you can interact.
2. Functional Programming: Clojure is a functional programming language. It provides functions as first-class objects, uses immutable data structures, and also, emphasizes on recursive iteration.
Since Clojure is functional the code is
robust, we can control
functions with the same freedom as we control
(defn rec-add-fn? [x] (let [y x] (fn [z] (+ y z)))) (def add2 (rec-add-fn? 2)) (add2 4) -> 6
3. Hosted on JVM: Clojure is often called “functional LISP for the JVM” . It’s a dialect of LISP for the JVM which allows Clojure to support following features:
4. Runtime Polymorphism: The systems which support runtime polymorphism are easier to change, extend and are able to handle different data-types with a uniform interface. Polymorphism isn’t just for object-oriented programming (OOP) languages. Clojure supports polymorphism in different ways :
5. Concurrent Programming: Concurrency is the ability to deal with multiple tasks at once, such as leveraging the power of multicore CPUs. Immutable data structures can easily be shared across multiple threads. Clojure widely supports concurrency.
What is Clojure useful for?
Clojure has support frameworks, tools, and a lot of language constructs like closures, functional programming, etc. Clojure is widely used to solve various real world problems such as:
Apart from this, we can build systems from the ground up in Clojure without ever touching Java code directly. For more detail in depth, read this documentation.
Hi 👋🏻, My name is Sonia, studying Information Technology from Panjab University, India. I am an Open Source enthusiast and passionate about about browsers, web-compatibility, developer tooling and developer communities. Recently, I finished my internship with Embark Studios on a new platform for gamemaking. I was the CNCF 2020 Intern at Thanos, and spent the winter of 2019 working with web-compatibility team of Mozilla as an Outreachy Intern. I also love to travel, teach, and speak about open source 👩🏻💻