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

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Naïveté vs. Experience

7,120

Published on

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

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

Published in: Technology
1 Comment
1 Like
Statistics
Notes
  • http://0845.com/Inr

    I tide fashion

    Good-looking, not expensive

    Free transport
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
7,120
On Slideshare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
56
Comments
1
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Naïveté vs. Experience How We Thought We Could Use Scala and Clojure, and How We Actually Did
  • 2. Who
  • 3.  
  • 4.
    • AI, Distributed Simulation, Code Generation, Machine Vision
    • 5. C, C++, Java, CLIPS, Clojure, Scala
    • 6. Co-author of The Joy of Clojure
      • http://joyofclojure.com
    • Local Boy
    Michael Fogus: Programmer
  • 7. Why
  • 8. Java
  • 9. Compression Potential
  • 10. Compression Potential
  • 11. Essential Boilerplate
  • 12. Essential Boilerplate equals hashCode get set public Foo toString
  • 13. 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
  • 14. What
  • 15.
      Java
  • 16.
      Java
      • Compiler
      • Problem
  • 17.
      Java
      • Compiler
      • Problem
    List<Map<String,String>> foo = new ArrayList<HashMap<String,String>>(); foo.add(new HashMap() {{ put(“bar”, “baz”); }});
  • 18.
      Java
      • Compiler
      • Problem
    Да
  • 19. Java != JVM
  • 20. Reprieve
  • 21.
  • 28.
  • 36.
      Scala
  • 37.
      Scala
      • Compiler
      • Problem
  • 38.
      Scala
      • Compiler
      • Problem
    val foo = List[Map[String,String]]() foo ++ Map(&quot;bar&quot; -> &quot;baz&quot;)
  • 39.
      Scala
      • Compiler
      • Problem
    Да
  • 40.
      Clojure
  • 41.
      Clojure
      • Compiler
      • Problem
  • 42.
      Clojure
      • Compiler
      • Problem
    (def foo {}) (assoc foo “bar” “baz”)
  • 43.
      Clojure
      • Compiler
      • Problem
    zzz
  • 44.
      Clojure
      • Compiler
      • Problem
      • Runtime
    Да
  • 45. 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 +
    • 46. (spouse != null ? &quot; married to &quot; + spouse.getFirstName() + &quot;.&quot; : &quot;.&quot; ); }
    }
  • 47. 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 +
    • 48. (spouse != null ? &quot; married to &quot; + spouse.getFirstName() + &quot;.&quot; : &quot;.&quot; ); }
    }
  • 49. 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 +
    • 50. (spouse != null ? &quot; married to &quot; + spouse.getFirstName() + &quot;.&quot; : &quot;.&quot; ); }
    }
  • 51. 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 +
    • 52. (spouse != null ? &quot; married to &quot; + spouse.getFirstName() + &quot;.&quot; : &quot;.&quot; ); }
    }
  • 53. Scala
    • case class Person ( val firstName : String , val lastName: String , val spouse: Option [ Person ]) {
    • 54. override def toString(): String = firstName + &quot; &quot; + lastName +
    • 55. (spouse match {
    • 56. case None => &quot;.&quot;
    • 57. case Some(s) => &quot; married to &quot; + s.firstName + &quot;.&quot;
    • 58. });
    • 59. }
    By default , Scala classes are immutable.
  • 60.  
  • 61. Disingenuous
  • 62. Of Course...
      ( defrecord Person [fname lname spouse]
    • Object
    • 63. ( toString [_]
    • 64. ( str fname &quot; &quot; lname
    • 65. ( when-let [n ( :fname spouse)]
    • 66. ( str &quot; married to &quot; n))
    • 67. .)))
    By default , Scala classes are immutable.
  • 68.  
  • 69.
      Scala Won (mostly)
  • 70.
      How
  • 71.
  • 80. Architecture
  • 81. services The Internet
  • 82. services The Internet
  • 83. services The Internet
  • 84. services The Internet
  • 85. services The Internet
  • 86. services The Internet
  • 87. services The Internet
  • 88. services The Internet
  • 89. The Internet
  • 90. The Internet
  • 91. The Internet
  • 92. The Internet
  • 93. Naïveté
  • 94.
  • 103.
    • Interoperability
    • 104. Everything is an Object
    • Embedded XML
  • 110.
    • Interoperability
  • 114. Experience
  • 115.
    • Interoperability
    • 116. Type Aliases
    • Traits
    • Functional Programming
    • 117. List Comprehensions
    • Immutability
    • Pattern Matching
    • 118. Currying
    • Closures
  • 119. Disingenuous
  • 120. Dis ingenuous
  • 121.
      Interoperability (near seamless – essential)
  • 122.
      Type Aliases
  • 123.
      D.I.
  • 124. Type Aliases
    • class Service extends IService {
    • 125. def get(ref:ReferenceParam):ComponentReturn = { ... }
    • 126. ...
    • 127. }
    By default , Scala classes are immutable.
  • 128. Type Aliases
    • class Service extends IService {
    • 129. def get(ref: ReferenceParam ): ComponentReturn = { ... }
    • 130. ...
    • 131. }
  • 132. Type Aliases
    • class Service extends IService {
    • 133. def get(ref: ReferenceParam ): ComponentReturn = { ... }
    • 134. ...
    • 135. }
    • type ReferenceParam = java.util.Map[String,String]
    • type ComponentReturn = java.util.Map[String,Object]
  • 136.
      Traits
  • 137.
      D.I.
  • 138.
      D.I.
  • 139. Traits
    • class Service extends IService {
    • 140. def get(ref: ReferenceParam ): ComponentReturn = { ... }
    • 141. ...
    • 142. }
    • trait RPCTypes {
    • type ReferenceParam = java.util.Map[String,String]
    • type ComponentReturn = java.util.Map[String,Object]
    • 143. }
  • 144. Traits
    • class Service extends IService with RPCTypes {
    • 145. def get(ref: ReferenceParam ): ComponentReturn = { ... }
    • 146. ...
    • 147. }
    • trait RPCTypes {
    • type ReferenceParam = java.util.Map[String,String]
    • type ComponentReturn = java.util.Map[String,Object]
    • 148. }
  • 149. RPCTypes LocalTypes CachedTypes DelayedTypes ... RPCTypes LocalTypes ... The Internet
  • 150.
      Functional Programming
  • 151.
      List Comprehensions
  • 152.
      Immutability
  • 153. When a tree falls in a lonely forest ... does it make a sound? – Charles Riborg Mann and George Ransom Twiss
  • 154. If a pure function mutates some local data in order to produce an immutable return value, is that ok? – Rich Hickey
  • 155.
      Pattern Matching (a language for error shapes)
  • 156.
      Currying (gratuitous, but cool, control structures)
  • 157.
      Closures (gratuitous, but cool, simplified delays)
  • 158.
      Woe
  • 159.
  • 165.
    • Literals-lite
    Clojure!
  • 170. Thanks To
    • You
    • 171. My employer
    • 172. Dean Wampler for feedback
    • 173. Rich Hickey and Martin Odersky for Clojure and Scala
    • 174. Chris Houser my co-author
    • 175. Ryan Tomayko for the screaming face
    • 176. The fam
  • 177. Questions? (example questions below)
    • Joel or Mike?
    • 178. Is Scala too complicated?
    • 179. Best zombie movies?
    • 180. Kobaia is de hundin?
    • 181. Favorite hangout in Baltimore?
    • 182. What's with the tie?

×