• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

Make what simple?

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 3
Mac Clojure Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chris Devine wrote:Clojure views data as code and code as data.


Amazing!Thanks for your reply.
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 7
5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 don't like that guy. The tiny ad agrees with me.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic