Naïveté vs. Experience
Upcoming SlideShare
Loading in...5
×
 

Naïveté vs. Experience

on

  • 7,551 views

Presentation given at the 2010 Commercial Users of Functional Programming conference.

Presentation given at the 2010 Commercial Users of Functional Programming conference.

Statistics

Views

Total Views
7,551
Views on SlideShare
4,241
Embed Views
3,310

Actions

Likes
1
Downloads
55
Comments
1

7 Embeds 3,310

http://www.fogus.me 1973
http://blog.fogus.me 1269
http://lanyrd.com 31
http://fogus.me 26
http://www.linkedin.com 7
https://www.linkedin.com 3
http://translate.googleusercontent.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • http://0845.com/Inr

    I tide fashion

    Good-looking, not expensive

    Free transport
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Naïveté vs. Experience Naïveté vs. Experience Presentation Transcript

  • Naïveté vs. Experience How We Thought We Could Use Scala and Clojure, and How We Actually Did
  • Who
  •  
    • AI, Distributed Simulation, Code Generation, Machine Vision
    • C, C++, Java, CLIPS, Clojure, Scala
    • Co-author of The Joy of Clojure
      • http://joyofclojure.com
    • Local Boy
    Michael Fogus: Programmer
  • Why
  • Java
  • Compression Potential
  • Compression Potential
  • Essential Boilerplate
  • Essential Boilerplate equals hashCode get set public Foo toString
  • Essential Boilerplate equals hashCode get set public Foo toString try catch finally ; { } @override static int System.out boolean . void import String Exception throws toString toString throws throws finally finally finally get get equals hashCode try } System.out boolean toString throws throws finally get public Foo catch finally ; int import String Exception throws toString get equals get toString try finally static import String toString throws finally equals try toString throws get finally String Exception hashCode finally { @override int void Exception toString throws finally hashCode toString throws finally public Foo finally int Exception @override static finally hashCode try throws throws static @override hashCode throws hashCode @override void toString toString int hashCode void finally finally public Foo int hashCode @override void toString toString int hashCode void finally finally public Foo int hashCode @override void toString toString int hashCode void finally finally public Foo int toString static finally equals try finally String toString throws finally toString finally
  • What
    • Java
    • Java
      • Compiler
      • Problem
    • Java
      • Compiler
      • Problem
    List<Map<String,String>> foo = new ArrayList<HashMap<String,String>>(); foo.add(new HashMap() {{ put(“bar”, “baz”); }});
    • Java
      • Compiler
      • Problem
    Да
  • Java != JVM
  • Reprieve
    • JRuby
    • Jython
    • Jess
    • Scala
    • Clojure
    • Groovy
    • Rhino
    • JRuby
    • Jython
    • Jess
    • Scala
    • Clojure
    • Groovy
    • Rhino
    • Scala
    • Clojure
    • Scala
    • Scala
      • Compiler
      • Problem
    • Scala
      • Compiler
      • Problem
    val foo = List[Map[String,String]]() foo ++ Map(&quot;bar&quot; -> &quot;baz&quot;)
    • Scala
      • Compiler
      • Problem
    Да
    • Clojure
    • Clojure
      • Compiler
      • Problem
    • Clojure
      • Compiler
      • Problem
    (def foo {}) (assoc foo “bar” “baz”)
    • Clojure
      • Compiler
      • Problem
    zzz
    • Clojure
      • Compiler
      • Problem
      • Runtime
    Да
  • Essential Boilerplate public class Person { private String lastName; private String firstName; private Person spouse; public Person(String firstName, String lastName, Person spouse) { this .lastName = lastName; this .firstName = firstName; this .spouse = spouse; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public Person getSpouse() { return spouse; } public String toString() {
    • return firstName + &quot; &quot; + lastName +
    • (spouse != null ? &quot; married to &quot; + spouse.getFirstName() + &quot;.&quot; : &quot;.&quot; ); }
    }
  • Less Boilerplate
    • case class Person ( val firstName : String , val lastName: String , val spouse: Option [ Person ]) {
    public Person(String firstName, String lastName, Person spouse) { this .lastName = lastName; this .firstName = firstName; this .spouse = spouse; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public Person getSpouse() { return spouse; } public String toString() {
    • return firstName + &quot; &quot; + lastName +
    • (spouse != null ? &quot; married to &quot; + spouse.getFirstName() + &quot;.&quot; : &quot;.&quot; ); }
    }
  • Kittens
    • case class Person ( val firstName : String , val lastName: String , val spouse: Option [ Person ]) {
    public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public Person getSpouse() { return spouse; } public String toString() {
    • return firstName + &quot; &quot; + lastName +
    • (spouse != null ? &quot; married to &quot; + spouse.getFirstName() + &quot;.&quot; : &quot;.&quot; ); }
    }
  • Kittens and Aquaman
    • case class Person ( val firstName : String , val lastName: String , val spouse: Option [ Person ]) {
    • override def toString(): String = firstName + &quot; &quot; + lastName +
    • return firstName + &quot; &quot; + lastName +
    • (spouse != null ? &quot; married to &quot; + spouse.getFirstName() + &quot;.&quot; : &quot;.&quot; ); }
    }
  • Scala
    • case class Person ( val firstName : String , val lastName: String , val spouse: Option [ Person ]) {
    • override def toString(): String = firstName + &quot; &quot; + lastName +
    • (spouse match {
    • case None => &quot;.&quot;
    • case Some(s) => &quot; married to &quot; + s.firstName + &quot;.&quot;
    • });
    • }
    By default , Scala classes are immutable.
  •  
  • Disingenuous
  • Of Course...
      ( defrecord Person [fname lname spouse]
    • Object
    • ( toString [_]
    • ( str fname &quot; &quot; lname
    • ( when-let [n ( :fname spouse)]
    • ( str &quot; married to &quot; n))
    • .)))
    By default , Scala classes are immutable.
  •  
    • Scala Won (mostly)
    • How
    • Embedded XML
    • Everything is an Object
    • Functional Programming
    • List Comprehensions
    • Case Classes
    • Pattern Matching
    • Interoperability
    • Currying
    • Implicits
  • Architecture
  • services The Internet
  • services The Internet
  • services The Internet
  • services The Internet
  • services The Internet
  • services The Internet
  • services The Internet
  • services The Internet
  • The Internet
  • The Internet
  • The Internet
  • The Internet
  • Naïveté
    • Embedded XML
    • Everything is an Object
    • Functional Programming
    • List Comprehensions
    • Case Classes
    • Pattern Matching
    • Interoperability
    • Currying
    • Implicits
    • Interoperability
    • Everything is an Object
    • Embedded XML
    • Functional Programming
    • List Comprehensions
    • Case Classes
    • Pattern Matching
    • Currying
    • Implicits
    • Interoperability
    • Functional Programming
    • List Comprehensions
    • Pattern Matching
    • Currying
  • Experience
    • Interoperability
    • Type Aliases
    • Traits
    • Functional Programming
    • List Comprehensions
    • Immutability
    • Pattern Matching
    • Currying
    • Closures
  • Disingenuous
  • Dis ingenuous
    • Interoperability (near seamless – essential)
    • Type Aliases
    • D.I.
  • Type Aliases
    • class Service extends IService {
    • def get(ref:ReferenceParam):ComponentReturn = { ... }
    • ...
    • }
    By default , Scala classes are immutable.
  • Type Aliases
    • class Service extends IService {
    • def get(ref: ReferenceParam ): ComponentReturn = { ... }
    • ...
    • }
  • Type Aliases
    • class Service extends IService {
    • def get(ref: ReferenceParam ): ComponentReturn = { ... }
    • ...
    • }
    • type ReferenceParam = java.util.Map[String,String]
    • type ComponentReturn = java.util.Map[String,Object]
    • Traits
    • D.I.
    • D.I.
  • Traits
    • class Service extends IService {
    • def get(ref: ReferenceParam ): ComponentReturn = { ... }
    • ...
    • }
    • trait RPCTypes {
    • type ReferenceParam = java.util.Map[String,String]
    • type ComponentReturn = java.util.Map[String,Object]
    • }
  • Traits
    • class Service extends IService with RPCTypes {
    • def get(ref: ReferenceParam ): ComponentReturn = { ... }
    • ...
    • }
    • trait RPCTypes {
    • type ReferenceParam = java.util.Map[String,String]
    • type ComponentReturn = java.util.Map[String,Object]
    • }
  • RPCTypes LocalTypes CachedTypes DelayedTypes ... RPCTypes LocalTypes ... The Internet
    • Functional Programming
    • List Comprehensions
    • Immutability
  • When a tree falls in a lonely forest ... does it make a sound? – Charles Riborg Mann and George Ransom Twiss
  • If a pure function mutates some local data in order to produce an immutable return value, is that ok? – Rich Hickey
    • Pattern Matching (a language for error shapes)
    • Currying (gratuitous, but cool, control structures)
    • Closures (gratuitous, but cool, simplified delays)
    • Woe
    • Breaking Changes
    • Optional Immutability
    • Weak Laziness
    • Less Functional
    • Grand Hierarchies
    • Literals-lite
    • Breaking Changes
    • Optional Immutability
    • Weak Laziness
    • Less Functional
    • Grand Hierarchies
    • Literals-lite
    Clojure!
  • Thanks To
    • You
    • My employer
    • Dean Wampler for feedback
    • Rich Hickey and Martin Odersky for Clojure and Scala
    • Chris Houser my co-author
    • Ryan Tomayko for the screaming face
    • The fam
  • Questions? (example questions below)
    • Joel or Mike?
    • Is Scala too complicated?
    • Best zombie movies?
    • Kobaia is de hundin?
    • Favorite hangout in Baltimore?
    • What's with the tie?