1 / 93

Confessions of a used programming language salesperson ( an appeal to purity ) Erik Meijer

Confessions of a used programming language salesperson ( an appeal to purity ) Erik Meijer. Why Functional Programming Matters Reloaded. … 100 … 110 x = x+1 120 … …. Artificial Intelligence via massively parallel machines using logic programming. SASL, Miranda, SKI.

zander
Download Presentation

Confessions of a used programming language salesperson ( an appeal to purity ) Erik Meijer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Confessions of a used programming language salesperson (an appeal to purity)Erik Meijer

  2. Why Functional Programming Matters Reloaded

  3. 100 … 110 x = x+1 120 … …

  4. Artificial Intelligence via massively parallel machines using logic programming

  5. SASL, Miranda, SKI [f.x.(f (f x))] = (S (S (K S) (S (K K) I)) (S (S (K S) (S (K K) I)) (K I))) Only need 3 instructions and massively parallel reduction machines

  6. Data Presentation Business logic

  7. Presentation (HaskellScript) Business logic(HSP,XM) Data(HaskellDB)

  8. List ComprehensionsExample factors n = [ x Select | x <- [1..n] From , n `mod` x == 0 Where ] isPrime n = factors n = [1,n] primes n = [ p | p <- [2..n], isPrime p ]

  9. List ComprehensionsSimplified translation [ e | True ] = [ e ] [ e | q ] = [ e | q, True ] [ e | b, Q ] = filter b [ e | Q ] [ e | x <- l, Q ] = concatMap (\x -> [e | Q ]) l [ e | let decls, Q ] = let decls in [ e | Q ] Syntactic sugar over standard list operations

  10. Monad ComprehensionsExample IO monad generalize lists words :: IO [String]words = do{ putStr “enter a value …” ; x <- getLine ; return (words x) } class Monad m where { (>>=) :: m a -> (a -> m b) -> m b ; return :: a -> m a } Parametrized over type constructor Syntactic sugar over standard monad operations

  11. HaskellDb Query Monad SELECT X.FirstName, X.LastName FROM Authors AS X WHERE X.City = 'OakLand' oaklands = do{ x <- table authors ; restrict (x!city .==. constant "Oakland") ; project ( au_fname = x!au_fname , au_lname = x!au_lname ) } Query monadgeneralizes IO monad intentional representation for expressions

  12. Haskell Server Pages XHTML Literals table :: TABLE table = <TABLE border="1"> <% mkRows cells %> </TABLE> cells :: [[(Int,Int)]] cells = [[ (x,y) | x <- [1..16] ] | y <- [1..16] ] mkRows :: [[(Int,Int)]] -> [TR] mkRows = map $ \cs -> <TR><% mkColums cs %></TR> mkColumns :: [(Int,Int)] -> [TD] mkColums = map $ \c -> <TD bgcolor=(color c)><% c %></TD> Translated to universal DOM representation ASP-style embedding

  13. http://radar.oreilly.com/erlanghaskellruby-thumb.png

  14. XML 2003: Growing C streams tuples Unions Content classes XML object literals Generalized member access+ SQL comprehensions

  15. Type System Extensions (structural) closures arrays T ::= N | T[] | T{} | T(…,T,…) | T|T | T&T | T! | T? | T+ | T* | struct {…, T m,…} intersection, union streams tuples (rows) XQuery data model

  16. C Query Comprehensions String n = "Wolfram"; struct{String? Subject}* subjects = selectit.Subject fromitin inboxwhereit.From == n Compiler plugins foreach(r in select CustomerID, ContactName from dbo.Customers where City == mycityorder by ContactName) { … } Type inference

  17. SQL = data model + query syntax Select Name, Age From CustomersWhere City = "Seattle" Table of rows

  18. XQuery/XPath = data model + query syntax From $C In CustomersWhere $C/City = "Seattle"Return<CustName={$C/Name}> { $C/Age }</Cust> Set of nodes

  19. Objects = data model + query syntax Foreach C In Customers If C.City="Seattle"R.Add(New With {C.Name, C.Age})End IfNext Collection of objects

  20. T  (T  Bool)  T Filtering 2 2 0 3 X Mod 2 = 0 0 3 6 5 6 5 1 1 4 4

  21. Mapping T  (T  S)  S 2 4 X * 2 0 3 0 6 6 5 12 10 1 2 4 8

  22. Aggregating T  (S, (S,T)  S)  S 2 Sum 0 3 6 5 21 1 4 T  ((T,T)  T)  T

  23. Monads ! A container type ℳ<T> A function type ST A constructor ℳ<T> Unit<T>(T src) ℳ<T> SelectMany<S,T> (ℳ<S> src, Sℳ<T> f) A composer

  24. Monads ! IEnumerable<T> IQueryable<T> ℳ<T> Func<S,T>Expr<Func<S,T>> ST ℳ<T> Unit<T>(T src) ℳ<T> SelectMany<S,T> (ℳ<S> src, Sℳ<T> f) Standard Query Pattern(generics not expressive enough)

  25. LINQ Project == monad comprehensions in C# & VB VB 9 C# 3.0 … StandardQueryOperators DLinq(relational) XLinq(xml) LINQ Framework

  26. Features • Local Type Inference • Object & Collection Initializers • Anonymous Types • Lambda Expressions • Query Comprehensions • Extension Methods • Expression Trees • Simplified Properties • Partial Methods • Deep XML Support (VB) • Nullable Types (VB) Enables Language Extensions via libraries

  27. LINQ 2.0 A better paradigm for programming massive clusters of commodity hardware than Google MapReduce based on LINQ

  28. From W In WordsGroup By WAggregate N = Count()Select W, N Map Group By Repartition Aggregate

  29. SawzallExample 3 submitsthroughweek: table sum[minute: int] of count: int; log: P4ChangelistStats = input; t: time = log.time; # microseconds minute: int = minuteof(t) +60*(hourof(t) +24*(dayofweek(t)-1)); emit submitsthroughweek[minute] <- 1;

  30. Using C# 3.0Comprehensions var SubmitsThroughWeek =from s in db.Submits group s by s.SubmitTime.Minute + 60*(s.SubmitTime.Hour + 24*s.SubmitTime.DayOfWeek) into g selectnew { minute = g.Key , count = g.Count() };

  31. Using Visual Basic 9Comprehensions Dim SubmitsThroughWeek =From s In db.Submits GroupBy Minute = s.SubmitTime.Minute + 60*(s.SubmitTime.Hour + 24*s.SubmitTime.DayOfWeek) Into Minute, Count()

  32. UsingStandard Sequence Operators var SubmitsThroughWeek = db.Submits .GroupBy(s=>s.SubmitTime.Minute + 60*(s.SubmitTime.Hour + 24*s.SubmitTime.DayOfWeek)) .Select(g=>new { minute=g.Key , count=g.Count()} );

  33. Repartition “Map” “Reduce”

  34. Division By 0 Is The Goal, Not An Error

  35. Do you see a pattern? Functional PL Object-Oriented PL Smalltalk Java Haskell OCaml XML JSON LaTex MS Word Betamax VHS Nouvelle Cuisine Fastfood Semantic WebSearch … …

  36. “For Dummies” Version Next release is even better! Cool! Geeks P(success) = F(10X improvement * Moore’s Law) P(success) = F(perceived crisis/perceived pain of adoption) Coerce users to believe gadgets will make them happy Marketing Users Just want to get job done No patience to learn new stuff

  37. C 10x better Haskell Haskell98 Moore’sLaw Haskell’

  38. Change Function to the rescue What is the user biggest crisis? P(success) = F(perceived crisis perceived pain of adoption) How can we make adoption truly painless?

  39. Change Function to the rescue P(success) = F(perceived crisis perceived pain of adoption) P(success) = F(100% 0) P(success) = 

More Related