SlideShare uma empresa Scribd logo
1 de 34
Not Everything is an Object

        By Gary Short
      Gibraltar Software
What this Session is not…
• OO hating
• Deep dive of Clojure
• If you’ve written a Clojure App, you’ll probably
  not learn anything.
What this Session is…
• Point out why OO dev is hard sometimes
• Show you that there is an alternative
• “It shouldn’t be this hard”.
Introduction
• Gary Short
• Head of Gibraltar Labs
  – “Skunk Works” division of Gibraltar Software
• MVP C#
  – Python
  – NodeJS
• gary.short@gibraltarsoftware.com
• @garyshort
• Facebook.com/theOtherGaryShort

                                                   4
The Road to Here




http://www.flickr.com/photos/fyngyrz/
Ada Lovelace
• 1842 - 1843 Lovelace translated a memoir of
  an Italian mathematician on Charles Baggage’s
  newest proposed machine... the Analytical
  Engine. The article she wrote contained the
  entire specification of how to calculate
  Bernoulli numbers with the Engine. This is
  believed to be the first ever computer
  program.
The 1940s
• Then in the 1940’s along comes the first
  recognisable computers and we get
  programming languages to go with them...

• 1943 - Plankalkül (Konrad Zuse)
• 1943 - Colossus
• 1949 - C-10
The 1950s
• In the 1950s the first three modern programming
  languages whose descendants are still in
  widespread use today were designed:
• FORTRAN (1955), the "FORmula
  TRANslator", invented by John Backus et al.;
• LISP, the "LISt Processor", invented by John
  McCarthy et al.;
• COBOL, the COmmon Business Oriented
  Language, created by the Short Range
  Committee, heavily influenced by Grace Hopper.
More 1950s
•   1951 - Regional Assembly Language
•   1952 - Autocode
•   1954 - FORTRAN
•   1954 - IPL (forerunner to LISP)
•   1955 - FLOW-MATIC (forerunner to COBOL)
•   1957 - COMTRAN (forerunner to COBOL)
•   1958 - LISP
•   1958 - ALGOL 58
•   1959 - FACT (forerunner to COBOL)
•   1959 - COBOL
The 1960s
•   1962 - APL
•   1962 - Simula
•   1964 - BASIC
•   1964 - PL/I
The 1970s
•   1970 - Pascal
•   1970 - Forth
•   1972 - C
•   1972 - Smalltalk
•   1972 - Prolog
•   1973 - ML
•   1975 - Scheme
•   1978 - SQL
The 1980s
•   1983 - Ada
•   1983 - C++
•   1985 - Eiffel
•   1986 - Erlang
•   1987 - Perl
•   1989 - FL
The 1990s
•   1990 - Haskell
•   1991 - Python
•   1991 - Java
•   1993 - Ruby
•   1993 - Lua
•   1994 - ANSI Common Lisp
•   1995 - JavaScript
•   1995 - PHP
•   1997 - Rebol
Where we are Now




 http://www.flickr.com/photos/gtarded/
What OOP/D is Good For




   http://www.flickr.com/photos/gserafini/
What is it Not Good For?




  http://www.flickr.com/photos/aloshbennett/
Also, we really suck at OOM…
Also hierarchies are brittle…
Also, OOPs get complex real fast…
The Solution
What Does it Mean to be Functional?
•   First order functions
•   Function like constructs
•   Stateless
•   Immutable data
Clojure
• A Lisp                 •   JVM
• Dynamic                •   Java Interop
• Functional             •   Fast
   – Impure              •   Persistent collections
• “Lockless” Concurrency •   Easy to learn.
• Macros
Introduction to Clojure
•   Java.Lang.Object
•   Arbitrary sized numbers
•   Ratios: 18/20
•   Nil is null and is treated as false
Persistent Collections
• Immutable
  – Cheap to copy
• Examples
  – (1 2 3)
     • List – sequential lookup time
  – [1 2 3]
     • Vector – logarithmic lookup time
  – {“key” 1, 3 7, “foo” “bar”}
     • Hashmap – unordered, key value pairs
Equality Vs Identity
• Equality
  – Two objects are equal
     • Two cylinders maybe equal if their volumes are equal
  – Identity
     • Two pointers to the same object
  – Clojure favours equality :-O
Clojure is Impure so has Mutability
• Var
    – Mutable pointer to immutable data
        • You can’t change the data
        • But you can change what data the var points to
•   But vars hold global data, function defs etc .
•   This data won’t change
•   So why are vars mutable?
•   So we can patch running software. 
The Reader
• Other programming languages
  – Compiler
     • Text -> lexing and parsing -> AST
• Clojure
  – The Reader
     • Text -> lexing and parsing -> Literals (Data)
     • As soon as it reads a complete literal it’s passed to...
The Evaluator
• Compile Phase
  – Traverses the data
     • Symbol evaluation
         – Symbols evaluate into Vars
             » Symbol Dog evaluates to a var in the current namespace
             » Symbol MyPets/Dog evaluates to var in namespace MyPets
     • List evaluation
         – Lists evaluate into function calls
              » (+ 1 2 3)
     • Process macros
  – Execute phase
     • Effects the special forms
     • Calls functions.
Special Forms
• Reserved symbol
   – Denotes special list evaluation
      • Not a function call – it’s “something else”
• Def, if, do, let, quote, var, fn, loop, recur, throw, tr
  y, ., new, set!
• If a list starts with any of those it’s evaluated in a
  special way particular to that form
• (if condition a b?)
• (if (been_drinking) (hungover) (happy))
• (if (have_beers) (drink))
Let’s Talk About the ‘crazy’ Syntax



         (prn “Hello World!”)
Maybe it’s not so Crazy



Console.WriteLine(“Hello World”)
Looping
Tail Recursion




http://www.flickr.com/photos/43911015@N05
Questions
• gary.short@gibraltarsoftware.com
• @garyshort
• Facebook.com/theOtherGaryShort




                                     34

Mais conteúdo relacionado

Mais procurados

Lua. The Splendors and Miseries of Game Scripting
Lua. The Splendors and Miseries of Game ScriptingLua. The Splendors and Miseries of Game Scripting
Lua. The Splendors and Miseries of Game ScriptingDevGAMM Conference
 
Not Everything Is An Object
Not Everything Is An ObjectNot Everything Is An Object
Not Everything Is An ObjectGary Short
 
2012-02-15 jfokus2012 - regex applied
2012-02-15 jfokus2012 - regex applied2012-02-15 jfokus2012 - regex applied
2012-02-15 jfokus2012 - regex appliedStaffan Nöteberg
 
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" Ecosystems
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" EcosystemsPyData Frankfurt - (Efficient) Data Exchange with "Foreign" Ecosystems
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" EcosystemsUwe Korn
 
Why i love ruby than x
Why i love ruby than xWhy i love ruby than x
Why i love ruby than xSamnang Chhun
 
Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3mametter
 
What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?Reuven Lerner
 
State of Python (2010)
State of Python (2010)State of Python (2010)
State of Python (2010)Richard Jones
 
De-mystifying contributing to PostgreSQL
De-mystifying contributing to PostgreSQLDe-mystifying contributing to PostgreSQL
De-mystifying contributing to PostgreSQLLætitia Avrot
 

Mais procurados (17)

Lua. The Splendors and Miseries of Game Scripting
Lua. The Splendors and Miseries of Game ScriptingLua. The Splendors and Miseries of Game Scripting
Lua. The Splendors and Miseries of Game Scripting
 
Not Everything Is An Object
Not Everything Is An ObjectNot Everything Is An Object
Not Everything Is An Object
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Children of Ruby
Children of RubyChildren of Ruby
Children of Ruby
 
2012-02-15 jfokus2012 - regex applied
2012-02-15 jfokus2012 - regex applied2012-02-15 jfokus2012 - regex applied
2012-02-15 jfokus2012 - regex applied
 
仙台Ruby会議02 LT
仙台Ruby会議02 LT仙台Ruby会議02 LT
仙台Ruby会議02 LT
 
Intro for RoR
Intro for RoRIntro for RoR
Intro for RoR
 
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" Ecosystems
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" EcosystemsPyData Frankfurt - (Efficient) Data Exchange with "Foreign" Ecosystems
PyData Frankfurt - (Efficient) Data Exchange with "Foreign" Ecosystems
 
OOPS Advanced
OOPS AdvancedOOPS Advanced
OOPS Advanced
 
Why i love ruby than x
Why i love ruby than xWhy i love ruby than x
Why i love ruby than x
 
Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3Type Profiler: Ambitious Type Inference for Ruby 3
Type Profiler: Ambitious Type Inference for Ruby 3
 
Craft of coding
Craft of codingCraft of coding
Craft of coding
 
Haskell Tour (Part 1)
Haskell Tour (Part 1)Haskell Tour (Part 1)
Haskell Tour (Part 1)
 
What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?What can Ruby learn from Python (and vice versa)?
What can Ruby learn from Python (and vice versa)?
 
Intro To Ror
Intro To RorIntro To Ror
Intro To Ror
 
State of Python (2010)
State of Python (2010)State of Python (2010)
State of Python (2010)
 
De-mystifying contributing to PostgreSQL
De-mystifying contributing to PostgreSQLDe-mystifying contributing to PostgreSQL
De-mystifying contributing to PostgreSQL
 

Semelhante a Not Everything is an Object - Rocksolid Tour 2013

Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Martijn Verburg
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talkReuven Lerner
 
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...InfinIT - Innovationsnetværket for it
 
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
 
Hunting for anglerfish in datalakes
Hunting for anglerfish in datalakesHunting for anglerfish in datalakes
Hunting for anglerfish in datalakesDominic Egger
 
Lisp, An Introduction.ppt
Lisp, An Introduction.pptLisp, An Introduction.ppt
Lisp, An Introduction.pptLuis Soza
 
Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Omar Abdelhafith
 
Functional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersFunctional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersDiego Freniche Brito
 
Polyglot and functional (Devoxx Nov/2011)
Polyglot and functional (Devoxx Nov/2011)Polyglot and functional (Devoxx Nov/2011)
Polyglot and functional (Devoxx Nov/2011)Martijn Verburg
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threadsmperham
 
Erlang: TL;DR
Erlang: TL;DRErlang: TL;DR
Erlang: TL;DRvorn
 
Performance and Abstractions
Performance and AbstractionsPerformance and Abstractions
Performance and AbstractionsMetosin Oy
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkTomas Doran
 
Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Justin Lin
 

Semelhante a Not Everything is an Object - Rocksolid Tour 2013 (20)

Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)Polyglot and Functional Programming (OSCON 2012)
Polyglot and Functional Programming (OSCON 2012)
 
Lexing and parsing
Lexing and parsingLexing and parsing
Lexing and parsing
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talk
 
JRuby: The Hard Parts
JRuby: The Hard PartsJRuby: The Hard Parts
JRuby: The Hard Parts
 
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...Are High Level Programming Languages for Multicore and Safety Critical Conver...
Are High Level Programming Languages for Multicore and Safety Critical Conver...
 
Rustbridge
RustbridgeRustbridge
Rustbridge
 
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
 
Hunting for anglerfish in datalakes
Hunting for anglerfish in datalakesHunting for anglerfish in datalakes
Hunting for anglerfish in datalakes
 
intro.ppt
intro.pptintro.ppt
intro.ppt
 
intro.ppt
intro.pptintro.ppt
intro.ppt
 
Lisp, An Introduction.ppt
Lisp, An Introduction.pptLisp, An Introduction.ppt
Lisp, An Introduction.ppt
 
Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)
 
Taming Text
Taming TextTaming Text
Taming Text
 
Functional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersFunctional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented Programmers
 
Polyglot and functional (Devoxx Nov/2011)
Polyglot and functional (Devoxx Nov/2011)Polyglot and functional (Devoxx Nov/2011)
Polyglot and functional (Devoxx Nov/2011)
 
Actors and Threads
Actors and ThreadsActors and Threads
Actors and Threads
 
Erlang: TL;DR
Erlang: TL;DRErlang: TL;DR
Erlang: TL;DR
 
Performance and Abstractions
Performance and AbstractionsPerformance and Abstractions
Performance and Abstractions
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
 
Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.
 

Mais de Gary Short

Raspberry Pi - Rocksolid Tour 2013
Raspberry Pi  - Rocksolid Tour 2013Raspberry Pi  - Rocksolid Tour 2013
Raspberry Pi - Rocksolid Tour 2013Gary Short
 
Marginal Gains - Rocksolid Tour 2013
Marginal Gains  - Rocksolid Tour 2013Marginal Gains  - Rocksolid Tour 2013
Marginal Gains - Rocksolid Tour 2013Gary Short
 
.Net Collection Classes Deep Dive - Rocksolid Tour 2013
.Net Collection Classes Deep Dive  - Rocksolid Tour 2013.Net Collection Classes Deep Dive  - Rocksolid Tour 2013
.Net Collection Classes Deep Dive - Rocksolid Tour 2013Gary Short
 
Algorithms - Rocksolid Tour 2013
Algorithms  - Rocksolid Tour 2013Algorithms  - Rocksolid Tour 2013
Algorithms - Rocksolid Tour 2013Gary Short
 
Building an Internet Radio on the RaspberryPI
Building an Internet Radio on the RaspberryPIBuilding an Internet Radio on the RaspberryPI
Building an Internet Radio on the RaspberryPIGary Short
 
Connecting to the Raspberry Pi from your Laptop
Connecting to the Raspberry Pi from your LaptopConnecting to the Raspberry Pi from your Laptop
Connecting to the Raspberry Pi from your LaptopGary Short
 
Setting up the Raspberry Pi Using BerryBoot
Setting up the Raspberry Pi Using BerryBootSetting up the Raspberry Pi Using BerryBoot
Setting up the Raspberry Pi Using BerryBootGary Short
 
Everything you Wanted to Know About Refactoring
Everything you Wanted to Know About RefactoringEverything you Wanted to Know About Refactoring
Everything you Wanted to Know About RefactoringGary Short
 
Technical Debt
Technical DebtTechnical Debt
Technical DebtGary Short
 

Mais de Gary Short (9)

Raspberry Pi - Rocksolid Tour 2013
Raspberry Pi  - Rocksolid Tour 2013Raspberry Pi  - Rocksolid Tour 2013
Raspberry Pi - Rocksolid Tour 2013
 
Marginal Gains - Rocksolid Tour 2013
Marginal Gains  - Rocksolid Tour 2013Marginal Gains  - Rocksolid Tour 2013
Marginal Gains - Rocksolid Tour 2013
 
.Net Collection Classes Deep Dive - Rocksolid Tour 2013
.Net Collection Classes Deep Dive  - Rocksolid Tour 2013.Net Collection Classes Deep Dive  - Rocksolid Tour 2013
.Net Collection Classes Deep Dive - Rocksolid Tour 2013
 
Algorithms - Rocksolid Tour 2013
Algorithms  - Rocksolid Tour 2013Algorithms  - Rocksolid Tour 2013
Algorithms - Rocksolid Tour 2013
 
Building an Internet Radio on the RaspberryPI
Building an Internet Radio on the RaspberryPIBuilding an Internet Radio on the RaspberryPI
Building an Internet Radio on the RaspberryPI
 
Connecting to the Raspberry Pi from your Laptop
Connecting to the Raspberry Pi from your LaptopConnecting to the Raspberry Pi from your Laptop
Connecting to the Raspberry Pi from your Laptop
 
Setting up the Raspberry Pi Using BerryBoot
Setting up the Raspberry Pi Using BerryBootSetting up the Raspberry Pi Using BerryBoot
Setting up the Raspberry Pi Using BerryBoot
 
Everything you Wanted to Know About Refactoring
Everything you Wanted to Know About RefactoringEverything you Wanted to Know About Refactoring
Everything you Wanted to Know About Refactoring
 
Technical Debt
Technical DebtTechnical Debt
Technical Debt
 

Not Everything is an Object - Rocksolid Tour 2013

  • 1. Not Everything is an Object By Gary Short Gibraltar Software
  • 2. What this Session is not… • OO hating • Deep dive of Clojure • If you’ve written a Clojure App, you’ll probably not learn anything.
  • 3. What this Session is… • Point out why OO dev is hard sometimes • Show you that there is an alternative • “It shouldn’t be this hard”.
  • 4. Introduction • Gary Short • Head of Gibraltar Labs – “Skunk Works” division of Gibraltar Software • MVP C# – Python – NodeJS • gary.short@gibraltarsoftware.com • @garyshort • Facebook.com/theOtherGaryShort 4
  • 5. The Road to Here http://www.flickr.com/photos/fyngyrz/
  • 6. Ada Lovelace • 1842 - 1843 Lovelace translated a memoir of an Italian mathematician on Charles Baggage’s newest proposed machine... the Analytical Engine. The article she wrote contained the entire specification of how to calculate Bernoulli numbers with the Engine. This is believed to be the first ever computer program.
  • 7. The 1940s • Then in the 1940’s along comes the first recognisable computers and we get programming languages to go with them... • 1943 - Plankalkül (Konrad Zuse) • 1943 - Colossus • 1949 - C-10
  • 8. The 1950s • In the 1950s the first three modern programming languages whose descendants are still in widespread use today were designed: • FORTRAN (1955), the "FORmula TRANslator", invented by John Backus et al.; • LISP, the "LISt Processor", invented by John McCarthy et al.; • COBOL, the COmmon Business Oriented Language, created by the Short Range Committee, heavily influenced by Grace Hopper.
  • 9. More 1950s • 1951 - Regional Assembly Language • 1952 - Autocode • 1954 - FORTRAN • 1954 - IPL (forerunner to LISP) • 1955 - FLOW-MATIC (forerunner to COBOL) • 1957 - COMTRAN (forerunner to COBOL) • 1958 - LISP • 1958 - ALGOL 58 • 1959 - FACT (forerunner to COBOL) • 1959 - COBOL
  • 10. The 1960s • 1962 - APL • 1962 - Simula • 1964 - BASIC • 1964 - PL/I
  • 11. The 1970s • 1970 - Pascal • 1970 - Forth • 1972 - C • 1972 - Smalltalk • 1972 - Prolog • 1973 - ML • 1975 - Scheme • 1978 - SQL
  • 12. The 1980s • 1983 - Ada • 1983 - C++ • 1985 - Eiffel • 1986 - Erlang • 1987 - Perl • 1989 - FL
  • 13. The 1990s • 1990 - Haskell • 1991 - Python • 1991 - Java • 1993 - Ruby • 1993 - Lua • 1994 - ANSI Common Lisp • 1995 - JavaScript • 1995 - PHP • 1997 - Rebol
  • 14. Where we are Now http://www.flickr.com/photos/gtarded/
  • 15. What OOP/D is Good For http://www.flickr.com/photos/gserafini/
  • 16. What is it Not Good For? http://www.flickr.com/photos/aloshbennett/
  • 17. Also, we really suck at OOM…
  • 18. Also hierarchies are brittle…
  • 19. Also, OOPs get complex real fast…
  • 21. What Does it Mean to be Functional? • First order functions • Function like constructs • Stateless • Immutable data
  • 22. Clojure • A Lisp • JVM • Dynamic • Java Interop • Functional • Fast – Impure • Persistent collections • “Lockless” Concurrency • Easy to learn. • Macros
  • 23. Introduction to Clojure • Java.Lang.Object • Arbitrary sized numbers • Ratios: 18/20 • Nil is null and is treated as false
  • 24. Persistent Collections • Immutable – Cheap to copy • Examples – (1 2 3) • List – sequential lookup time – [1 2 3] • Vector – logarithmic lookup time – {“key” 1, 3 7, “foo” “bar”} • Hashmap – unordered, key value pairs
  • 25. Equality Vs Identity • Equality – Two objects are equal • Two cylinders maybe equal if their volumes are equal – Identity • Two pointers to the same object – Clojure favours equality :-O
  • 26. Clojure is Impure so has Mutability • Var – Mutable pointer to immutable data • You can’t change the data • But you can change what data the var points to • But vars hold global data, function defs etc . • This data won’t change • So why are vars mutable? • So we can patch running software. 
  • 27. The Reader • Other programming languages – Compiler • Text -> lexing and parsing -> AST • Clojure – The Reader • Text -> lexing and parsing -> Literals (Data) • As soon as it reads a complete literal it’s passed to...
  • 28. The Evaluator • Compile Phase – Traverses the data • Symbol evaluation – Symbols evaluate into Vars » Symbol Dog evaluates to a var in the current namespace » Symbol MyPets/Dog evaluates to var in namespace MyPets • List evaluation – Lists evaluate into function calls » (+ 1 2 3) • Process macros – Execute phase • Effects the special forms • Calls functions.
  • 29. Special Forms • Reserved symbol – Denotes special list evaluation • Not a function call – it’s “something else” • Def, if, do, let, quote, var, fn, loop, recur, throw, tr y, ., new, set! • If a list starts with any of those it’s evaluated in a special way particular to that form • (if condition a b?) • (if (been_drinking) (hungover) (happy)) • (if (have_beers) (drink))
  • 30. Let’s Talk About the ‘crazy’ Syntax (prn “Hello World!”)
  • 31. Maybe it’s not so Crazy Console.WriteLine(“Hello World”)

Notas do Editor

  1. Programming languages pre date computers themselves...Starting in 1842 and finishing in 1843 Ada Lovelace translated a memoir of an Italian mathematician on Charles Baggage’s newest proposed machine... the Analytical Engine. The article she wrote contained the entire specification of how to calculate Bernoulli numbers with the Engine. This is believed to be the first ever computer program.Then in the 1940’s along comes the first recognisable computers and we get programming languages to go with them...1943 - Plankalkül (KonradZuse) 1943 - ENIAC coding system1949 - C-10In the 1950s the first three modern programming languages whose descendants are still in widespread use today were designed:FORTRAN (1955), the "FORmulaTRANslator", invented by John Backus et al.; LISP, the "LIStProcessor", invented by John McCarthy et al.; COBOL, the COmmonBusiness Oriented Language, created by the Short Range Committee, heavily influenced by Grace Hopper. 1951 - Regional Assembly Language1952 - Autocode1954 - FORTRAN1954 - IPL (forerunner to LISP) 1955 - FLOW-MATIC (forerunner to COBOL) 1957 - COMTRAN (forerunner to COBOL) 1958 - LISP1958 - ALGOL 581959 - FACT (forerunner to COBOL) 1959 - COBOL1962 - APL1962 - Simula1964 - BASIC1964 - PL/I1970 - Pascal1970 - Forth1972 - C1972 - Smalltalk1972 - Prolog1973 - ML1975 - Scheme1978 - SQL (initially only a query language, later extended with programming constructs) 1983 - Ada1983 - C++1985 - Eiffel1986 - Erlang1987 - Perl1989 - FL (Backus) 1990 - Haskell1991 - Python1991 - Java1993 - Ruby1993 - Lua1994 - ANSI Common Lisp1995 - JavaScript1995 - PHP1997 - Rebol2000 - C#2008 - JavaFX Script
  2. Through the 1990s and up until today, OO languages are in the ascendency due to: the GUI. A GUI lends itself well to the concept of discrete objects due to: having their own knowledge and behaviour messaging each other in an event driven model. Low cost of memory
  3. Modelling object graph where objects are passing messagesModelling state changeModelling problem domains where the actors are hierarchal in natureEvent driven programming
  4. Object graphs or sub graphs mean lots of shared dataShared data bad for concurrencyRequires lockingLocking is bad because it is either coarse grained which is expensive in time or it’s fine grained which is expensive in terms of management.Locking management is hard because there is no compiler or VM support, it’s down to you to work out how to do itExample: lock objects by alphabetical orderYou have to remember to do it that wayErrors are next to impossible to test for, hard to debug
  5. First order functions means that functions can be treated like values and can be return from and passed into other functionsFunction like constructs means that flow control constructs are more like functions in that they may return the last value etcStateless because it’s functional in the sense of a mathematical function. Values are passed in, those values are operated upon and a new value is passed out. The function does not depend on any outside state. If the function is pure it has no side effects.The advantage of this is that a pure function is simple to understand, the whole essence of the function is encapsulated within the function itself. Easy to testEasy to debugConcurrency – if there is no dependency on shared state then work can be easily parallelised.
  6. Pure functional language = no side effects allowedImpure functional language = side effects are not restrictedLockless concurrency does not mean there are no locks, just that the language manages them for you.
  7. Nil is null and is treated as false kinda sucks.Here is a value and it is trueHere is a value and it is falseNil/null should mean there is no value.
  8. Mutable collection you can modify the collection: add, remove etcImmutable collections cannot be modified but instead you get a new copy of the collection with the changes.Key idea is that copies are cheap, both in terms of time and memoryHow does this work?Copies of mutable collections take time and memory, copying 100 items needs 100+ operations but..Because data is immutable, it’s not going to change, so I don’t have to copy the data, just provide a pointer to it.If I want your data with a new member added then I get a collection which shares most of the data but has my deltas
  9. Clojure favours equality but this is not a big problem as data is immutable and so objects and object graphs have a hash, since this can’t change equality simply compares the hash values and not the data in the graphThe only exception to this is string comparisons because Clojure strings are just Java stringsNot a big problem as string comparison is efficient in JavaFirst check identityThen check lengthThen check equality
  10. Vars must be defined before first useThey must be def’d but not necessarily boundWhat is a macro?A macro is a function that modifies reader data
  11. If is a special form as code execution is conditionalIf the condition is true then a will be returnedIf the condition is false then b will be returnedThe ? Denotes that b is optionalI said before that if were function likeFirst example returns the result of hungover if true else the result of happySecond example returns the result of drink else nil
  12. Prefix notation
  13. Tail RecursionSpecial form of recursion whereby the last thing a function does is to call itselfFunctions need a stack frameCall a function 1,000 times recursively then you need 1,000 stackframesBut if calling the function is the last thing you are going to doThen you are not coming back to the calling functionSo there’s an optimisation where you can just overwrite the stackframe of the calling funcSo you only ever need one stack frameMost lisp dialects have this tail recursion optimisationClojure doesn’t as there is not tail recursion on the JMV