Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Hello!

Slide 3

Slide 3 text

Божидар

Slide 4

Slide 4 text

Bozhidar

Slide 5

Slide 5 text

Божo

Slide 6

Slide 6 text

Bozho cool

Slide 7

Slide 7 text

Bozo not cool

Slide 8

Slide 8 text

Bug cool

Slide 9

Slide 9 text

Sofia, Bulgaria Sofia, Bulgaria

Slide 10

Slide 10 text

Balkan Ruby @balkanruby https://balkanruby.com May 2017 Sofia, Bulgaria

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

bbatsov

Slide 14

Slide 14 text

Ruby & Rails style guides

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Not on Ruby’s Core Team

Slide 24

Slide 24 text

–Matz “We’ll aim to release Ruby 3 for the Olympic Games in Tokyo in 2020.”

Slide 25

Slide 25 text

Ruby is now mature

Slide 26

Slide 26 text

We’re aware of all of our mistakes

Slide 27

Slide 27 text

Compatibility is important

Slide 28

Slide 28 text

Ruby has survived for 24 years

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

People are still making a living a with Ruby

Slide 31

Slide 31 text

People are still making a living with COBOL

Slide 32

Slide 32 text

Build the things your users need, instead of the things they want.

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

The track record of recent Ruby innovation

Slide 35

Slide 35 text

Ruby != MRI

Slide 36

Slide 36 text

3.times do puts "Ruby Rocks!" end

Slide 37

Slide 37 text

Ruby 2.0

Slide 38

Slide 38 text

•keyword arguments •%i •UTF-8 is now the default source file encoding •Refinements (experimental feature)

Slide 39

Slide 39 text

Ruby 2.1

Slide 40

Slide 40 text

•Rational/Complex Literal •defs return value •Refinements are no longer experimental feature

Slide 41

Slide 41 text

Ruby 2.2

Slide 42

Slide 42 text

Nada

Slide 43

Slide 43 text

Ruby 2.3

Slide 44

Slide 44 text

•frozen string literals pragma •safe navigation operator (&.) •squiggly heredocs (<<~)

Slide 45

Slide 45 text

Ruby 2.4

Slide 46

Slide 46 text

•Unify Fixnum and Bignum into Integer •Support Unicode case mappings

Slide 47

Slide 47 text

Ruby 2.5?

Slide 48

Slide 48 text

•Top-level constant look-up is removed •rescue/else/ensure are allowed inside do/end blocks •refinements take place in string interpolations


Slide 49

Slide 49 text

Java innovates more!

Slide 50

Slide 50 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 51

Slide 51 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 52

Slide 52 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 53

Slide 53 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 54

Slide 54 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 55

Slide 55 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 56

Slide 56 text

No content

Slide 57

Slide 57 text

Trailblazer

Slide 58

Slide 58 text

Hanami

Slide 59

Slide 59 text

What about Ruby 3.0?

Slide 60

Slide 60 text

Little is known about it…

Slide 61

Slide 61 text

Little concrete is known about it…

Slide 62

Slide 62 text

Optional static typing? rejected

Slide 63

Slide 63 text

Duck inference?

Slide 64

Slide 64 text

Better support for concurrent & parallel programming

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

3 times faster performance?

Slide 67

Slide 67 text

mjit?

Slide 68

Slide 68 text

Getting rid of some quirky features?

Slide 69

Slide 69 text

We’re not going to repeat the Python 3 mistakes! — Matz

Slide 70

Slide 70 text

And what about the Perl 6 mistakes? — Bozhidar

Slide 71

Slide 71 text

Who said Ruby is dead? — Matz

Slide 72

Slide 72 text

Ruby is dead!

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

–Zach Tellman There has been a consistent migratory pattern from Ruby to node.js to Go, Rust, and Elixir. At first, each community is defined by its potential. But as that potential is realized, the community begins to be defined by its compromises. That change is felt most keenly by the people who were there first, who remember what it was like when anything seemed possible. They feel fenced in and so they move on, in search of their golden city…”

Slide 76

Slide 76 text

Stewardship: The Sobering Parts https://www.youtube.com/watch?v=2y5Pv4yN0b0

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

Ruby 4.0: To INFINITY and Beyond by Bozhidar Batsov

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

Codename Buzz

Slide 81

Slide 81 text

Ruby 4x4

Slide 82

Slide 82 text

Ruby 4 is going to be 4 times faster than Ruby 3

Slide 83

Slide 83 text

Ruby 4 is going to be 12 times faster than Ruby 2

Slide 84

Slide 84 text

Ruby 4 is finally going to be fast enough!

Slide 85

Slide 85 text

Ruby 4.0, the language

Slide 86

Slide 86 text

Ruby 4.0, the language (and maybe the Standard Library)

Slide 87

Slide 87 text

Design principle #1

Slide 88

Slide 88 text

Continue to optimize for happiness

Slide 89

Slide 89 text

Add some useful new features

Slide 90

Slide 90 text

Immutable data structures

Slide 91

Slide 91 text

vector

Slide 92

Slide 92 text

v = @[1, 2, 3]

Slide 93

Slide 93 text

immutable hash

Slide 94

Slide 94 text

m = @{one: 1, two: 2}

Slide 95

Slide 95 text

immutable set

Slide 96

Slide 96 text

s = @${1, 2, 3}

Slide 97

Slide 97 text

s = ${1, 2, 3}

Slide 98

Slide 98 text

Static typing and runtime contracts

Slide 99

Slide 99 text

Inspired by RDL

Slide 100

Slide 100 text

type '(Fixnum, Fixnum) -> String' def m(x, y) ... end

Slide 101

Slide 101 text

pre { |x| x > 0 } post { |r,x| r > 0 } def sqrt(x) # return the square root of x end

Slide 102

Slide 102 text

type '(Float x {{ x>=0 }}) -> Float y {{ y>=0 }}' def sqrt(x) # return the square root of x end

Slide 103

Slide 103 text

Better concurrency APIs

Slide 104

Slide 104 text

Inspired by concurrent-ruby

Slide 105

Slide 105 text

CSP

Slide 106

Slide 106 text

messages = Concurrent::Channel.new Concurrent::Channel.go do messages.put 'ping' end msg = messages.take puts msg

Slide 107

Slide 107 text

def sum(a, c) sum = a.reduce(0, &:+) c << sum # `<<` is an alias for `put` or `send` end a = [7, 2, 8, -9, 4, 0] l = a.length / 2 c = Concurrent::Channel.new Concurrent::Channel.go { sum(a[-l, l], c) } Concurrent::Channel.go { sum(a[0, l], c) } x, y = ~c, ~c # `~` is an alias for `take` or `receive` puts [x, y, x+y].join(' ')

Slide 108

Slide 108 text

Namespaces!

Slide 109

Slide 109 text

class A class B < A # bla end end

Slide 110

Slide 110 text

module A::B::M end

Slide 111

Slide 111 text

A::B.class_eval do module M end end

Slide 112

Slide 112 text

# does the right thing always namespace A::B module M end end

Slide 113

Slide 113 text

Pattern Matching

Slide 114

Slide 114 text

Deprecation API

Slide 115

Slide 115 text

class SomeClass extend Gem::Deprecate def no_more close end deprecate :no_more, :close, 2015, 5 def close # new logic here end end

Slide 116

Slide 116 text

class SomeClass deprecate replacement: close, version: 2 def no_more close end def close # new logic here end end

Slide 117

Slide 117 text

class SomeClass deprecate scope: :class, version: 2.1 def ala # something truly deep end def bala # something extremely profound end end

Slide 118

Slide 118 text

Design principle #2

Slide 119

Slide 119 text

Simplicity

Slide 120

Slide 120 text

Simplicity is the ultimate sophistication.

Slide 121

Slide 121 text

Less is more

Slide 122

Slide 122 text

Simplicity leads to happiness.

Slide 123

Slide 123 text

Let’s drop some stuff

Slide 124

Slide 124 text

Let’s drop some useless stuff

Slide 125

Slide 125 text

for loops

Slide 126

Slide 126 text

for name in names puts name end

Slide 127

Slide 127 text

names.each do |name| puts name end

Slide 128

Slide 128 text

autoload

Slide 129

Slide 129 text

BEGIN & END

Slide 130

Slide 130 text

END { puts 'Bye!' } puts 'Processing...' BEGIN { puts 'Starting...' }

Slide 131

Slide 131 text

puts 'Bye!' puts 'Starting...' puts 'Processing...'

Slide 132

Slide 132 text

Kernel#at_exit, anyone?

Slide 133

Slide 133 text

flip-flops

Slide 134

Slide 134 text

DATA.each_line do |line| print(line) if (line =~ /begin/)..(line =~ /end/) end

Slide 135

Slide 135 text

block comments

Slide 136

Slide 136 text

=begin comment line another comment line =end

Slide 137

Slide 137 text

Must be placed at the very beginning of a line

Slide 138

Slide 138 text

class SomeClass =begin This is a top comment. Or is it? =end def some_method end end

Slide 139

Slide 139 text

class SomeClass =begin This is a top comment. Or is it? =end def some_method end end

Slide 140

Slide 140 text

Character literals

Slide 141

Slide 141 text

pry(main)> ?a => "a"

Slide 142

Slide 142 text

$SAFE

Slide 143

Slide 143 text

https://bugs.ruby-lang.org/ issues/8468

Slide 144

Slide 144 text

No content

Slide 145

Slide 145 text

Refinements

Slide 146

Slide 146 text

Let’s drop some redundant stuff

Slide 147

Slide 147 text

There’s more than one way to do it

Slide 148

Slide 148 text

(There are way too many ways to do it)

Slide 149

Slide 149 text

core library method aliases

Slide 150

Slide 150 text

collect => map inject => reduce detect => find select => find_all sprintf => format length => size raise => fail

Slide 151

Slide 151 text

Where is filter?

Slide 152

Slide 152 text

map reduce find filter format length raise

Slide 153

Slide 153 text

Farewell, fail!

Slide 154

Slide 154 text

procs

Slide 155

Slide 155 text

No arity check

Slide 156

Slide 156 text

Non-local return

Slide 157

Slide 157 text

Do we really need them?

Slide 158

Slide 158 text

So many languages are getting by just fine with only lambdas…

Slide 159

Slide 159 text

No content

Slide 160

Slide 160 text

Single-quoted string literals

Slide 161

Slide 161 text

No content

Slide 162

Slide 162 text

A ton of obscure %-something literals

Slide 163

Slide 163 text

%s, %x, %w, %W, %, %i

Slide 164

Slide 164 text

%r, %q, %Q

Slide 165

Slide 165 text

So excited to be here!

Slide 166

Slide 166 text

puts "Hello, Budapest!" puts "Hello, Budapest!" puts "Hello, Budapest!”

Slide 167

Slide 167 text

for i in 1..3 puts "Hello, Budapest!" end

Slide 168

Slide 168 text

3.times do puts "Hello, Budapest!” end

Slide 169

Slide 169 text

3.times do puts %(Hello, Budapest!) end

Slide 170

Slide 170 text

3.times do puts %Q(Hello, Budapest!) end

Slide 171

Slide 171 text

3.times do puts 'Hello, Budapest!’ end

Slide 172

Slide 172 text

3.times do puts %q(Hello, Budapest!) end

Slide 173

Slide 173 text

No content

Slide 174

Slide 174 text

No content

Slide 175

Slide 175 text

Are all those options worth our while?

Slide 176

Slide 176 text

No content

Slide 177

Slide 177 text

Let’s fix some stuff!

Slide 178

Slide 178 text

and & or have the same precedence

Slide 179

Slide 179 text

So many nils floating around

Slide 180

Slide 180 text

pry(main)> "TOP".upcase => "TOP" pry(main)> "TOP".upcase! => nil

Slide 181

Slide 181 text

pry(main)> 0.zero? => true pry(main)> 1.zero? => false pry(main)> 0.nonzero? => nil pry(main)> 1.nonzero? => 1

Slide 182

Slide 182 text

Mutable strings

Slide 183

Slide 183 text

Even JavaScript got this right…

Slide 184

Slide 184 text

Reassignable constants

Slide 185

Slide 185 text

Reassignable constants

Slide 186

Slide 186 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 187

Slide 187 text

No content

Slide 188

Slide 188 text

Class variables

Slide 189

Slide 189 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"

Slide 190

Slide 190 text

Poorly named methods

Slide 191

Slide 191 text

Kernel#puts

Slide 192

Slide 192 text

Kernel#println, anyone?

Slide 193

Slide 193 text

Kernel#print

Slide 194

Slide 194 text

defined?

Slide 195

Slide 195 text

[1] pry(main)> defined? 10 => "expression" [2] pry(main)> defined? Test => nil [3] pry(main)> defined? TrueClass => "constant"

Slide 196

Slide 196 text

No content

Slide 197

Slide 197 text

Enumerable#include?

Slide 198

Slide 198 text

Enumerable#includes?

Slide 199

Slide 199 text

Kernel#%

Slide 200

Slide 200 text

'%d %d' % [20, 10]

Slide 201

Slide 201 text

sprintf('%d %d', 20, 10)

Slide 202

Slide 202 text

sprintf( '%{first} %{second}', first: 20, second: 10 )

Slide 203

Slide 203 text

format('%{first} %{second}', first: 20, second: 10)

Slide 204

Slide 204 text

In what universe would you prefer Kernel#% over Kernel#format???

Slide 205

Slide 205 text

Perl-style global variables

Slide 206

Slide 206 text

$:

Slide 207

Slide 207 text

$LOAD_PATH

Slide 208

Slide 208 text

$;

Slide 209

Slide 209 text

$FIELD_SEPARATOR

Slide 210

Slide 210 text

$*

Slide 211

Slide 211 text

$ARGV

Slide 212

Slide 212 text

JRuby defines the English aliases by default

Slide 213

Slide 213 text

Ruby 4.0 will do this as well!

Slide 214

Slide 214 text

WTF? Global variables?

Slide 215

Slide 215 text

No content

Slide 216

Slide 216 text

Even Java doesn’t have globals…

Slide 217

Slide 217 text

The future of the standard library

Slide 218

Slide 218 text

The Ruby Stdlib is a Ghetto http://www.mikeperham.com/2010/11/22/the-ruby-stdlib-is-a-ghetto/

Slide 219

Slide 219 text

A ton of legacy code (often last updated 2000-2003)

Slide 220

Slide 220 text

Horrible APIs

Slide 221

Slide 221 text

net/http anyone?

Slide 222

Slide 222 text

The Kill List • Net::* • DRb • REXML • RSS • Rinda • WEBrick • XML

Slide 223

Slide 223 text

What are the parts of the standard library you dislike the most? Why so?

Slide 224

Slide 224 text

No content

Slide 225

Slide 225 text

No content

Slide 226

Slide 226 text

No content

Slide 227

Slide 227 text

No content

Slide 228

Slide 228 text

1. Move the important bits to the Core Library

Slide 229

Slide 229 text

2. Remove everything outdated/obscure

Slide 230

Slide 230 text

3. Leverage modern Ruby features in the Standard Library

Slide 231

Slide 231 text

Wait, there’s more!

Slide 232

Slide 232 text

Formal language specification and compatibility test suite

Slide 233

Slide 233 text

Roadmaps for future Ruby releases

Slide 234

Slide 234 text

Epilogue

Slide 235

Slide 235 text

When will Ruby 4 be released?

Slide 236

Slide 236 text

Ruby 4.0 will likely never happen

Slide 237

Slide 237 text

No content

Slide 238

Slide 238 text

Ruby 4.0 ETA ~ 2048

Slide 239

Slide 239 text

Ruby 4.0 is already here!

Slide 240

Slide 240 text

No content

Slide 241

Slide 241 text

Opal

Slide 242

Slide 242 text

No content

Slide 243

Slide 243 text

No content

Slide 244

Slide 244 text

Clojure

Slide 245

Slide 245 text

Elixir

Slide 246

Slide 246 text

Scala

Slide 247

Slide 247 text

–William Gibson “Тhe future is already here it's just not evenly distributed.”

Slide 248

Slide 248 text

Felina

Slide 249

Slide 249 text

One more thing…

Slide 250

Slide 250 text

–Matz “Ruby is no longer my project. It’s the Ruby community’s project.”

Slide 251

Slide 251 text

File tickets

Slide 252

Slide 252 text

Send patches

Slide 253

Slide 253 text

Blog about the issues

Slide 254

Slide 254 text

Speak about the issues

Slide 255

Slide 255 text

Let’s make Ruby better together!

Slide 256

Slide 256 text

Ruby Ruby

Slide 257

Slide 257 text

Thanks! twitter: @bbatsov github: @bbatsov http//batsov.com http://emacsredux.com EuRuKo 2017 Budapest, Hungary 30.09.2017