File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Clojure and the fly likes Clojure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Clojure
Bookmark "Clojure" Watch "Clojure" New topic
Author

Clojure

Arjun Shastry
Ranch Hand

Joined: Mar 13, 2003
Posts: 1874
Hi Authors,
What kinds of problems can be easily solved using functional programing language like Clojure but not by imperative languages?
What kind of background is required for learning Clojure?

Thanks


MH
Stian Almaas
Ranch Hand

Joined: Sep 22, 2005
Posts: 33

As far as I can tell, you don't need any special background for learning clojure. It seems like a mathematical mindset would help since the functions in functional programming are quite like mathematical functions.

As for applications suited for FP I understand that computationally heavy domains like human genome sequencing and number crunching in research usually is where you'll find functional programming applied today. I guess that is where the strength is at.

Best regards,
Stian
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

While you can certainly learn Clojure from the scratch, I find have a Lisp background (C Lisp or Scheme) is massively helpful.
I remember that I read "Programming Clojure" first but simply I was scratching my head wondering: what is this?
Not because it is a bad book (later I found it excellent) but Lisp because is alien.
After maybe 6 months or so, I saw "Land of Lisp" book and couldn't resist it !
That book is legendary, it is on my top ten books ever and with it I entered the Lisp land.
Later I reread "Programming Clojure" and every thing started to make sense to me.
Stian Almaas
Ranch Hand

Joined: Sep 22, 2005
Posts: 33

Yep, lisp is very different. But that's also one of the things that is drawing me in.

I've also been drooling at "Land of Lisp" for some time now. I love the humour. We'll see how long it takes before I cave in.
Chris Houser
author
Greenhorn

Joined: Feb 07, 2011
Posts: 22

It's not the case that some problems can only be solved with a functional language. These are all general purpose Turing-complete languages, after all. What's perhaps more interesting then is consider which problems are "better" solved in a functional language, for some measure of "better". Personally I find the biggest wins in code that deals with data -- functions that take data object, do computations, combinations, filtering, and in the end produce new or different data objects. This kind of code is often at the heart of a difficult problem -- the algorithmic core, or the main data-processing code. This is the kind of task where classic mutable objects are the most uncomfortable, where you have to worry about changing collections with iterators are open on them, where you'd like to use parallelism but are afraid to risk the potential deadlocks and race conditions. A functional approach to these tasks can be a real breath of fresh air.

Note that in other parts of a program where Clojure's functional toolset is perhaps less compelling, its macros often step in to still provide benefits compared to some other languages.

As for background, if you already know functional programming or a LISP, Clojure will be easier to pick up than if you don't. That said, I don't see why Clojure's not as good a place to start building such a background as any. :-)
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Stian Almaas wrote:
Yep, lisp is very different. But that's also one of the things that is drawing me in.

I've also been drooling at "Land of Lisp" for some time now. I love the humour. We'll see how long it takes before I cave in.

Get that book, you wont regret it, believe me.
One of the best books you will ever read.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

I think functional programming is used in Artifical intelligenece [AI] WORLD.


Groovy
Michael Fogus
author
Greenhorn

Joined: Feb 07, 2011
Posts: 12

Pradeep bhatt wrote:I think functional programming is used in Artifical intelligenece [AI] WORLD.


As someone who has had one form of AI job or another since 1999, I have to say that I've seen very little functional code in my time. The majority of AI projects that I've seen or worked on have been created using either Java or C++. However, there is a newer wave of AI projects focused on big data processing and statistical methods that I think functional techniques (hint Clojure) are especially suited for.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

In case of clojure , the code gets compiled to .class files.What happens in LISP, is it interpreted langauge ?
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Pradeep bhatt wrote:In case of clojure , the code gets compiled to .class files.What happens in LISP, is it interpreted langauge ?

To be more accurate, Clojure compiles directly to JVM byte.
If you are running your Clojure code, you wont find class files in your directory, every thing is done on the fly unless of course you are forcing compilation:
http://clojure.org/compilation
Michael Fogus
author
Greenhorn

Joined: Feb 07, 2011
Posts: 12

Pradeep bhatt wrote:In case of clojure , the code gets compiled to .class files.What happens in LISP, is it interpreted langauge ?


We have to be careful to lump all Lisps into the generic term LISP. "Lisp" refers to a whole family of languages from Common Lisp to Scheme to Clojure to Dylan and on. There are certainly some Lisps that are interpreted, but Common Lisp in particular is a compiled language.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Clojure