Ruby Archaeology

I take this as a call to action to run old code. In this talk we dig, together, through historical Ruby. We will have fun excavating interesting gems from the past.

Further, I will answer the following questions:

What code greater than 12 years old still runs in Ruby 3.0?
What idioms have changed?
And for the brave: how can you set up an environment to run Ruby 1.8 code from ~2008 on a modern machine?

RubyConf 2021

00:00:00.950 [Music]
00:00:10.240 hi everybody my name is nick schwaderer
00:00:13.040 today i'll be talking to you about ruby
00:00:15.440 archaeology i am a production engineer
00:00:18.800 at shopify you've probably heard of them
00:00:21.039 this conference but i'll say there's
00:00:23.359 never been a better time to work at
00:00:24.640 shopify i'm a huge fan of the work they
00:00:27.519 do
00:00:28.400 seeing the work that their engineers
00:00:29.679 have done over the years at ruby comps
00:00:31.519 attracted me there
00:00:32.960 and slide into my dms or just tap me on
00:00:35.200 the shoulder any questions you have i'm
00:00:37.440 happy to talk about that but i'm not
00:00:38.879 talking about shopify today
00:00:40.960 i'm talking about a little project that
00:00:43.040 i'm interested in and it's kind of fun
00:00:45.039 when you find yourself doing a deep dive
00:00:46.800 at one in the morning on a subject to
00:00:48.960 start throwing it out as a cfp and then
00:00:51.120 if somebody accepts it for a talk you
00:00:52.640 can do even more hours looking into this
00:00:54.879 weird subject that no one would pay you
00:00:56.719 to do probably well maybe
00:00:58.800 the first thing i'd like to say is thank
00:01:00.160 you thank you to the organizers to the
00:01:02.000 staff
00:01:02.960 the people who put this whole thing
00:01:04.640 together
00:01:11.200 the last couple days it felt like a big
00:01:13.200 chunk of healing over the last couple of
00:01:15.280 years that we've been mainly at home
00:01:17.439 working on our computers not socializing
00:01:19.759 and honestly i think a few people almost
00:01:21.920 felt overwhelmed with it and uh it's one
00:01:24.720 of the hardest times to make a
00:01:25.680 conference so really appreciate that and
00:01:27.200 thank you to all of you for taking 30
00:01:29.200 minutes out of your day to listen to
00:01:30.880 what i have to say
00:01:33.200 so you might be asking yourself what is
00:01:34.640 ruby archaeology
00:01:36.640 well it's obviously a term that i made
00:01:38.880 up for this talk and it kind of covers
00:01:41.759 applied uh creeping on ruby history via
00:01:45.280 code or or things that happened in the
00:01:46.960 past and i'll give you a few snippets
00:01:48.880 about what i've been into that kind of
00:01:51.280 feed into this
00:01:52.880 so the first is i i occasionally put out
00:01:54.880 the past ruby's newsletter so you could
00:01:56.799 go to if you want to
00:01:58.719 subscribe like plug there
00:02:00.799 um
00:02:01.680 and it just does kind of like a link
00:02:03.200 list not dissimilar to like a really
00:02:05.439 tiny not as shiny version of ruby weekly
00:02:08.479 but like on this week in history but for
00:02:10.239 ruby so it could be releases cool talks
00:02:12.800 from like all the way back to 2003
00:02:15.360 um blog posts uh articles all sorts of
00:02:18.400 stuff like that and i love doing this so
00:02:20.480 much i even have my own private code i
00:02:22.560 keep to myself for like doing this
00:02:24.879 research that i can pass a date object
00:02:26.879 into and it'll give me articles and
00:02:29.680 blogs and posts from this week in
00:02:31.360 history from all these different
00:02:32.959 resources and then it just has kind of
00:02:34.879 like an adapter that figures out how to
00:02:36.720 parse that page so i can just run one
00:02:39.120 command and it'll give me 500 tabs
00:02:42.239 slowly opened up to click through and
00:02:44.160 curate for the newsletter so i
00:02:46.080 automate in my own life
00:02:48.560 i also wrote portalgun which is a
00:02:50.480 rubygem
00:02:51.599 that allows you to take a gem file so
00:02:53.920 it'll either infer one or you can supply
00:02:55.840 it
00:02:56.560 and if you have a situation where say a
00:02:58.159 gemfile.luck is corrupted or if you're
00:03:00.800 doing what i do and you look at old code
00:03:02.560 and you know a time that it worked say
00:03:04.239 march 5th 2011.
00:03:06.560 you run the portalgun executable and a
00:03:08.640 date it'll give you a full gem file
00:03:10.879 pointing towards the stable versions of
00:03:12.400 every gem from that date in history
00:03:16.640 but a lot of my uh time in ruby and work
00:03:20.080 and reading in the past has been heavily
00:03:21.599 influenced by why the lucky stiff
00:03:24.480 why was and i think is the symbol of all
00:03:26.319 that is whimsical and right with
00:03:27.920 programming i think that whimsy is core
00:03:30.080 to ruby and i think having the care of
00:03:32.720 about the building and the art and the
00:03:34.640 sharing what you do
00:03:36.159 and he represented a time where you
00:03:37.280 could give major conference talks
00:03:38.720 without giving your real name job or
00:03:40.560 location
00:03:41.840 and it's a bit surreal to me to think
00:03:43.760 that i'm in the room or the same
00:03:45.200 conference as individuals who actually
00:03:47.680 would have physically interacted with
00:03:49.280 why or interacted with why on the
00:03:51.040 internet and it's just wild and we never
00:03:53.200 overlapped i wrote my first line of ruby
00:03:54.879 in 2014 but it's still quite an impact
00:03:57.840 on me
00:03:59.760 why wrote a tweet
00:04:02.080 a few weeks before he disappeared in
00:04:04.080 2009
00:04:06.480 programming is rather thankless
00:04:08.560 you see your works become replaced by
00:04:10.080 superior works in a year
00:04:11.920 unable to run it all in a few more
00:04:14.959 so thinking of that which has haunted me
00:04:17.280 for a number of years
00:04:18.799 and leading into my normal interests for
00:04:20.880 this talk i say
00:04:22.400 let's run some old code
00:04:25.440 the first problem you want to do
00:04:27.680 tackling this issue
00:04:29.280 at least for me was setting up a 2009
00:04:31.199 coding environment on a 2021 machine i
00:04:34.240 lost several days to this right
00:04:36.240 uh you can't just like
00:04:38.560 rvm
00:04:39.759 ruby 1a or rbm or chu like it's not it's
00:04:43.280 not really the best path to do things
00:04:45.680 right uh
00:04:46.800 you know uh one eight and one nine and
00:04:49.199 spoiler alert we're gonna do ruby 1.8
00:04:50.880 today we're end of life seven years ago
00:04:52.960 and ruby 1.8 wasn't even the latest
00:04:54.639 greatest for over 14 years now so this
00:04:57.840 is not the best path
00:04:59.840 but i think looking to our past is
00:05:02.160 important
00:05:03.199 because we now have a mature language
00:05:05.360 with a feature-rich robust ecosystem
00:05:07.840 that is very supported globally like
00:05:10.080 there was a time where you couldn't even
00:05:11.039 get paid to do ruby and i think to
00:05:13.360 progress forward with this language we
00:05:16.000 must keep an eye on the old code keep an
00:05:17.919 eye on the patterns and keep an eye on
00:05:19.280 the styles and debates to move forward
00:05:21.680 a motif i'll highlight in this talk is
00:05:24.880 the
00:05:26.000 with the more that we work with ruby to
00:05:28.000 earn our livings the more interest there
00:05:30.479 is in kind of narrowing down
00:05:32.320 on one way to use the sharp knife to
00:05:34.560 write code
00:05:36.880 so let's get started how did i actually
00:05:38.800 tackle this and spoiler alert there are
00:05:40.800 so many different ways to tackle this
00:05:43.440 problem this is not the right way this
00:05:45.520 is the way that i got away with it
00:05:47.919 uh first thing i did was set up a
00:05:50.400 vagrant box that had an operating system
00:05:53.199 that was germaine to 2008 so again i'm
00:05:55.120 focusing on the year 2008 kind of
00:05:56.800 bleeding into 2009 for parts of this
00:05:59.520 and if you're i
00:06:01.039 don't expect any knowledge here if
00:06:02.479 you're like what in the world is vagrant
00:06:04.400 it just lets you set up this box on your
00:06:06.560 machine and i'll just give you commands
00:06:07.919 just copy paste brew install vagrant
00:06:10.080 vagrant in it this exact version of
00:06:11.840 ubuntu up ssh you're in the terminal
00:06:14.080 right that's all that's all you need to
00:06:15.280 care about
00:06:16.479 so we're part way there we've got the
00:06:18.240 operating system but we're still
00:06:21.199 not quite in the past we're pointing
00:06:23.440 towards modern packages
00:06:25.759 so if you're trying to app get
00:06:27.680 packages into here you're pointing
00:06:29.919 towards 2021
00:06:31.919 well that's going to cause you all sorts
00:06:33.360 of headache and you're not fully synced
00:06:34.639 yet
00:06:35.680 so something that i did to tackle this
00:06:37.840 was i went to the sources.list
00:06:40.400 and there's actually
00:06:42.080 a repo a website out there that
00:06:43.680 maintains old releases and so you just
00:06:45.759 need to make sure that you tell your
00:06:48.000 operating system to point to that so
00:06:50.240 swap us.archive and security for old
00:06:52.560 releases you don't have to do a cute
00:06:54.240 said argument you can just nano or vim
00:06:56.240 into it and like type it yourself i just
00:06:58.400 was so pleased that i was using said
00:06:59.759 that i wanted to put in the slide
00:07:02.720 and again another thing i'll under the
00:07:05.199 line this in your thinking process
00:07:06.720 you're in 2008 now act like it don't
00:07:09.280 think like oh i'm bad and feel guilt and
00:07:11.360 like all this so so make your search
00:07:13.919 engine whatever you use use the flag
00:07:15.840 this is actually quite a powerful
00:07:17.360 feature we never get to use so if you
00:07:19.440 want to be
00:07:20.639 january 10 2009 say before january 11th
00:07:24.000 2009 it'll give you like what we're the
00:07:26.000 latest grace it probably searches it
00:07:27.919 even better right than it did 12 years
00:07:29.680 ago
00:07:30.400 and i found that to be incredibly
00:07:31.520 helpful
00:07:33.199 so for the so now we've we're able to
00:07:35.280 get packages from 2008
00:07:37.280 and we've got our operating system and
00:07:38.800 we're typing code in there so that's
00:07:40.319 pretty good
00:07:41.919 and for the next steps i got ruby in the
00:07:44.160 one way i would never get ruby in real
00:07:45.840 life
00:07:47.039 i did app get install ruby dev and it
00:07:48.800 just worked ruby 1.8.7 right out of the
00:07:51.360 box
00:07:52.319 pretty cool
00:07:53.520 and then also like think about this way
00:07:55.039 i'm never going to do a different
00:07:56.000 version of ruby in this container right
00:07:58.479 like this is the version of ruby i want
00:08:00.080 to play with in the sandbox and share
00:08:01.599 with you and code today
00:08:03.360 i was able to get ruby gems as well
00:08:04.960 because that had been around for about
00:08:06.319 four years
00:08:07.520 and also uh get but there was a couple
00:08:09.919 of problems here with these because
00:08:12.000 we're talking to the outside world so if
00:08:14.479 you're trying to use git to like get
00:08:16.639 clone from
00:08:17.919 modern existing infrastructure it's just
00:08:20.879 it's going to complain it's going to
00:08:22.639 fight and then ruby gems for gem install
00:08:25.360 similarly
00:08:26.400 you know it's just a different protocol
00:08:28.080 you know you'd probably have to alter
00:08:29.919 the package a little bit so i couldn't
00:08:32.000 use git or ruby gems to talk to the
00:08:34.800 outside world
00:08:36.640 so i was thinking right i've got a
00:08:38.000 limited tool set how can i macgyver this
00:08:40.719 to work
00:08:42.080 and i realized just do it in a couple of
00:08:44.240 steps so an alternative method i used to
00:08:46.640 snag and install gems was just literally
00:08:49.519 if you remember you go to ruby gems and
00:08:51.120 there's the download link just download
00:08:53.120 the dot jam just use it from your
00:08:54.640 terminal and then gem install supports
00:08:56.560 the local flag which we probably use for
00:08:58.160 development right and just do that to
00:09:00.080 install your gem and while out you're in
00:09:02.080 business and you're officially just
00:09:04.240 playing with all the gems you want just
00:09:06.160 remember you're going to be doing loads
00:09:07.440 of dependencies and every time you get a
00:09:09.440 bug just know it's almost certainly a
00:09:11.760 package that you need to install for
00:09:13.600 that
00:09:15.120 so okay
00:09:16.720 we're in business we have a machine that
00:09:18.480 works we're able to get ruby gems
00:09:20.880 and for this part of the talk i'd like
00:09:22.240 to look at a couple of them
00:09:24.000 and run them in real life to show you
00:09:25.600 that i actually got them working and
00:09:27.600 then i'd also like to step out and look
00:09:28.959 at the library code from the time
00:09:30.560 because i think that's part of the ethos
00:09:32.320 of this talk
00:09:33.760 so the first thing is h per cut
00:09:36.399 put your hand up if you've heard of
00:09:37.519 apricot
00:09:38.640 holy mackerel i did not expect that many
00:09:41.200 people i'm so pleased because h
00:09:42.880 uh
00:09:43.680 was was one of wise gems that wasn't
00:09:46.000 actively developed after he left so i
00:09:47.600 wasn't sure so it's not necessarily uh
00:09:50.080 the industry industry standard anymore
00:09:51.680 but it was the industry standard for
00:09:53.600 html parsing up until and through 2008
00:09:56.800 and if i know what i'm doing here
00:09:58.880 i'm not going to do live coding demo for
00:10:00.560 you i've recorded it and i've altered
00:10:03.040 the speed so you don't know how slow i
00:10:04.240 type in real life
00:10:05.839 um
00:10:06.720 so let's look at h for cot this is in my
00:10:08.480 box this is in a terminal so you require
00:10:10.800 h picot
00:10:12.240 and one of the things i really liked
00:10:13.600 with this api that i designed was you
00:10:15.920 just have straight up h percat and then
00:10:18.399 prams no dot new no setting up
00:10:20.720 instantiation you just pass your file or
00:10:23.680 your html directly into it
00:10:26.160 and then it takes it
00:10:27.760 and then we're able to kind of
00:10:29.680 manipulate it and in this case i'll just
00:10:31.600 do something really simple where i'm
00:10:33.440 going to take the document and iterate
00:10:35.440 over table rows and again i like this
00:10:37.040 with the forward slash and just punching
00:10:39.279 in the string table tr
00:10:41.680 and we're going to
00:10:43.200 grab each of those rows in turn and then
00:10:45.760 we're going to iterate through the cells
00:10:47.519 and say if the first cell is lamb and
00:10:49.839 the second cell is premium that's what
00:10:51.200 we're trying to pull out of this table
00:10:53.040 then we want to bring it down and just
00:10:55.839 look at this collection and maybe we'll
00:10:57.600 try and sample it and then realize that
00:10:59.519 that doesn't work in ruby one point
00:11:01.200 eight point seven
00:11:02.320 uh for the arrays and then just have a
00:11:04.560 bit of fun there
00:11:06.800 and that's age per cop
00:11:08.560 and it works i've shown my work i didn't
00:11:10.560 just do screenshots and say this
00:11:12.160 definitely happened you got to see some
00:11:13.760 typing albeit pre-recorded because no
00:11:16.000 way is i could type in real time
00:11:18.560 but let's look at some of the library
00:11:19.760 code for all the slides that are in this
00:11:21.760 manner i show the link to the code and
00:11:25.839 also the date for the commit where it
00:11:27.360 was pulled
00:11:28.560 um
00:11:29.680 this is
00:11:31.839 got a few things going on i'll do some
00:11:33.440 highlighting the first that i liked is
00:11:35.120 that we have def h prakata as a method
00:11:37.040 at top you know so normally oh wait a
00:11:39.360 capital at the at the front of a method
00:11:41.920 no that's wrong and then wait but we
00:11:43.920 have a module h how are we defining a
00:11:45.839 method at the top but that is what
00:11:47.440 facilitates this really cool api where
00:11:50.240 you're calling h percott directly and
00:11:52.160 then it's passing you down into the
00:11:53.360 module and and uh running make with your
00:11:56.800 input and it's able to facilitate that
00:11:58.800 api second
00:12:00.320 y'all probably are familiar with going
00:12:01.839 self inside your modules or your classes
00:12:04.320 self is age for cop
00:12:06.000 and that was another way that was quite
00:12:08.079 common back then i'm sure your linter
00:12:09.360 would scream at you if you did it now
00:12:11.440 but the thing that i like about this
00:12:13.279 approach is that's what you call in real
00:12:14.800 life
00:12:15.760 that's what you see h4cot.make right
00:12:17.600 it's not self but i know what what i
00:12:19.839 mean when i'm calling self
00:12:21.519 let's look at some more code
00:12:23.519 this is the blank slate class somebody
00:12:25.600 can come up to me later and correct me
00:12:26.880 if i'm wrong but i know it was
00:12:28.079 referenced a jim wyrick talk around this
00:12:30.639 uh maybe a year or two before this time
00:12:32.480 i believe it was invented for rake
00:12:35.040 and it was used here as well and the
00:12:37.519 beauty of the
00:12:39.040 blank slate class is it gives you an
00:12:41.519 abstract base class with no predefined
00:12:43.680 methods except you see the exception
00:12:45.360 here underscore underscore to cover
00:12:47.279 underscore underscore send and id and
00:12:49.360 also instance eval but that means if
00:12:51.760 you're doing like a dynamic proxy that
00:12:53.680 you want to depend on method missing and
00:12:55.760 have no collisions
00:12:57.200 this is the class that lets you do
00:12:59.680 all that
00:13:01.839 and now going into config we do a couple
00:13:03.600 of things some that i've talked about
00:13:05.279 and some that are new
00:13:07.120 so i'll highlight again
00:13:08.560 so we're still instead of doing self
00:13:10.160 we're saying config
00:13:12.160 and then the second is called
00:13:13.279 recursively and then the second is colon
00:13:15.200 colon
00:13:16.160 colon colon to call a method there are
00:13:18.160 13 ways to call a method in ruby there's
00:13:20.320 a popular article that there's 12 ways
00:13:21.839 to call a method in ruby and this was
00:13:23.920 not in those lists you can definitely
00:13:26.240 call cohen cullen i never did until i've
00:13:28.320 realized this in this talk but i thought
00:13:30.320 maybe i was wrong so i tweeted about it
00:13:32.639 a week ago to gregory woodtech with
00:13:35.200 i said i believe like i was
00:13:37.920 a little nervous i was like i think this
00:13:39.360 is another way like or if i
00:13:41.199 misinterpreted ruby and i'm just being
00:13:42.720 stupid and you know what you replied 12
00:13:45.279 years of using ruby no idea that that
00:13:47.199 was possible that you could just call
00:13:48.399 cohen colon instead full stop
00:13:55.440 why does this matter i believe that we
00:13:57.519 can use that and i think it has been
00:13:59.120 used historically to communicate a
00:14:01.120 little bit more information when you
00:14:02.800 have something that can be done two ways
00:14:04.320 that's identical in ruby as engineers we
00:14:06.720 can develop our own idioms that say hey
00:14:09.040 when i do it with this thing i'm also
00:14:10.959 telling you something else maybe there's
00:14:12.880 a third party api wrapper
00:14:16.000 and also uh talking about self a bit
00:14:18.000 like here's a snip snippet from ruby
00:14:19.680 talk in 2006 all the different ways to
00:14:22.160 approach self uh in class methods um
00:14:25.600 it's it's a long running discussion
00:14:28.240 and then one more here we have a
00:14:31.519 alias method whereas i think we're very
00:14:33.440 used to alias but this this is just
00:14:35.600 another thing that i saw that was quite
00:14:37.279 unique
00:14:38.800 this leads me into my second gem that
00:14:40.639 i'm going to talk to you about today
00:14:42.720 i'm not gonna ask you if you've heard of
00:14:43.920 it
00:14:44.639 it's nokogiri
00:14:46.320 i'm a little nervous
00:14:48.720 to be talking about this i didn't really
00:14:50.320 think i had
00:14:51.519 are mike d'alessio or aaron patterson in
00:14:53.519 the room
00:14:55.199 good act oh hey hey mike so mike mike's
00:15:04.639 mike thank you for coming to my talk um
00:15:07.040 yes uh so mike is the oh god he is for i
00:15:11.440 believe for for 10 years been the core
00:15:13.040 maintainer but i also believe you may
00:15:14.320 have been working in nokogiri for longer
00:15:15.839 than that um and nokogiri is the
00:15:18.880 industry standard html parser gem and
00:15:21.839 and thank you to mike and for the work
00:15:23.519 that you do because so much of our
00:15:25.279 infrastructure
00:15:26.480 sets on that gem
00:15:28.560 it's like the it's like the relevant
00:15:30.079 xkcd you might have seen it about like
00:15:32.079 the one project that like everybody
00:15:33.519 relies on and it's you know not hundreds
00:15:35.440 of people so like
00:15:36.959 very much appreciate it uh nokogiri was
00:15:39.120 developed
00:15:40.560 by aaron patterson in 2008 as a drop-in
00:15:42.959 replacement for h bricot with a similar
00:15:44.880 dsl
00:15:46.320 it was marketed as being faster and less
00:15:48.160 buggy and i believe both cases that were
00:15:49.839 true there's a little bit more history
00:15:51.600 there if you want to
00:15:53.120 do a deep dive but it's not germane to
00:15:54.720 this talk and we'll just do a tiny bit
00:15:57.920 of
00:15:58.880 noco gear here just again to prove that
00:16:00.639 i did it it's a beautiful library in
00:16:02.720 that it's
00:16:03.680 like ruby esque with the principle of
00:16:05.199 least surprise
00:16:07.600 require ruby gems
00:16:09.199 before ruby 1.9 you had to require ruby
00:16:11.199 gems some might remember that
00:16:13.120 uh in the 2008 version i had a direct
00:16:15.360 drop in replacement for h per cut so you
00:16:17.680 could literally literally and this is me
00:16:19.360 saying hello um and this would work
00:16:21.759 directly in your library but it also
00:16:24.399 adopted the
00:16:25.920 uh forward parenthesis and i think a lot
00:16:27.360 of this dsl is the same today mike can
00:16:28.720 tell me if i'm wrong
00:16:30.000 um and this is just showing me doing a
00:16:32.560 lot of the different parsing so either
00:16:34.000 calling css
00:16:35.519 or you know search
00:16:37.360 it's one of those ones that you could
00:16:38.560 actually not have to look through the
00:16:40.079 docs and you'd understand how it works
00:16:42.399 uh just straight out of the box
00:16:44.800 so let's look at some of the uh library
00:16:47.120 code circa 2008
00:16:50.320 for
00:16:51.839 uh nokogiri and again
00:16:53.920 so this is this is important so what i
00:16:55.360 just ran there isn't in isn't today's
00:16:56.800 nokogiri it was uh set back to a commit
00:16:59.120 from 2008 and installed that the version
00:17:01.279 from there
00:17:02.399 and this is 2008 nokogiri as well so
00:17:05.199 again
00:17:06.000 this
00:17:07.360 may have not may have changed quite a
00:17:08.720 bit um
00:17:10.160 if you've been coding ruby for more than
00:17:11.679 maybe seven years nothing here looks
00:17:13.439 interesting
00:17:14.640 right it's not like oh that's just ruby
00:17:16.400 code have you've been coding less than
00:17:18.160 seven years you might say
00:17:19.760 what
00:17:20.880 hey i can't do i can't do multi-line for
00:17:23.439 a curly brace what's going on with that
00:17:25.919 and there was a great discussion about
00:17:27.280 this from avdi grimm just over a decade
00:17:29.360 ago and i'm going to read this exactly
00:17:31.120 about this approach
00:17:33.520 he said use curly brackets for
00:17:35.039 functional blocks where the primary
00:17:36.720 purpose of the block is to return a
00:17:38.240 value use due end for procedural blocks
00:17:40.880 where the primary purpose of the block
00:17:42.720 is its side effects that is the block is
00:17:44.799 intended to change the state of the
00:17:46.000 system
00:17:47.120 later on in this blog avd
00:17:49.760 reflected that he'd seen this before
00:17:52.160 this wasn't something that he made up
00:17:53.679 and he dug through the archives and and
00:17:56.080 i did too and i think i agree that this
00:17:57.600 is the first reference to it seven years
00:17:59.520 earlier so 17 and a half years ago from
00:18:02.000 again jim weirich
00:18:03.679 saying the big remaining question in
00:18:05.360 ruby coding style is when do you use
00:18:08.000 either or
00:18:09.200 and he said he used the curlies that
00:18:11.039 return values and he used do end for
00:18:13.360 blocks that execute for their side
00:18:14.960 effects
00:18:15.919 and this is something i hinted to
00:18:17.440 earlier this has the advantage of using
00:18:20.240 your choice of block delimiter to convey
00:18:22.640 a little bit extra information to the
00:18:24.799 engineer reading the code
00:18:26.400 and because of this avd grim referred to
00:18:28.559 this as the wiret convention and i am
00:18:30.799 sticking with it too i think a few
00:18:32.160 others are as well
00:18:34.400 let's do some more code
00:18:37.840 oh this is fun this is what i was
00:18:39.600 talking about earlier but seeing it in
00:18:41.039 the wild and i'll highlight again
00:18:43.440 this is a colon colon method call and
00:18:45.760 we're doing camel case instead of snake
00:18:47.440 case which makes me think that this
00:18:49.200 isn't just some weird idea i've had but
00:18:51.280 back in 2008 there was some
00:18:53.520 i actually didn't deep dive into this
00:18:55.280 method i probably should have um but for
00:18:57.760 certain types of methods colon colon
00:19:00.000 might have a different kind of feel as
00:19:02.160 pul as opposed to the full stoppard or
00:19:03.919 dot for the method and then i think this
00:19:06.160 was even communicated further by
00:19:07.760 swapping from snake case to camelcase
00:19:09.679 for the method
00:19:12.720 and if we go into here and i'll probably
00:19:14.799 just highlight the use of and
00:19:19.360 ann's kind of gotten a hard time the
00:19:21.600 last decade so is orr
00:19:24.240 and if i'm allowed to quote avd grim for
00:19:26.400 a second time in this talk
00:19:28.080 uh avdi poopoo'd and or for a while but
00:19:30.799 then kind of came back about this their
00:19:32.480 ability to communicate more information
00:19:34.240 or or add more to ruby he said i think
00:19:36.799 their reputation for being confusing
00:19:39.039 stems from thinking of them as boolean
00:19:40.720 logic operators at all if you think
00:19:42.799 about them that way then you have to
00:19:44.320 keep remembering how they differ from
00:19:46.160 ampersand ampersand and pipe pipe
00:19:48.240 whereas if you think of them as control
00:19:49.760 flow operators in the same vein as you
00:19:51.679 know if and unless they're a lot more
00:19:53.600 self-explanatory
00:19:55.120 so instead of you know
00:19:58.160 next if
00:19:59.840 one equals or foo equals one
00:20:02.880 foo equals one and next
00:20:06.240 so there we go i have i've shown you two
00:20:09.120 demos of real gems working in 2008
00:20:11.600 showing you how to get there i've kind
00:20:12.960 of communicated the ethos of why in the
00:20:14.400 world you'd want to do that
00:20:16.080 but
00:20:17.200 you can only go so far with that you
00:20:18.960 only have so much fun so for this next
00:20:21.039 bit i am going to run on this 2008
00:20:23.520 machine with all 2008 dependencies a
00:20:25.760 full stack web application i'm going to
00:20:28.080 make it accessible to the whole world
00:20:30.480 and i'm not going to use rails because
00:20:31.919 i'm at rubyconf not rails is ruby but i
00:20:34.960 feel like it'd be the easy low hanging
00:20:37.120 fruit to be like oh what version of
00:20:38.799 rails 2008
00:20:40.480 so today i am going to build a camping
00:20:42.720 app who is familiar with camping
00:20:45.039 oh that's pretty this is my crowd that's
00:20:47.280 pretty good
00:20:48.559 uh camping was again so i'm focusing on
00:20:51.360 why because of what i said earlier
00:20:53.520 there's a micro framework
00:20:55.360 that was very small it's either 3.9
00:20:57.840 kilobytes 39 kilobytes something like
00:20:59.520 that the idea was that you could write
00:21:01.280 your whole web app in one ruby file of
00:21:03.840 course you could extract it out it was
00:21:05.440 pure ruby you could do whatever you want
00:21:07.280 but the idea is that you could do model
00:21:08.960 view controller in one file
00:21:11.679 and it was actually a big part of the
00:21:13.280 inspiration for sinatra and even flask i
00:21:16.960 learned this a couple of weeks ago from
00:21:18.960 a post from github talking about why and
00:21:21.120 the link from camping to flask so again
00:21:23.840 things that we enjoy today
00:21:26.480 that have these sort of origins
00:21:29.360 so what do i need to do with my vagrant
00:21:31.120 box to make this work there's a few
00:21:32.880 vagrant settings that you enable a lot
00:21:34.960 of these come from uncommenting things
00:21:36.480 in a config file which enable your
00:21:38.640 private network so you can actually talk
00:21:40.320 to it from the outside and send in html
00:21:42.240 requests and then also the easiest thing
00:21:44.400 is getting a synced folder and all that
00:21:46.000 does
00:21:46.880 is bring in a folder that you can write
00:21:48.960 in your own machine
00:21:50.320 uh so vs code so you're not trying to
00:21:52.480 vim in this box and like have a really
00:21:54.159 hard time
00:21:56.400 and have direct access to it there then
00:21:58.400 i change my center hose to give kind of
00:22:00.400 a cool syntactic sugar for accessing the
00:22:02.880 website
00:22:03.919 and i'm the cheat for like engrocking in
00:22:06.480 just so people can access it
00:22:09.200 so with all this pulled down um i used
00:22:11.600 the same flow as before my two-step
00:22:13.520 approach to
00:22:14.640 bringing down a gem i started to reach
00:22:16.720 some of the limitation of it here
00:22:17.840 because this had maybe six dependencies
00:22:20.240 and because i had to do this two-step i
00:22:21.840 literally had to do like old school ruby
00:22:24.240 manual dependency installation like
00:22:26.240 myself and it made me appreciate bundler
00:22:28.880 even more and all the work that people
00:22:30.320 do at bundler
00:22:31.600 and once you have that done and you have
00:22:33.120 a camping rb file written you just do
00:22:35.440 camping and then directory so if if you
00:22:37.840 did this any rb file that was camping
00:22:40.559 compliant would run
00:22:42.320 and with this
00:22:43.679 i had a webric server going
00:22:46.640 but what's in there what does this look
00:22:48.240 like
00:22:49.280 i'll i'll give you some code that i'd
00:22:51.520 written for this particular application
00:22:54.000 and and kind of explore it
00:22:56.000 and it's kind of influenced by some of
00:22:57.600 the examples as well from why
00:23:00.080 so you have camping goes blog that's
00:23:01.440 where you kind of define what this is
00:23:02.799 going to look like everything's going to
00:23:04.640 be namespaced you know module blog and
00:23:07.600 then you have your models in 2008
00:23:09.679 actually
00:23:10.640 um it had an active record dependency
00:23:13.440 later maintainers did remove it but i
00:23:15.440 want to be on honest to the time that i
00:23:18.080 was in there so
00:23:20.080 you have uh your models here
00:23:22.400 and a
00:23:23.679 red cloth i've mentioned in there which
00:23:25.360 is also some work with y
00:23:27.840 and then with your views you write it in
00:23:29.919 well you can write whatever you want
00:23:31.120 because this is how it's designed but
00:23:32.799 the default would be markaby
00:23:34.559 all right one more time anyone familiar
00:23:36.240 with markkuby
00:23:37.520 boy we're still getting there so markup
00:23:39.200 is ruby which allowed you again y which
00:23:42.480 allow you to write markup as ruby some
00:23:44.480 of you might be like gosh it almost
00:23:45.679 looks hamilesque if you got rid of the
00:23:47.520 ends or something you know it's it's
00:23:49.360 it's very intuitive and it just kind of
00:23:51.360 probably heavily depends on method
00:23:52.720 missing and does what you expect it to
00:23:54.480 do and it could probably kind of extend
00:23:56.000 with whatever tags you were trying to
00:23:57.760 call
00:23:58.960 your migrations would also be in this
00:24:00.640 file
00:24:01.919 and something that i thought was
00:24:02.960 interesting i saw a quite a bit in wise
00:24:05.440 work and uh elsewhere is
00:24:08.720 underscore underscore end being used
00:24:12.480 i don't actually really use that in day
00:24:14.000 to day and a few of you because we have
00:24:16.320 the best rubios in the world in the room
00:24:17.679 obviously are very familiar probably
00:24:19.520 you're slinging this out every other day
00:24:21.279 having your latte and just writing it
00:24:23.039 into your code
00:24:24.480 but uh
00:24:26.080 i'd heard of this for the first time on
00:24:28.080 a tweet from gemma isroff
00:24:30.240 in the last month and then i literally
00:24:32.080 saw it in the code about two days later
00:24:33.760 while i was preparing for this talk
00:24:35.600 and what what end does is it tells ruby
00:24:38.159 that everything after me
00:24:40.400 just just ignored it treat it almost
00:24:41.919 like a comment so put the end of your
00:24:43.679 file doesn't matter but also if you
00:24:45.600 declare it it's accessible via a global
00:24:48.960 constant called data all caps data so
00:24:51.520 that means if you're keeping track at
00:24:53.120 home there's three n's you can write in
00:24:55.039 ruby lower case lowercase e and d which
00:24:58.000 is ending the normal line uppercase end
00:25:00.720 which is a special thing that you can
00:25:02.000 pass a block they'll run at the end of
00:25:03.200 the file and it's the double underscore
00:25:05.440 end which uh does the comment so what
00:25:08.640 what's the utility of this how can this
00:25:10.799 help in this one line file well if
00:25:13.039 you're why it lets you write css
00:25:17.120 so throw your css on your rb file and
00:25:19.440 then you're able to write everything you
00:25:20.559 want and then when you go into your
00:25:22.480 style class you just read it in you swap
00:25:24.880 out where the end is and there you go
00:25:26.320 your css is ready
00:25:28.799 i love it that's how i want to do it
00:25:30.559 from now
00:25:32.400 where's my css file it's right here
00:25:36.159 i was running it worked
00:25:38.240 2008 full stack web application writing
00:25:41.120 some blog posts saying hello to twitter
00:25:42.880 and i'll get into that in a second
00:25:44.880 and i had it running
00:25:46.880 and as a part of an experiment for this
00:25:48.720 talk for 20 minutes i opened an ngrok
00:25:51.919 tunnel to this website
00:25:54.720 and i said hey anybody who's out there
00:25:58.000 feel free to come in and look at
00:26:00.320 whatever i have on this ngrok like a
00:26:02.720 bitcoin miner for you
00:26:04.880 and i got i got a couple of hits but i
00:26:06.559 only got one like on this tweet
00:26:09.600 shocking isn't it one like come on this
00:26:11.520 is a great tweet
00:26:13.600 it's from andrew mason who has
00:26:15.039 definitely gone to this url so thank you
00:26:16.640 andrew mason who's here today
00:26:21.039 andrew is ready at all times for some
00:26:22.960 sweet content
00:26:24.400 time sensitive to drop on my twitter and
00:26:26.240 was ready and and looked at a website
00:26:28.720 from thousands of miles away that was
00:26:30.880 built on y technology so thank you very
00:26:33.760 much for that
00:26:35.360 so
00:26:37.279 ruby archaeology is fun
00:26:39.520 right it's really a treat to to start a
00:26:43.360 project where you know you're not going
00:26:45.600 to
00:26:47.520 have a deliverable for a customer
00:26:49.679 or or try to change the game on
00:26:52.480 performance or or invent some new gem
00:26:54.880 you're just going into the past with
00:26:56.799 valid ruby code and ruby like for
00:26:58.480 running ruby there's a gem i didn't
00:26:59.840 reference today
00:27:01.039 bloop's a phone from y that uh came out
00:27:04.559 probably didn't have an update since 187
00:27:06.320 or 199 and i was going to go into it but
00:27:08.480 it runs on 3-0
00:27:10.400 so
00:27:11.360 you know ruby has there's huge areas of
00:27:13.760 how we write ruby and what it means for
00:27:15.440 an engineer to write ruby that have not
00:27:17.200 changed so this code is actually
00:27:19.039 super accessible even today
00:27:21.520 and
00:27:22.320 it's been enjoyable and great to be able
00:27:24.000 to give this talk with it
00:27:25.919 for
00:27:26.720 future considerations i think i want to
00:27:28.720 put my past ruby's
00:27:30.240 web archive so not the newsletter but
00:27:31.840 the website on camping and i think i
00:27:33.919 want to put it on the camping that i've
00:27:35.200 shared there because i don't need all
00:27:36.960 the bells and whip whistles to host a
00:27:39.039 big site
00:27:40.720 i'm going to do a future talk dedicated
00:27:42.480 to one gem that was so gnarly i couldn't
00:27:44.799 fit it in today and it has to be its own
00:27:46.320 talk you can ask me about that at the
00:27:47.760 bar
00:27:48.799 and i'd love to update my box to have
00:27:50.799 like a schwa install instead of a gem
00:27:53.120 install so you're not having to remember
00:27:54.720 those two commands every time you want
00:27:55.919 to pull a gem down to the machine right
00:27:59.039 so why should you become a ruby
00:28:00.399 archaeologist
00:28:03.679 there are hundreds of millions if not
00:28:05.360 billions of lines of valid code
00:28:08.559 open source for free on the internet
00:28:12.000 that you can access today
00:28:14.559 in the ruby community today sometimes it
00:28:16.799 feels like we're converging
00:28:19.120 and when i look at ruby code again with
00:28:21.520 all the same tools we have now from 13
00:28:23.919 years ago
00:28:24.960 there's a lot of different ways to
00:28:26.399 express yourself and i'm not saying that
00:28:28.080 we shouldn't have standards at work
00:28:30.480 and like have really predictable apps so
00:28:32.320 engineers can come in and understand
00:28:33.679 your code i'm not saying do crazy meta
00:28:35.440 programming and obviously intentionally
00:28:37.520 obfuscated code golf no i'm just saying
00:28:40.320 we should be open to these ideas
00:28:43.120 and
00:28:44.720 to help you
00:28:46.240 i have something to give you today
00:28:49.039 this is uh i released this vagrant box
00:28:51.279 myself schwad ruby archaeologist the
00:28:53.760 current version is 0.3.0 just run the
00:28:56.559 command at the bottom of the screen
00:28:57.679 vagrant in it schward ruby archaeologist
00:28:59.760 vagrant up and you can have it what's in
00:29:02.640 the box
00:29:03.679 ruby 1.8.7 an example camping app and
00:29:07.120 all the dependencies and many many more
00:29:08.880 gems that i ran in there to play with
00:29:10.480 this so i say to you go forth
00:29:14.720 explore the past ruby share them with me
00:29:17.200 and see what we can learn and make ruby
00:29:19.919 whimsical fun and better for everyone
00:29:23.760 thank you very much for your time it's
00:29:25.760 been a pleasure of my lifetime to have
00:29:27.440 the chance to speak at ruby conf and
00:29:29.440 connect with me anywhere and it's been
00:29:31.200 an honor thank you so much
00:29:33.170 [Applause]