• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Thinking functionally

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys!

I've been looking into clojure a little bit now and I find it fascinating but also hard. After basically twenty years of imperative programming it's really hard to change my way of thinking to solve problems effectively in clojure. What I need is basically a how-to in functional programming. How do you attack a problem when thinking functionally, that's what I'm struggling with.

Do any of you guys know of any resources that can help me with that. I'm thinking perhaps the clojure koans on github are a bit like that, but I haven't had time to look at that yet.

Regards,
Stian
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although I haven't done them all, I think that the github exercises are more focused on the core syntax and api, rather than anything else.
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to check http://codingkata.org/ and the Euler Project also.
I didn't get the functional thinking (yet) but I think it started to tickle my mind a little bit.
My suggestion is if you already know Java and want to start being functional, I recommend you play with Scala for many reasons:
1. The syntax is really similar to Java (to some degree).
2. Scala blending OOP and FP, you don't have to change your mind set instantly.
 
author
Posts: 22
VI Editor Clojure Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made the jump from imperative to functional programming while solving Project Euler problems. They're fun and I continue to recommend them. They start start simple and get harder, while never really demanding you learn a lot of miscellaneous library functions (for networking, databases, GUIs, etc.) as you might for any "real world" project you might use as a learning vehicle. This keeps them relatively approachable.

Also, lots of other people have gone there before and once you've solved a particular problem you can check and see how others have solved it. This will help you learn even faster, giving you ideas to solve the next harder problem.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Chris Houser wrote:I made the jump from imperative to functional programming while solving Project Euler problems. Also, lots of other people have gone there before and once you've solved a particular problem you can check and see how others have solved it.


This looks interesting, unless you hate mathematics :)
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm planning to read "Real World Haskell" to learn much more about FP when I get some time:
http://book.realworldhaskell.org/
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

John Todd wrote:I'm planning to read "Real World Haskell" to learn much more about FP when I get some time:
http://book.realworldhaskell.org/


Personally I find it confusing to study several of these languages. They look similar from the outside, but have their own notation and api. If there were something else that I'd look for, it'd be Lisp (Practical Common Lisp)
 
Rancher
Posts: 352
21
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Christophe Verré wrote:Personally I find it confusing to study several of these languages. They look similar from the outside, but have their own notation and api.



Then I suspect you wouldn't vote for Bruce Tate's "Seven Languages in Seven Weeks"? I found it an excellent way to learn enough of several different languages in a short space of time - and be challenged to "think different".

Caveat: I got into functional programming back in the early/mid 80's, then picked up Prolog, then C and later got into OOP (with C++ in '92 and Java in '97) so my view of all this may be very different to a lot of Java developers.

I'm very pleased to see functional programming becoming mainstream with increased interest in Haskell and Lisp as well as solid options on the JVM in the form of Clojure and Scala.
 
author
Posts: 12
Monad BSD Clojure
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sean Corfield wrote:I'm very pleased to see functional programming becoming mainstream with increased interest in Haskell and Lisp as well as solid options on the JVM in the form of Clojure and Scala.



Further, functional techniques and features are finding their way into mainstream languages like C#, Javascript, and (to some extent) Java.
 
Stian Almaas
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wanted to send a thank you to Mr. Houser. I have done a few of the Euler problems before but now I have studied example solutions provided in LISP and that's been a real eye opener!

I just did problem 2 with a loop recur to generate fibonacci numbers. Yay me!

Thanks again, Chris!
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding exercises - there are also 99 Lisp problems
 
Ranch Hand
Posts: 222
Google Web Toolkit Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try getting any university materials that teach about functional programming, cause even if the language is different, the concepts are the same. We've been learning SML in our university, however I am sure I after learning the syntax, I could equally well program in Clojure or any other functional language.
 
Greenhorn
Posts: 4
Scala Clojure Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out

http://4clojure.com

It's an addictive site with a ton of Clojure challenges.
 
Ranch Hand
Posts: 98
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classic college text for learning to think functionally is "Structure and Interpretation of Computer Programs" by Harold Abelson and Gerald Sussman. They use the Scheme dialect of Lisp in their book. There are also videos on YouTube of the course taught by Abelson and Sussman, which are worth taking a look at.
 
Ranch Hand
Posts: 100
VI Editor Chrome Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Kurt Van Etten wrote:The classic college text for learning to think functionally is "Structure and Interpretation of Computer Programs" by Harold Abelson and Gerald Sussman. They use the Scheme dialect of Lisp in their book. There are also videos on YouTube of the course taught by Abelson and Sussman, which are worth taking a look at.



There is also a Cal Berkeley course teaching SICP http://www-inst.eecs.berkeley.edu/~cs61a/sp11/ with several years worth of lectures available on YouTube.
I was happy to try just now clojure koans and 4clojure.com but getting strange results with examples, f.e. false on (= (- 10 (* 2 3)) 4) on 4clojure, while (= false (= 2.0 2)) is seemingly accepted in the koans.
 
Stian Almaas
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Matthew Lucas wrote:Check out

http://4clojure.com

It's an addictive site with a ton of Clojure challenges.



Thanks Matthew. I believe I have heard of it before but you made me go over and have a look. Great fun!
 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic