This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Make what simple?

 
Runrioter Wung
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have never learnt Clojure and just heard about it.And I know it is the same as Java based on JVM.I doubt how Clojure makes a difference. Compared with Java or other languages based on JVM? And make what simple?
Looking forward to your reply.
 
Chris Devine
Greenhorn
Posts: 3
Clojure Linux Mac
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clojure is a functional programming language and a derivative of Lisp. As a result of its functional and declarative nature it can be difficult to understand for those (like me) coming from an object-oriented/imperative programming background.

The most obvious difference is the syntax of its functions. As a Lisp it uses Polish or prefix notation. This allows an arbitrary number of arguments to be passed to any function (which must be the first item in a list). For example, the addition operator '+' only needs to be given once as the first argument in a list and it can take any number of other arguments to add:
=> (+ 1 2 3 4 5)
15

In Java you would have to use the '+' operator between every value being added:
int sum = 1 + 2 + 3 + 4 + 5;

You can also pass functions as arguments to other functions, since Clojure views data as code and code as data. I won't try to explain all the implications of this statement, but it's crucial for understanding functional programming.
 
Runrioter Wung
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chris Devine wrote:Clojure views data as code and code as data.

Amazing!Thanks for your reply.
 
chris webster
Bartender
Pie
Posts: 2359
31
Linux Oracle Postgres Database Python Scala
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Simple" is an important concept in Clojure-land, so you might like to check out Rich Hickey's now famous talk "Simple Made Easy" http://www.infoq.com/presentations/Simple-Made-Easy-QCon-London-2012

There's also an interesting (and IMO quite persuasive) explanation of why Rich Hickey created Clojure on the Clojure.org website: http://clojure.org/rationale

Finally, you might also be interested in Neal Ford's talk on "Functional Thinking" and why it's important: http://www.infoq.com/presentations/Functional-Thinking
 
John Stevenson
author
Greenhorn
Posts: 7
5
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Runrioter Wung wrote:I have never learnt Clojure and just heard about it.And I know it is the same as Java based on JVM.I doubt how Clojure makes a difference. Compared with Java or other languages based on JVM? And make what simple?
Looking forward to your reply.


As others have mentioned here, although both Clojure and Java run on the Java Virtual Machine (JVM), the are both very different languages in terms of syntax and paradigm. Java is a procedural language based on OOP and Clojure is a declarative language based on functional programming.

Clojure encourages you to create code where you do not change state (immutable variables) as in this way it is simpler to write applications that scale through parallelism. This is one reason why Clojure is great for working with big data sets. As Clojure is dynamically typed, it also means it is great for working with very adhoc and unstructured data sets (unfortunately which most data sets are).

The great thing about both languages running on the JVM is that its pretty easy to call code written in Java from code written in Clojure (and vice versa). So you dont have to throw away any Java code you already have (unless you want to).

What am I trying to make simple with the book? I hopefully have made it easier to understand the value of Clojure and give developers new to the language a good kickstart. I have kept the book "simple" so that this can be done relatively quickly.

Thanks
John Stevenson
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic