BRUG - Hello, Scala


Published on

Introduction to functional programming for the Bristol Ruby User Group

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Afternoon everyone; welcome to this talk on Lift the web framework for Scala.
  • Before we get started with the presentation here’s a little information about me.** CLICK **I’ve been working on the lift project for around 2.5 years and using it in production for about 3 years. I work on a lot of different aspects of the framework but I am particularly interested in localization and process abstractions within Lift core. I also use Lift during my day job as do most of the other committers so in that sense we are not just making a framework for the sake of it, what we put into lift are real-life abstractions from the field ** CLICK **I am the author of a new book called Lift in Action, available on Manning publications. At the end of this talk I will be giving away a 40% discount for people who are interested in learning more about Lift.** CLICK **CodingScala since the end of 2007 – both with Lift and standalone Scala applications** CLICK **Before I came to the scala community I was working extensively with Ruby, along with Rails. Before that I was coding a lot of Objective-C and Java for desktop applications. ** CLICK **My day job is producing interesting sections of middleware for marketing automation and cross-media marketing for a division of Xerox corporation.** CLICK **
  • ModularityThe degree to which the parts can be separated and recombined.CompositionalityUnderstand the parts, and the connections, and you understand the whole.
  • creating a block (Ruby’s name for a closure) which takes a single parameter and passes it to the built-in puts method.  This block is then passed as an object to the each method of class Array, which calls the block once for each element in series
  • creating a block (Ruby’s name for a closure) which takes a single parameter and passes it to the built-in puts method.  This block is then passed as an object to the each method of class Array, which calls the block once for each element in series
  • BRUG - Hello, Scala

    1. 1. Hello, Scala Timothy Perrett BRUG, October 2011 software. done right.
    2. 2. About Me Author of Lift in Action Coding Scala since 2007 (its awesome) Background in both dynamic and statically typed languages Manufacturing and marketing automation is my day job software. done right.
    3. 3. Scalais…software. done right.
    4. 4. A statically typed, hybrid object-functional programming language software. done right.
    5. 5. functional programming is... software. done right.
    6. 6. …programming with functions software. done right.
    7. 7. A program is software. done right.
    8. 8. a single, referentially transparent expression software. done right.
    9. 9. An expression is software. done right.
    10. 10. a combination of sub expressions,using the constructs of a language. It evaluates to a result. software. done right.
    11. 11. a referentially transparent expression... software. done right.
    12. 12. …is an expression that can be replaced directly by its result without affecting the program operation. i.e. no side-effects software. done right.
    13. 13. a side-effect is... software. done right.
    14. 14. for example:  I/O  variable mutation throwing exceptions software. done right.
    15. 15. a function is... software. done right.
    16. 16. a relation between every value of type A to exactly one value of type B. (given f: A => B) software. done right.
    17. 17. functional programming gives you… software. done right.
    18. 18. modularity and compositionality software. done right.
    19. 19. fpis a style, not a language software. done right.
    20. 20. and static typing?... software. done right.
    21. 21. well, ruby is… software. done right.
    22. 22. duck typed… software. done right.
    23. 23. …scala is statically typed software. done right.
    24. 24. ”…types save you from errors, give you usefulprogram documentation and act as a safety net forrefactoring…" Martin Odersky software. done right.
    25. 25. code samples software. done right.
    26. 26. nums = [1,2,3,4] do |n|n % 2 == 0end software. done right.
    27. 27. valnums = Seq(1,2,3,4)nums.filter { n =>n % 2 == 0} software. done right.
    28. 28. valnums = Seq(1,2,3,4)nums.filter(_ % 2 == 0) software. done right.
    29. 29. useful data types software. done right.
    30. 30. valfoo = Option("thing")//=>Some(“thing”)val bar = Option(null)//=> None software. done right.
    31. 31. foo = … // comes from user inputif foo == nil then // do something with fooend software. done right.
    32. 32. // where foo is user inputOption(foo).map(x => …) software. done right.
    33. 33. implicit pimps software. done right.
    34. 34. class Foo(word: String) { def say = println(word)}implicit def strToFoo(in: String): Foo …“word”.say software. done right.
    35. 35. supports DSLs… software. done right.
    36. 36. take 2 pills and call me in the morningtake(2.pills).and(call).me(in).the(morning) software. done right.
    37. 37. blistering performance software. done right.
    38. 38. Performance 60 50 40 30 Scala Ruby (Jruby) Ruby 1.9 20 10 0 Scala Ruby (Jruby) Ruby 1.9source: software. done right.
    39. 39. heaps more awesome  Concurrency abstractions  Parallel data structures  BDD & property testing  Ad-hoc polymorphism  Higher-kinded types  Existential types software. done right.
    40. 40. Questions? Lift in software. done right.