$30 off During Our Annual Pro Sale. View Details »

Ruby (sometimes) sucks

Ruby (sometimes) sucks

Ruby is a neat and elegant language, we all love Ruby, that's why we are here. Right? But the limits of our language are the limits of our world. Would you really dare to use Ruby everywhere, everytime? Would you?... Here we are, the ones who know when Ruby sucks and what you can use instead, trust us! With no marketing bullshit, we will tell you about cases where Ruby just doesn't fit or can even give you a lot of headaches and sleepless nights. Wanna sleep well?

Pablo Astigarraga

October 20, 2012
Tweet

More Decks by Pablo Astigarraga

Other Decks in Programming

Transcript

  1. WAKE UP KIDS!
    Saturday, October 20, 12

    View Slide

  2. Ruby
    sucks
    Saturday, October 20, 12

    View Slide

  3. Ruby
    - sometimes -
    sucks
    Saturday, October 20, 12

    View Slide

  4. nu7hatch
    Poteland
    @
    @
    @
    @
    Saturday, October 20, 12

    View Slide

  5. Saturday, October 20, 12

    View Slide

  6. Saturday, October 20, 12

    View Slide

  7. Saturday, October 20, 12

    View Slide

  8. Saturday, October 20, 12

    View Slide

  9. We love Ruby
    Saturday, October 20, 12

    View Slide

  10. but let’s be
    honest
    Saturday, October 20, 12

    View Slide

  11. We are using it
    everywhere
    Saturday, October 20, 12

    View Slide

  12. the Right tool for
    the job
    We should have fucking shotguns for this shit
    Saturday, October 20, 12

    View Slide

  13. RUBY SUCKS AT
    CONCURRENCY
    Saturday, October 20, 12

    View Slide

  14. CONCURRENCY
    vs.
    PARALLELISM
    Saturday, October 20, 12

    View Slide

  15. CONCURRENCY
    Saturday, October 20, 12

    View Slide

  16. PARALLELISM
    Saturday, October 20, 12

    View Slide

  17. RUBY SUCKS AT ANY
    HIGH PERFORMANCE
    COMPUTING
    Saturday, October 20, 12

    View Slide

  18. ... LIKE IMAGE
    PROCESSING
    Saturday, October 20, 12

    View Slide

  19. ... CLUSTERING
    Saturday, October 20, 12

    View Slide

  20. ... AND SOMETIMES
    EVEN HIGH LOAD
    WEBSERVICES
    Saturday, October 20, 12

    View Slide

  21. ALTERNATIVES?
    Saturday, October 20, 12

    View Slide

  22. C - extensions
    Saturday, October 20, 12

    View Slide

  23. FAST... OBVIOUSL
    Y
    Saturday, October 20, 12

    View Slide

  24. HARD TO MAINTAIN
    Saturday, October 20, 12

    View Slide

  25. SOMETIMES SEGV...
    Saturday, October 20, 12

    View Slide

  26. ...AND STILL NOT
    PARALLEL AT ALL
    Saturday, October 20, 12

    View Slide

  27. CONCURRENCY IN
    RUBY
    Saturday, October 20, 12

    View Slide

  28. Celluloid
    Saturday, October 20, 12

    View Slide

  29. THE ACTOR PATTERN
    Saturday, October 20, 12

    View Slide

  30. class Jackson
    include Celluloid
    def initialize(name)
    @name = name
    end
    def set_status(status)
    @status = status
    end
    def report
    "#{@name} is #{@status}"
    end
    end
    Saturday, October 20, 12

    View Slide

  31. >> samuel = Jackson.new "Samuel L Jackson"
    => #@name="Samuel L Jackson">
    >> samuel.set_status "nervous"
    => "nervous"
    >> samuel.report
    => "Samuel L Jackson is nervous" # This is when
    motherfuckers get shot.
    >> samuel.async.set_status "asynchronously
    nervous"
    => nil
    >> samuel.report
    => "Samuel L Jackson is asynchronously nervous"
    Saturday, October 20, 12

    View Slide

  32. >> samuel = Jackson.new "Samuel L Jackson"
    => #@name="Samuel L Jackson">
    >> samuel.set_status "nervous"
    => "nervous"
    >> samuel.report
    => "Samuel L Jackson is nervous" # This is when
    motherfuckers get shot.
    >> samuel.async.set_status "asynchronously
    nervous"
    => nil
    >> samuel.report
    => "Samuel L Jackson is asynchronously nervous"
    Saturday, October 20, 12

    View Slide

  33. >> samuel = Jackson.new "Samuel L Jackson"
    => #@name="Samuel L Jackson">
    >> samuel.set_status "nervous"
    => "nervous"
    >> samuel.report
    => "Samuel L Jackson is nervous" # This is when
    motherfuckers get shot.
    >> samuel.async.set_status "asynchronously
    nervous"
    => nil
    >> samuel.report
    => "Samuel L Jackson is asynchronously nervous"
    Saturday, October 20, 12

    View Slide

  34. >> samuel = Jackson.new "Samuel L Jackson"
    => #@name="Samuel L Jackson">
    >> samuel.set_status "nervous"
    => "nervous"
    >> samuel.report
    => "Samuel L Jackson is nervous" # This is when
    motherfuckers get shot.
    >> samuel.async.set_status "asynchronously
    nervous"
    => nil
    >> samuel.report
    => "Samuel L Jackson is asynchronously nervous"
    Saturday, October 20, 12

    View Slide

  35. >> samuel = Jackson.new "Samuel L Jackson"
    => #@name="Samuel L Jackson">
    >> samuel.set_status "nervous"
    => "nervous"
    >> samuel.report
    => "Samuel L Jackson is nervous" # This is when
    motherfuckers get shot.
    >> samuel.async.set_status "asynchronously
    nervous"
    => nil
    >> samuel.report
    => "Samuel L Jackson is asynchronously nervous"
    Saturday, October 20, 12

    View Slide

  36. Fire and forget
    Saturday, October 20, 12

    View Slide

  37. Futures
    Saturday, October 20, 12

    View Slide

  38. >> future = samuel.future.report
    => #
    >> future.value
    => "Samuel L Jackson is nervous"
    >> future = Celluloid::Future.new { 2 + 2 }
    => #
    >> future.value
    => 4
    Saturday, October 20, 12

    View Slide

  39. >> future = samuel.future.report
    => #
    >> future.value
    => "Samuel L Jackson is nervous"
    >> future = Celluloid::Future.new { 2 + 2 }
    => #
    >> future.value
    => 4
    Saturday, October 20, 12

    View Slide

  40. Pools
    Saturday, October 20, 12

    View Slide

  41. class MyWorker
    include Celluloid
    def add_one(number)
    # roflscale computation goes here
    number + 1
    end
    end
    pool = MyWorker.pool(size: 9000, args:
    [:foo, :bar, :baz])
    i_am_three = pool.add_one(2)
    (0..10).to_a.map { |n| pool.future(:add_one, n) }
    Saturday, October 20, 12

    View Slide

  42. class MyWorker
    include Celluloid
    def add_one(number)
    # roflscale computation goes here
    number + 1
    end
    end
    pool = MyWorker.pool(size: 9000, args:
    [:foo, :bar, :baz])
    i_am_three = pool.add_one(2)
    (0..10).to_a.map { |n| pool.future(:add_one, n) }
    Saturday, October 20, 12

    View Slide

  43. class MyWorker
    include Celluloid
    def add_one(number)
    # roflscale computation goes here
    number + 1
    end
    end
    pool = MyWorker.pool(size: 9000, args:
    [:foo, :bar, :baz])
    i_am_three = pool.add_one(2)
    (0..10).to_a.map { |n| pool.future(:add_one, n) }
    Saturday, October 20, 12

    View Slide

  44. class MyWorker
    include Celluloid
    def add_one(number)
    # roflscale computation goes here
    number + 1
    end
    end
    pool = MyWorker.pool(size: 9000, args:
    [:foo, :bar, :baz])
    i_am_three = pool.add_one(2)
    (0..10).to_a.map { |n| pool.future(:add_one, n) }
    Saturday, October 20, 12

    View Slide

  45. one thing though...
    Saturday, October 20, 12

    View Slide

  46. MRI
    @
    ?
    Saturday, October 20, 12

    View Slide

  47. global
    Lock
    interpreter
    Saturday, October 20, 12

    View Slide

  48. ... NO REAL
    PARALLELISM
    Saturday, October 20, 12

    View Slide

  49. What to do?
    Saturday, October 20, 12

    View Slide

  50. rubinius and jruby
    Saturday, October 20, 12

    View Slide

  51. rubinius
    Saturday, October 20, 12

    View Slide

  52. rubinius
    Actual parallel threads
    Saturday, October 20, 12

    View Slide

  53. rubinius
    Actual parallel threads
    built with ruby
    Saturday, October 20, 12

    View Slide

  54. rubinius
    Actual parallel threads
    built with ruby
    We all love it
    Saturday, October 20, 12

    View Slide

  55. Rubinius
    Saturday, October 20, 12

    View Slide

  56. Rubinius
    compatibility PROBLEMS
    Saturday, October 20, 12

    View Slide

  57. Rubinius
    compatibility PROBLEMS
    not production ready
    Saturday, October 20, 12

    View Slide

  58. JRUBY
    Saturday, October 20, 12

    View Slide

  59. JRUBY
    REAL PARALLELISM
    Saturday, October 20, 12

    View Slide

  60. JRUBY
    REAL PARALLELISM
    access to java libraries!
    Saturday, October 20, 12

    View Slide

  61. JRUBY
    REAL PARALLELISM
    access to java libraries!
    Fairl
    y good performance
    Saturday, October 20, 12

    View Slide

  62. JRUBY
    Saturday, October 20, 12

    View Slide

  63. JRUBY
    must Marry java
    Saturday, October 20, 12

    View Slide

  64. JRUBY
    must Marry java
    compatibility PROBLEMS
    Saturday, October 20, 12

    View Slide

  65. TRUL
    Y CONCURRENT
    STUFF...
    Saturday, October 20, 12

    View Slide

  66. A LITTLE BIT OF
    HISTORY
    Saturday, October 20, 12

    View Slide

  67. ADA
    Saturday, October 20, 12

    View Slide

  68. TASK BASED
    CONCURRENCY
    Saturday, October 20, 12

    View Slide

  69. OCCAM
    Saturday, October 20, 12

    View Slide

  70. Communicating
    SEQUENTIAL
    PROGRAMMING
    Saturday, October 20, 12

    View Slide

  71. CLIK
    Saturday, October 20, 12

    View Slide

  72. SPAWN and SYNC
    Saturday, October 20, 12

    View Slide

  73. PLAN9
    Saturday, October 20, 12

    View Slide

  74. ALEF
    Saturday, October 20, 12

    View Slide

  75. LIMBO
    Saturday, October 20, 12

    View Slide

  76. MESSAGE PASSING
    Saturday, October 20, 12

    View Slide

  77. THAT’s ENOUGH
    Saturday, October 20, 12

    View Slide

  78. TIME TO GET
    SERIOUs
    Saturday, October 20, 12

    View Slide

  79. ERLANG
    Saturday, October 20, 12

    View Slide

  80. MESSAGE PASSING
    CONCURRENCY
    Saturday, October 20, 12

    View Slide

  81. NOT ONL
    Y A
    LANGUAGE
    Saturday, October 20, 12

    View Slide

  82. AN ECOSYSTEM FOR
    DISTRIBUTED APPS
    Saturday, October 20, 12

    View Slide

  83. ONL
    Y FOR THE PROS
    Saturday, October 20, 12

    View Slide

  84. TIME TO GO
    Saturday, October 20, 12

    View Slide

  85. MESSAGE PASSING
    DONE RIGHT
    Saturday, October 20, 12

    View Slide

  86. GO IN 5 MINUTES
    Saturday, October 20, 12

    View Slide

  87. SYNCHRONIZE YOUR
    WATCHES
    Saturday, October 20, 12

    View Slide

  88. BASICS
    Saturday, October 20, 12

    View Slide

  89. package main
    import "fmt"
    import uuid "github.com/nu7hatch/gouuid"
    import (
    "fmt"
    uuid "github.com/nu7hatch/gouuid"
    )
    func main() {
    // *snip*
    }
    Saturday, October 20, 12

    View Slide

  90. package main
    import "fmt"
    import uuid "github.com/nu7hatch/gouuid"
    import (
    "fmt"
    uuid "github.com/nu7hatch/gouuid"
    )
    func main() {
    // *snip*
    }
    Saturday, October 20, 12

    View Slide

  91. package main
    import "fmt"
    import uuid "github.com/nu7hatch/gouuid"
    import (
    "fmt"
    uuid "github.com/nu7hatch/gouuid"
    )
    func main() {
    // *snip*
    }
    Saturday, October 20, 12

    View Slide

  92. package main
    import "fmt"
    import uuid "github.com/nu7hatch/gouuid"
    import (
    "fmt"
    uuid "github.com/nu7hatch/gouuid"
    )
    func main() {
    // *snip*
    }
    Saturday, October 20, 12

    View Slide

  93. package main
    import "fmt"
    import uuid "github.com/nu7hatch/gouuid"
    import (
    "fmt"
    uuid "github.com/nu7hatch/gouuid"
    )
    func main() {
    // *snip*
    }
    Saturday, October 20, 12

    View Slide

  94. FUNCTIONS
    Saturday, October 20, 12

    View Slide

  95. func IDoNothingWrong() {
    }
    func PrintMotherfucker(something string) {
    fmt.Println(something + " motherfucker!")
    }
    func PrintMoreMotherfuckers(one, two string, three int) {
    fmt.Printf("%s, %s, %d motherfucker!\n",
    one, two, three)
    }
    func PrintAllTheThings(args ...string) {
    fmt.Println(args...)
    }
    Saturday, October 20, 12

    View Slide

  96. func IDoNothingWrong() {
    }
    func PrintMotherfucker(something string) {
    fmt.Println(something + " motherfucker!")
    }
    func PrintMoreMotherfuckers(one, two string, three int) {
    fmt.Printf("%s, %s, %d motherfucker!\n",
    one, two, three)
    }
    func PrintAllTheThings(args ...string) {
    fmt.Println(args...)
    }
    Saturday, October 20, 12

    View Slide

  97. func IDoNothingWrong() {
    }
    func PrintMotherfucker(something string) {
    fmt.Println(something + " motherfucker!")
    }
    func PrintMoreMotherfuckers(one, two string, three int) {
    fmt.Printf("%s, %s, %d motherfucker!\n",
    one, two, three)
    }
    func PrintAllTheThings(args ...string) {
    fmt.Println(args...)
    }
    Saturday, October 20, 12

    View Slide

  98. func IDoNothingWrong() {
    }
    func PrintMotherfucker(something string) {
    fmt.Println(something + " motherfucker!")
    }
    func PrintMoreMotherfuckers(one, two string, three int) {
    fmt.Printf("%s, %s, %d motherfucker!\n",
    one, two, three)
    }
    func PrintAllTheThings(args ...string) {
    fmt.Println(args...)
    }
    Saturday, October 20, 12

    View Slide

  99. CONSTANTS
    Saturday, October 20, 12

    View Slide

  100. const foo = 1
    const (
    one = iota
    two
    three
    four
    )
    Saturday, October 20, 12

    View Slide

  101. const foo = 1
    const (
    one = iota
    two
    three
    four
    )
    Saturday, October 20, 12

    View Slide

  102. VARIABLES
    Saturday, October 20, 12

    View Slide

  103. var (
    name string
    age int = 32
    )
    func IDoNothingWrong() {
    var name string
    age := 32
    // *snip*
    }
    Saturday, October 20, 12

    View Slide

  104. var (
    name string
    age int = 32
    )
    func IDoNothingWrong() {
    var name string
    age := 32
    // *snip*
    }
    Saturday, October 20, 12

    View Slide

  105. - Go will never get popular...
    - Porque?
    - Languages with := never get popular.
    Saturday, October 20, 12

    View Slide

  106. CONDITIONS
    Saturday, October 20, 12

    View Slide

  107. if vince.IsOutOfTheToilet() {
    // kill the bastard!
    } else {
    // stay cool...
    }
    // WROOOONG!
    if mia.IsOverdosed()
    vince.ApplyAdrenalineTo(mia)
    if vince, ok := people["Vince"]; !ok {
    panic "Vince is dead!"
    }
    Saturday, October 20, 12

    View Slide

  108. if vince.IsOutOfTheToilet() {
    // kill the bastard!
    } else {
    // stay cool...
    }
    // WROOOONG!
    if mia.IsOverdosed()
    vince.ApplyAdrenalineTo(mia)
    if vince, ok := people["Vince"]; !ok {
    panic "Vince is dead!"
    }
    Saturday, October 20, 12

    View Slide

  109. if vince.IsOutOfTheToilet() {
    // kill the bastard!
    } else {
    // stay cool...
    }
    // WROOOONG!
    if mia.IsOverdosed()
    vince.ApplyAdrenalineTo(mia)
    if vince, ok := people["Vince"]; !ok {
    panic "Vince is dead!"
    }
    Saturday, October 20, 12

    View Slide

  110. SLICES
    Saturday, October 20, 12

    View Slide

  111. var people []Person
    people := make([]Person, 5)
    dumbNumbers := []int{1,2,3,4}
    len(dumbNumbers) // => 4
    cap(people) // => 5
    motherfuckers := people[1:3]
    dumbNumbers := append(dumbNumbers, 5)
    Saturday, October 20, 12

    View Slide

  112. var people []Person
    people := make([]Person, 5)
    dumbNumbers := []int{1,2,3,4}
    len(dumbNumbers) // => 4
    cap(people) // => 5
    motherfuckers := people[1:3]
    dumbNumbers := append(dumbNumbers, 5)
    Saturday, October 20, 12

    View Slide

  113. var people []Person
    people := make([]Person, 5)
    dumbNumbers := []int{1,2,3,4}
    len(dumbNumbers) // => 4
    cap(people) // => 5
    motherfuckers := people[1:3]
    dumbNumbers := append(dumbNumbers, 5)
    Saturday, October 20, 12

    View Slide

  114. var people []Person
    people := make([]Person, 5)
    dumbNumbers := []int{1,2,3,4}
    len(dumbNumbers) // => 4
    cap(people) // => 5
    motherfuckers := people[1:3]
    dumbNumbers := append(dumbNumbers, 5)
    Saturday, October 20, 12

    View Slide

  115. var people []Person
    people := make([]Person, 5)
    dumbNumbers := []int{1,2,3,4}
    len(dumbNumbers) // => 4
    cap(people) // => 5
    motherfuckers := people[1:3]
    dumbNumbers := append(dumbNumbers, 5)
    Saturday, October 20, 12

    View Slide

  116. var people []Person
    people := make([]Person, 5)
    dumbNumbers := []int{1,2,3,4}
    len(dumbNumbers) // => 4
    cap(people) // => 5
    motherfuckers := people[1:3]
    dumbNumbers := append(dumbNumbers, 5)
    Saturday, October 20, 12

    View Slide

  117. var people []Person
    people := make([]Person, 5)
    dumbNumbers := []int{1,2,3,4}
    len(dumbNumbers) // => 4
    cap(people) // => 5
    motherfuckers := people[1:3]
    dumbNumbers := append(dumbNumbers, 5)
    Saturday, October 20, 12

    View Slide

  118. MAPS
    Saturday, October 20, 12

    View Slide

  119. var people map[string]Person
    people = make(map[string]Person)
    people := make(map[string]Person)
    people := map[string]Person{}
    jules := people["Jules"]
    delete(people, "Vince")
    Saturday, October 20, 12

    View Slide

  120. var people map[string]Person
    people = make(map[string]Person)
    people := make(map[string]Person)
    people := map[string]Person{}
    jules := people["Jules"]
    delete(people, "Vince")
    Saturday, October 20, 12

    View Slide

  121. var people map[string]Person
    people = make(map[string]Person)
    people := make(map[string]Person)
    people := map[string]Person{}
    jules := people["Jules"]
    delete(people, "Vince")
    Saturday, October 20, 12

    View Slide

  122. var people map[string]Person
    people = make(map[string]Person)
    people := make(map[string]Person)
    people := map[string]Person{}
    jules := people["Jules"]
    delete(people, "Vince")
    Saturday, October 20, 12

    View Slide

  123. var people map[string]Person
    people = make(map[string]Person)
    people := make(map[string]Person)
    people := map[string]Person{}
    jules := people["Jules"]
    delete(people, "Vince")
    Saturday, October 20, 12

    View Slide

  124. var people map[string]Person
    people = make(map[string]Person)
    people := make(map[string]Person)
    people := map[string]Person{}
    jules := people["Jules"]
    delete(people, "Vince")
    Saturday, October 20, 12

    View Slide

  125. LOOPS
    Saturday, October 20, 12

    View Slide

  126. for i := 0; i < 100; i++ {
    fmt.Println(i)
    }
    i := 0;
    for i < 1000 {
    fmt.Println(i)
    i++
    }
    for name, motherfucker := range motherfuckers {
    motherfucker.Kill()
    fmt.Printf("%s is fucking dead\n", name")
    }
    Saturday, October 20, 12

    View Slide

  127. for i := 0; i < 100; i++ {
    fmt.Println(i)
    }
    i := 0;
    for i < 1000 {
    fmt.Println(i)
    i++
    }
    for name, motherfucker := range motherfuckers {
    motherfucker.Kill()
    fmt.Printf("%s is fucking dead\n", name")
    }
    Saturday, October 20, 12

    View Slide

  128. for i := 0; i < 100; i++ {
    fmt.Println(i)
    }
    i := 0;
    for i < 1000 {
    fmt.Println(i)
    i++
    }
    for name, motherfucker := range motherfuckers {
    motherfucker.Kill()
    fmt.Printf("%s is fucking dead\n", name")
    }
    Saturday, October 20, 12

    View Slide

  129. STRUCTURES
    Saturday, October 20, 12

    View Slide

  130. type Vince struct {
    Stoned bool
    }
    type Stoner struct {
    Stoned bool
    }
    type Vince struct {
    Stoner
    }
    var vince Vince
    var vince = Vince{true}
    var vince = &Vince{true}
    func NewVince() *Vince {
    return &Vince{stoned: true}
    }
    Saturday, October 20, 12

    View Slide

  131. type Vince struct {
    Stoned bool
    }
    type Stoner struct {
    Stoned bool
    }
    type Vince struct {
    Stoner
    }
    var vince Vince
    var vince = Vince{true}
    var vince = &Vince{true}
    func NewVince() *Vince {
    return &Vince{stoned: true}
    }
    Saturday, October 20, 12

    View Slide

  132. type Vince struct {
    Stoned bool
    }
    type Stoner struct {
    Stoned bool
    }
    type Vince struct {
    Stoner
    }
    var vince Vince
    var vince = Vince{true}
    var vince = &Vince{true}
    func NewVince() *Vince {
    return &Vince{stoned: true}
    }
    Saturday, October 20, 12

    View Slide

  133. type Vince struct {
    Stoned bool
    }
    type Stoner struct {
    Stoned bool
    }
    type Vince struct {
    Stoner
    }
    var vince Vince
    var vince = Vince{true}
    var vince = &Vince{true}
    func NewVince() *Vince {
    return &Vince{stoned: true}
    }
    Saturday, October 20, 12

    View Slide

  134. type Vince struct {
    Stoned bool
    }
    type Stoner struct {
    Stoned bool
    }
    type Vince struct {
    Stoner
    }
    var vince Vince
    var vince = Vince{true}
    var vince = &Vince{true}
    func NewVince() *Vince {
    return &Vince{stoned: true}
    }
    Saturday, October 20, 12

    View Slide

  135. type Vince struct {
    Stoned bool
    }
    type Stoner struct {
    Stoned bool
    }
    type Vince struct {
    Stoner
    }
    var vince Vince
    var vince = Vince{true}
    var vince = &Vince{true}
    func NewVince() *Vince {
    return &Vince{stoned: true}
    }
    Saturday, October 20, 12

    View Slide

  136. type Vince struct {
    Stoned bool
    }
    type Stoner struct {
    Stoned bool
    }
    type Vince struct {
    Stoner
    }
    var vince Vince
    var vince = Vince{true}
    var vince = &Vince{true}
    func NewVince() *Vince {
    return &Vince{stoned: true}
    }
    Saturday, October 20, 12

    View Slide

  137. METHODS
    Saturday, October 20, 12

    View Slide

  138. type Vince struct {
    isStoned bool
    }
    func (vince *Vince) IsStoned() bool {
    return vince.isStoned
    }
    func (vince *Vince) SmokePot() bool {
    vince.isStoned = true
    }
    type FuckingInt int
    func (x FuckingInt) Square() int {
    return int(x) * int(x)
    }
    Saturday, October 20, 12

    View Slide

  139. type Vince struct {
    isStoned bool
    }
    func (vince *Vince) IsStoned() bool {
    return vince.isStoned
    }
    func (vince *Vince) SmokePot() bool {
    vince.isStoned = true
    }
    type FuckingInt int
    func (x FuckingInt) Square() int {
    return int(x) * int(x)
    }
    Saturday, October 20, 12

    View Slide

  140. INTERFACES
    Saturday, October 20, 12

    View Slide

  141. type Jules struct {}
    func (jules *Jules) IsStoned() bool {
    return false
    }
    type Vince struct {}
    func (vince *Vince) IsStoned() bool {
    return true
    }
    type Stoner interface {
    IsStoned() bool
    }
    func PrintStoner(s Stoner) {
    fmt.Printf("%x", s)
    }
    var x interface{}
    Saturday, October 20, 12

    View Slide

  142. type Jules struct {}
    func (jules *Jules) IsStoned() bool {
    return false
    }
    type Vince struct {}
    func (vince *Vince) IsStoned() bool {
    return true
    }
    type Stoner interface {
    IsStoned() bool
    }
    func PrintStoner(s Stoner) {
    fmt.Printf("%x", s)
    }
    var x interface{}
    Saturday, October 20, 12

    View Slide

  143. type Jules struct {}
    func (jules *Jules) IsStoned() bool {
    return false
    }
    type Vince struct {}
    func (vince *Vince) IsStoned() bool {
    return true
    }
    type Stoner interface {
    IsStoned() bool
    }
    func PrintStoner(s Stoner) {
    fmt.Printf("%x", s)
    }
    var x interface{}
    Saturday, October 20, 12

    View Slide

  144. type Jules struct {}
    func (jules *Jules) IsStoned() bool {
    return false
    }
    type Vince struct {}
    func (vince *Vince) IsStoned() bool {
    return true
    }
    type Stoner interface {
    IsStoned() bool
    }
    func PrintStoner(s Stoner) {
    fmt.Printf("%x", s)
    }
    var x interface{}
    Saturday, October 20, 12

    View Slide

  145. GOROUTINES AND
    CHANNELS
    Saturday, October 20, 12

    View Slide

  146. go func() {
    for i := 1; i < 100; i++ {
    fmt.Println(i)
    }
    }()
    go SomeMotherfuckingExpensiveLoop()
    go AnotherMotherfuckingLoop()
    // app is keep going here...
    var killed chan bool
    killed = make(chan bool)
    go func() {
    <-killed
    }()
    killed <- true
    <-time.After(10 * time.Second)
    Saturday, October 20, 12

    View Slide

  147. go func() {
    for i := 1; i < 100; i++ {
    fmt.Println(i)
    }
    }()
    go SomeMotherfuckingExpensiveLoop()
    go AnotherMotherfuckingLoop()
    // app is keep going here...
    var killed chan bool
    killed = make(chan bool)
    go func() {
    <-killed
    }()
    killed <- true
    <-time.After(10 * time.Second)
    Saturday, October 20, 12

    View Slide

  148. go func() {
    for i := 1; i < 100; i++ {
    fmt.Println(i)
    }
    }()
    go SomeMotherfuckingExpensiveLoop()
    go AnotherMotherfuckingLoop()
    // app is keep going here...
    var killed chan bool
    killed = make(chan bool)
    go func() {
    <-killed
    }()
    killed <- true
    <-time.After(10 * time.Second)
    Saturday, October 20, 12

    View Slide

  149. select {
    case <-jules.Shoot():
    fmt.Println("Jules killed motherfucker")
    case <-vince.Shoot():
    fmt.Println("Vince killed motherfucker")
    }
    select {
    // *snip*
    default:
    // do something while waiting for the channels.
    }
    Saturday, October 20, 12

    View Slide

  150. select {
    case <-jules.Shoot():
    fmt.Println("Jules killed motherfucker")
    case <-vince.Shoot():
    fmt.Println("Vince killed motherfucker")
    }
    select {
    // *snip*
    default:
    // do something while waiting for the channels.
    }
    Saturday, October 20, 12

    View Slide

  151. GOING DEEPER...
    Saturday, October 20, 12

    View Slide

  152. func main() {
    for i := 0; i < 10; i++ {
    fmt.Println(i)
    }
    }
    Saturday, October 20, 12

    View Slide

  153. func main() {
    go func() {
    for i := 0; i < 10; i++ {
    fmt.Println(i)
    }
    }()
    }
    Saturday, October 20, 12

    View Slide

  154. func PrintShit() {
    for i := 0; i < 10; i++ {
    fmt.Println(i)
    }
    }
    func main() {
    go PrintShit()
    <-time.After(2 * time.Second)
    }
    Saturday, October 20, 12

    View Slide

  155. func PrintShit(done chan bool) {
    for i := 1; i < 10; i++ {
    fmt.Println(i)
    }
    done <- true
    }
    func main() {
    isItThereYet := make(chan bool)
    go PrintShit(isItThereYet)
    <-isItThereYet
    }
    Saturday, October 20, 12

    View Slide

  156. func PrintShit() <-chan bool {
    done := make(chan bool)
    go func() {
    for i := 1; i < 10; i++ {
    fmt.Println(i)
    }
    done <- true
    }()
    return done
    }
    func main() {
    <-PrintShit()
    }
    Saturday, October 20, 12

    View Slide

  157. SUMARIZING...
    Saturday, October 20, 12

    View Slide

  158. Limits of your language are limits of
    your world...
    Saturday, October 20, 12

    View Slide

  159. Limits of your language are limits of
    your world...
    Some Smart Motherfucker
    Saturday, October 20, 12

    View Slide

  160. Thank you
    @
    !
    Saturday, October 20, 12

    View Slide

  161. Saturday, October 20, 12

    View Slide

  162. Questions
    Saturday, October 20, 12

    View Slide

  163. I DON’T REMEMBER ASKING YOU A
    GODDAMN THING!!
    Saturday, October 20, 12

    View Slide

  164. Links ‘n stuff
    this talk: - http://bit.ly/RDGxyC
    rubinius: - http://rubini.us/
    Celulloid - http://celluloid.io/
    ERLANG: - http://erlang/
    GO: - http://golang.org/
    GO: TOUR - http://tour.golang.org/
    Saturday, October 20, 12

    View Slide

  165. nu7hatch
    Poteland
    @
    @
    @
    @
    Saturday, October 20, 12

    View Slide

  166. WWW.AREYOUFUCKINGCODING.ME
    WWW.POTELAND.COM
    Saturday, October 20, 12

    View Slide