• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Five Languages in a Moment
 

Five Languages in a Moment

on

  • 1,526 views

 

Statistics

Views

Total Views
1,526
Views on SlideShare
1,502
Embed Views
24

Actions

Likes
1
Downloads
24
Comments
0

5 Embeds 24

http://speakerrate.com 12
https://twitter.com 6
http://www.techgig.com 4
http://twitter.com 1
http://115.112.206.131 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

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…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Five Languages in a Moment Five Languages in a Moment Presentation Transcript

  • Five Languages in a Moment Sergio Gil
  • Sergio Gil Pérez de la Manga @porras
  • I Creating Software
  • I Ruby
  • “Excusatio non petita,accussatio manifesta”
  • 2005
  • 2005
  • “Learn a new language each year”
  • 2006
  • 2006 Ruby
  • 2006 Ruby2007
  • 2006 Ruby2007 -
  • 2006 Ruby2007 -2008
  • 2006 Ruby2007 -2008 -
  • 2006 Ruby2007 -2008 -2009
  • 2006 Ruby2007 -2008 -2009 -
  • 2006 Ruby2007 -2008 -2009 -2010
  • 2006 Ruby2007 -2008 -2009 -2010 -
  • Ruby isawesome!!
  • 2010
  • THE POWERCONTINUUM
  • Highest levelLowest level
  • Highest level MachineLowest level
  • Highest level Assembler MachineLowest level
  • Highest level C Assembler MachineLowest level
  • Highest level Java C Assembler MachineLowest level
  • Highest level Ruby Java C Assembler MachineLowest level
  • Abstractions are tools for the mind
  • 1
  • Created by Joe Armstrong at Ericsson in 1986
  • Functional Language
  • Functional LanguageConcurrency Oriented
  • Functional LanguageConcurrency OrientedDistribution Oriented
  • Functional LanguageConcurrency OrientedDistribution Oriented Error Tolerant
  • Functional Programming
  • http://www.defmacro.org/ramblings/fp.html
  • Side effects free programming
  • x = x + 1
  • > X = 1.
  • > X = 1.> X.1
  • > X = 1.> X.1> X = 2.** exception error
  • Pattern Matching
  • > Point = {point, 15, 20}.
  • > Point = {point, 15, 20}.> {point, X, Y} = Point.
  • > Point = {point, 15, 20}.> {point, X, Y} = Point.> X.15
  • > Point = {point, 15, 20}.> {point, X, Y} = Point.> X.15> Y.20
  • Lists
  • ListsHead and Tail
  • ListsHead and Tail [H|T]
  • > L = [1, 2, 3, 4].
  • > L = [1, 2, 3, 4].> [H|T] = L.
  • > L = [1, 2, 3, 4].> [H|T] = L.> H.1
  • > L = [1, 2, 3, 4].> [H|T] = L.> H.1> T.[2, 3, 4]
  • Functions
  • double(X) -> X * 2.
  • fact(0) -> 1;fact(X) -> X * fact(X - 1).
  • sum([]) -> 0;sum([H|T]) -> H + sum(T).
  • sum([]) -> 0;sum([H|T]) -> H + sum(T).map(_, []) -> [];map(F, [H|T]) -> [F(H) | map(F, T)].
  • sum([]) -> 0;sum([H|T]) -> H + sum(T).map(_, []) -> [];map(F, [H|T]) -> [F(H) | map(F, T)]....
  • area({rectangle, Width, Height}) -> Width * Height;area({square, X}) -> X * X;area({circle, R}) -> 3.14159 * R.
  • area({rectangle, Width, Height}) -> Width * Height;area({square, X}) -> X * X;area({circle, R}) -> 3.14159 * R.> area({square, 3}).9
  • class Rectangle def initialize(width, height) @width = width @height = height end def area @width * height endendclass Square def initialize(x) @x = x end def area @x * @x endendclass Circle def initialize(r) @r = r end def area 3.14159 * @r endend
  • def area(*args) case args[0] when :rectangle args[1] * args[2] when :square args[1] * args[1] when :circle 3.141519 * args[1] endend
  • Concurrency
  • Pid = spawn(Fun).
  • Pid ! Message.
  • receive Pattern -> Expression; Pattern -> Expressionend
  • Remember map?map(_, []) -> [];map(F, [H|T]) -> [F(H) | map(F, T)].
  • pmap(F, L) -> Parent = self(), Pids = map(fun(I) -> spawn(fun() -> Parent ! {self(), F(I)} end) end, L), gather(Pids).
  • pmap(F, L) -> Parent = self(), Pids = map(fun(I) -> spawn(fun() -> Parent ! {self(), F(I)} end) end, L), gather(Pids).gather([]) -> [];gather([Pid|T]) -> receive {Pid, Result} -> [Result|gather(T)] end.
  • xN
  • Distribution Oriented
  • More interesting things about Erlang
  • More interesting things about Erlang Error control, even distributed
  • More interesting things about Erlang Error control, even distributed OTP
  • More interesting things about Erlang Error control, even distributed OTPWeb development with ChicagoBoss
  • You should try Erlang if...
  • ...you want to play with functional programming
  • ...youre interested in writing parallel programs
  • 2
  • Haskell
  • Created by Simon Peyton Jones in 1990
  • Pure functional language
  • Pure functional language Lazy evaluation
  • Pure functional language Lazy evaluationStrict but powerful type system
  • mymap _ [] = []mymap f (x:xs) = f x : map f xs
  • Haskell Type System
  • Haskell Type System Strong
  • Haskell Type System Strong Static
  • Haskell Type System Strong Static Inferred
  • Char
  • Char[Char]
  • Char[Char]String
  • Char[Char]StringInteger
  • Char[Char]StringInteger([Char], Integer)
  • data BookInfo = Book Int String [String]
  • data BookInfo = Book Int String [String]myBook = Book 987987 "About Wadus" ["Fulano", "Mengano"]
  • data Color = Red | Yellow | Green | RGB Int Int Int
  • data Color = Red | Yellow | Green | RGB Int Int Intyellow = Yellowblack = RGB 0 0 0
  • Type System + Pattern Matching
  • data Shape = Circle Float | Rectangle Float Float | Square Float
  • data Shape = Circle Float | Rectangle Float Float | Square Floatarea (Circle r) = r * 3.14area (Rectangle w h) = w * harea (Square x) = x * x
  • data Shape = Circle Float | Rectangle Float Float | Square Floatarea (Circle r) = r * 3.14area (Rectangle w h) = w * harea (Square x) = x * xcircle = Circle 5rectangle = Rectangle 2 3square = Square 1.5
  • data Shape = Circle Float | Rectangle Float Float | Square Floatarea (Circle r) = r * 3.14area (Rectangle w h) = w * harea (Square x) = x * xcircle = Circle 5rectangle = Rectangle 2 3square = Square 1.5-- > area circle-- 15.700001
  • data Shape = Circle Float | Rectangle Float Float | Square Floatarea (Circle r) = r * 3.14area (Rectangle w h) = w * harea (Square x) = x * xcircle = Circle 5rectangle = Rectangle 2 3square = Square 1.5-- > area circle-- 15.700001-- > :type area-- area :: Shape -> Float
  • More Functional Programming
  • square_all list = map (n -> n^2) list> square_all [1, 2, 5][1,4,25]
  • square_all list = map (n -> n^2) listsquare_all list = map (^2) list> square_all [1, 2, 5][1,4,25]
  • square_all list = map (n -> n^2) listsquare_all list = map (^2) listsquare_all = map (^2)> square_all [1, 2, 5][1,4,25]
  • Laziness
  • @articles = Article.where(:status => published)
  • @articles = Article.where(:status => published)<% @articles.each do |article| %><h2><%= article.title %></h2><p><%= article.body %></p><% end %>
  • @articles = Article.where(:status => published)<% @articles.limit(5).each do |article| %><h2><%= article.title %></h2><p><%= article.body %></p><% end %>
  • wadus 1 + 2
  • iforelse cond a b = if cond then a else b
  • iforelse cond a b = if cond then a else b> iforelse True (1 + 2) (3 + 4)3
  • iforelse cond a b = if cond then a else b> iforelse True (1 + 2) (3 + 4)3> iforelse False (1 + 2) (3 + 4)7
  • You should try Haskell if...
  • ...you tried the functional paradigm and want to go further
  • ...you want to see your belief“types are useless” challenged
  • ...you want to write extremellyefficient programs in a high level language
  • 3
  • Common Lisp
  • Invented by John McCarthy in 1958
  • Invented by John McCarthy in 1958
  • Lots ofIrritatingSuperfluousParentheses
  • HOMOICONIC
  • “property of someprogramming languages, in which the primary representation of programs is also a data structure in a primitive type of the language itself”
  • CODE = DATA
  • (1 2 3 ("wadus" 5) (1.3 1.7))
  • (1 2 3 ("wadus" 5) (1.3 1.7))[1, 2, 3, ["wadus", 5], [1.3, 1.7]]
  • (+ (* 3 5) (/ 10 2))
  • (+ (* 3 5) (/ 10 2)) 20
  • (1 2 3 ("wadus" 5) (1.3 1.7)) (+ (* 3 5) (/ 10 2))
  • (1 2 3 ("wadus" 5) (1.3 1.7)) (+ (* 3 5) (/ 10 2)) CODE = DATA
  • Lisp has no syntax
  • Valid Lisp code is composed of lists whose first element is thename of a function and the rest are the parameters passed
  • Macros
  • Metaprogramming
  • Metaprogramming is creating and manipulating code
  • Metaprogramming is creating and manipulating code lists
  • LISt Processing
  • (defmacro backwards (code)
  • (defmacro backwards (code) (reverse code))
  • (defmacro backwards (code) (reverse code))(backwards ("wadus" print))
  • (defmacro backwards (code) (reverse code))(backwards ("wadus" print))(print "wadus")
  • You should try Common Lisp if...
  • ...you want to take a flight in a retrofuturist jetpack
  • ...you like metaprogramming
  • ...you want to try one of the most abstraction-capableand still efficient languages
  • ...you want to understandwhy Lisp-lovers love Lisp so much
  • 4
  • Created by Rick Hickey in 2007
  • Lisp meets XXI century
  • Lisp meets the JVM
  • Lisp meets the JVMLisp meets purelly functional programming
  • Lisp meets the JVMLisp meets purelly functional programming Lisp meets laziness
  • Lisp meets the JVMLisp meets purelly functional programming Lisp meets laziness Lisp meets concurrency
  • Clojure is a Lisp
  • More laziness
  • (def whole-numbers (iterate inc 1))
  • (def whole-numbers (iterate inc 1))(first whole-numbers); 1
  • (def whole-numbers (iterate inc 1))(first whole-numbers); 1(take 5 whole-numbers); (1 2 3 4 5)
  • (def whole-numbers (iterate inc 1))(first whole-numbers); 1(take 5 whole-numbers); (1 2 3 4 5)(last whole-numbers) ; => CATACROKER!
  • (defn fibonacci [] (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
  • (defn fibonacci [] (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))(take 20 (fibonacci)); (0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 15972584 4181)
  • STM
  • (def fulano-balance (ref 100))(def mengano-balance (ref 80))
  • (def fulano-balance (ref 100))(def mengano-balance (ref 80))(dosync (ref-set fulano-balance (+ @fulano-balance 20)) (ref-set mengano-balance (- @mengano-balance 20)))
  • (def fulano-balance (ref 100))(def mengano-balance (ref 80))(dosync (ref-set fulano-balance (+ @fulano-balance 20)) (ref-set mengano-balance (- @mengano-balance 20)))@fulano-balance; 120
  • (def fulano-balance (ref 100))(def mengano-balance (ref 80))(dosync (ref-set fulano-balance (+ @fulano-balance 20)) (ref-set mengano-balance (- @mengano-balance 20)))@fulano-balance; 120@mengano-balance; 60
  • (dosync (alter fulano-balance + 20) (alter mengano-balance - 20))
  • (dosync (alter fulano-balance + 20) (alter mengano-balance - 20))@fulano-balance; 140
  • (dosync (alter fulano-balance + 20) (alter mengano-balance - 20))@fulano-balance; 140@mengano-balance; 40
  • More interesting things about Clojure
  • More interesting things about ClojureWeb development with Compojure
  • More interesting things about ClojureWeb development with Compojure
  • You should try Clojure if...
  • ...you like both Lisp and the functional approach
  • ...you need/want Java/JVM interoperability
  • 5
  • Ujfalusi
  • <
  • >
  • -
  • http://github.com/porras/ ujfalusi
  • You should create your own language if...
  • ...you want to learn about how languages internally work
  • ...you want to have fundoing something very geek
  • ...your favorite playerleaves your team and breaks your heart
  • And thewinneris...
  • ME!
  • Fun
  • New abstractions
  • New tools
  • Polyglotism
  • Go out
  • Play
  • Break something
  • Have fun
  • Thank you! :)