Personal Notes On Clojure [Unofficial]

Future Official Posts: 
  • What makes Clojure different
  • Clojure as a Lisp
  • Clojure for parallel programming 

Uniform syntax

  • forms

In other languages, there is restriction on the type of parameter. In C, only variables and pointers. In Java, only primitive and reference types. In functional languages, values and functions. There is no such limitation in Lisps & Clojure.

Metaprogramming
Uniform Syntax

First Class Functions

Code as Data

List Datatype – fundamental 

  • cons, first, rest; OOP languages – references to Objects

Tree structured execution. No syntax.

Data Abstraction – functions on lists

Dynamic Naming?

Forms, Uniform Syntax – Metaprogramming, Syntactic Abstraction, Parameter

Code have same structure as Data (cons, first, rest)

Execution model – functions working on data

Data Structure, Lots of functions

“Seq” abstraction

Datatype and Protocol

Multimethods

Compound Data – Data Abstraction – with Sequence

(No need for a Class template.)

Higher Order Function (Control Abstraction) on Sequence

Common pattern of Data access: first and recursive rest on Sequence
cons

Concurrency support

Functional programming

  • Localize thinking space
  • Localize testing
  • Easily parallelizable

In languages with non-uniform syntax, one has to define macro for each type of sentence. But Clojure, being a Lisp and having uniform syntax (sentence), doesn’t have that sort of restrictions.

Metaprogramming
Macro
Uniform Syntax, Forms
Code as Data

Programmable Programming Language

Creation of abstractions

  • Functional 
  • Control
  • Data
  • Class
  • Syntactic

Parameter:
Other languages: Data or Function
Clojure / Lisps: Data or Function or Expression (Forms)

Function: Defined execution model.

Macro:

Large scale development? Reusable libraries and framework? Real world modeling?

Each of the high level functions can be seen as taking inputs and returning output using the same recursive “list” model – functions working as data processors. Study.

Immutability 

  • Efficiency?


Clojure reader

Programming Languages I Am Learning / Working With

  1. C/C++
    • Systems (Linux, Android, Chrome) Programming 
    • Efficiency. Memory manipulation. Complete control over the environment. 
  2. Go 
    • Systems, Concurrent and Networked Programming 
    • Static Typing
    • Faster compilation 
  3. Java 
    • Managed Code
    • Android Application Development
    • Open Source Libraries and Frameworks
  4. Scala 
    • A blend of all the features you ever saw in different languages! 
    • Tries to answer “So, if we want to let programmers implement this feature as language library rather than language syntax, what features do we need to introduce in the language?” 
      • Features:
        • Actors Library 
        • Operators as Functions 
        • Flexible syntax (Prefix, Infix, Postfix mixing) 
      • Makes Scala DSL friendly and “scalable”.
      • Makes the core language small (rest of the features are implemented in the library). Lisp Philosophy. 
    • What happens when you try to fuse OOP and Functional Programming on JVM? 
    • Static Typing and Terse syntax
    • Concurrent and Distributed Programming
  5. Clojure 
    • Lisp on JVM
    • Metaprogramming (Programmable Language) 
    • Functional Programming
    • Concurrent Programming
  6. Python 
    • Rapid Development
    • Open Source Libraries and Frameworks
  7. JavaScript 
    • Web Front-end (with HTML5 & CSS)
    • Object-based Programming 
    • Node.JS
    • Statistical, Numerical Computing 
  8. Haskell
    • Purely Functional Programming
  9. Erlang
    • Fault-tolerant Real-time Parallel Distributed Computing
    • Modifiable without downtime

Current Preference

    If you need complete control over the environment, go down to C++. Otherwise, use Scala, Java, Clojure.