SlideShare a Scribd company logo
Scala clojure techday_2011
Functional Programming
          on the JVM with
          Scala and Clojure
            What they are and why you should care


      Cristiano Breuel                         Thadeu Russo
Advisory Software Engineer              Advisory Software Engineer
   (cbreuel@br.ibm.com)                   (thadeurc@br.ibm.com)
Y = λf.(λx.f (x x)) (λx.f (x x))
Y = λf.(λx.f (x x)) (λx.f (x x))
What is functional programming
            about?
Lambda calculus (a.k.a λ-calculus)

  function definition

  function application

  recursion
Scala clojure techday_2011
Referential Integrity

  Avoids state and mutable data

Higher-Order functions:

  Functions can receive and return other
  functions

Lazy Evaluation:

  Evaluate an expression only when
  necessary
Scala clojure techday_2011
Scala clojure techday_2011
Scala clojure techday_2011
Scala clojure techday_2011
Scala clojure techday_2011
Scala clojure techday_2011
Scala clojure techday_2011
FP has been around since the 1950’s

   Why it is becoming more important now?
FP has been around since the 1950’s

   Why it is becoming more important now?
FP has been around since the 1950’s

   Why it is becoming more important now?




                Why should I care?
Because of them...
Because of them...



... the multi-core processors
Because of them...



... the multi-core processors

    (also, to become a smarter
             developer!)
On the other side...
On the other side...


 The JVM is cool!
JVM -> Java Language

Huge investment already on the JVM
(libraries, middleware, performance, GC,
remote communication, etc..)

JVM executes byte-code
The question is:
The question is:


    Why not create new (functional)
     languages on top of the JVM?
Scala clojure techday_2011
(not Closure)
Clojure has...
Clojure has...
... tight integration with the JVM and Java
Clojure has...
... tight integration with the JVM and Java

... compilation for performance
Clojure has...
... tight integration with the JVM and Java

... compilation for performance

... dynamic evaluation
Clojure has...
... tight integration with the JVM and Java

... compilation for performance

... dynamic evaluation

... memory-efficient immutable collections
Clojure has...
... tight integration with the JVM and Java

... compilation for performance

... dynamic evaluation

... memory-efficient immutable collections

... lazy sequences
Clojure has...
... tight integration with the JVM and Java

... compilation for performance

... dynamic evaluation

... memory-efficient immutable collections

... lazy sequences

... primitives for concurrency (STM, agents)
Clojure is a LISP
Clojure is a LISP


  (Lots of (Irritating
(Stupid (Parentheses))))
Clojure is a LISP


  (Lots of (Irritating
(Stupid (Parentheses))))



    a.k.a. List Processing
LISP
LISP


Homoiconicity - code is data
LISP


Homoiconicity - code is data

Macros
LISP


Homoiconicity - code is data

Macros

Multiple dispatch (multi-methods)
Syntax
              Operands
Operator     (arguments)


(str "Hello" "World")

           Expression
           delimiters
Syntax

["red" "green" "blue"]               Array

{:color "blue" :length 2}              Map

:color                             Keyword

#(even? %)               Anonymous function
Higher-Order Functions
Efficient Immutable
    Collections
Lazy Sequences
import java.util.HashMap;
import java.util.Map;



public class ColorMapper {

	   private static String[] COLORS = {"white", "blue"};
	
	   public static Map<String, String> mapLineColors(String[] values) {
	   	   Map<String, String> retVal = new HashMap<String, String>();
	   	   int i = 0;
	   	   for (String value: values) {
	   	   	    retVal.put(value, COLORS[i % COLORS.length]);
	   	   	    i++;
	   	   }
	   	   return retVal;
	   }
	
	   public static void main(String[] args) {
	   	
	   	   String[] values = {"Clojure", "Java", "Scala", "Visual Basic"};
	   	
	   	   System.out.println(mapLineColors(values));
	   }
	
}
Java Integration

(def now (new java.util.Date))

(def now (java.util.Date.))

(. now getTime)

(doto (JFrame.)
  (. add (JLabel. "Hello, Clojure!"))
  (. pack)
  (. show))
sample
Scala
Fast

Functional

Expressive

Statically typed (with type inference)

Concurrent
every value is an object

vals / vars

traits

companion objects

currying

closures / high order functions

pattern matching / case classes

XML literals

Lazy evaluation, and much more...
sample
To sum up...
Scala clojure techday_2011
We cannot choose our problems....

  .... but we can choose our tools.

It is our responsibility to figure out
           the “right” tool.
Even if you can't use
these languages in your
  day job yet, learning
 them will make you a
  better programmer!
References



http://clojure.org/

http://www.scala-lang.org/
Scala clojure techday_2011
Scala clojure techday_2011

More Related Content

What's hot (20)

PDF
Introduction to kotlin
NAVER Engineering
 
PDF
Functional Programming in Scala
Bassam Abd El Hameed
 
PDF
Clojure, Plain and Simple
Ben Mabey
 
PDF
Quick introduction to scala
Mohammad Hossein Rimaz
 
PPT
Oscon keynote: Working hard to keep it simple
Martin Odersky
 
PDF
Scala eXchange opening
Martin Odersky
 
KEY
Scala: functional programming for the imperative mind
Sander Mak (@Sander_Mak)
 
PDF
Functional Programming In Practice
Michiel Borkent
 
PPTX
Scala - The Simple Parts, SFScala presentation
Martin Odersky
 
PPTX
Introduction to Kotlin Language and its application to Android platform
EastBanc Tachnologies
 
PDF
Swift and Kotlin Presentation
Andrzej Sitek
 
PDF
Aggregate Programming in Scala
Roberto Casadei
 
PDF
Weaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
Taro L. Saito
 
PDF
Generics Past, Present and Future
RichardWarburton
 
PDF
scalaliftoff2009.pdf
Hiroshi Ono
 
PPTX
Kotlin presentation
MobileAcademy
 
PPTX
Intro to Akka Streams
Michael Kendra
 
PDF
Generics Past, Present and Future (Latest)
RichardWarburton
 
PPTX
Systematic Generation Data and Types in C++
Sumant Tambe
 
PDF
Collections forceawakens
RichardWarburton
 
Introduction to kotlin
NAVER Engineering
 
Functional Programming in Scala
Bassam Abd El Hameed
 
Clojure, Plain and Simple
Ben Mabey
 
Quick introduction to scala
Mohammad Hossein Rimaz
 
Oscon keynote: Working hard to keep it simple
Martin Odersky
 
Scala eXchange opening
Martin Odersky
 
Scala: functional programming for the imperative mind
Sander Mak (@Sander_Mak)
 
Functional Programming In Practice
Michiel Borkent
 
Scala - The Simple Parts, SFScala presentation
Martin Odersky
 
Introduction to Kotlin Language and its application to Android platform
EastBanc Tachnologies
 
Swift and Kotlin Presentation
Andrzej Sitek
 
Aggregate Programming in Scala
Roberto Casadei
 
Weaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
Taro L. Saito
 
Generics Past, Present and Future
RichardWarburton
 
scalaliftoff2009.pdf
Hiroshi Ono
 
Kotlin presentation
MobileAcademy
 
Intro to Akka Streams
Michael Kendra
 
Generics Past, Present and Future (Latest)
RichardWarburton
 
Systematic Generation Data and Types in C++
Sumant Tambe
 
Collections forceawakens
RichardWarburton
 

Similar to Scala clojure techday_2011 (20)

PDF
Introduction to clojure
Abbas Raza
 
ODP
Clojure
alandipert
 
PDF
I know Java, why should I consider Clojure?
sbjug
 
PDF
Clojure - An Introduction for Lisp Programmers
elliando dias
 
PDF
Why Functional Programming and Clojure - LightningTalk
Jakub Holy
 
PDF
Introduction to Clojure
Renzo Borgatti
 
PPT
Indic threads pune12-polyglot & functional programming on jvm
IndicThreads
 
PDF
Clojure and The Robot Apocalypse
elliando dias
 
ODP
Programming with Freedom & Joy
Hildeberto Mendonça
 
PDF
Clojure
Rohit Vaidya
 
PDF
Clojure talk at Münster JUG
Alex Ott
 
PPTX
Not Everything is an Object - Rocksolid Tour 2013
Gary Short
 
PDF
Clojure - A practical LISP for the JVM
Matthias Nüßler
 
ODP
Getting started with Clojure
John Stevenson
 
KEY
Polyglot and functional (Devoxx Nov/2011)
Martijn Verburg
 
PDF
Seeking Clojure
chrisriceuk
 
ODP
Clojure made simple - Lightning talk
John Stevenson
 
ODP
Clojure made really really simple
John Stevenson
 
PDF
Clojure intro
Basav Nagur
 
PPTX
All about scala
Yardena Meymann
 
Introduction to clojure
Abbas Raza
 
Clojure
alandipert
 
I know Java, why should I consider Clojure?
sbjug
 
Clojure - An Introduction for Lisp Programmers
elliando dias
 
Why Functional Programming and Clojure - LightningTalk
Jakub Holy
 
Introduction to Clojure
Renzo Borgatti
 
Indic threads pune12-polyglot & functional programming on jvm
IndicThreads
 
Clojure and The Robot Apocalypse
elliando dias
 
Programming with Freedom & Joy
Hildeberto Mendonça
 
Clojure
Rohit Vaidya
 
Clojure talk at Münster JUG
Alex Ott
 
Not Everything is an Object - Rocksolid Tour 2013
Gary Short
 
Clojure - A practical LISP for the JVM
Matthias Nüßler
 
Getting started with Clojure
John Stevenson
 
Polyglot and functional (Devoxx Nov/2011)
Martijn Verburg
 
Seeking Clojure
chrisriceuk
 
Clojure made simple - Lightning talk
John Stevenson
 
Clojure made really really simple
John Stevenson
 
Clojure intro
Basav Nagur
 
All about scala
Yardena Meymann
 
Ad

Recently uploaded (20)

PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Ad

Scala clojure techday_2011

Editor's Notes

  • #2: \n
  • #3: Thadeu e Cristiano: Apresenta&amp;#xE7;&amp;#xE3;o dos palestrantes\n
  • #4: Thadeu: Apenas assustar o pessoal - dizer que precisamos antes entender o combinador Y\n
  • #5: Thadeu: slide apenas de passagem, sem muitos comentarios.\n
  • #6: Thadeu: basicamente ler o slide.\n
  • #7: Thadeu: da wikipedia: is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data.\nenfatiza a aplicacao de funcoes ao contrario da mudanca de estado, como eh feito em linguagens interativas\n
  • #8: Thadeu: Parar em visual F# - lembrar de chamar aten&amp;#xE7;&amp;#xE3;o para sql e spredsheets\n
  • #9: Thadeu: Parar em visual F# - lembrar de chamar aten&amp;#xE7;&amp;#xE3;o para sql e spredsheets\n
  • #10: Thadeu: Parar em visual F# - lembrar de chamar aten&amp;#xE7;&amp;#xE3;o para sql e spredsheets\n
  • #11: Thadeu: Parar em visual F# - lembrar de chamar aten&amp;#xE7;&amp;#xE3;o para sql e spredsheets\n
  • #12: Thadeu: Parar em visual F# - lembrar de chamar aten&amp;#xE7;&amp;#xE3;o para sql e spredsheets\n
  • #13: Thadeu: Parar em visual F# - lembrar de chamar aten&amp;#xE7;&amp;#xE3;o para sql e spredsheets\n
  • #14: Thadeu: intrigar a plateia - perguntar se alguem sabe e nao deixar responder - comentar que as linguagens sempre foram vistar como muito teoricas para o mundo n&amp;#xE3;o academico\n
  • #15: Thadeu: intrigar a plateia - perguntar se alguem sabe e nao deixar responder - comentar que as linguagens sempre foram vistar como muito teoricas para o mundo n&amp;#xE3;o academico\n
  • #16: Thadeu: discutir um pouco os detalhes tecnicos do impacto\n
  • #17: Thadeu: discutir um pouco os detalhes tecnicos do impacto\n
  • #18: Thadeu passa para Cristiano.\n
  • #19: Cristiano:\n
  • #20: Cristiano:\n
  • #21: Cristiano:\n
  • #22: Cristiano:\n
  • #23: Cristiano:\n
  • #24: Cristiano:\n
  • #25: Cristiano:\n
  • #26: Cristiano:\n
  • #27: Cristiano:\n
  • #28: Cristiano:\n
  • #29: Cristiano:\n
  • #30: Cristiano:\n
  • #31: Cristiano:\n
  • #32: Cristiano:\n
  • #33: Cristiano:\n
  • #34: Cristiano:\n
  • #35: \n
  • #36: \n
  • #37: \n
  • #38: \n
  • #39: \n
  • #40: Thadeu: Comentar cada um dos itens acima (dizer tbm q eh menos verborragica que java) - veremos exemplo\n
  • #41: Thadeu: ir para o repl e fazer alguns exemplos destes caras\nval\nfunction as objects\nreduceLeft - usar as chaves e fazer o currying\n\n\nsobre a parte de lazy - comentar que nao existem lazy collections assim como em haskell ou closure, porem\nda para criar metodos que fazer conversoes de modo lazy (usando iteradores)\n
  • #42: Thadeu: Converter codigo java para scala\n
  • #43: \n
  • #44: \n
  • #45: \n
  • #46: \n
  • #47: \n
  • #48: \n
  • #49: \n