Ruby:
The Bad Parts
narrated by Bozhidar I. Batsov
Slide 2
Slide 2 text
Вiтаю!
Slide 3
Slide 3 text
Доброго
ранку!
Slide 4
Slide 4 text
No content
Slide 5
Slide 5 text
I love Ruby
Slide 6
Slide 6 text
I’m an Emacs zealot
Slide 7
Slide 7 text
No content
Slide 8
Slide 8 text
bbatsov
Slide 9
Slide 9 text
No content
Slide 10
Slide 10 text
(think)
http://batsov.com
Slide 11
Slide 11 text
Emacs Redux
http://emacsredux.com
Slide 12
Slide 12 text
@bbatsov
Slide 13
Slide 13 text
No content
Slide 14
Slide 14 text
No content
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
No content
Slide 17
Slide 17 text
github.com/
bbatsov
Slide 18
Slide 18 text
I’m a mythbuster!
Slide 19
Slide 19 text
No content
Slide 20
Slide 20 text
No content
Slide 21
Slide 21 text
The Myth
Slide 22
Slide 22 text
Ruby is perfect!
Slide 23
Slide 23 text
The harsh
truth
Slide 24
Slide 24 text
No, it’s not!
Slide 25
Slide 25 text
No programming
language is perfect
Slide 26
Slide 26 text
(not even Clojure)
Slide 27
Slide 27 text
No content
Slide 28
Slide 28 text
The
problems
Slide 29
Slide 29 text
Ruby is object-
oriented
Slide 30
Slide 30 text
Ruby is dynamically
typed
Slide 31
Slide 31 text
Ruby doesn’t have
immutable data
structures
Slide 32
Slide 32 text
Ruby doesn’t have strong
concurrency primitives
Slide 33
Slide 33 text
Ruby doesn’t have
enough parentheses
Slide 34
Slide 34 text
Ruby is not Clojure!
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
The
REAL
problems
Slide 37
Slide 37 text
Problems with the
runtime
Slide 38
Slide 38 text
Ruby is slow
wrong
Slide 39
Slide 39 text
MRI is slow
indeed
Slide 40
Slide 40 text
Ruby’s threads suck
wrong
Slide 41
Slide 41 text
MRI’s threads suck
indeed
Slide 42
Slide 42 text
Running Ruby on
Windows is a pain in the
ass
wrong
Slide 43
Slide 43 text
Running MRI on Windows
is a pain in the ass
indeed
Slide 44
Slide 44 text
Ruby doesn’t do JIT
compilation
wrong
Slide 45
Slide 45 text
MRI doesn’t do JIT
compilation
indeed
Slide 46
Slide 46 text
The core library is not
very approachable for
Rubyists
Slide 47
Slide 47 text
Array#compact!
static VALUE
rb_ary_compact_bang(VALUE ary)
{
VALUE *p, *t, *end;
long n;
rb_ary_modify(ary);
p = t = (VALUE *)RARRAY_CONST_PTR(ary); /* WB: no new reference */
end = p + RARRAY_LEN(ary);
while (t < end) {
if (NIL_P(*t)) t++;
else *p++ = *t++;
}
n = p - RARRAY_CONST_PTR(ary);
if (RARRAY_LEN(ary) == n) {
return Qnil;
}
ary_resize_smaller(ary, n);
return ary;
}
lame
Slide 48
Slide 48 text
Array#compact!
def compact!
Rubinius.check_frozen
if (deleted = @tuple.delete(@start, @total, nil)) > 0
@total -= deleted
reallocate_shrink()
return self
else
return nil
end
end Rubinius
Slide 49
Slide 49 text
Even Java got this
right!
Slide 50
Slide 50 text
Language != Runtime
Slide 51
Slide 51 text
We need a better
“standard” runtime
Slide 52
Slide 52 text
Rubygems & Bundler
Slide 53
Slide 53 text
bundle exec rake
Slide 54
Slide 54 text
RubyGems 2.2 introduced
support for Gemfile
Slide 55
Slide 55 text
gem bundle
Slide 56
Slide 56 text
No content
Slide 57
Slide 57 text
The Rails Effect
Slide 58
Slide 58 text
Ruby (2005)
Slide 59
Slide 59 text
No content
Slide 60
Slide 60 text
Ruby (2006)
Slide 61
Slide 61 text
OMG, Rails is
amazing!
Slide 62
Slide 62 text
Ruby (2008)
Slide 63
Slide 63 text
OMG, Rails is
amazing & useful!
Slide 64
Slide 64 text
Ruby (today)
Slide 65
Slide 65 text
4%
96%
Web Development Other
Slide 66
Slide 66 text
10%
90%
Rails Other
Slide 67
Slide 67 text
No content
Slide 68
Slide 68 text
Ruby 2.2 includes many new features and improvements
for the increasingly diverse and expanding demands for
Ruby.
For example, Ruby’s Garbage Collector is now able to
collect Symbol type objects. This reduces memory
usage of Symbols; because GC was previously unable
to collect them before 2.2. Since Rails 5.0 will require
Symbol GC, it will support only Ruby 2.2 or later. (See
Rails 4.2 release post for details.)
Also, a reduced pause time thanks to the new
Incremental Garbage Collector will be helpful for running
Rails applications. Recent developments mentioned on
the Rails blog suggest that Rails 5.0 will take advantage
of Incremental GC as well as Symbol GC.
Slide 69
Slide 69 text
Ruby 2.2 includes many new features and improvements
for the increasingly diverse and expanding demands for
Ruby.
For example, Ruby’s Garbage Collector is now able to
collect Symbol type objects. This reduces memory
usage of Symbols; because GC was previously unable
to collect them before 2.2. Since Rails 5.0 will require
Symbol GC, it will support only Ruby 2.2 or later. (See
Rails 4.2 release post for details.)
Also, a reduced pause time thanks to the new
Incremental Garbage Collector will be helpful for running
Rails applications. Recent developments mentioned on
the Rails blog suggest that Rails 5.0 will take advantage
of Incremental GC as well as Symbol GC.
Slide 70
Slide 70 text
Ruby 2.2 includes many new features and improvements
for the increasingly diverse and expanding demands for
Ruby.
For example, Ruby’s Garbage Collector is now able to
collect Symbol type objects. This reduces memory
usage of Symbols; because GC was previously unable
to collect them before 2.2. Since Rails 5.0 will require
Symbol GC, it will support only Ruby 2.2 or later. (See
Rails 4.2 release post for details.)
Also, a reduced pause time thanks to the new
Incremental Garbage Collector will be helpful for running
Rails applications. Recent developments mentioned on
the Rails blog suggest that Rails 5.0 will take advantage
of Incremental GC as well as Symbol GC.
Slide 71
Slide 71 text
Ruby 2.2 includes many new features and improvements
for the increasingly diverse and expanding demands for
Ruby.
For example, Ruby’s Garbage Collector is now able to
collect Symbol type objects. This reduces memory
usage of Symbols; because GC was previously unable
to collect them before 2.2. Since Rails 5.0 will require
Symbol GC, it will support only Ruby 2.2 or later. (See
Rails 4.2 release post for details.)
Also, a reduced pause time thanks to the new
Incremental Garbage Collector will be helpful for running
Rails applications. Recent developments mentioned on
the Rails blog suggest that Rails 5.0 will take advantage
of Incremental GC as well as Symbol GC.
Slide 72
Slide 72 text
Ruby 2.2 includes many new features and improvements
for the increasingly diverse and expanding demands for
Ruby.
For example, Ruby’s Garbage Collector is now able to
collect Symbol type objects. This reduces memory
usage of Symbols; because GC was previously unable
to collect them before 2.2. Since Rails 5.0 will require
Symbol GC, it will support only Ruby 2.2 or later. (See
Rails 4.2 release post for details.)
Also, a reduced pause time thanks to the new
Incremental Garbage Collector will be helpful for running
Rails applications. Recent developments mentioned on
the Rails blog suggest that Rails 5.0 will take advantage
of Incremental GC as well as Symbol GC.
Slide 73
Slide 73 text
Ruby 2.2 includes many new features and improvements
for the increasingly diverse and expanding demands for
Ruby.
For example, Ruby’s Garbage Collector is now able to
collect Symbol type objects. This reduces memory
usage of Symbols; because GC was previously unable
to collect them before 2.2. Since Rails 5.0 will require
Symbol GC, it will support only Ruby 2.2 or later. (See
Rails 4.2 release post for details.)
Also, a reduced pause time thanks to the new
Incremental Garbage Collector will be helpful for running
Rails applications. Recent developments mentioned on
the Rails blog suggest that Rails 5.0 will take advantage
of Incremental GC as well as Symbol GC.
Slide 74
Slide 74 text
Fuck this
shit!!!
Slide 75
Slide 75 text
We need grow out of
Rails’s shadow!
Slide 76
Slide 76 text
Problems with the
community
Slide 77
Slide 77 text
No content
Slide 78
Slide 78 text
–George S. Patton
“If everyone is thinking alike,
then somebody isn’t thinking.”
Slide 79
Slide 79 text
Stewardship
Slide 80
Slide 80 text
Benevolent
dictators are
still dictators
Slide 81
Slide 81 text
No clear vision
Slide 82
Slide 82 text
No standard
Slide 83
Slide 83 text
Informal deprecation
policy
Slide 84
Slide 84 text
Limited collaboration with
alternative
implementations
Slide 85
Slide 85 text
No content
Slide 86
Slide 86 text
There’s nothing
notable here!
Slide 87
Slide 87 text
Where’s the
innovation?
Slide 88
Slide 88 text
rubydramas.com
Slide 89
Slide 89 text
rubydrama.com
Slide 90
Slide 90 text
Problems with the
language
Slide 91
Slide 91 text
The useless stuff
Slide 92
Slide 92 text
No content
Slide 93
Slide 93 text
for loops
Slide 94
Slide 94 text
for name in names
puts name
end
Slide 95
Slide 95 text
names.each do |name|
puts name
end
Slide 96
Slide 96 text
BEGIN & END
Slide 97
Slide 97 text
END {
puts 'Bye!'
}
puts 'Processing...'
BEGIN {
puts 'Starting...'
}
DATA.each_line do |line|
print(line) if (line =~ /begin/)..(line =~ /end/)
end
Slide 102
Slide 102 text
–Matz
“Under the current plan, I am not going to
remove flip-flop from 2.0,
since we are not going to made incompatible
changes anytime soon. We
have to wait until 3.0.”
https://bugs.ruby-lang.org/issues/5400
Slide 103
Slide 103 text
block comments
Slide 104
Slide 104 text
=begin
comment line
another comment line
=end
Slide 105
Slide 105 text
Must be placed at the
very beginning of a line
Slide 106
Slide 106 text
class SomeClass
=begin
This is a top comment.
Or is it?
=end
def some_method
end
end
Slide 107
Slide 107 text
class SomeClass
=begin
This is a top comment.
Or is it?
=end
def some_method
end
end
autoload
(deprecated & scheduled for removal in 3.0)
Slide 150
Slide 150 text
and, or, not
Slide 151
Slide 151 text
Those are not flow of
control operators!
Slide 152
Slide 152 text
and & or have the
same precedence
Slide 153
Slide 153 text
Mutable strings
Slide 154
Slide 154 text
Even JavaScript got
this right…
Slide 155
Slide 155 text
Reassignable
constants
Slide 156
Slide 156 text
pry(main)> A = 5
=> 5
pry(main)> A = 6
(pry):39: warning: already initialized constant A
(pry):38: warning: previous definition of A was here
=> 6
pry(main)> Class = 3
(pry):40: warning: already initialized constant Class
=> 3
pry(main)> Class
=> 3
Slide 157
Slide 157 text
Class variables
Slide 158
Slide 158 text
class Parent
@@class_var = 'parent'
def self.print_class_var
puts @@class_var
end
end
class Child < Parent
@@class_var = 'child'
end
Parent.print_class_var # => will print "child"