SlideShare ist ein Scribd-Unternehmen logo
1 von 56
Didn’t code in ages.
HaXe got in the way.




                       LISP
or how I learned to stop worrying and
           love parentheses
; Clojure - a new dialect of LISP

(defn hello [name]
 (println "Hello," name, "!"))

(hello "TryHarder")
but we’re going to talk about more
           than just LISP
what is functional programming?
the history of functional programming
why did functional programming
  become so popular (again)?
or commonly used OO




              the differences between FP and
                 imperative programming
analyze the current usage of
 object-oriented languages
accidental complexity
let’s have a look at object-oriented
programming languages and their
        programming model
there are lots and lots of object-oriented
           languages out there
JAVA
  C#
  AS3
HaXe
Python
 Ruby
  PHP
   ...
but actually they aren’t really that
             different
similar features:
Still we have religious
fights about them!




                                Classes
                             Inheritance
                            Polymorphism
                               Closures
                              imperative
                                   ...
Still we have religious
fights about them!




                          slightly different styles:
                                   Indentation
                                   Semicolons
                                 Syntactic sugar
                                       ...
is this the holy grail of programming?
are we done?
accidental complexity
   “Accidental complexity is complexity that arises in
computer programs or their development process which
  is non-essential to the problem to be solved. While
    essential complexity is inherent and unavoidable,
accidental complexity is caused by the approach chosen
                 to solve the problem.”
Causes side effects
Factories or Dependency


                          variables vs. values
Injection are a sign of
Accidental Complexity




                          class Rhino
                          {
                          	

 private var _position:Point;

                          	

   public function Rhino(position:Point)
                          	

   {
                          	

   	

 _position = position;
                          	

   	

 or
                          	

   	

 _position = position.clone();
                          	

   }
                          }
Side effects

Everyone needs to
observe everyone.   observers / dispatching events
The environment stops
when observing it.




                    var rhino:Rhino = new Rhino();
                    var water:Water = new Water();
                    rhino.addEventlistender(Event.RHINO_JUMP, water.splash);
mutability and state


Mutability and state are accidental complexity.
We are to familiar with
OO to see the problems.




        Most programmers see syntax and and expressivity as the key features
                           in a programming language.

        Whereas we really run into problems understanding larger applications
         and also the effect that changes will take are very hard to predict.
A builder doesn’t need to


                                       building blocks
know what happens
inside a brick.

Pointers in C




                   Object-oriented programming/design is meant to simplify our
                  lives by using object-oriented modules/libraries as our building
                                      blocks for our program.

                      But without knowing the internals this is almost impossible.

                            (Pure) Functions are a far better fit for this purpose.
“Civilization advances by extending the
number of important operations which
   we can perform without thinking.”
         Alfred North Whitehead
now imagine you don’t know
       anything about
object-oriented programming
the history of functional-programming
Math theory:
Definition of functions
Their application

Functional languages
were developed to have a
clearer approach to
mathematics




                                lambda calculus
                           by Alonzo Church in 1930
functional-programming languages

          1959 	

   Lisp
          1975 	

   ML, FP, Scheme
          1986 	

   Standard ML
          1990 	

   Haskell, Erlang
          2000 	

   OCaml
          2003 	

   Scala
          2005 	

   F#
          2007 	

   Clojure
what is functional-programming?
They talk about
algorithms, ds, recursion,
scope ... on page 216
they introduce
ASSIGNEMENT

Available for free online.
In a restricted sense: functional programming means
programming without mutable variables, assignments, loops
            or imperative control structures.
In a wider sense: functional programming means to focus on functions.
In particular: functions can be values that are produced,
           can be consumed and composed.
what is essential in a language
for functional programming?
higher-order function


It has to be possible to use functions as in input or return values in other
                                 functions
function curryMe(input:Function):Function
{
	

 return curry(input, 2);
}
first-class functions


It has to be possible to declare functions anywhere, even inside other functions
function outerFunction():int
{
	

 function innerFunction():int
	

 {
	

 	

 return 0;
	

 }
	

 return innerFunction();
}
recursion


It has to be possible to call functions recursively
function sum(xs:Array):int
{
	

 if(xs.length == 0) return 0;
	

 return xs.shift() + sum(xs);
}
pure functions

    Take and/or return values
   Local scope: no side effects
  Same arguments: same result
Easy to understand, change & test
function pure(x:int, y:int):int
{
	

 return x + y;
}

var _y:int = 1000;
function notPure(x:int):int
{
	

 return x + _y;
}
No classes, what types


                           data-structures
do we have??

Just use basic types
(Lists) and operate on
them.

Basically the same as we
already.

Code == Data



           "It is better to have 100 functions operate on one data
           structure than to have 10 functions operate on 10 data
                           structures." - Alan J. Perlis
why did functional-programming did
become so popular (again) recently?
Clojure
 F#
 Scala




new functional-programming languages
     are popping up left and right
Clojure
F#
Scala




          Moores law
Single-Threaded clock
speed has stalled.
Number of cores
increases.
In a couple of years we
will have laptops with
32 or 64 cores.
examples
//AS3
a + b;
a * b;

;Clojure
(+ a b)
(* a b)
//AS3
Math.max(a, b);

;Clojure
(max a b)
//AS3
function add(x:int,y:int):int
{
  return x + y;
}

;Clojure
(defn add [x, y]
 (+ x y))
//AS3
function fibonacci( a:int ):int
{
  if( a == 0 || a == 1 )
    return a;
  else
    return fib( a - 1 ) + fib( a - 2 );
}
;Clojure
(defn fib [n]
   (if (= n 0) 0
       (if (= n 1) 1
           (+ (fib (- n 1)) (fib (- n 2))))))
;Clojure - whole fibonacci sequence
(defn lazy-seq-fibo
   ([]
       (concat [0 1] (lazy-seq-fibo 0 1)))
   ([a b]
       (let [n (+ a b)]
          (lazy-seq
              (cons n (lazy-seq-fibo b n))))))
(defn neighbours [[x y]]
 (for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])]
   [(+ dx x) (+ dy y)]))

(defn step [cells]
 (set (for [[loc n] (frequencies (mapcat neighbours cells))
         :when (or (= n 3) (and (= n 2) (cells loc)))]
      loc)))
Runs on the JVM

Interoperability with
Java libraries




                        why clojure?

Weitere ähnliche Inhalte

Was ist angesagt?

あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法x1 ichi
 
How to write a TableGen backend
How to write a TableGen backendHow to write a TableGen backend
How to write a TableGen backendMin-Yih Hsu
 
Scala Refactoring for Fun and Profit
Scala Refactoring for Fun and ProfitScala Refactoring for Fun and Profit
Scala Refactoring for Fun and ProfitTomer Gabel
 
Live coding scala 'the java of the future'
Live coding scala 'the java of the future'Live coding scala 'the java of the future'
Live coding scala 'the java of the future'Xebia Nederland BV
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming LangugeYaser Jaradeh
 
Practical REPL-driven Development with Clojure
Practical REPL-driven Development with ClojurePractical REPL-driven Development with Clojure
Practical REPL-driven Development with ClojureKent Ohashi
 
Weaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
Weaving Dataflows with Silk - ScalaMatsuri 2014, TokyoWeaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
Weaving Dataflows with Silk - ScalaMatsuri 2014, TokyoTaro L. Saito
 
The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of FlatteryJosé Paumard
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationMartin Odersky
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John StevensonJAX London
 
Speaking Scala: Refactoring for Fun and Profit (Workshop)
Speaking Scala: Refactoring for Fun and Profit (Workshop)Speaking Scala: Refactoring for Fun and Profit (Workshop)
Speaking Scala: Refactoring for Fun and Profit (Workshop)Tomer Gabel
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and SimpleBen Mabey
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines Parashuram N
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdbWei-Bo Chen
 
re-frame à la spec
re-frame à la specre-frame à la spec
re-frame à la specKent Ohashi
 
"Simple Made Easy" Made Easy
"Simple Made Easy" Made Easy"Simple Made Easy" Made Easy
"Simple Made Easy" Made EasyKent Ohashi
 
JDK8 Functional API
JDK8 Functional APIJDK8 Functional API
JDK8 Functional APIJustin Lin
 
Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformEastBanc Tachnologies
 
DevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programmingDevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programmingHenri Tremblay
 

Was ist angesagt? (20)

あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法あなたのScalaを爆速にする7つの方法
あなたのScalaを爆速にする7つの方法
 
How to write a TableGen backend
How to write a TableGen backendHow to write a TableGen backend
How to write a TableGen backend
 
Scala Refactoring for Fun and Profit
Scala Refactoring for Fun and ProfitScala Refactoring for Fun and Profit
Scala Refactoring for Fun and Profit
 
Live coding scala 'the java of the future'
Live coding scala 'the java of the future'Live coding scala 'the java of the future'
Live coding scala 'the java of the future'
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming Languge
 
Practical REPL-driven Development with Clojure
Practical REPL-driven Development with ClojurePractical REPL-driven Development with Clojure
Practical REPL-driven Development with Clojure
 
Weaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
Weaving Dataflows with Silk - ScalaMatsuri 2014, TokyoWeaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
Weaving Dataflows with Silk - ScalaMatsuri 2014, Tokyo
 
The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of Flattery
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
Java Full Throttle
Java Full ThrottleJava Full Throttle
Java Full Throttle
 
Clojure made-simple - John Stevenson
Clojure made-simple - John StevensonClojure made-simple - John Stevenson
Clojure made-simple - John Stevenson
 
Speaking Scala: Refactoring for Fun and Profit (Workshop)
Speaking Scala: Refactoring for Fun and Profit (Workshop)Speaking Scala: Refactoring for Fun and Profit (Workshop)
Speaking Scala: Refactoring for Fun and Profit (Workshop)
 
Clojure, Plain and Simple
Clojure, Plain and SimpleClojure, Plain and Simple
Clojure, Plain and Simple
 
Understanding Javascript Engines
Understanding Javascript Engines Understanding Javascript Engines
Understanding Javascript Engines
 
Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdb
 
re-frame à la spec
re-frame à la specre-frame à la spec
re-frame à la spec
 
"Simple Made Easy" Made Easy
"Simple Made Easy" Made Easy"Simple Made Easy" Made Easy
"Simple Made Easy" Made Easy
 
JDK8 Functional API
JDK8 Functional APIJDK8 Functional API
JDK8 Functional API
 
Introduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platformIntroduction to Kotlin Language and its application to Android platform
Introduction to Kotlin Language and its application to Android platform
 
DevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programmingDevNexus 2018: Learn Java 8, lambdas and functional programming
DevNexus 2018: Learn Java 8, lambdas and functional programming
 

Ähnlich wie LISP: How I Learned To Stop Worrying And Love Parantheses

ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyTypesafe
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypseelliando dias
 
About Functional Programming
About Functional ProgrammingAbout Functional Programming
About Functional ProgrammingAapo Kyrölä
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of JavascriptSamuel Abraham
 
Domain specific languages and Scala
Domain specific languages and ScalaDomain specific languages and Scala
Domain specific languages and ScalaFilip Krikava
 
Fp for the oo programmer
Fp for the oo programmerFp for the oo programmer
Fp for the oo programmerShawn Button
 
Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Ralf Laemmel
 
Go Beyond Higher Order Functions: A Journey into Functional Programming
Go Beyond Higher Order Functions: A Journey into Functional ProgrammingGo Beyond Higher Order Functions: A Journey into Functional Programming
Go Beyond Higher Order Functions: A Journey into Functional ProgrammingLex Sheehan
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional ProgrammingJordan Parmer
 
Scala: functional programming for the imperative mind
Scala: functional programming for the imperative mindScala: functional programming for the imperative mind
Scala: functional programming for the imperative mindSander Mak (@Sander_Mak)
 
Introduction to scala for a c programmer
Introduction to scala for a c programmerIntroduction to scala for a c programmer
Introduction to scala for a c programmerGirish Kumar A L
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийSigma Software
 
Functional programming is the most extreme programming
Functional programming is the most extreme programmingFunctional programming is the most extreme programming
Functional programming is the most extreme programmingsamthemonad
 
Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)Konstantin Haase
 
Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsAjax Experience 2009
 

Ähnlich wie LISP: How I Learned To Stop Worrying And Love Parantheses (20)

ScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin OderskyScalaDays 2013 Keynote Speech by Martin Odersky
ScalaDays 2013 Keynote Speech by Martin Odersky
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypse
 
About Functional Programming
About Functional ProgrammingAbout Functional Programming
About Functional Programming
 
Knowledge of Javascript
Knowledge of JavascriptKnowledge of Javascript
Knowledge of Javascript
 
Domain specific languages and Scala
Domain specific languages and ScalaDomain specific languages and Scala
Domain specific languages and Scala
 
Fp for the oo programmer
Fp for the oo programmerFp for the oo programmer
Fp for the oo programmer
 
Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)Functional OO programming (as part of the the PTT lecture)
Functional OO programming (as part of the the PTT lecture)
 
Presentation
PresentationPresentation
Presentation
 
Java
JavaJava
Java
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
 
Go Beyond Higher Order Functions: A Journey into Functional Programming
Go Beyond Higher Order Functions: A Journey into Functional ProgrammingGo Beyond Higher Order Functions: A Journey into Functional Programming
Go Beyond Higher Order Functions: A Journey into Functional Programming
 
Clojure
ClojureClojure
Clojure
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional Programming
 
Scala: functional programming for the imperative mind
Scala: functional programming for the imperative mindScala: functional programming for the imperative mind
Scala: functional programming for the imperative mind
 
Introduction to scala for a c programmer
Introduction to scala for a c programmerIntroduction to scala for a c programmer
Introduction to scala for a c programmer
 
Javascript
JavascriptJavascript
Javascript
 
LISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола МозговийLISP: назад в будущее, Микола Мозговий
LISP: назад в будущее, Микола Мозговий
 
Functional programming is the most extreme programming
Functional programming is the most extreme programmingFunctional programming is the most extreme programming
Functional programming is the most extreme programming
 
Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)Beyond Ruby (RubyConf Argentina 2011)
Beyond Ruby (RubyConf Argentina 2011)
 
Douglas Crockford Presentation Goodparts
Douglas Crockford Presentation GoodpartsDouglas Crockford Presentation Goodparts
Douglas Crockford Presentation Goodparts
 

LISP: How I Learned To Stop Worrying And Love Parantheses

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n