1. One Ring to Rule Them All?
Why Programming Languages Matter
1
2. 2
Some people think, and act, like Java is the One Programming Language to Rule Them All. Is it
really? Is it possible to have everything you need in a single language?
3. TIOBE Programming Community Index
1 Java 19.002%
2 C 15.931%
3 C++ 10.116%
4 (Visual) Basic 9.161%
5 PHP 8.882%
6 C# 5.609%
7 Python 4.731%
8 Perl 4.303%
9 JavaScript 3.360%
10 Delphi 3.303%
January 2009
3
Interestingly, Ruby is #11 and is the only other language with greater than 3% reporting.
4. 4
From a Cadbury chocolate label. Simple things, like this list of ingredients, are relatively easy to
translate. Concepts, logic and emotions are much harder.
5. 5
Sandburg reminds us that language, like culture, is always changing. What we mean when we use a
particular word evolves and changes. Consider the word “flour”, for example. In the Middle English
of the Canterbury Tales, it means a flower. Nowadays it typically means ground wheat.
6. “if something can't be said, then it
can't be thought”
-- Orwell
6
In George Orwell’s 1984, NewSpeak was an attempt to control what people could think by
controlling what they could say. Can you think of analogies to computer programming languages
that you use?
7. 7
These are obviously shoes. They have dierent shapes, colors, sizes and styles, yet we immediately
recognize them as shoes. Some languages insist on attaching implicit metadata about objects, such
as gender (e.g. German, Italian) or even general shape (e.g. Japanese, -mai, -hon forms as in “kutsu
ni-hon”). Consider also the dierence between material types in English (“some sand” vs. “a sand”).
8. 8
When does an object become a shoe? Or stop being a shoe? We often pretend that our words have
hard, Boolean meanings, but they are really quite flexible. This strongly dierentiates human
languages from programming languages.
9. quot;The limits of my language mean the limits
of my world.quot;
-- Wittgenstein
9
Ludwig Wittgenstein (1889–1951) was “an Austrian-British philosopher who worked primarily in
logic, the philosophy of mathematics, the philosophy of mind, and the philosophy of language”.
[Wikipedia]
10. quot;About what one can not speak, one must
remain silent.quot;
-- Wittgenstein
10
11. quot;The structures of your language shape the
way you think and perceive the world.quot;
- Sapir-Whorf Hypothesis
11
Cognitive research has proven a link from language to perception, but it seems to be weaker in
adults. The “strength” of the Sapir-Whorf is an area of controversy [http://scienceblogs.com/
cognitivedaily/2005/05/does_our_language_aect_our_t.php]
12. Language is innate and universal
- Chomsky
12
Noam Chomsky (1928-) is an American linguist, philosopher, cognitive scientist, political activist,
author, and lecturer. [Wikipedia]
13. quot;Some people argue that language just
changes what you attend to, but what
you attend to changes what you encode
and remember.quot;
-- Lera Boroditsky
13
Lera Boroditsky is an Assistant Professor of Psychology at Stanford University doing research in
cognitive science with a specific focus on cognitive linguistics. [Wikipedia]
14. 14
Perhaps there is no “one ring”. Perhaps the ring is made of many possible components, or maybe
even fractal...
15. Chimeric Programming
15
Chimeric programming; like the mythical Chimera which was a beast made of parts of many animals
(related to the Hydra and Cerberus).
Chimera on a red-figure Apulian plate, ca 350-340 BCE (Musée du Louvre) -- Wikipedia
Use many languages to say the right thing at the right time.
16. Kinnersley’s Categories
Constraint
Procedural
Object-Oriented
Imperative
Concurrent
Declarative
Fourth Generation
Applicative
Query
Functional
Specification
Definitional
Assembly
Single Assignment
Intermediate
Dataflow
Metalanguage
Logic
16
Bill Kinnersley, husband of a University of Kansas EE prof and coder. He maintains the list of
computer languages at http://people.ku.edu/~nkinners/LangList/Extras/langlist.htm
17. Kinnersley’s Categories
Java, Javascript
Object-Oriented BeanShell
Procedural
Constraint
Imperative
Declarative HTML, CSS Concurrent
Fourth Generation
Applicative
Functional XSL, RelaxNG Query SQL
Specification
Definitional
Assembly
Single Assignment
Dataflow DPML Intermediate
Metalanguage XML, BNF
Logic
17
Languages used for the PURL project, notionally written in Java.
18. Kinnersley’s Categories
Java
Object-Oriented Javascript
Procedural
Constraint
Imperative
Declarative HTML, CSS Concurrent
Fourth Generation
Applicative
XSL, XPath Query SPARQL
Functional
XQuery
Specification
Definitional
Assembly
Single Assignment
Dataflow Drools, DPML Intermediate
Logic OWL, SKOS Metalanguage RDF, XML
18
Languages used for the ICFS project, also notionally a Java project.
20. Typing
Dynamic Static
Strong Ruby/Groovy Java/C#
Weak JavaScript/Perl C/C++
From Venkat Subramaniam’s “Programming Groovy”
20
We used to snub our noses over dynamic languages over features like weak typing. The situation
has changed and we should acknowledge that.
21. Dynamic/Strong
Ruby
$ irb
i = 10
= 10
s = quot;stringquot;
= quot;stringquot;
s + i
TypeError: can't convert Fixnum into String
from (irb):3:in `+'
from (irb):3
from :0
From Nate Schutta’s “JavaScript : The Good, The Bad and the Ugly”
21
22. Dynamic/Weak
JavaScript
var i = 12;
var j = quot;helloquot;;
out(i + j)
Yields:
“12 hello”
From Nate Schutta’s “JavaScript : The Good, The Bad and the Ugly”
22
23. Closures
• Functions that are evaluated in an environment
containing one or more bound variables.
• Associated with functional languages.
• Some OO languages now exposing closures for
use by programmers - they appear as closed
anonymous functions.
23
Closures may be used to implement OO (because state can be hidden and variables maintain state
across calls).
Example later.
24. Metaprogramming
• Code that writes code at runtime to perform
operations traditionally performed at compile time.
• Typically via dynamic execution of string
expressions that contain programming commands.
24
Example later.
25. Expando Metaclass
Dynamically add
• methods
• constructors
• properties
• static methods
to classes using closures.
25
Example later.
26. 26
The language market is crowded; roughly 2,000 programming languages created in the last four
decades (some 13 of which have “stuck”). Here are some you should know.
27. Lisp (is back!)
Functional
• Conditionals • Program as expression
• Functions as data • Symbol type
• Recursion • Code as tree of symbols
• Dynamic typing • Read/Run/Compile
• Garbage collection
http://www.paulgraham.com/icad.html
27
Also, LISP-variant Clojure for concurrent programming. Clojure runs on the JVM.
31. Ericsson AXD 301
HA ATM Switch
1,000,000 Erlang LOC
Used Not Used
Message-passing Inheritance
Isolation Methods
Concurrency Classes
Higher-Order Programming UML
31
Written in Erlang, now FLOSS.
No traditionally OO structures used!
32. JavaScript
Dynamic OO
• Prototype Inheritance
• Closures
• Function as a data type
32
Web 2.0 engine - dynamic language of choice in the Web browser, also on a JVM via Rhino.
33. Ruby
Dynamic OO/Functional
• Metaprogramming
• Rails engine!
• Mixins
33
Runs on JVM
“Metaprogramming is the writing of computer programs that write or manipulate other programs
(or themselves) as their data, or that do part of the work at runtime that would otherwise be done at
compile time.” [Wikipedia]
34. Groovy
Dynamic OO - The next Java syntax?
• Closures
• Metaprogramming
• Grails engine!
• Builder Syntax (XML, Swing, Data)
• Access to legacy Java code
34
Runs on JVM
35. // By Scott Davis, Brian Sletten
class FoafPerson {
Map facts = [:]
Object invokeMethod(String predicate, Object value) {
if(facts.containsKey(predicate)) {
value.each{ obj -
facts.get(predicate).add(obj)
}
} else {
facts.put(predicate, value as List)
}
}
}
35
Invoking the method that wasn’t there.
36. brian = new FoafPerson()
brian.'foaf:name' 'Brian Sletten'
brian.'foaf:knows' quot;Ericquot;, quot;Davidquot;,quot;Uchequot;
brian.'foaf:dateOfBirth' '1972-05-26'
brian.'foaf:interest' quot;http://www.w3.org/RDF/quot;, quot;http://
www.w3.org/2000/01/sw/quot;
36
Using the method that wasn’t there.
38. 38
Don’t be an angry monkey (in the learned behavior study sense) - question group think inherent in
language choice.
39. Photos
Title Ring http://www.flickr.com/photos/mk1971/1348204498/
One Ring http://www.flickr.com/photos/generalnoir/391009102/
Language http://www.flickr.com/photos/margolove/1526032187/
Cadbury http://www.flickr.com/photos/nofrills/10895361/
Fractal http://www.flickr.com/photos/swaymedia/84294191/
Monkey http://www.flickr.com/photos/oskarn/122047239/
1984 http://www.newspeakdictionary.com/go-movie.html
http://www.flickr.com/photos/visualgrammar/
Shoes 114831391/
http://www.flickr.com/photos/undercover_surrealist/
Bottles 2405406526/
39
40. Photos
Crowd http://www.flickr.com/photos/vividbreeze/480057824/
Bells http://www.flickr.com/photos/hirsuteursus/637705224/
Quotes
Orwell 1984
On Language Collected by Brian Sletten
Others as noted inline
40