$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. the Right tool for the job We should have fucking

    shotguns for this shit Saturday, October 20, 12
  2. 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
  3. >> samuel = Jackson.new "Samuel L Jackson" => #<Celluloid::Actor(Jackson:0x00000100a312d0) @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
  4. >> samuel = Jackson.new "Samuel L Jackson" => #<Celluloid::Actor(Jackson:0x00000100a312d0) @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
  5. >> samuel = Jackson.new "Samuel L Jackson" => #<Celluloid::Actor(Jackson:0x00000100a312d0) @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
  6. >> samuel = Jackson.new "Samuel L Jackson" => #<Celluloid::Actor(Jackson:0x00000100a312d0) @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
  7. >> samuel = Jackson.new "Samuel L Jackson" => #<Celluloid::Actor(Jackson:0x00000100a312d0) @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
  8. >> future = samuel.future.report => #<Celluloid::Future:0x000001009759b8> >> future.value => "Samuel

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

    L Jackson is nervous" >> future = Celluloid::Future.new { 2 + 2 } => #<Celluloid::Future:0x000001008425f0> >> future.value => 4 Saturday, October 20, 12
  10. 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
  11. 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
  12. 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
  13. 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
  14. package main import "fmt" import uuid "github.com/nu7hatch/gouuid" import ( "fmt"

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

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

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

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

    uuid "github.com/nu7hatch/gouuid" ) func main() { // *snip* } Saturday, October 20, 12
  19. 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
  20. 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
  21. 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
  22. 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
  23. const foo = 1 const ( one = iota two

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

    three four ) Saturday, October 20, 12
  25. var ( name string age int = 32 ) func

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

    IDoNothingWrong() { var name string age := 32 // *snip* } Saturday, October 20, 12
  27. - Go will never get popular... - Porque? - Languages

    with := never get popular. Saturday, October 20, 12
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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
  36. 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
  37. 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
  38. 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
  39. 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
  40. 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
  41. 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
  42. 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
  43. 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
  44. 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
  45. 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
  46. 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
  47. 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
  48. 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
  49. 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
  50. 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
  51. 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
  52. 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
  53. 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
  54. 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
  55. 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
  56. 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
  57. 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
  58. 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
  59. 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
  60. 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
  61. 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
  62. 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
  63. 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
  64. 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
  65. func main() { for i := 0; i < 10;

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

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

    i++ { fmt.Println(i) } } func main() { go PrintShit() <-time.After(2 * time.Second) } Saturday, October 20, 12
  68. 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
  69. 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
  70. Limits of your language are limits of your world... Some

    Smart Motherfucker Saturday, October 20, 12
  71. 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