Monday, May 5, 2014

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

No comments:

Post a Comment