1. Why would someone learn Clojure ?
Jan Herich
2014-08-28 Thu
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 1 / 14
2. Outline
1 Motivation to go functional
2 Doubts & Fears
3 Reaping benefits of functional approach
4 Is switch to new language really necessary ?
5 Where to start
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 2 / 14
3. Motivation to go functional
Obvious reasons
You already know Ruby, Python or Java very well, but you
probably noticed that there is a lot of buzz about FP languages
today
You are curious about any new technology on the horizon
You are perfectionist, never really satisfied, always trying to do
better
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 3 / 14
4. Motivation to go functional
Less obvious reasons
To step out of you comfort zone, to challenge yourself
This is of course not exclusive to OOP -> FP transition
It’s valid every time you learn something really new
The first point is more important then most people realize, as
it’s sort of mental exercise which will broaden your horizons and
improve your cognitive skills
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 4 / 14
5. Doubts & Fears
I will loose too much by abandoning OOP
FP seems to be approach best suited for limited class of
problems, with serious deficiencies for general purpose
programming
Is there some way to implement run-time polymporhism ?
What about class hierarchies ?
I will have to switch contexts very often
Is it possible to use FP for interactive UI at all ?
What about performance critical parts of the code ?
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 5 / 14
6. Doubts & Fears
IDE options for Clojure in suck in general
True, but it’s getting better pretty fast
very good support for Clojure in IntelliJ (as Cursive plugin)
abandoned development of Counterclockwise eclipse plugin :/
But most important, there are better options then classic IDEs
Fantastic Emacs support, almost always up-to date with big and
active contributors comunity
Only slightly less amazing VIM support as a FirePlace plugin :)
More radical and innovative approaches to development
environment in the form of LightTable editor and graphical
REPLs such as Gorilla REPL
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 6 / 14
7. Doubts & Fears
Is it worth investing my time ?
It’s nice to learn something new, but it takes a lot of time to
familiarize yourself with a new programming language, especially
if it’s an ’alien’ one
There is nothing wrong with questioning the cost-effectiveness
of such investment, especially if you don’t have much free time
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 7 / 14
8. Doubts & Fears
Does anybody really use FP ?
At 28. August 2014, i opened profesia.sk and searched for
’Clojure’, i got exactly zero results :)
But it get’s a lot better when you consider remote working, with
sites as functionaljobs.com offering Clojure/Haskell jobs with
increasing tendency
Active Clojure community worldwide (Around 300 attendees at
EuroClojure 2014 in Krakow)
Clojure meetup group in Vienna since April 2014 (20-30 active
members)
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 8 / 14
9. Reaping benefits of functional approach
In the beginning it won’t be easy
Learning basic FP techniques as passing functions around,
composing them, building abstractions with partial functions and
learning to leverage higher-order functions can be tough, but it’s
very rewarding and fun at the same time
After those baby steps, you will probably struggle with general
layout of an application once you start to build something bigger
Don’t panic, it’s just because the class hierarchy you are so
accustomed to is not there anymore
As strange as it sounds, you will get used to it and after a while,
you won’t miss it at all
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 9 / 14
10. Reaping benefits of functional approach
But then later at some point, you will realize
One whole class of problems basically disappears
Incidental complexity resulting from no separation of identity
and state goes away
This could be reasonable source of complexity for bigger OOP
programs, even worse if you start to use multiple threads
Refactoring of functional code is much easier
Even harmless local state could become a problem in that case,
ever forgot to increment some counter, set some flag ?
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 10 / 14
11. Is switch to new language really necessary ?
Why not only adopt ’good parts’ of FP ?
It seems to be a wise idea to adopt only ’good parts’ of FP into
your favorite language you are already proficient with
Many people already do and you will find a lot of libraries or
even core language features slowly slipping into ’mainstream’
OOP languages - such as lambda expressions in Java or
Hamster- immutable data-structure library for Ruby
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 11 / 14
12. Is switch to new language really necessary ?
Why not only adopt ’good parts’ of FP ?
Unfortunately, there are many problems with that approach
Features are only added slowly and there is sometimes lack of
coherence as the ’old way’ of doing things is almost always
retained to ensure backwards compatibility
This is the reason why functional features/additions sometimes
feels ’bolted on’
Even if we don’t mind those minor technical details, there is still
biggger social problem - most of the community is slow to
embrace those features
If you work with more developers, you can be sure that whenever
you will push for those features, there will be arguing and lack of
common idiomatic approach
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 12 / 14
13. Where to start
Resources & Tutorials
Official Clojure site: http://clojure.org
Very approachable tutorial series for beginners by Daniel
Higginbotham: http://www.braveclojure.com/
Beginner-friendly Clojure programming workshops for women:
http://www.clojurebridge.com
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 13 / 14
14. Where to start
Some interesting videos about FP and Clojure
Tim Ewald - Clojure: Programming with Hand Tools:
https://www.youtube.com/watch?v=ShEez0JkOFw
Stuart Halloway - Narcissistic Design:
http://vimeo.com/77199361
Rich Hickey- Clojure Concurrency:
https://www.youtube.com/watch?v=dGVqrGmwOAw&index=
3&list=PLZdCLR02grLrEwKaZv-5QbUzK0zGKOOcr
Jan Herich Why would someone learn Clojure ? 2014-08-28 Thu 14 / 14