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

Naïveté vs. Experience