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

Bozhidar

Slide 6

Slide 6 text

Bożydar

Slide 7

Slide 7 text

Bożydar

Slide 8

Slide 8 text

Bożo cool

Slide 9

Slide 9 text

@bbatsov

Slide 10

Slide 10 text

Sofia, Bulgaria Sofia, Bulgaria

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

bbatsov

Slide 16

Slide 16 text

Ruby, RSpec & Rails style guides

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

I’m back!

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Not on Ruby’s Core Team

Slide 30

Slide 30 text

Matz on Ruby

Slide 31

Slide 31 text

Ruby is now mature

Slide 32

Slide 32 text

We’re aware of all of our mistakes

Slide 33

Slide 33 text

Compatibility is important

Slide 34

Slide 34 text

Most ideas for changes will be discarded

Slide 35

Slide 35 text

Ruby has survived for 24 years

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Ruby is dead every year.

Slide 38

Slide 38 text

People are still making a living with Ruby

Slide 39

Slide 39 text

People are still making a living with COBOL

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

The track record of recent Ruby innovation

Slide 43

Slide 43 text

Ruby != MRI

Slide 44

Slide 44 text

3.times do puts "Ruby Rocks!" end

Slide 45

Slide 45 text

Ruby 2.0

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

Ruby 2.1

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

Ruby 2.2

Slide 50

Slide 50 text

Nada

Slide 51

Slide 51 text

Ruby 2.3

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

Ruby 2.4

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

Ruby 2.5

Slide 56

Slide 56 text

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


Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

Java innovates more!

Slide 59

Slide 59 text

JavaScript innovates way more!

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

Ruby.NEXT: Live Long and prosper by Bożydar Batsov

Slide 62

Slide 62 text

Ruby 2.6

Slide 63

Slide 63 text

•endless ranges (1..) •begin/else/end is now a syntax error (it used to be a warning) •some core lib methods now take optional keyword arguments (e.g. system(), Integer(), Float()) •a first stab at MJIT •built-in AST module

Slide 64

Slide 64 text

arr[1..-1]

Slide 65

Slide 65 text

arr[1..]

Slide 66

Slide 66 text

arr.drop(1)

Slide 67

Slide 67 text

There’s no easy way to express an infinite loop with index in Ruby

Slide 68

Slide 68 text

1.step …

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

Float("foo", exception: false)

Slide 71

Slide 71 text

Float("foo", exception: false)

Slide 72

Slide 72 text

AST Module

Slide 73

Slide 73 text

pry(main)> Ripper.sexp('alias :some :test') => [:program, [[:alias, [:symbol_literal, [:symbol, [:@ident, "some", [1, 7]]]], [:symbol_literal, [:symbol, [:@ident, "test", [1, 13]]]]]]]

Slide 74

Slide 74 text

each(:method_add_arg, sexp) do |s| next if s[1][0] != :call receiver = s[1][1][1] method_name = s[1][3][1] if receiver && receiver[1] == 'Array' && method_name == 'new' && s[2] == [:arg_paren, nil] offences.delete(Offence.new(:convention, receiver[2].lineno, ERROR_MESSAGE)) add_offence(:convention, receiver[2].lineno, ERROR_MESSAGE) end end

Slide 75

Slide 75 text

What about Ruby 3.0?

Slide 76

Slide 76 text

Little is known about it…

Slide 77

Slide 77 text

Little concrete is known about it…

Slide 78

Slide 78 text

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

Slide 79

Slide 79 text

Duck inference?

Slide 80

Slide 80 text

Better support for concurrent & parallel programming

Slide 81

Slide 81 text

Guilds

Slide 82

Slide 82 text

GIL -> Global Interpreter Lock

Slide 83

Slide 83 text

GIL -> Guild Interpreter Lock

Slide 84

Slide 84 text

https://olivierlacan.com/posts/ concurrency-in-ruby-3-with-guilds/

Slide 85

Slide 85 text

3 times faster performance?

Slide 86

Slide 86 text

(3 times faster performance than Ruby 2.0)

Slide 87

Slide 87 text

Ruby 2.5 is 154% faster than Ruby 2.0

Slide 88

Slide 88 text

Getting rid of some quirky features?

Slide 89

Slide 89 text

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

Slide 90

Slide 90 text

And what about the Perl 6 mistakes? — Bożydar

Slide 91

Slide 91 text

I’ve got a “secret” for you…

Slide 92

Slide 92 text

There’s no real plan for Ruby 3

Slide 93

Slide 93 text

Ruby 3 is not a real release!

Slide 94

Slide 94 text

Ruby 3 is an idea!

Slide 95

Slide 95 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 96

Slide 96 text

No content

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

Good artists copy; great artists steal. — Pablo Picasso

Slide 99

Slide 99 text

We looked for “inspiration” everywhere…

Slide 100

Slide 100 text

PHP

Slide 101

Slide 101 text

Visual Basic Script

Slide 102

Slide 102 text

Java

Slide 103

Slide 103 text

The Future of Java and the JDK Who’s in charge? https://www.youtube.com/watch?v=HpbchS5kmio

Slide 104

Slide 104 text

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

Slide 105

Slide 105 text

Maintainer vs Programmer

Slide 106

Slide 106 text

Long-term vs short-term

Slide 107

Slide 107 text

Foresight vs short-sightedness

Slide 108

Slide 108 text

Key take-aways

Slide 109

Slide 109 text

You need a clear strategy

Slide 110

Slide 110 text

You need a detailed game-plan (roadmap) for implementing your strategy

Slide 111

Slide 111 text

Additive changes, instead of destructive ones

Slide 112

Slide 112 text

It’s better to deprecate than to remove

Slide 113

Slide 113 text

Small increments

Slide 114

Slide 114 text

Guiding principles

Slide 115

Slide 115 text

Ruby Next, the language

Slide 116

Slide 116 text

Design principle #0

Slide 117

Slide 117 text

Continuous thoughtful innovation

Slide 118

Slide 118 text

Design principle #1

Slide 119

Slide 119 text

Continue to optimize for happiness

Slide 120

Slide 120 text

Add some useful new features

Slide 121

Slide 121 text

Make deprecating things easy

Slide 122

Slide 122 text

class Foo # DEPRECATED: Please use useful instead. def useless warn "[DEPRECATION] `useless` is deprecated. Please use `useful` instead." useful end def useful # ... end end

Slide 123

Slide 123 text

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

Slide 124

Slide 124 text

Immutable data structures

Slide 125

Slide 125 text

vector

Slide 126

Slide 126 text

v = @[1, 2, 3]

Slide 127

Slide 127 text

immutable hash

Slide 128

Slide 128 text

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

Slide 129

Slide 129 text

immutable set

Slide 130

Slide 130 text

s = @${1, 2, 3}

Slide 131

Slide 131 text

s = ${1, 2, 3}

Slide 132

Slide 132 text

arr1 - arr2

Slide 133

Slide 133 text

[1,2] - [1,2,3] => [] [1,2,9] - [1,2,3] => [9]

Slide 134

Slide 134 text

${1,2} ^ ${1,2,3} => [3] ${1,2,9} ^ ${1,2,3} => [9,3]

Slide 135

Slide 135 text

.to_immutable

Slide 136

Slide 136 text

.to_mutable

Slide 137

Slide 137 text

.to_v

Slide 138

Slide 138 text

Pattern Matching

Slide 139

Slide 139 text

class Struct def deconstruct; [self] + values; end end A = Struct.new(:a, :b) case A[0, 1] in (A, 1, 1) :not_match in A(x, 1) # Syntactic sugar of above p x #=> 0 end

Slide 140

Slide 140 text

class Struct def deconstruct; [self] + values; end end A = Struct.new(:a, :b) match A[0, 1] in (A, 1, 1) :not_match in A(x, 1) # Syntactic sugar of above p x #=> 0 end

Slide 141

Slide 141 text

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

Slide 142

Slide 142 text

No content

Slide 143

Slide 143 text

Design principle #2

Slide 144

Slide 144 text

Simplicity

Slide 145

Slide 145 text

Simplicity is the ultimate sophistication.

Slide 146

Slide 146 text

Less is more

Slide 147

Slide 147 text

Simplicity leads to happiness.

Slide 148

Slide 148 text

Let’s deprecate some stuff

Slide 149

Slide 149 text

deprecate != remove

Slide 150

Slide 150 text

Let’s deprecate some useless stuff

Slide 151

Slide 151 text

for loops

Slide 152

Slide 152 text

for name in names puts name end

Slide 153

Slide 153 text

names.each do |name| puts name end

Slide 154

Slide 154 text

autoload

Slide 155

Slide 155 text

flip-flops

Slide 156

Slide 156 text

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

Slide 157

Slide 157 text

block comments

Slide 158

Slide 158 text

=begin comment line another comment line =end

Slide 159

Slide 159 text

Must be placed at the very beginning of a line

Slide 160

Slide 160 text

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

Slide 161

Slide 161 text

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

Slide 162

Slide 162 text

Character literals

Slide 163

Slide 163 text

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

Slide 164

Slide 164 text

$SAFE

Slide 165

Slide 165 text

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

Slide 166

Slide 166 text

No content

Slide 167

Slide 167 text

Refinements

Slide 168

Slide 168 text

Let’s fix some stuff!

Slide 169

Slide 169 text

and & or have the same precedence

Slide 170

Slide 170 text

So many nils floating around

Slide 171

Slide 171 text

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

Slide 172

Slide 172 text

Optional keyword param?

Slide 173

Slide 173 text

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

Slide 174

Slide 174 text

x.non_zero?

Slide 175

Slide 175 text

!x.zero?

Slide 176

Slide 176 text

Mutable strings

Slide 177

Slide 177 text

Even JavaScript got this right…

Slide 178

Slide 178 text

Frozen string literals are a step in the right direction

Slide 179

Slide 179 text

ImmutableString

Slide 180

Slide 180 text

Frozen strings?

Slide 181

Slide 181 text

Reassignable constants

Slide 182

Slide 182 text

Reassignable constants

Slide 183

Slide 183 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 184

Slide 184 text

No content

Slide 185

Slide 185 text

Class variables

Slide 186

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

Slide 187 text

Poorly named methods

Slide 188

Slide 188 text

Kernel#puts

Slide 189

Slide 189 text

Kernel#println, anyone?

Slide 190

Slide 190 text

Kernel#print

Slide 191

Slide 191 text

defined?

Slide 192

Slide 192 text

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

Slide 193

Slide 193 text

No content

Slide 194

Slide 194 text

Enumerable#include?

Slide 195

Slide 195 text

Enumerable#includes?

Slide 196

Slide 196 text

File.exists is deprecated in favour of File.exist…

Slide 197

Slide 197 text

No content

Slide 198

Slide 198 text

Perl-style special global variables

Slide 199

Slide 199 text

$:

Slide 200

Slide 200 text

$LOAD_PATH

Slide 201

Slide 201 text

$;

Slide 202

Slide 202 text

$FIELD_SEPARATOR

Slide 203

Slide 203 text

$*

Slide 204

Slide 204 text

$ARGV

Slide 205

Slide 205 text

JRuby defines the English aliases by default

Slide 206

Slide 206 text

Why can’t we do this as soon as Ruby 2.6?

Slide 207

Slide 207 text

Why can’t we do all (most) of this as soon as Ruby 2.6?

Slide 208

Slide 208 text

WTF? Global variables?

Slide 209

Slide 209 text

No content

Slide 210

Slide 210 text

Even Java doesn’t have globals…

Slide 211

Slide 211 text

Felina

Slide 212

Slide 212 text

One more thing…

Slide 213

Slide 213 text

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

Slide 214

Slide 214 text

File tickets

Slide 215

Slide 215 text

Send patches

Slide 216

Slide 216 text

Blog about the issues

Slide 217

Slide 217 text

Speak about the issues

Slide 218

Slide 218 text

Let’s make Ruby better together!

Slide 219

Slide 219 text

Ruby Ruby

Slide 220

Slide 220 text

Thanks! twitter: @bbatsov github: @bbatsov http://batsov.com http://emacsredux.com Grill.rb 2018 Wroclaw, Poland 11.08.2018