00:00:01.800
all right this is pretty awesome to see um yeah we're going to be starting uh we're going to be starting this
00:00:08.400
but I I want to say it's just so amazing to see people to see people chatting and
00:00:15.599
yeah not willing to stop and just connecting this is pretty awesome yeah
00:00:20.960
thank you all um thank you all for coming I I should speak up got it
00:00:30.400
you remember my rails c talk I can do should I do this
00:00:38.280
no you can control yeah all right awesome um so yeah uh we we're beginning
00:00:45.360
and um so first of all thank you all for coming my name is Serena uh huge shout
00:00:51.920
out to chim hosting us today
00:01:03.519
so cool very kind of non-standard space yeah and but most of all thank you
00:01:11.080
thank thank you to all of you for coming for connecting for being here and um
00:01:17.360
just kind of building this excitement for Ruby and rails and this
00:01:23.560
community uh that I'm enjoying so much you guys have no idea what it means uh
00:01:30.680
because since I moved to San Francisco in January this event has been the
00:01:36.399
highlight of my experience here and I just love uh seeing all of you and
00:01:42.799
seeing so many uh now already familiar faces and friends so thank you thank you
00:01:48.719
for coming so we're gonna have a pretty crazy uh agenda today because we have
00:01:55.479
Noel rapping whom whose books I'm sure you all know uh talking about um Rubik system and and
00:02:05.079
Noel works for chime so he will open with some intro about Chim
00:02:12.680
uh then we have my colleague Vadim de also a PO popular book author uh talking
00:02:20.160
about some beautiful patterns and then after the Break um we have an open mic
00:02:29.040
as always so prepare your short announcements
00:02:35.440
shoutouts if you're hiring if you're looking to get hired if you are just
00:02:41.280
discovered some gem or if you have a question please prepare those little
00:02:47.360
bits to share and finally we'll have a presentation from brandan which will be
00:02:54.200
a u like a sneak peek into rubikon keynote this year here so it's going to
00:03:01.280
be pretty amazing and uh finally after um after this uh we can go whomever can
00:03:11.959
we can go grab drinks in a place nearby so that's kind of an addition to the
00:03:18.040
agenda yeah I I just loved people did it last time and it was kind of cool after
00:03:23.920
GitHub so yeah with that uh let me just um uh
00:03:33.200
what happened what happened uh remind you
00:03:53.959
yeah okay this pause oh this pause is sponsored by evil Martians just just for
00:04:00.439
you to yeah just to watch our logos more so yeah I run evil martians we are on a
00:04:07.079
mission to support startups on Rails so we built open source I hope you've
00:04:12.319
recognize and use uh some of that we build uh we write content but also we support companies so if you have if
00:04:18.359
you're a real startup and you're struggling with something please reach out we'll fix those problems for you and
00:04:24.680
will help you be insanely successful just like ch
00:04:31.000
yeah so uh by the way final link um SF Ruby at Luma sign up this is where you
00:04:39.160
will see the uh next event um which I'm not disclosing the date yet uh but I'm
00:04:46.960
going to say we'll have a rockstar okay we'll have Jeremy Evans
00:04:52.280
right all right I said it yep um now no you're up
00:05:01.160
so we have this amazing uh book author
00:05:07.880
and um Ruby is Enthusiast I'm sure you uh you might have seen his presentations
00:05:13.880
at many conferences but today no traveled to San Francisco to meet all of
00:05:21.039
you and to what could be I I I have no idea like what could be better and more
00:05:27.880
amazing than to have no rapping speaking on behalf of Chim at our
00:05:36.800
Meetup I am thank you um thank you for that extremely generous introduction I am
00:05:42.680
going to try something ridiculous which is to run my presentation off of my phone for stupid Logistics reasons that
00:05:48.319
you don't care about um hopefully it will work if not I have at least two backup plans uh one of which is just
00:05:55.360
vamping anyway who needs slides slides are not important uh I want to give a shout out out to um the chime workspace
00:06:02.479
team that put together the food spread and set up the room and made sure all the AV and stuff was laid out uh just
00:06:08.880
really great people to work with um also we have a number of chime employees here
00:06:15.039
chime people please raise your hand um they will be happy to talk to you about
00:06:20.520
chime uh during the break or whenever uh you want to uh chime is a financial
00:06:26.680
services company uh our we do a ton of rubyan rails on our back end um we are
00:06:34.120
possibly hiring I honestly have no idea uh careers chime.com careers is a good
00:06:39.800
place to go we are hiring I'm sure we're hiring we're probably hiring
00:06:44.919
um and I uh if you are interested in making the financial World better for
00:06:51.360
people who could use uh a better Financial World um CH is a great place
00:06:56.599
to be uh so I'm sure all the time employees will be very happy happy to speak to you about that uh uh during the
00:07:02.840
break or afterwards so I wanted to thank them and uh you can talk among yourselves for like two seconds while I
00:07:08.720
figure out how to share my screen
00:07:23.000
here outstanding outstanding outstanding uh there we go
00:07:32.000
better there we go yeah all right very exciting uh the dumbest thing I've actually ever
00:07:39.360
done uh yeah normally I normally I leave this up while I introduce stuff uh so uh
00:07:46.120
but we'll just keep going okay so I had kind of a unique
00:07:53.440
experience with a legacy Ruby codebase uh a legacy Ruby project I guess it's
00:08:00.000
it's better to say um and that was of course this uh when I suddenly found myself contractually obligated to turn
00:08:07.840
the book on the left which is the fourth edition of the programming Ruby book which came out in 2013 into the book on
00:08:15.240
the right which is the uh fifth edition which came out last January this uh forced me uh so the so
00:08:22.720
sorry the existing version was a pretty good snapshot of the Ruby ecosystem as it existed in 2012 um much has changed
00:08:30.000
since then as I'm sure you can all understand uh in particular we had I think 11 versions of Ruby 2122 so on
00:08:38.120
through 3 three um and countless other uh versions of gems and tools and all
00:08:45.040
sorts of changes like that and that forced me to confront uh what had
00:08:51.120
changed in the ecosystem like had very pragmatic need to think both about what had changed and which of those changes
00:08:58.200
were most important uh because the goal of course is to change the book but not change the book
00:09:05.959
right we want it to still be the reference place for people beginning rubyists intermediate rubyist expert
00:09:12.399
rubius rubyists we still wanted to give that overview of the entire Ruby
00:09:17.959
ecosystem so um this is a metaphor I guess for legacy code um but it's not
00:09:24.360
just a metaphor um as you may know pragmatic press
00:09:30.079
uh has a build system for their books the books exist as markdown text used to be XML text a whole bunch of J Ruby code
00:09:37.519
actually that converts them to uh PDF and whatever the pickaxe book has some
00:09:42.800
special Ruby code all of the code samples in the pickax book are um
00:09:48.800
executed when you build the book so the output is directly inserted uh this is
00:09:54.480
as you might imagine kind of weird and esoteric Ruby code that's pulling random strings and throwing them to an
00:09:59.519
interpreter in messing with build pass this code was written by Dave Thomas probably in the year 2000 I don't know
00:10:05.920
for sure I never asked so like one of the smartest Ruby developers I have ever
00:10:10.959
met uh bequeathed me a bunch of code that was written 20 plus years ago that he never intended anybody else to see
00:10:18.680
and basically said I'll help you if something breaks so a legacy code project
00:10:25.959
literally and uh figuratively so we're going to talk about this this in terms of in terms of Ruby's Legacy and Ruby's
00:10:32.920
future as you know by now because it's been said multiple times I'm no rapping I work here at chime thank you all so
00:10:39.880
much for coming out I very much appreciate it I'm not done actually that's just the intro um so we'll go
00:10:45.680
from here so the perspective that I eventually came to was to think about Ruby's entire
00:10:55.160
ecosystem as a one big Legacy code base and the definition here of Legacy code
00:11:03.360
that I use is code where the context of the creation has been lost the Ruby ecosystem is thousands upon thousands of
00:11:10.200
decisions that were made under a particular set of constraints some of which are still applicable some of which
00:11:15.920
are not right the analogy I like to use is a parking lot how many times have you
00:11:21.200
gone into a parking lot seen somebody parked at like a 35 degree angle and you go what how could anybody be such bad at
00:11:27.480
parking that they would park that at that crazy angle and what actually happened is when they got there it was the only place left and the person next
00:11:34.160
to them was parked at a crazy angle that person is left and now all you have is
00:11:39.240
like the the one stupid looking car at the bad angle but you don't know what
00:11:44.440
the constraints were like when that person showed up and similarly we don't we can't we don't and can't know all of
00:11:51.600
the constraints that various people have put into various Ruby decisions over the years so the way I like to uh keep keep
00:11:59.480
that in mind so uh it is also like another feature of
00:12:06.440
Legacy code is it is risky to change because of hidden dependencies and if you think about the Ruby ecosystem we're
00:12:12.959
not even just talking about dependencies in terms of code breaking we're talking about dependencies that change the way
00:12:19.720
that Ruby developers think about Ruby if you've ever looked at a longstanding rails program you can be you can look at
00:12:26.800
it almost archaeologically in terms of at like that was the year we all cared about structs and uh that was the year
00:12:33.600
we used form objects uh and and you know all of these individual changes deeply
00:12:41.160
affect the way people interact with Ruby and with the ecosystem so I want to talk about like
00:12:48.320
specifically what changed and I'm sort of working towards a theory of what
00:12:54.320
changes take and what changes don't and I also just think it's interesting to
00:12:59.760
talk about what changed over the 12E period so the language itself changed
00:13:06.320
every version of Ruby has two three four syntax changes sometimes small sometimes
00:13:11.519
big I'm going to split those into like incremental changes and big changes
00:13:16.600
incremental changes we'll go through this real quickly this is a representative sample it is not exhaustive um there uh the uh Ruby
00:13:24.480
changes site and I am blanking on the person's name the uh who who runs it is uh absolutely outstanding at tracking
00:13:31.040
this stuff over time it was invaluable to me uh when putting this together so incremental changes in in Ruby 21 def
00:13:38.680
returns a symbol which offers this alternate way of basically allows decorator uh function decorators um we
00:13:46.839
had rational and complex literals 23 uh added the safe navigation operator a
00:13:52.680
common Ruby idiom on the top line that was made like easier to type um it also
00:13:58.600
added here do with indentation a less common Ruby idiom made significantly less annoying to type um 26 and 27 added
00:14:07.839
partial ranges in both directions you know these kinds of things 27 added numbered block progams endless method
00:14:14.680
syntax argument for writing the main point of this is that you get the idea here that there are a number of a number
00:14:20.759
of changes here along the lines of here is a common Ruby pattern that we are
00:14:26.279
going to make slightly easier to type there have also been big changes my
00:14:33.120
definition here of a big change was a change that was uh designed to really
00:14:38.440
change the way that you interact with Ruby as a programming language there was one that just missed refinements which
00:14:44.800
actually did make it into the previous book just barely um which was designed to change the way you do monkey patching
00:14:50.800
um there were in this time period uh there were three things that I classified as big changes uh pattern
00:14:57.720
matching um uh pattern matching is uh introduced in 27 augmented in 30 and Beyond is a how
00:15:05.680
many people actually use pattern matching on a regular basis raise your hands higher than that I can't see it if
00:15:11.360
you hide it behind the other person so that is a solid 5% of the
00:15:16.480
room uh what you want to you just got okay I want to I just
00:15:24.120
got on 27 good good good good luck um uh so pattern matching is an ambitious
00:15:30.600
attempt to change the way you deal with complicated data structures in Ruby it is not an incremental change it is a
00:15:36.600
dramatic change to allow you to massively simplify certain patterns of interaction uh I credit Brandon with one
00:15:43.800
of the first uh presentations I ever saw that had it make sense to me uh which was which was very helpful um so that's
00:15:51.480
one the second one is not quite in the same league the keyword argument separation I think of this as a big
00:15:57.120
change between 27 and 3 because because it was a breaking change if you've updated a large chunk of code from 27 to
00:16:04.199
30 you know that even though it wasn't really supposed to break that much code it actually did break quite a bit of
00:16:10.319
code um so that counts as a big change it it is designed to force you to think
00:16:16.040
about the separation between keyword and and positional arguments in Ruby and the
00:16:21.160
third one and I guess is RBS how many people here use RBS he said to No Hands
00:16:28.360
coing Up one hand in the back I would have I would have taken the under on zero
00:16:34.639
frankly uh uh oh well Brandon is like Brandon is sort of like sheepishly
00:16:42.199
casually no no determinedly raising a hand what okay that's a definite hand
00:16:47.639
there's two two two RBS users so a solid god um RBS just just to be
00:16:55.759
complete how many people here have ever used refinements in Ruby he tried how many people continue
00:17:03.440
to use refinements regularly it's a solid three uh I'm building this there's a reason why I'm
00:17:09.760
asking all of this uh at least I hope there is you you better hope there is I'm just GNA start asking random yes
00:17:18.039
or no questions anyway um RBS is an attempt to add uh static typing to Ruby
00:17:25.919
uh officially as opposed to something like sorbet um Matt somewhat famously does not like static typing so this is
00:17:32.919
kind of a way to have static typing without actually having it in the actual syntax
00:17:39.120
um and I think I don't know what else to say about this like there's been very little tooling and very little pickup of
00:17:44.679
it even as it has been out for two or three years at this point um so those
00:17:50.640
are the big those are the big language changes there have also been changes to the Ruby Library um every new version of
00:17:58.559
Ruby has a dozen or so small big changes to the Ruby standard Library often
00:18:03.840
individual methods I didn't bother to put all of these on separate slides but these are these are basically many of
00:18:10.200
these uh are mentioned in the book one of these actually obliterated an example in the book because it it made it a
00:18:16.559
oneliner instead of a cool use of how to use functional Pro how to chain functions um but you know these are this
00:18:24.240
is again just a representative sample every version of Ruby makes a bunch of changes like this they get they are
00:18:30.640
created typically for a very specific purpose and they are used for that specific purpose often you will pick one
00:18:36.960
of these things up and you won't have any idea how recently it's been added it's just like oh cool I can use match
00:18:43.360
question mark now I didn't know that was there uh there have been a couple of
00:18:48.679
changes that I would consider big changes from the Ruby Library again the same uh definition that library library
00:18:55.600
editions that are really meant to change the way that you interact act with Ruby and I I count
00:19:01.440
two uh rators how many people use
00:19:07.280
rators three thought about it once I used it for the book uh I learned them
00:19:14.640
for the book ra so here's the thing rators are an insanely complicated
00:19:19.679
technical a technical accomplishment in Ruby from the beginning of Ruby till the
00:19:24.880
introduction of rators one of the actual real constraints on Ruby programming was that it had a global interpreter lock
00:19:31.559
and only one piece of code could go through it at a time rators obliterated that like any time you take a
00:19:37.360
longstanding constraint and remove it there's going to be code that depends on it and and it's going to be subtle and
00:19:43.720
that happened here too it also invented an entirely new way to share code
00:19:48.960
between threads and Ruby that didn't exist before and only exists to share code within Raptors and for all that
00:19:56.039
work we have three people in this room who have used it um
00:20:03.080
uh they actually I mean they're not they're they we we'll we'll come back to this uh the other thing is not anywhere
00:20:10.240
near as big a change in the library but I think it's in its own way a very ambitious attempt to change the way that
00:20:16.320
you interact with Ruby and that is the data Library the data object how many people are using data objects I'm going
00:20:21.880
to bet that's a few more so that's about 10 or 12 uh so data um is an attempt to
00:20:28.960
give you an object that is as immutable as an object can be in Ruby um with and
00:20:34.919
although it is a fairly small set of code it has a very ambitious uh mandate
00:20:40.760
to really encourage people to use immutable value objects uh rather than
00:20:46.280
hashes and strings for their data so that that counts to me as a big a potentially big change okay um okay
00:20:54.200
category three I swear there's only five categories we're not going to be going through this forever um Category 3 is
00:20:59.600
implementation changes most of these didn't affect the book they don't really affect the ecosystem directly um it is
00:21:06.400
interesting that uh at least uh two of these four changes this is again a representative sample every version of
00:21:12.640
Ruby has minor minor performance and incr and and implementation changes these are the ones that seem most
00:21:17.760
important to me it's worth noting that both the symbol change and the yit change specifically have the goal of
00:21:23.679
making long running Ruby processes easier to manage and more performant uh as as kind of a trend in the Ruby
00:21:29.960
community over this time um I think prism it's not really clear what the impact of prism is going to be prism is
00:21:36.600
the new Ruby parser introduced in 33 it's going to be default in Ruby 34 um
00:21:42.000
it's not clear what the impact of that is going to be we'll talk a little bit more about that in a second but but I I
00:21:47.240
think it's going to be a hopefully a big change um the ecosystem around Ruby the
00:21:54.679
language has changed in a bajillion ways uh this is I think a complete list of
00:22:00.520
third-party tools that are mentioned in the pickaxe book in the new version of the pickaxe book uh bundler uh debugger
00:22:06.559
and pry rubocop and standard sorbet rack Sinatra WM yard it is worth noting that
00:22:12.440
the majority of these tools either did not exist in 2012 or were just getting started and had not achieved M share uh
00:22:19.360
in 2012 so bundler was mentioned in passing I think pry may have been mentioned in passing uh most of the
00:22:25.360
other ones did not exist um and many of these tools are like day-to-day pieces
00:22:31.960
of of people's life like how many people are using bundler it's going to be more than 10 hands right this is this is a
00:22:37.559
test of how many people are willing to raise their hands in public frankly uh you know how many people C I'm just
00:22:43.679
curious how many people are using sorbet on any kind of basis so that's 15 10 12 seven I don't know I
00:22:51.200
just keep saying numbers until one of them seems reasonable more than RBS is I think the relevant Point here um uh so
00:22:59.200
you know many of these changes really do affect the way that we work like bundler had a profound impact on the way Ruby
00:23:05.720
developers shared code um you know many of these have had other effects too there's obviously other third party
00:23:11.400
tools that you could mention that have had huge effects um and most importantly maybe
00:23:17.320
most importantly and sort of the hardest to quantify is how the Ruby Community itself has changed over that decade and
00:23:26.200
I this is I don't know I this is just more notes than anything else um a very strong change is the change in languages
00:23:34.120
that you that people are coming to Ruby from um especially the early versions of the pickaxe assumed that you knew Pearl
00:23:40.880
or Java uh nobody's coming to Ruby from Pearl anymore uh we are now getting
00:23:46.640
people mostly from Python and JavaScript and Java basing on my based on my own experience um that has a big impact on
00:23:55.279
how people write their Ruby code what idioms they're comfortable with what things seem strange to them it's a
00:24:00.679
different set of things um in this 10-year period we went through the whole boot camp uh rise and fall which had an
00:24:08.799
extremely profound impact on the the people the people who were coming into the Ruby Community especially in the
00:24:15.200
years when the boot camps were teaching people Ruby just a whole bunch of people came into the Ruby Community who might
00:24:20.919
not have been otherwise that have had like a tremendous and I think extremely positive impact on the community as a
00:24:26.399
whole um there's been a like emphasis on contributions from Big
00:24:32.440
players in the ecosystem especially Shopify but not just Shopify um and also
00:24:38.320
an emphasis on contributions that that um encourage long running rails program
00:24:45.080
kind of things um in a way that like the needs of a long running rails program are far different than the needs of a small scripting program uh and I think
00:24:52.840
recent changes in the Ruby ecosystem reflect that okay so where does that leave us um
00:24:59.600
a lot of those incremental changes have been adopted um as you can see like we have an extremely poor hit rate on those
00:25:06.399
big changes we had I listed five like big changes that came from the Ruby Community basically none of them had
00:25:13.760
majority usage in this group of Ruby enthusiasts um uh and I think that
00:25:21.120
that's that's interest and if you add ref like adding refinements that's six changes I guess the keyboard the keyword
00:25:27.559
thing everybody had to use so I guess that counts um but I think that's
00:25:32.720
interesting to me that that there have been all of these attempts to really uh
00:25:38.159
make dramatic changes to the Ruby ecosystem and they haven't to like a
00:25:43.440
first approximation have had very little effect whereas these small incremental
00:25:49.720
changes like I bet uh many of you use many of those small incremental changes
00:25:54.840
that I listed some probably more than others but I'm sure you found one two on that list that you use I'm not going to
00:26:00.440
go through them all with a show of hands that would be extremely tedious for everybody who is not me uh but I I do
00:26:06.080
think I think that there's something I think that there's something here in terms of like what kinds of changes are
00:26:11.960
adopted um but I also think it is interesting to think about like why
00:26:17.000
those big changes haven't been adopted and I think in several of those cases um
00:26:23.000
not data but definitely pattern matching and uh definitely RBS and definitely um
00:26:31.679
uh uh refinements and one of them that I'm just completely blanking on at the moment all were sort of introduced
00:26:38.640
Raptors sorry we're all introduced to the community in an explicitly not ready
00:26:43.679
for Primetime or experimental status which is great in terms of like getting
00:26:49.600
things out there and getting front of people at least in theory but I think meant that many people tried these
00:26:55.480
things or wanted to try these things and found that they were like not suitable
00:27:00.520
for what they were doing because they weren't finished yet or they didn't seem to be uh potentially they didn't seem to
00:27:07.399
be bottom up they seem to be imposed top down and sort of file them in the I don't need to know about this basket
00:27:13.880
which is a great basket to have trust me uh and never really came back to them um
00:27:20.360
it I think it's worth interesting it's it's worth contrasting a little bit with the rails ecosystem specifically the
00:27:26.159
rails ecosystem has reinvented itself a couple of times in the same time period and many of those changes to my like
00:27:32.080
informal bubble have been more widely adopted the rails team has is reinvented
00:27:37.760
their front-end implementation twice at least in that time both of those seem to have more ad option even the the really
00:27:44.799
new no build stimulus Hotwire stuff seems to have more pickup and play than any of those big Ruby changes um why I
00:27:53.480
think one of the reasons for that is that most of the time a big change in rail
00:27:58.640
comes only after it has been successful in a project where I think often big change in Ruby come from a more I don't
00:28:05.880
want to necessarily say academic perspective but from a definitely from a less of a battle tested perspective one
00:28:12.840
of the things that I am hopeful for in a world where the where prism is the Ruby parser is that it will enable more of a
00:28:19.640
playground mindset where you have the opportunity to turn on experimental
00:28:25.039
features or turn off experimental features and really exper experiment them without having them be official
00:28:31.640
parts of Ruby in a way that really isn't possible now um but I think might be really beneficial to the uh adoption of
00:28:39.679
these kind of new uh parts of Ruby as they go so uh all I've talked through
00:28:47.120
all of my slides I think incremental improvements have an up battle whatever new things survive when they solve
00:28:52.320
problems and I think one of the things that comes from the rails world is that a lot of their new things have already
00:28:58.200
solved a problem and they can say that and show those examples whereas a lot of the Ruby things are like these this
00:29:04.120
seems like a good idea and often they seem like really good ideas rators really do seem like a good idea uh as
00:29:09.840
somebody who is generally allergic to threading I find the metaphor of reactors like genuinely appealing and
00:29:15.679
relatively easy to get my head around and also I would never recommend it for a project at the moment um so because
00:29:23.840
it's just not quite there right so that's it so I I think that these ambitious projects within the Ruby
00:29:29.120
they're great but they need to they they need support they need support from us they need support from the Ruby Central
00:29:34.320
team hope the Ruby core team hopefully again we we'll have a world coming up where it will be easier to be more
00:29:40.840
experimental with these kinds of things um it's worth noting that Ruby 34 had a
00:29:45.880
syntax moratorium for the last six months or so uh the only major syntactic change in Ruby 34 is the introduction of
00:29:53.559
the keyword it to replace the underscore one uh which is minor but but also I'm
00:29:58.919
kind of looking forward to it um uh this was explicitly to allow the parsers
00:30:04.159
specifically prism to catch up um rather than having them try to hit a moving Target and we'll see where that goes we
00:30:10.600
also know from some things that Matt said I believe that this is true um that there will be a there's a major change
00:30:16.720
coming which may in fact turn out to be the breaking change that separates Ruby 3 from Ruby 4 which is the introduction
00:30:22.399
of Nam spaces being like modules the Nam separating out the namespace only feature of modules from the mod feature
00:30:28.399
of modules this may be coming there are a couple of different proposals I honestly don't pay a whole lot of attention to the Ruby proposals in draft
00:30:35.640
um but but uh this is one that that definitely came across my radar somebody else probably knows more somebody else
00:30:40.720
people somebody else here probably knows more about it but I think that that the question is how we can allow uh Ruby to
00:30:48.519
sustain continual change and be flexible and continue to evolve and grow you know
00:30:54.440
over the next 10 years as it has over the last 10 so try a new thing today we
00:31:00.320
I've given you many many options to choose from uh that's it that's all I've got I have no idea whether I was near
00:31:07.240
time on time under time uh I shouldn't turn my phone while it's sharing screen
00:31:12.320
and thank you for being a part of this this uh presentation experiment um programming Ruby is on sale uh you can
00:31:20.000
get it in ebook form from pragprog uh title ruby5 um there's an Amazon link
00:31:26.480
you can follow me on no rapid . um chime.com careers if you're interested
00:31:31.679
in chime in chime careers also separately if you are interested in writing for the pragmatic press please
00:31:39.480
talk to me I am also the Ruby series editor uh for pragmatic press and we're looking to get Ruby books in the
00:31:44.720
pipeline these do not have to be I promise they do not have to be 700 page bricks uh we're really they're really
00:31:50.320
leaning towards smaller uh books that you can turn around much faster uh if you have something that you are
00:31:56.120
passionate about in the Ruby community that you want to spend some time explaining to everybody in the Ruby Community uh please see me or contact me
00:32:03.720
somehow that is all I got uh I'm going to see if I can figure out how to turn off sharing here um but thank you very
00:32:10.240
much for your time thank you so much for coming out to our space we are so excited to host all of you here thank
00:32:15.639
you
00:32:29.679
wow that was amazing thank you thank you now right while vmer is very slowly
00:32:35.880
moving to the stage you're next
00:32:41.279
um yeah I'm just gonna do this I'm going to take a photo of you
00:32:48.760
all how about this okay this yep yep yep
00:32:58.880
all right um okay the next stop is
00:33:21.799
yeah um so always going to talk about something no mentioned
00:33:29.799
right you noticed what is
00:33:37.039
it you need
00:33:42.799
Power share and I can get you on the Wi-Fi yep go ahead wi know the password
00:33:53.519
y okay we'll take a minute
00:34:56.640
juste e
00:35:31.000
I think we're watching a movie
00:35:56.079
no yeah he wants to turn the lights off but no
00:36:02.480
no we're not doing it okay lights oh it it works you just need to
00:36:09.839
speak louder okay um okay
00:36:16.200
uh it's okay better okay hi everyone uh my name is Vladimir
00:36:24.400
and um want to share some thoughts on Rails and how we I don't
00:36:33.200
know try I would say try try to keep our code bases maintainable and some uh
00:36:39.440
particular use case actually I want to share today which deals with um
00:36:46.319
okay let me see um yeah um yeah the talk
00:36:52.640
today is forms on Rails and we're going to talk about I want to use use this as a particular
00:36:58.760
example of like modeling code and rails applications on a particular problem
00:37:04.319
dealing with complex forms and actually uh the use case I'm going to show we
00:37:09.960
just need to wait for the video to complete okay before I can switch to the next slide uh how
00:37:16.960
to fight complex UI while being a rails developer while
00:37:23.040
being a classic rails application developer not an API one with was front
00:37:28.400
end being a part of responsibility of another team uh but uh trying to be as
00:37:33.599
close to the classic rails to the HTML first approach and still being able to
00:37:39.720
solve challenges that sometimes we Face uh with with modern applications so this an an example
00:37:47.400
application in question let from the project called any cable plus it doesn't
00:37:53.440
matter what's important here is that that's how we kind of started like it's a rails startup so it's like rails
00:38:00.040
generate scaffold blah blah and and go on like and release and let users figure out what to do and we had some forms
00:38:07.760
there so this is we how we set up an any cable instance in the cloud and it
00:38:13.040
actually requires um decent amount of configuration settings it's not just the
00:38:19.040
whole format just a part of it and it contains like eight seven some inputs
00:38:24.960
and you need to scroll down you lose the context and it's not well the best user experience that's fine for rails
00:38:30.760
applications starting like you know just yesterday but you want to provide a
00:38:36.520
better user experience so we wanted to build something like this and that's what we've built in the end so we have a
00:38:43.640
form a multistep form or visard like we call it where you have multiple steps
00:38:49.640
you have some useful instructions on what you should add there at each step
00:38:55.240
and in the end you can submit it and create everything like a pretty common experience we you know uh learned back
00:39:03.839
in the windows days you know all windows installers looks like that so but how to
00:39:10.119
build this in rails so for our regular form we just created form for enumerate all the
00:39:17.960
fields like add some styling and that's it but now we have multiple steps back
00:39:24.119
and forth navigation we need to keep the state some how and so on we have a lot
00:39:29.560
of things to think about here and that's actually a lot of questions and I want to answer these questions uh by taking a
00:39:38.160
look at what is the Ra's way of doing things and how we
00:39:44.640
can kind of oh I would say enhance it to
00:39:49.839
make such non-trivial I would say forms uh possible but let's start with the rail
00:39:57.480
way as it looks from the form perspective so what is a form it's actually some request with some data and
00:40:04.200
this data goes through the layers of your rails abstractions so first we hit
00:40:09.680
the controller where we do something with the input filter data whatever then
00:40:15.000
we persist the data or invoke validations at the model level and then
00:40:20.319
we show some result using our view templates uh the question is where and
00:40:27.480
this configuration we must we should implement the multistep form the visard logic where it should live how we should
00:40:34.920
handle it well my answer would be is like well nowh we shouldn't try to fit
00:40:40.800
something that doesn't actually fit the classic rails Trio of MVC uh in we shouldn't fill it logic
00:40:47.839
into the classic MVC Trio we should try to add something else something in between your controller and model and
00:40:53.839
that's going to be something now already mentioned in his talk oh object they were popular someday and actually um
00:41:00.920
we're going to talk about the history a bit but the reason why we want to introduce something new and I think it's important to highlight here is this want
00:41:09.040
to separate the concerns the form and the logic we try to implement is actually UI driven logic it's not a part
00:41:15.520
of your model your model doesn't care how many steps do you need to fill the form it actually just needs the final
00:41:22.880
data user input to create something and invoke some business operations or
00:41:28.040
whatever and at the same time your controller also is not responsible for
00:41:33.760
thinking about this multi-step process it's only responsible for getting data
00:41:39.240
and passing it forward in a right format so we need something to separate these
00:41:44.520
concerns and without using rails concerns because they are well questionable um so we introduce firm
00:41:52.560
objects to deal with the following concerns the following responsibilities uh there are many of them they're just
00:41:59.400
the the most popular four it's about introducing context specific validations
00:42:04.680
because because not every validation should live at the model layer you only need to keep there something that's
00:42:11.000
required for your data consistency not for the particular use case sometimes we want to transform user
00:42:18.119
input because well your UI form might look not like your database table right
00:42:24.319
in most cases it is not we also need a way to provide a useful feedback to users that's an important role of this
00:42:30.760
intermediate abstraction it's not only about oneway uh data flow from user to
00:42:37.040
database it also about telling user what went wrong if something went wrong and
00:42:42.480
of course in our particular scenario we have some uid driven logic like
00:42:47.920
multistep form it also must have its own place in the code base but let's talk
00:42:53.119
about some past uh ideas with regards so
00:42:59.119
to adding something to rails to solve this problem and actually one of the
00:43:05.280
oldest mention of something that looked like form object comes from this gist by
00:43:10.880
dhh he called it aggregator but the idea is basically the same you have some form
00:43:17.280
in the interface that operates on multiple records or some like aggregate record like in this case we have a user
00:43:22.960
record and an email record let's create an agregator model whatever he wanted to
00:43:28.880
call it and use it in the controller like a regular model that's something
00:43:33.920
that looked like that never turned into life at least uh in rails or in uh
00:43:40.720
Source available 37 signal project but there was an attempt uh to actually
00:43:46.400
create an action form framework for rails uh about the same time like almost
00:43:52.640
seven eight years ago um well the attempt were considered
00:43:58.400
unsuccessful so that that's why we don't have it right in rails but it's an interesting project just to learn about
00:44:03.920
how PR prior prior Generations tried to solve this problem including the rails
00:44:09.839
score team uh some days uh like yeah we're doing archology right now so reform was
00:44:17.520
a popular tool to generate forms it's a part of a Trailblazer I would say package for
00:44:25.640
modeling business logic and ra application but the reform were usually used independently of other Trail based
00:44:32.400
features and it was quite popular but also didn't kind of survive till uh till
00:44:38.599
now but it was looked like well you have a form object you create and you
00:44:44.119
operated like a whatever regular model in Ruby uh finally last history bit here uh
00:44:52.800
the latest attempt to bring something uh that looked like a for object at least the foundation for
00:44:59.599
potential form object happened just a year ago like almost exactly a year ago
00:45:05.319
uh there was the idea of introducing active model base like in a active record base but for non database backed
00:45:11.680
models for like virtual models unfortunately uh the idea was rejected
00:45:19.040
and with the same reason as the action form was rejected railcare team is not quite happy yeah the railcare team
00:45:26.440
understand that there is the need for something like that there is a missing Point uh the missing um Link in
00:45:35.000
this like abstractions chain in rails for some use cases at least but still there is no good solution that would
00:45:41.839
satisfy the core team and probably particular members well uh let me share the form
00:45:51.160
object abstraction that I'm happy with and I'm using in my R project and
00:45:56.440
actually not just using but trying to promote it in this
00:46:02.240
book uh which has a chapter dedicated to the problem with a lot of examples and
00:46:08.960
some useful stuff you can check it out later I don't fortunately I don't have copies with me today maybe next
00:46:14.760
time so I'm not going to recall like the book it's doesn't make sense you can
00:46:20.559
download it from Torrance probably or just ask me well and we don't don't have
00:46:27.200
discounts now I don't know maybe we do I don't know I'm I'm bad on promoting stuff so
00:46:34.920
yeah I'm going to show some stuff so this is a form object for our original form was just like one screen all the
00:46:43.520
fields but here I how I would implement it using not the model but the form
00:46:49.720
object like uh using some application form we're going to talk about it in a minute uh let's take a closer look what
00:46:55.520
do we have here so so we have attributes that corresponds one to one to the
00:47:01.079
fields we have in the UI right and we have some Logic for initializing the
00:47:07.440
object we want to create and actually creating submitting a form so we use the
00:47:12.599
term submit because well that's what we do with forms well it doesn't bring a lot of
00:47:19.040
additional value to like uh compared to using a model the
00:47:25.079
only probably thing that we solve here is that we decouple UI fields from the
00:47:31.040
database schema so we can have different map like we have some specific mapping to map UI form values to the actual
00:47:38.880
model attributes and we don't need to update our UI or model to reflect one
00:47:44.720
another so that's better than nothing but still not enough to justify
00:47:49.760
introducing this abstraction right well in in reality we have more stuff here we
00:47:55.880
can add validations at this level without adding them to the model however
00:48:01.079
uh here have like validates name and region presence these two are probably
00:48:06.960
are invariance of the model they should be validated at the model L and we can
00:48:12.000
do this by just delegating validations to the model and that's fine that's how we avoid duplication with using when
00:48:18.520
using form objects we just uh add the validations that only make sense in this
00:48:23.680
particular context uh also we can introduce callbacks to trigger some side
00:48:30.960
operations or some other stuff that relates to this particular form compared to model callbacks this going to be
00:48:38.520
executed only in the context of this particular user action in this particular scenario so we do not need to
00:48:44.960
deal with the global callbacks defined in the model finally uh there is one
00:48:50.640
line that's hard to explain why do we have it what does it mean like self
00:48:55.720
model name cable and to talk about it we need to
00:49:02.119
learn the rules behind the abstraction the application form I use in
00:49:07.400
application and in the book and why I build it this way and the reasoning behind this is whatever you try to
00:49:14.960
introduce into the rails application though should play nicely with what
00:49:20.760
rails gives you you shouldn't play against the framework you should try to be a part of the team
00:49:27.640
that's actually some the first edition of the rail sway book uh also pretty old like almost 20 years old right now but
00:49:34.920
the phrase still holds what does it mean to play with
00:49:40.680
framework play the same team well I split this into several important points
00:49:47.720
first you need to know how rails Works actually under the hood why rails is designed this way which building blocks
00:49:54.920
rails relies on because there are many well not so many actually things and rails that's used throughout all the
00:50:02.160
components of the framework and you can easily find a pattern and try to use it in your code that that would make your
00:50:08.599
code look like the rails original code of course you must follow the
00:50:15.000
conventions conventions is the most powerful feature introduced by Rubi on
00:50:20.960
Rails and that's what you what makes you productive and productivity is a thing we uh care the most uh when building
00:50:30.359
with rails otherwise we wouldn't use rails right so that would make you code
00:50:35.400
play nicely with rails let's see uh how we achieve this uh by the example of
00:50:41.040
this abstraction so this is a application form class we do not inherit from anything that's a just a rubby
00:50:47.440
class but we include some active model uh functionality because active model is
00:50:52.799
actually what's used throughout all the rails parts to to bring you uh something
00:50:58.839
like attribute like behavior um and uh validations also part of
00:51:05.799
active model API and so on we add callbacks well yeah callbacks might be
00:51:11.559
evil but that's the Ra's way of doing things that's actually if you use
00:51:16.640
callbacks properly it is uh to separate
00:51:22.240
the main logic of your like function method class from the peripheral logic that the
00:51:29.440
best usage for callbacks and you should not avoid them for that so it's nice to have them actually we also have some
00:51:37.280
additional safety checks within this abstraction transaction awareness which
00:51:42.640
is important and uh yeah we have some interface just a single method we must Implement in your class to create any
00:51:49.000
kind of logic it's not necessary creating model it could just be send in email it's still a form submit finally
00:51:55.720
that's where we use model name it's actually used for active active now action sorry yeah still confusing uh
00:52:04.240
action view compatibility and that's uh one of the most important things here uh we're going to see it in action in a
00:52:10.559
second so let's see how using a rails W form object compares to using a regular
00:52:18.319
model so this is a kind of code using just regular rails model just a scaffold with some like alization added and this
00:52:25.400
is the code used in a for model object it stays almost the same anyone looking at this code understands what's going on
00:52:31.240
oh okay we create some form data we save it and we redirect that's how we do it
00:52:37.760
with regular rails nothing new what about the view so this is our form for
00:52:43.200
cable original one uh just to remind you it converts to this HTML like style
00:52:49.640
emitted and this is the same version for the form object we just changed the single word but everything stays the
00:52:56.920
same due to this model name thing we tell rails how actually to use this
00:53:04.200
object to generate URLs parameters and all the stuff that we use in various
00:53:10.160
action view helpers just by the matter of single method in the abstraction and
00:53:16.280
that makes our form object quack like a model so we don't need to change anything here so now it's time to actually
00:53:23.480
Implement our multistep form our wizard
00:53:36.799
so we introduced form object and that gave us actually enough flexibility to build
00:53:44.520
to and improve the functionality of this particular action operation to build on top of that because now we have a single
00:53:52.760
place in our code base responsible for this interaction and we can localize all
00:53:58.160
the changes if we want to change the user experience so we don't need to
00:54:03.640
touch multiple places out codebase to create a wizard we don't need to introduce any gems no create new
00:54:10.720
controllers nothing we can do everything but just relying on our form object
00:54:15.880
first of all what is wizard wizard is actually deterministic finite automaton yeah uh some nice pictures
00:54:23.839
anyway if you're curious you can ask me after afterwards uh it has some story behind
00:54:29.040
it um so what is a good way to implement uh automaton or state machines as many
00:54:37.480
people call it in uh software engineering of course we can use some State machine implementation and since
00:54:44.359
we're dealing with pure Ruby object we're not going to use any popular gems for State machines for active record
00:54:51.200
because they pollute your active record model and bring unnecessary complexity
00:54:56.359
we're going to use another gem uh I like it's called workflow it's it provides a
00:55:02.079
very minimal State machine functionality to any Ruby class you want and we're
00:55:07.720
going to use it like this so we create a separate class within our form we call
00:55:14.079
it Wizard and it's actually going to be a workflow and we Define State transitions yeah we use some DSL maybe
00:55:21.319
well at least it's it's readable and we can control the steps where to go from
00:55:28.200
where and which case because there's some conditional transitions right in this class and all
00:55:35.640
the logic of moving between pages is implemented here then we just use this
00:55:42.400
wizard to decide whether we need to really create the record or we just
00:55:48.640
need to step to the next iteration so we change our submit meod a bit
00:55:56.799
um again the code is kind of self-explaining let's see how it Chang
00:56:02.640
the way we write our controllers so for the controller we need to update just a single bit when we submit an
00:56:09.920
intermediate step we do not create the record so we do not redirect to the record page in this case so we must
00:56:16.640
proceed to the next form uh wizard stab and here we just respond with the same
00:56:23.039
new uh template but with a status created the reason why we use created
00:56:28.240
and not okay here is just to satisfy turbo because if you respond with okay
00:56:34.920
like 20 200 for post request it's going to tell you oh no you must redirect when
00:56:40.079
for submits so sorry I'm U I don't want to redirect but okay create it solve
00:56:45.480
this at least for now and if there is a validation error we just uh respond with a regular unprofitable entity and can
00:56:52.599
show errors right for this step the the most interesting part is here the only
00:56:59.039
other part of code that is changed is our form template that's what we do here
00:57:06.599
here we can ask our visard workflow what is the current state oh the current
00:57:12.359
state is name okay let's render the text fil name otherwise let's render a hidden
00:57:19.000
filed name that's how we persist the unsaved data okay let's go to the next
00:57:24.559
step same here we just add if and else and we render the current step or render
00:57:32.319
the state same goes again oh here we introduced something that wasn't in the
00:57:39.000
original version now when we have a m step logic we have some kind of a logic
00:57:44.440
tree we can actually add some intermediate steps and tell user okay you decided that you go with rails this
00:57:50.920
is some tips you need to know for using them any cable with rails go and run
00:57:56.240
these commands in your rails application so it's there is no input just just a um information step we go further we have
00:58:04.640
again this if else stuff finally one more step and at the final step we have
00:58:12.160
one input it's emitted from the template and we have some Logic for showing buttons here we again check for the
00:58:19.119
wizard State uh whether it can complete so what whether this step is potentially
00:58:24.839
final can lead to the final step State whether we can go back and we show the back button and we have some like HTML
00:58:31.960
magic using form action and value for the submit button to differentiate between back and forth operations and
00:58:39.039
that's pretty much it so that's all you need to introduce a mod step logic or whatever
00:58:45.160
step logic to your rail forms without changing your models changing your
00:58:51.480
controllers by describing your logic in a like human readable way as a state
00:58:57.039
machine and just a little bit updating the your template so that's all you need
00:59:03.200
if you create an obstruction that works the rails way yeah this one is
00:59:12.039
Happy well that's it for today actually I'm open to any questions because we
00:59:17.160
have a break right now I don't know if we're going to do it right now or we just stop the stream whatever so thank
00:59:33.839
hacking and one last thing I have some Fortune with me so if you want
00:59:41.240
to chase Your Luck come here and buite
00:59:51.079
one okay that's a 20 minute break 20 minute break I'm very loud um and bold
01:00:00.599
yeah um 20 minutes and then we uh meet for the open
01:00:09.520
mic thank you Rea can we all just give a big hand to Arena and evil martians for organizing this every
01:00:15.359
month before this year we haven't had a continuous Ruby meet up for many many
01:00:21.559
many years and I'm so glad to see so many old faces well sorry no offense but
01:00:28.039
like so many so many uh longtime friends let me put it that way and uh also New
01:00:33.760
Friends and it's just always re-energizing to come and see you all so I'm so happy and really grateful to
01:00:39.440
arann team for putting this together so big hand for them
01:00:45.599
please so my name is a pundit I'm up here every month I'm sorry thank you um
01:00:50.720
I'm the executive director of Ruby Central the us-based nonprofit that works to cultivate the Ruby Community
01:00:57.880
here in the United States and hopefully around the world if you're interested in following me on social media I don't recommend it it's mostly about bicycles
01:01:04.480
although sometimes so you can also follow Marco which is probably a lot more useful um and if you do follow me
01:01:12.559
you could see this kind of dumb stuff that I do while I'm listening to other people if you don't know Marco he's uh
01:01:19.359
at almost every single Ruby conference and he was saying that this year I think he's already done 12 Ruby conferences
01:01:26.079
and by the end of the year he's going to get to 14 maros a he is a true Gem and he's
01:01:33.079
working on all kinds of different projects including this Ruby video library he was just showing me uh which
01:01:38.280
is a mission to index all of the Ruby conferences this is pretty if you get a chance you should check this out um it's
01:01:45.440
done by Speaker uh conference um and even uh some of the sponsors so this is
01:01:51.440
an incredible project and I think we're all um this is the kind of stuff that we at Ruby Central are excited to support
01:01:57.240
and promote um because if you're here in this room there's only two reasons you
01:02:02.760
love programming in Ruby or and you enjoy being part of the Ruby Community
01:02:08.960
right either online or in person at the conferences and those are the two reasons why we're here and uh our
01:02:15.279
mission is to grow that conf grow that community and and help it be strong and
01:02:20.440
live on into the future as long as possible so check out Ruby video so again I work at Ruby Central um this is
01:02:27.400
our uh out ofate website um please help us update it if you have the opportunity
01:02:33.359
uh if you're interested in supporting us there's a lot of different ways to do that there's a link up here for support
01:02:38.400
us um if you want to become an individual member and support us financially uh you can go up in the
01:02:44.079
corner and click uh sign in and then there's there's options for um helping us financially which would be really
01:02:50.200
useful and helpful we do a lot of cool stuff and you can see all of our news there uh recently the big news that we
01:02:57.160
have is we welcome back Marty hot who ran Ruby Central for a very long time as our um interim lead for Ruby jems and
01:03:04.319
bundler in our open source program which is super cool so if you don't know about Ruby Central we admin we do two things
01:03:10.599
we do open source uh infrastructure and uh run events so you may have heard of
01:03:16.880
this program raise your again raise your hand if you've used this program great so the uh and then there's another uh
01:03:23.760
service and program that we run your hand if you use this one anybody heard of this website so we help keep this up
01:03:30.839
to date um we have recently completed a strict security audit so this service is
01:03:36.000
much more secure than it ever has been in the past and none of you uh probably know about that but we're going to be
01:03:42.279
working on putting a lot of that information out in the next couple weeks and helping you know like all the stuff
01:03:47.319
that's going on in the background to help your Ruby experience be um more secure first and foremost but also um a
01:03:55.079
better one we're developing organization level um administrative accounts for people who
01:04:00.839
are publishing many uh libraries that's coming soon and we'll launch that soon so that's exciting too um we also run
01:04:08.520
Ruby API uh or support and administer Ruby API which I recommend um and the
01:04:14.240
Ruby toolbox so if use any of these Services these are all supported by Ruby Central so we help keep them up to date
01:04:22.039
we make sure that they're secure um and we administer The Host and CDN bills and
01:04:27.359
things like that we have a lot of friends in the Ruby Community who we work with and support including wnb uh
01:04:35.440
the virtual community for women and non-binary rubis they have events at almost every Ruby Community event
01:04:42.760
conference um if this is a group that you identify with I strongly recommend
01:04:48.079
you join they're really awesome we have a light collaboration right now and we're working on making that collaboration a lot stronger so the
01:04:55.400
reason I'm up here is to invite you to Ruby Chicago um it's November 13th to
01:05:01.279
15th uh in beautiful downtown Chicago it is at the Hilton which is a gorgeous Art
01:05:08.240
Deco Hotel uh right downtown on the park it is the site of the 1968 um Democratic
01:05:15.200
National Convention and Associated riots um it's a really cool place it's Central
01:05:21.960
to the city and it's a great venue I strongly recommend getting your ticket soon and we have new
01:05:28.240
swag which is actually pretty fun um so
01:05:33.400
the shop is and this is Shopify a ruby and rails app uh store. rubby
01:05:39.240
central.org and I'm modeling for you right now the new uh swag for Ruby conf
01:05:44.279
so this is the zipup hoodie which just got released with the dragon on the back so even if you're not coming even though
01:05:50.400
you should come and you want to get a hoodie or some other rubycon swag uh you
01:05:55.640
you can pick it up there but again Ruby conf is uh November 13th to 15th in
01:06:01.240
Chicago uh and I would love to see everybody here attend uh there's some speakers here as well so if anybody has
01:06:09.039
any trouble getting to the conference please come and talk to me come message me we want as many people there as
01:06:14.480
possible um and one of the reasons that we want as many people there as possible is that conferences and Community only
01:06:20.760
exist if you participate so if you show up and the sponsors show up and then we
01:06:25.799
get to have our events and continue to be in person but you know as you see
01:06:31.599
from Ruby fuza which I've never attended but I know a lot of people have said really wonderful things about it's the
01:06:36.960
premier one of the Premier African Ruby conferences they weren able to get sponsorships and or tickets and so the
01:06:43.640
macroeconomic trends do affect our conferences and so if you want events like this to continue to exist encourage
01:06:50.160
your employers to sponsor and buy a ticket and invite a friend um and get a hoodie thank you
01:07:05.480
great thanks aders Serge your
01:07:13.920
next if anybody wants to buy it while I'm talking you're already selling a package
01:07:21.160
service come on you didn't even start to talk yet okay
01:07:26.720
um okay the hardest part is to like the microphone works now to figure out how
01:07:31.880
to share the whole screen and not to show something that is not supposed to be
01:07:38.760
there okay okay oh hi hi everyone so my name is Sergey Sergey I was the host of
01:07:46.599
U Yuko last year in vus uh I don't know who who have you
01:07:51.799
heard about Yuko uh like keep your hand up if you've
01:07:56.880
been to any okay cool awesome thank you guys so uh we also after the euruko
01:08:05.400
uh left to the other City we kick it off Baltic Ruby conference that's the conference that travel across the Baltic
01:08:12.599
seal uh this year we had it in uh Sweden in Malmo uh we had a couple of funny photos
01:08:19.319
of Ms but I don't have time to show it like if anybody's interested I will I
01:08:24.600
will show privately so this year Baltic Ruby comes to Ria lattia we're going to
01:08:32.120
have three tracks we have Tim Riley as a confirmed sponsor uh speaker as a
01:08:37.679
keynote and one of the track that we're going to have like actually we have one for Ruby one for open source and one for
01:08:45.239
everything else but not for rails like no offense but like I mean like
01:08:50.839
everybody's talking rails now and we we think like for this year maybe we need to give more like a spotlight for other
01:08:58.759
Frameworks like Hanami like dryer B and others so we can of encourage people who
01:09:04.199
have like who who interest in to come there but I wanted to show you one thing
01:09:09.359
that uh recently happened uh literally um we released the the gem
01:09:17.279
last week uh which is called rspec Lama so I'm interested who of you using
01:09:23.920
rpec okay who know who knows uh who created our
01:09:30.600
spec so yeah so the dude who created arpec called Steven Baker and he hates
01:09:36.759
arpec but we convince him to work together and make like a simple plugin
01:09:41.799
for arpec to kind of use arpec matchers and assertions to test uh local and not
01:09:49.319
only uh AI models so let me show you how it works so it's it's kind of pretty
01:09:58.600
um pretty easy so what do you need to do
01:10:03.679
um you need to add yeah it's going to be like I can handle okay so yeah you need
01:10:10.280
to add um now this one yay this one so you need
01:10:17.719
to add this Gem and in order if you want to use like any platforms some
01:10:23.199
credentials and and as soon as you have it uh and here is like a simple example
01:10:31.719
so let's have two classes so the one that's a pirate and uh it usually gives
01:10:38.000
you like a pirate speech so it says something like a pirate and another one
01:10:43.239
is like a robot so and like robots and Pirates they speak differently so if we
01:10:49.920
use rpec we kind of can validate that they both speak but our back cannot say
01:10:56.400
like does this guy speak as a pirate and this one speaks as a robot so using this
01:11:05.159
plugin for rpec you can easily do that so what do you do like you use the standard
01:11:12.120
uh uh standard syntax of rpec and you can configure which model you want to
01:11:17.800
run some parameters for the model and actually then check the uh the assertion
01:11:25.400
so does robot sounds like a robot and uh does the pirate sound like a pirate so
01:11:33.520
let's see uh if it's going to work or not because you never
01:11:47.320
open Ai and T what do we have here so it it
01:11:53.600
actually um shows you the output from the model so this one Yes sounds like a
01:12:00.080
robot but this one it says absolutely but we waiting for yes so it's a failure
01:12:06.199
which is let's run it again okay it's supposed to okay yes so
01:12:16.920
now yeah now like that's I think it's even better when you testing like using our spec and you use this
01:12:23.360
non-deterministic thing for uh for your unit test but uh it's not
01:12:29.880
only about using uh open Ai and the interfaces of open AI um arpec llama
01:12:37.199
also supports all the open not open like llama families like meta's llama
01:12:43.920
families and not only so we use local inference engine which is called llama CPP and bindings for for Ruby that exist
01:12:51.960
so for example if you don't want to use uh open AI uh you can download the
01:12:58.280
binary file of let's say metas Lama or whatever like MMO or mistal or other you
01:13:05.480
can specify in the in the line where is the model uh the actual binary file for the
01:13:11.560
model so like this one in dgf format so it's like literally something that lives
01:13:17.199
on your machine and um for this one let's ask more complex question so I
01:13:24.000
have this open Lama 7B uh download and uh let's ask who's
01:13:30.000
the creator of Ruby and as assertion we expect to be yukihiro Moto
01:13:35.920
son um so again let's see so it instantiates
01:13:42.880
the the local uh llama inference with llama CPP so there is no GPU but it uses
01:13:50.159
M2 CPU which is fine it's a little bit slower but so what do we have here who
01:13:56.480
is the creator of Ruby it gives a little bit more useless
01:14:01.639
information but finally as you can see it gives the right answer and the tests
01:14:07.120
pass so for example if you do you want to give it another try so for example we can ask another
01:14:15.000
question um you have any idea let's do rails right who's a
01:14:21.280
creator of rails B no no no it's like it's to too Fresh
01:14:29.199
So the creator of rails and uh let's say
01:14:35.360
dhh I think it should be fine let's
01:14:41.400
see so while it's it's doing this stuff so you can actually here's a creator of
01:14:46.600
rails yeah okay so you see it's it knows it
01:14:53.840
let's yeah yeah you can figure it out right so it's you don't need to read it all through we all doing this for M for
01:15:01.960
machines uh DAV
01:15:13.239
it you think okay now it's finally it sticks
01:15:20.520
with this with with its opinion uh which is David so um using this like simple
01:15:25.800
tool set you can build like multiple chains so if you thank you in if you use for example like for some purposes you
01:15:32.199
use open AI for other purposes you can use uh like your local uh models that
01:15:38.840
can natively using native extension work with Ruby so um yeah it's quite a fun
01:15:45.080
and I encourage everybody to try so the gem published last week it has the the very
01:15:53.080
first versions of give some support contribute and thank you very much for uh yeah for having me here thank
01:16:02.719
you perfect uh K kith uh come over yep your
01:16:13.840
turn Okay so mine is sort of a quick oh sorry I keep forgetting that uh
01:16:20.920
so I just have a real quick thing uh I'm speaking at Ruby
01:16:27.239
um in character um and if yall are coming stop
01:16:33.920
by I don't know where it's at it's in the program somewhere um it's uh lessons
01:16:39.600
that I learned uh running sidekick at scale at the large company that I work
01:16:45.400
for um and then secondly if yall are hiring find me at ruby.
01:16:53.560
Social um and uh or here whatever uh interested to
01:17:00.159
see what's available um yeah RTO and all that uh anyway but yeah that's it that's the
01:17:15.159
C thank you okay qu number four
01:17:22.679
um where is this yeah go yeah
01:17:29.040
Europe hello thanks for all the great talks um I'm Meredith I have been job
01:17:36.199
searching for far too long so um I came to the Ruby Meetup uh last month and
01:17:45.080
learned like 100% more about Ruby than I knew when I walked in um I was uh
01:17:52.560
formerly like devops SRE and then um yeah just looking for um any software
01:18:01.440
roles or Tech adjacent and um yeah I appreciate this community so nice
01:18:07.800
meeting you perfect uh so who has a different
01:18:16.679
Ruby roles please let merus know know about
01:18:22.080
them awesome all right um who's number five to be
01:18:27.520
honest maybe you ready yeah go
01:18:32.719
ahead hi uh kind of nervous to be here um actually I'm working on a product uh
01:18:40.280
a new test coverage service that combines both the CI simple Cup score
01:18:46.000
along with the production uh the production runtime heat map to tell you the actual test
01:18:53.360
coverage what I called usage weed test coverage so if you guys are interested in trying out it's currently very
01:18:59.840
unstable uh but I already published a gem called Oren cuff uh if you guys want
01:19:04.920
to try it out come talk to me I'll give you my name card um yeah that's
01:19:11.719
it wait wait say the name of the gem again uh oen o y n
01:19:19.760
coov yeah perfect thank you um we had jie it was you yeah right
01:19:31.199
right hello hello uh I'm Justin Bowen and I am
01:19:39.080
working on releasing an open-source gem so that we can build rails AI
01:19:46.880
apps and I'm also a Avid rubyist I've been using Ruby
01:19:53.760
on Rails for seven years but the last decade I have spent far too much time writing Python and the last year I've
01:20:01.320
actually had uh the opportunity to work with nextjs and part of the reason is because
01:20:08.440
we lack the tooling that those communities do I gave a talk at Ruby
01:20:13.600
comp 2022 on this topic which mostly mirrored what Adar just did with Marco
01:20:21.239
except with Andrew Kane if you're familiar very prolific rubyist who's made many gems including a lot of
01:20:29.239
machine learning and AI gems so I'm working on an initiative to
01:20:35.960
build a ruby AI working group and if you're interested in Ruby I hope you are
01:20:44.000
and Ai and you want to contribute to our open- source tooling come talk to
01:20:49.920
me thank you and if you're interested in the gem
01:20:55.480
I'm building active agents. forgot the plug and if you want
01:21:00.560
a sticker I have a couple yeah I I can recommend those stickers they're cool um all right um so
01:21:09.520
I think we're good with the open mic just to final second if
01:21:15.520
um somebody wants to go up but yeah I I think we're pretty good so
01:21:24.120
um with that Brandon go ahead start setting up um but yeah with that we are
01:21:32.000
um finally ready for the final presentation for
01:21:37.440
today um Brandon whoer is a I think principal software developer
01:21:44.320
at one medical and um we're going to be talking
01:21:53.080
about I hope going to be talking about
01:21:59.199
Lamor maybe some functional programming as well we'll see we'll see where it goes
01:22:05.520
but yep all right nice uh Brendon take it
01:22:16.199
away looks pretty good to me oh okay maybe too much Zoom yeah
01:22:24.880
uh what it is is I have to rehearse slideshow which will then put it there which does actually work no it's it's
01:22:31.880
good short version is zoom does not like showing my keynote notes and unfortunately I do not memorize things
01:22:38.320
very well so I need those notes so I had to make it work through this uh hacky if you want to see it's actually very
01:22:44.520
fascinating it's like literally please just zoom in on this narrow portion of the screen and I hope this works so here
01:22:50.760
we go so this talk is going to be the first
01:22:57.360
about 20 minutes of the Ruby keynote I'm going to be giving this year at Ruby comp I'm going to be on the third day
01:23:02.600
and the opening keynote for that day so I'd love it if you have any feedback any
01:23:08.840
type of ideas or otherwise but with that said we'll go ahead and get started with
01:23:14.920
red and fantasy land so first off who am I well simply
01:23:21.080
put my name is Brandon I love Ruby and I'm here to share that with you today and in fact I brought something special
01:23:26.600
a story I've wanted to tell for quite a while a story I deeply enjoyed writing and one I hope you enjoy as well with
01:23:33.120
that said should we go ahead and get started deep in
01:23:40.159
library we find ourselves in the Grand City libraries of the master Violet an
01:23:45.239
infinite well of information and wisdom in the world of the Lemurs why the library you might ask well you see
01:23:52.639
there's a particularly naughty lur named Indigo who's been repeatedly banned from the library and somehow keeps on finding
01:24:00.159
his way in along with his friend the esher cat and they're looking for something special in the deepest parts
01:24:06.960
of the library something so special in fact that we find ourselves journeying deeper and deeper into the depths of
01:24:13.280
Library where light begins to fade and a pressure can be felt Beyond even the depths of Lord Crimson is grimoires
01:24:18.960
there exists a book and to open that book is to incur a high cost indeed
01:24:26.040
so of course naturally we find Indigo and the eer cat retrieving such mysterious Blue Book one sealed with
01:24:33.000
ancient Magics and binding spells locked tightly in Chains and on its cover we can faintly make out the text Wonder
01:24:42.400
World upon opening the book of Blue Fog emerges the air in the room stirs and all the lanterns extinguish there deep
01:24:49.239
Magics here in Indigo and eer conspire amongst themselves to teach these Magics to a particularly unsuspecting young
01:24:55.320
lemur Indigo cackles to himself delighted discarding all warning notes and warning spells as he exclaims this
01:25:02.520
is perfect but they hear a noise a soft thump of slippers a light coming from
01:25:08.679
around the corner the master Library Violet was awake she enters the deeper Library
01:25:14.040
Lantern in hand trying to figure out what in the world is going on and why is so many alarms are ringing and found
01:25:20.000
Indigo in the eer cap with a particularly dangerous book what exactly are you Violet was cut off aser aser
01:25:27.400
time to make an exit whispered indigo violet and noid yells out after them Indigo aser don't you dare we cannot
01:25:33.600
have another eval incident especially not another mess with metaprogramming so mischievous smile came across the face
01:25:39.400
of indigo and the aser cat and with a snap of the aser cat's paw the two began to make their miraculous getaway fading
01:25:46.000
into dust Violet sigh and slowly approaches trying to find out which book had been
01:25:52.679
stolen and goes to look where the book once was seals undone multiple months
01:25:58.000
worth of binding spells broken the one book which must never be opened the one subject which must never be taught that
01:26:04.520
will render its reader incapable of ever teaching that subject again a subject no
01:26:09.679
wise lemur would ever dare touch so Violet takes a moment collecting herself
01:26:15.159
as the Shadows behind her stir and Coes and behind her several figures with
01:26:20.560
hoods drawn over their faces and Lead figures with a shining Stone Lambda pendant upon their chest the true owners
01:26:27.840
of the book they point to the missing book and the head liemer says simply it
01:26:33.199
must be found for there are some things the Lemur of this land are not ready for
01:26:38.600
something which must not be Unleashed within its Pages B agrees to this and says yes we can only hope that it can be
01:26:46.080
retrieved before that thing is let loose upon the world an ancient Creature From Time
01:26:52.719
immaterial granted his wisdom terrifying its potential who cannot be comprehended by the normal
01:26:58.560
lemur the only question left was where in the world Indigo might unleash such a force and what if anything could be done
01:27:06.239
to stop him in the eer cat the only hope was that no one would be caught up in
01:27:12.119
such a catastrophe and caught
01:27:17.800
unaware which brings us to part one a new adventure speaking of unawares we find
01:27:23.880
our friend read lemur studying in his tiny Forest Grotto he's just finishing up his book searching for his next
01:27:29.040
alignment but he found himself returning to the classics he sighed and looked up
01:27:34.320
to see saffron the great tailor sprinting on through with bolts of silk over his shoulders yelling early early
01:27:39.600
early I must be early as he dashed by he heard him repeating about tea parties and early and a piece of paper slipped
01:27:45.600
out of his bundle and landed in front of red early early early why was he so obsessed with being early and what was
01:27:51.920
this about a tea party red was confused set down his book and began to chase after sephron wait wait where are you
01:27:58.320
going in such a hurry asked Fred so many outfits to make I need to get there early before the party starts anything
01:28:04.480
through VV VIPs yelled saffron as he blew on by what tea party asked red
01:28:11.040
check your invitation they insisted you be invited as guest of honor said saffron so red stopped and took a look
01:28:17.400
at the invitation and saw what appeared to be a scraw of crayon with arrows pointing at what looked like a staircase
01:28:24.320
and uh what was this even when he looked up saffron was gone and in front of him
01:28:30.159
was a giant tree with a hole in the center a suspiciously well-designed sign that read fantasy land was it a trap
01:28:38.040
probably did Red particularly care probably not there was far more fun in
01:28:43.480
exploring and pushing the limits than sitting still and he wasn't going to miss out on whatever in the world this
01:28:48.600
adventure was so he found himself climbing through labyrinths of stairs right side left
01:28:54.679
side upside downside which way was even the correct direction which was was even up he found himself more and more lost
01:29:00.400
but at the same time approaching something until he found himself at a Gateway a gateway to a strange new
01:29:09.960
Land part two the forest of functions upon exiting the strange
01:29:15.520
Labyrinth he finds himself in a forest unlike anything he's seen before and in that Forest he can see a fire in the
01:29:21.600
distance and a few familiar voices as red enters the forest he comes across a fire and hears a group chatting was
01:29:28.440
told that Indigo was up to something again you think we should stop him why it seems interesting so far and who
01:29:34.800
knows what else him and that cat came up with said Lord Crimson it appears we have a guest shall
01:29:40.800
we serve him some tea just uh not a party we shouldn't interrupt those for later said
01:29:46.639
lavender red emerged from the forest confused and asked what in the world is going on in this strange place the two
01:29:52.880
looked at each other and began to laugh and then Crimson answered it appears our friends Indigo and the eaat are having
01:29:58.719
their fun and they've been so kind as to involve us in their plans to get ready and also to supply the tea for the
01:30:05.480
little party said lavender red looked confused at this it's an odd place yes but we'd best
01:30:13.000
get you ready for what lies ahead young one we're here to talk to you about functions today but just a few and a
01:30:19.320
quick review for those who need more of an introduction others might know some of this already said l
01:30:25.760
now in Ruby there are a few types of functions the first two that you might see are prox and lambdas but we'll be
01:30:31.520
focusing on lambdas for today and you can find QR codes in the top right which will link you to just I'll eventually
01:30:38.199
have a repo for that so in fact there's a type of programming called functional
01:30:44.000
programming which composes smaller functions together to do larger tasks in this case we have two functions one
01:30:49.960
which adds five and one which multiplies by three in Ruby we can compose those
01:30:55.080
using the double angle bracket when used in this direction multiply 3 is called
01:31:00.119
first but if we flip it around the opposite would be true and that you get both of those functions still
01:31:07.760
called now there's even a particular odd function which does nothing why would
01:31:13.400
you want to do nothing well if we use it we'll notice that it does indeed quite literally do nothing
01:31:20.480
it takes in parameter V and returns that parameter a function after my my own heart I must say but very useful in
01:31:26.000
certain contexts we can even use it to prove if
01:31:31.080
you'd like but it does indeed do nothing such an odd little function but what I have a feeling you'll be seeing quite a
01:31:37.080
bit of later functions are everywhere in functional programming they take all types of unexpected shapes did you know
01:31:43.239
you're already using them in Ruby today you might recognize this and say of course well it's a block well yes we
01:31:50.639
can call them blocks but they're also functions block block function function the same difference really the important
01:31:56.800
part is what they do and in this case they allow us to select only the even numbers out of a
01:32:03.320
list if we wanted to we could even make our own method which took a block function itself and an argument like so
01:32:10.000
and what that would be doing is we'd be starting with what we call a predicate function you'll notice I don't call these blocks because I prefer to reflect
01:32:17.360
on what it's actually doing in this case we're using it to decide whether or not an item should be included in a new list
01:32:25.480
and in this case what it's doing is if that is in fact true we're creating an item here and we're going to
01:32:32.480
give it to a new array and we add that item to a new array which we will return at the end of the method giving us only
01:32:38.840
the values for which the predicate function returned a truth result but there's something interesting
01:32:44.159
in Ruby and something to keep in mind which is there are many many different ways to
01:32:49.719
do something which is more correct well long hand shorthand select filter it it
01:32:55.199
really depends doesn't it which answer is correct depends on the code base you're working in and the people you're working with aim first and foremost to
01:33:02.000
be understood and not clever beyond that there are many lessons from other languages some with
01:33:08.840
different philosophies and what you might find with Ruby all are valuable certainly but be careful not to become
01:33:14.639
dogmatic said lavender with all that said there are others to meet and lessons to be learned
01:33:21.440
ahead from Friends old and new alike said Crimson so red wandered on to the
01:33:27.800
next area you you think we should warn him about the lavender was cut off nah it'll
01:33:34.520
be more fun if they learn it themselves answer Crimson part three The mapable
01:33:46.880
Meadows so we find red entering the mapable Meadows a place filled with flowers and plants of all kinds
01:33:54.080
in there ahead he finds chartreuse his teacher from many years past that taught him the ways of map but this is a
01:33:59.760
different place at a different time ah it's been what now six years my
01:34:05.719
how time flies and the young ones grow and so too does our understanding of what we think we might already
01:34:11.920
understand what do you mean Master last we spoke you taught me about map but wasn't implementing it with reduce all
01:34:18.280
there really was to learn what is map do you suppose
01:34:25.040
well of course it's using a block function to transform every element of a list and return a new list isn't
01:34:30.679
it yes that's true but there's far more to it let's take a look consider this example we know that
01:34:38.719
we can double every element of list by applying a function that takes a parameter V and returns back V * 2
01:34:45.480
but why do we know that how do we know that how do we even know what that block
01:34:50.520
function is going to do to that array how do we know that that trans Ates into a new array there are a lot of
01:34:56.639
assumptions we're making here but if we were to implement such a function for an array in that context certainly it does
01:35:03.520
do that and in doing so we notice that interestingly enough it returns a new array array in Array out if you will
01:35:10.920
that's because map in the context of Ruby's array means to return a new array with every value transformed by the
01:35:17.159
function we provided but what if this were a different type I'm not entirely sure
01:35:25.320
let's suppose that we had to Define map for a string what might that look like do you
01:35:31.320
suppose perhaps in the context of a string map would make a new string and
01:35:37.440
inside of that we' iterate through each one of the characters of that old string and then we would append the result of
01:35:44.000
calling a function on each one of those characters to append it to a new string which would be returned at the
01:35:50.159
end of the method and we would call it something like
01:35:56.320
this which gives us something very similar to what that map function was doing with
01:36:02.320
array but I think we can go further in our exploration What If instead we happen to
01:36:09.360
put map directly onto the string class much like what array has through
01:36:16.360
enumerable the noticeable differences here are that we're getting the characters directly from self and while
01:36:21.960
not required here it does make it clear where it comes from the other is that we're directly calling map on the string
01:36:28.320
itself there at the bottom which gives us something a little
01:36:33.480
bit more ergonomic but we could go further what if we were to implement map
01:36:40.320
using map there's certainly no rule against it and it would shorten our code a good deal too the two differences are
01:36:46.480
now that we're using map but we're also using join to join the characters back together at the end in fact we could
01:36:53.080
even take the one step further to condense that to a short hand to pass the function directly to the new map
01:36:58.920
we're calling on strings characters now that all said we should probably not monkey patch core Ruby classes as
01:37:04.960
generally frowned upon nowadays isn't it so what other options might we have here
01:37:10.520
well to start we could wrap our map function in a module like this and call it like so which would look similar to
01:37:15.840
our initial example the problem with this is let's say that you wanted to map more than
01:37:21.920
once It's Quickly going to become unwieldy so
01:37:27.040
we're going to need to find another option another option which allows us to express this idea in something a little
01:37:32.320
bit more containable What If instead we mapped our string in a class our own custom
01:37:39.040
context where we Define the rules and we get to decide what map means for that
01:37:44.119
context we can even Define map on it but this map has a problem do you see
01:37:50.040
it it returns back a string meaning that if you were to call map twice the code right here would crash
01:37:58.480
because string has no map method on it that's because we went outside of the context of our class and returned a
01:38:04.760
string instead so what's one to do well what we could do is take our code right here and we
01:38:12.400
can make a new method that we call WP which is how do we put it back inside of our container how do we put it back
01:38:18.400
inside of the context that we're dealing with and we can introduce the term R to do just that so every time we map we
01:38:25.400
would also make sure to use wrap right before we do so and it would work about as well as
01:38:34.360
you'd expect it to but here are the things to keep in mind the value is still in the context of our string characters class and we need to get it
01:38:40.840
back out having our own rules is great but our program probably wants a string it has no idea how to deal with string
01:38:45.960
characters so how do we get it back out well we do that by calling
01:38:51.599
value which gives us back that result on the other end so let's take a look back at our
01:38:57.599
implementation it looks like we have some things which could be used elsewhere no like the idea of rap and the idea of a value what if we happen to
01:39:04.880
pull that into say a module and we call that module something like mappable to
01:39:10.560
represent something which can be mapped and follow certain set of rules this basic example for making our own context
01:39:16.760
but it does serve a point by doing so our implementation of string characters is shorten to this but
01:39:23.440
but what's more is that you'll notice this pattern is very common like let's say I didn't want string characters I
01:39:29.159
decided that I wanted to instead iterate a string by its words albeit a naive implementation but still we can now
01:39:35.880
transform that or let's say that I happen to want to instead even do the lines of a
01:39:41.239
strain these are very general shapes and they can apply to a lot of different things and by establishing our own rules
01:39:47.840
for map we can do a lot of things which may not make sense for classes like string or array we can Define our own
01:39:53.440
rules of what it means to map in our own context in our own way and we can even use that idea if we were to use
01:39:59.119
something completely different like let's say take this single white flower here could that also be
01:40:06.960
mappable in the context of a single flower we have a color inside of it and mapping in this context means to
01:40:12.719
transform the color and return a new flower we could even add rules to it defining what a valid flower is by
01:40:18.639
checking if the value is indeed a color an easy mistake to make here is to think that map only works on collections not
01:40:24.960
so map just means to transform and to return the same type and a flower is
01:40:30.360
just as much a context as an array is or string is or hashes or any other Ruby type might
01:40:36.520
be so to test this we might take white and red here and create a new Flower by which we Mak 0% white with 100% red
01:40:44.239
effectively painting this flower red now there was a song Once I'd heard
01:40:51.840
about painting flowers red but that's neither here nor there but now that we have an idea of
01:40:58.679
what it means to be mappable there are also a few rules we must keep in mind ones you might already have noticed the
01:41:04.639
reason for earlier the first rule is that if we do nothing it should unsurprisingly do
01:41:11.480
nothing we start by defining equality for a mappable module for something as mapable to be equal it should be both
01:41:17.719
the same type as well as have the same value inside of it now let's take an example of a string
01:41:24.440
like hey world over here we make ourselves a do nothing function which takes no parameter V and returns V and
01:41:31.480
we give ourselves a new string characters class now afterwards we can check if it
01:41:37.639
does nothing to the rapper and in fact it does do nothing and we get back true response that means that doing nothing
01:41:43.560
in the context of something which is mappable does well nothing you might wonder why in the
01:41:49.679
world do I care about doing nothing Well back with our module context with our string characters class before map these
01:41:56.520
would have failed if it fails that means we're not returning the same type and we can think this as a baseline to ensure
01:42:02.560
our mappable class works as expected rule number two is if we call
01:42:08.199
map twice using two different functions we should get back the same result as if we compose those two functions
01:42:13.719
independently so let's say that we had two functions one which wraps a character in Brackets and the next one
01:42:19.159
which gets the success of next character such that a do success is going to give us back
01:42:25.239
B we could again create our context as an experiment here with the string hey world and then map it twice using the
01:42:32.560
function separately and use the same thing by using functional composition
01:42:38.080
here why do we care about this because after all these are just functions we shouldn't be changing how functions work
01:42:43.800
they're just functions they should always behave as expected our string characters class should not be doing anything unexpected mutation extra steps
01:42:51.000
and this is a way to prove that we're doing exactly what one might expect what you see is what you get no
01:42:56.679
surprises we may be able to Define our own rules but for functions they have their own rules we should respect those
01:43:02.679
and we should be very careful not to break them and do unexpected things though in some cases in Ruby this
01:43:09.520
does not hold true such as Ruby's hash instance doesn't behave the way you'd
01:43:15.119
expect it to because inherits map from inumerable and returns an array instead
01:43:20.320
now we must be very careful of this but Ruby's hat also has another method which works far more like map which is a 2
01:43:27.400
method which actually takes in a block function as well and it behaves a lot more like what you expect now here's a
01:43:34.280
question does that mean that we should change map on hash probably not because
01:43:39.639
do you realize how much Cod relies on that and how much Behavior probably is built upon that presumption that would
01:43:44.920
be very dangerous so there's a reason to get this right and to follow rules in the initial set which makes it a lot
01:43:49.960
easier to build upon things but map map can do so much more than
01:43:56.119
what we've seen and in fact it can even reach into the future if given a
01:44:01.239
chance our context might even be the future itself it could contain a thread
01:44:06.520
which will eventually finish and what we can do inside of this is that we can take map and add the
01:44:14.000
context of making HTTP requests which will eventually return and we can eventually parse adjacent it and we can
01:44:19.639
eventually get the value this is exactly what you might see in it's a trick we learned from lemur of JavaScript which
01:44:25.199
is a very fascinating concept so you see red there's far more
01:44:31.599
to map than it appears an entire world of mappable things to discover out there in the wide world Ruby we've only
01:44:37.560
covered a small portion of its potential consider it a pattern to be used when you find things in your programs with
01:44:43.159
similar shapes and that follow those rules so with that red had learned more about map and began to walk to his next
01:44:51.040
destination which brings us to the the end of what I actually have prepared because unfortunately I have to draw all
01:45:07.239
time yep I think I'm about 90 hours worth of artwork in so far and I have about 24 left so I'll make it by the
01:45:13.320
conference but uh that's going to be chancy oh yes trust me I'm wor I have
01:45:19.400
myself a deadline of the 24th actually do I have that Chrome window open I might just be willing to show you
01:45:27.199
the magical sheet that I'm going to make sure to censor the names of the slide so it's to
01:45:33.960
not give you spoilers of things zoomy zoomi zoom zoom zoom where is the zoomy share there you are
01:45:42.840
screens share yep about 116 hours total with the commitment of going through
01:45:48.679
draft Blue Line ink color slides notes and various other things and uh uh
01:45:54.199
there's a lot of red that I'm not looking forward to this weekend but we will endeavor and we will get it done but those are all custom illustrations
01:46:00.520
drawn by hand and for me I like giving Illustrated stories to give a bit of a different experience from what people
01:46:06.000
are usually used to and I like to tell stories around functional programming or other novel Concepts in Ruby now granted
01:46:12.520
some of those are much harder than others and some of you might be guessing where I'm going with this and know exactly what type of danger I managed to
01:46:18.199
set my foot in so there are be traps there I'm GNA try my best to see if we can pull this talk off
01:46:23.480
but they said we want the most technical talk you can come up with you have an hour figure out what you want to do and that's the only chance I'm going to get
01:46:29.400
to give this type of talk so here we
01:46:43.679
questions we can we can take some um
01:47:13.080
uh if you paid attention as well whenever red was reading the book there is a why Fox on the front of that book
01:47:19.159
as well and I'll put a whole bunch more references in there this is the initial draft version which means I haven't
01:47:24.840
actually done all the finishing touches on this so if you pay attention during the live talk you're going to see in
01:47:30.199
library every single one of those books is going to have some sort of reference to some sort of Ruby book including ones by say uh Vlad and noell and I should
01:47:37.159
really write a book I feel like I'm the only person up here doesn't have a book I mean to be fair I did have
01:47:42.360
contract for I should probably finish it they're probably mad at me by now anyway uh moving on from that subject no I try
01:47:48.320
and sneak as many Easter eggs into there as possible like you might have noticed during the staircase there's a special
01:47:53.880
little uh time and space vehicle which happens to be flying around in the background
01:47:59.800
there technically it is the dartis which is day and relative time in Ruby or
01:48:05.800
something like that I don't forget what exactly the acronym was but I had a doctor who variant talk which was going to be at rails 2021 but uh certain Coy
01:48:13.880
events happened and I didn't finish at once so I try and make references to it so I can eventually give that talk but
01:48:19.080
it's like half done I should probably finish it
01:48:25.800
uh do we have any other questions or other things I appreciate that's a very very heavy subject and can lose the heck
01:48:31.480
out of everyone so I try to make it as approachable as I can but it's rough to figure that one out so a lot more build
01:48:37.760
steps just takes a bit go for it
01:49:19.520
mhm yep yep so there's a fun little secret in the end of the talk to where I almost can't do that so the way it works
01:49:27.719
is that I'm hiding something in the middle of there and I'm trying to introduce Concepts in a way which is approachable at least decently to Ruby
01:49:34.440
people but also not telling people what I'm actually doing because the second I say those words out loud everyone's going to lock up and say oh my gosh I'm
01:49:40.960
learning about X I cannot learn about X I've heard that's hard and that's impossible so there are certain words I
01:49:46.440
can't say out loud quite yet which happens to relate to the Beast of the book and the symbols on the back
01:49:53.840
of the hoods of all those L that showed up in the library but no it's a tough line to run
01:50:01.360
between I want to tell you but I shouldn't tell you but I want to but I shouldn't so I'll try and find a better way to approach
01:50:11.440
that go for
01:50:19.440
it oh it's going exactly where you think it's going and it's exactly I'll put it this way whenever I said it's a subject
01:50:25.800
which must not be taught because if you ever read the book and understand the book you're not allowed to teach it
01:50:30.920
anymore because you'll never know what in the world to explain it
01:50:40.400
with now the trick is and I'm not sure I know how to explain it either so let's hope I figure it out between now and
01:50:47.360
then I keep on doing this to myself I give myself an impossible challenge and say what happens if I try and teach this
01:50:52.440
thing I have no business teaching I guess I learn a lot one time I even showed up with a BTO
01:50:58.199
looking wig and tried to learn how in the world to do it Symphony Orchestra using midi with the audience's cell phones that blew up on stage but hey it
01:51:04.320
was
01:51:16.679
right all right this um this concludes our event today but we are planning
01:51:23.599
to go check out this cafet turus like a bar super close by um so
01:51:33.199
you're all welcome to ter ter ter tuse right something like that um I put
01:51:40.920
it on Luma by the way uh the name of the the place it's straight here like around
01:51:46.599
the corner and yeah just want to say thank you to
01:51:53.000
uh to our hosts at Chim uh again for for hosting us today so thank you guys and
01:51:59.119
let's let's just give them a shout out and I'll see you next time uh yep