00:00:06.319
hello and welcome to ruby galaxy today we are talking about ruby off the rails which is a really
00:00:12.080
exciting topic because i think a lot of times when we think about ruby we're focused on the context of inside
00:00:17.199
one of its most popular frameworks but there are a ton of uses for ruby outside that today we're joined by corey
00:00:22.400
kings who's going to talk about how ruby can be used to automate your life
00:00:27.519
whoa okay hey cory i can't remember you telling oh sorry no go ahead i was just saying
00:00:34.640
hi to cory i've never met you so i just want to say like this is the virtual wave hello hello nice to meet
00:00:40.399
you we'll do the virtual handshake i was a little too quick on the trigger there i like jumped in okay
00:00:46.960
corey haynes can you tell everyone a little bit about yourself and what you do well i'm a software developer i've been
00:00:53.199
developing for a long time and gone through like doing trainings um
00:00:58.640
you know taught other people how to develop software i've started companies led teams things like that um i
00:01:06.479
was one of the co-creators of the code retreat workshop which i'm super proud of if people have heard of that um
00:01:14.080
and yeah now i just i'm sort of taking a what i call a retreat into competence
00:01:22.240
sabbatical where i'm doing contract development work after sort of burning out from starting a
00:01:27.920
company and running a company and burning out i was like you know what i'm just going to go back and do
00:01:35.040
hourly give me money i'll write code for you i've been doing that last couple years
00:01:40.240
it's and relaxing um and playing with my cats which is the
00:01:45.759
more important aspect of me i think cory i'm gonna also be uh taking notes
00:01:52.399
just for myself so if i'm looking down i'm not a transcribing everything you're saying
00:01:57.680
i'm actually just writing nuts and first okay two cats
00:02:03.040
and uh top of the list avoid burnout um i'm excited to feel like the bird out
00:02:08.720
cat's help two cats what are the cat's names oh
00:02:14.800
sorry i'm sorry it's nicole of newsie and little miss louise
00:02:20.800
yes nicholases and little miss louise um i so
00:02:28.879
i got new c two years ago and two years ago or last year two years
00:02:35.840
ago and i wanted i forget what his name was
00:02:41.360
at the place at the the treehouse um animal shelter but i didn't like it and so
00:02:49.200
i was calling him new cat and then my best friend she was like i
00:02:56.239
just i just kind of think his name's nickel and i was like and so i was calling him new cat and
00:03:02.480
then i would shrink it to nc and then when my friend said nickel i
00:03:08.159
was like well i could see that but i really like nc and so it turned into noosie
00:03:15.440
and so it's and then of course cats it's gotta he's gotta be a sir um that makes sense that makes sense
00:03:22.959
yeah okay i also forgot to introduce danny danny my card hello everyone my name is
00:03:29.840
danny ramos and uh yes went through touring of learning ruby so i'm a very
00:03:37.120
ruby beginner so corey please i apologize so i'm just like what does this mean what does that mean
00:03:43.920
um touring in uh denver yeah yeah just uh
00:03:48.959
graduated this last september how wonderful yeah i used to hang out with jeff a lot
00:03:55.920
oh what really nice oh yeah yeah back back in the day when we all
00:04:02.239
would hang out at the conferences yeah and saw people in person all right so on to the topic uh if i
00:04:09.920
understand correctly you've been automating something with bitcoin with ruby in your life lately
00:04:15.120
yeah well it's it's more of just like the idea of if you find yourself doing something a
00:04:20.959
lot like write a ruby script to do it for you
00:04:26.240
and like this the one you know i mentioned one thing that like super tiny like 20 line script that i
00:04:33.759
used to go check because i have a couple i have like a small bit of uh bitcoin and other cryptocurrency not
00:04:40.080
enough to make me like actually care that much but it was fun to climb you know to go
00:04:46.080
to the website and check on how much it was and the thing is as as developers
00:04:51.280
there's always apis to look at stuff and so i just wrote a little script that goes gets the api
00:04:57.680
and then of course you make it configurable on the command line and like
00:05:03.199
you know it can print out and then i hooked it into an alfred workflow so i just use alfred to do check crypto and print some big
00:05:10.160
large texts what my portfolio is and um but i think it's it's a good example of
00:05:18.639
what i think a lot of developers don't think about a lot of times because they spend you know most of the time you're working
00:05:24.720
in a system like rails or one of those and you you you don't think about it as much of like
00:05:31.120
ruby's a scripting language yes it's really fantastic it's fantastic to take
00:05:37.280
standard in and it's super great at pushing the standard out so you can write
00:05:42.560
small focused scripts to do stuff and you don't have to build big systems like i also mentioned one of
00:05:49.600
the things that i've done and i know quite a few people have done is like writing small like
00:05:57.199
task management utilities and stuff that just use a flat file and it's just like you have a bunch
00:06:04.400
of little scripts that you can add or you can delete from it or something and you don't have to build these big
00:06:09.919
large frameworks um even to the point of of like
00:06:15.520
um you don't need our spec to test things like you don't need always to have these
00:06:22.080
sort of frameworks you could just write a little assert equals right when you right when you right when you said you don't have to
00:06:28.400
test things jail just goes no yeah you don't need our spec
00:06:34.800
yeah you don't need our spec and i was thinking about it today of like how many
00:06:42.479
people have gone in and like traced when you do like rails s to start up a
00:06:49.360
server what does that do like how do you kick off rails like what's the flow
00:06:56.880
um like because if you if you start off and live your life like you write just little ruby
00:07:02.000
scripts that do things it's pretty easy because you run ruby and you give it the file name and it runs ruby
00:07:08.479
but like understanding how that then leads to starting up
00:07:14.560
something is a really i think a valuable thing to look into because rails is just running ruby on a ruby
00:07:21.680
file and like what's that that ruby file do like it's
00:07:26.800
it's interesting so it's and understanding some of those things
00:07:32.880
makes it so that when you want to like it takes away that mystery
00:07:37.919
of could i write something like that that's like well sure sure you could
00:07:43.680
like why not i think this kind of ties back to like our spec right when we were talking
00:07:49.680
about that um also i just wanted to note i built all my advent of code solutions in ruby and literally i added only one
00:07:56.960
gem and it was our specs so when you said that it definitely like went straight to the heart and i was like
00:08:02.319
but that's our spec but like i hear what you mean right like you can
00:08:07.759
write a method called asserts and then in ruby if you call something like asserts this this it looks like it's
00:08:15.199
something more than a method right and i think we especially see this when we're looking
00:08:20.319
at um kind of like frame and domain specific languages and
00:08:26.479
things like that is like validators and like r spec they don't look like they're just
00:08:34.800
methods but that's all they are like most of the time we're extending from a base class
00:08:40.959
yeah and when you get into those um like say r spec
00:08:48.560
one of the interesting things is when you really start writing a lot of our spec tests you you're kind of not
00:08:55.440
writing ruby anymore like you're writing cards back respects a dsl for writing tests
00:09:02.240
and the underlying syntax is a ruby syntax but
00:09:07.440
so often like when you do describe or you do it or you you do expect these are implemented
00:09:15.279
in ruby's but they're really the r-spec language and it's that interesting
00:09:22.399
idea of how often times if you have a problem the first thing that you might want to
00:09:27.920
do is write a language that lets you solve that problem easily
00:09:33.760
and that's what a dsl's for like if you have um i mean if you think about
00:09:41.120
our spec as a as a well-known understanding before that and if you look at like many
00:09:46.560
tests the way kind of mini test works is you you write functions and and one of the things that mini test
00:09:52.160
um talks about as it's good quality is that it's just ruby
00:09:58.640
and there's like you write functions and then it looks for functions that have tests or whatever um whereas our spec said we we have a
00:10:06.000
problem which is testing and so we're going to write a language for testing and then
00:10:14.800
that and it's going to be very focused on testing and so you because it's focused on
00:10:21.920
testing all of the pieces parts fit together and you're not just sort of like
00:10:28.240
writing a function that ends in tests and then you're you know figuring out
00:10:35.200
what are the uh the ways you want to test for example
00:10:40.240
um not to say that's bad or good because like i like to just write in a certs function and use that when i'm writing
00:10:47.760
stuff and like advent of code the first few days i just had an asserts
00:10:52.880
but then as things got more complicated it became more
00:10:59.440
it became smoother if i had a dsl for for being explicit about my tests
00:11:06.399
and that's when i brought our spec in now hang on a second hang on a second advent of code breaks
00:11:11.839
down into a couple categories of strong of like problems right there's the first problem which is always like get the data from this file and
00:11:18.399
structure it in a way you can use and then there's the second one that's like process all of this data
00:11:23.680
in the structure that you use and get the answer and then there's output the answer in the format that they want right all of the problems break
00:11:31.680
down this way i almost feel like we're reaching a point where we can say you can build a language
00:11:37.440
to handle and and by language here we mean domain specific language not a
00:11:42.720
different coding language not a different programming language because i think often as developers we think like i want to change the syntax i
00:11:49.200
have to build a new language with domain specific languages we're just saying no you can write your own syntax and ruby
00:11:56.800
is gorgeous for that yeah why is that do you think
00:12:02.079
um well one and i've got strong opinions about this in other languages
00:12:07.279
but um the the parentheses optional
00:12:14.560
make it so that you can have a little bit more um fluid fluidity in how it reads
00:12:22.079
the really strong um sort of runtime technical you know
00:12:29.440
people call it meta programming but it's really just programming
00:12:34.720
and so it's it at runtime you're doing both changing the program
00:12:42.160
and running the code so you can actually like it's it's nice because it doesn't have a
00:12:47.920
macro uh system which tends to run before
00:12:53.519
like you kind of have a two-phase thing where macros run expand into code that then runs
00:13:00.240
whereas in ruby one of the things i love about it is that there can be an interaction between
00:13:08.240
the code that is doing whatever you want it to do the work and the code that is making it
00:13:15.600
easier for the code to do the work it needs to do so the dsl is not built ahead of time
00:13:23.519
it actually is running at the same time that your code is running and i love that because then the they
00:13:30.000
sort of merge and and you can start to think of them around the same time
00:13:36.880
um which is one of the reasons like um i just in one of the contracts i built
00:13:43.199
some shared some shared examples in our spec and just added a method that the
00:13:49.120
example's called and didn't have to do anything fancy with it i just
00:13:54.399
wrote a method and i knew that when all of the dsl stuff was going on and all the meta programming was going on
00:14:00.959
it still had access to my code and so it was actually calling my code into it
00:14:06.079
um and i think i think when you start to think that way
00:14:12.399
about the the code that's doing the process
00:14:17.760
and the code that is making it so that the code that does the process is easier to write or all of that they're just
00:14:23.040
they're the same thing and they're running and like they can interact with each other um
00:14:28.959
that i think is is really powerful in ruby and and also just ruby is a
00:14:35.440
fine like ruby's intended to be readable it's intended to write these sorts of
00:14:42.160
things and so that's a good amount of red lines yes
00:14:47.519
exactly like it so i think that's it and it just i don't know i love ruby so that was
00:14:54.560
like one thing that we would always hear in school was like over and over and over like oh ruby is
00:15:00.639
nice to you ruby is nice to you and uh i never really understood that i
00:15:05.680
was because that was like my first experience with any language so i was like i don't know this seems pretty hard anyway
00:15:11.040
and but then once i got to rails or uh later on with like python or like
00:15:16.480
node.js no js i was like uh i miss ruby it was nice to
00:15:21.519
me yeah i always i think it is more common
00:15:27.199
to find ruby developers who will tell you they smile when they write ruby
00:15:34.639
than any other language put that on a t-shirt yeah it's
00:15:41.440
it's you know built and you know matt says this it's built you know it's optimized for programmer happiness and
00:15:48.720
it feels that way like i you know i do other languages but i always come back to ruby because
00:15:56.160
it's it's it's like a hug when you write when you write in it
00:16:01.199
and this is one of the reasons that kind of going back to like writing really small little scripts with it is
00:16:08.160
that when you spend all of your time say in rails and both of my the contracts i'm doing are
00:16:14.880
rails apps um and that's kind of a lot of what's out there
00:16:20.480
you're you're working within within some constraints and you should be working within the
00:16:26.160
constraints of rails and so you bump up against some side things because rails is optimized i
00:16:32.160
i think this is just me i think rails is optimized for productivity
00:16:38.880
less so than happiness and it doesn't mean that rails doesn't make you happy or it makes you sad but ruby is just like you want to be
00:16:47.360
happy when you're writing this so getting outside of some of these frameworks that are there to be productive in and
00:16:55.040
just write fun things on your own that like you know i'm always hitting this website
00:17:01.440
or um i'm always copying these files around or
00:17:06.640
whatever it is that you find yourself doing a lot on the computer you know jumping back to spending some
00:17:14.799
time writing it in ruby is is sort of like giving yourself a present because you're going to go back
00:17:20.160
and remember you know what it was like when you were learning ruby and was just like this is
00:17:25.439
a nice language i love it and then and the other thing that i i like to do is
00:17:32.080
when i'm when i'm working in some other thing like i'm going through i went through a
00:17:38.320
course on um building basically starting from nothing and
00:17:43.360
building up a computer in a circuit simulator it wasn't the man to tetris one but it was this other one
00:17:50.400
and i wrote a bunch of scripts in ruby to help run all of the other stuff i was
00:17:59.280
doing because i found that i was always like doing making this change or that change or
00:18:04.320
combining these files and running this and analyzing i wrote a small i end up doing this a lot i wrote a small testing
00:18:12.000
tool in ruby that would run the circuit simulator and then figure out whether or not it
00:18:17.520
outputted what i wanted it to output and so ruby was testing the surface stimulator or my my circuit
00:18:24.640
um i like that because it doesn't really matter what you're interfacing with also we have a question from chat and
00:18:30.000
the gargoyles here wants to know what is your favorite ruby exclusive feature and why
00:18:35.360
my favorite ruby exclusive feature exclusive
00:18:40.840
um it's hard to think of one that's
00:18:46.720
exclusive isn't it yeah yeah um yeah i wouldn't
00:19:02.240
let me tell you when i got into ruby because that was the thing that i i left
00:19:07.520
c sharp i was doing c sharp for i don't know i did see sharp for about six years seven
00:19:13.200
years and what i would the reason i left one
00:19:18.640
of the reasons i left c sharp this was back in like 2007 was that
00:19:24.000
my style of coding was changing in that i was starting to move
00:19:30.160
more in sort of like an outside in tdd style and whenever i would write something
00:19:38.160
um the c-sharp compiler would yell at me and say that doesn't exist yet it doesn't exist
00:19:43.440
yet and so my editor would be in visual studio
00:19:49.120
and it was just red squiggly lines the entire thing with red squiggly lines
00:19:54.799
and i like to uh do a style called programming by wishful thinking
00:20:00.799
which was um i used to call it turtles all the way down but then i watched the
00:20:06.320
um the structure and interpretation of computer programs
00:20:11.760
uh course that the videos that are out there and they describe exactly how i coded
00:20:17.360
and called it programming by wishful thinking so it's like i'm not i will go with the cannot you know the
00:20:23.360
official name but you know you start out you just write wouldn't it wouldn't it be nice if if this did this
00:20:32.080
yeah like i i sure i sure wish i had a function that did this i don't have it but i wish i had it and
00:20:38.480
see the c-sharp compiler by virtue of some of the safeties that it gives you it goes
00:20:44.080
that doesn't exist and i would go i know i'll build a window
00:20:53.440
and then the c-sharp compiler would say yeah it would be nice and it would put a
00:20:58.640
red squiggly line and so it's just my style as it was changing
00:21:04.480
sort of moved me away and i got more frustrated with that and so at that time ruby was really sort of
00:21:10.640
coming into its research not resurgence but surging because of rails and
00:21:16.799
a lot of people were thinking about it and when i started working in ruby that
00:21:23.600
never happened like the ruby supported the idea of just sort of
00:21:29.520
saying like let's just pretend that exists and ruby would go
00:21:42.400
love the way they've constructed the new type system for ruby because i think i'd develop in a similar but almost inverted
00:21:48.640
way right like i like to sit there and be like i have a thing this thing works it does not return what
00:21:55.120
i want it doesn't return my results yet but i'm going to like tack on bits until it does
00:22:00.640
right i'll be like i'm just going to run it on one of these or i'll be like i'm just going to write the loop to iterate
00:22:05.919
through these and at the entire like phase of it i'm constantly changing what the return type is what my inputs are adding new ones
00:22:13.600
it's very very iterative and iterative and iterative and i feel like with the with the normal
00:22:20.559
way that static type systems are introduced you feel very stuck like i'm constantly
00:22:26.080
going back to the method like name and i'm like no it's returning a string now no it's returning a string away now no
00:22:32.159
it's returning to this the way ruby structured it you can build and develop and experiment and wishful thinking your
00:22:39.520
way through it and then at the end you can say i'd like to harden this with an rbs file
00:22:46.080
yeah and and it can yeah it'll be interesting to see how it comes about i mean i do a lot of
00:22:51.840
you know i'm a big helm guys you know i always talk about it um and so i really i really love a good
00:22:57.840
type system um but ruby is ruby's got a different feel to me
00:23:05.360
than than it is when i'm coding and like at home because i actually start my types are generally
00:23:12.480
stand in for a large but a large portion of my tests
00:23:17.760
my type stand in for so i actually just write my type signatures for my functions
00:23:23.600
and those are the tests and by virtue of kind of how the things work
00:23:29.440
once the compiler compiles i'm almost always
00:23:35.360
guaranteed that that function works and so i write so much fewer tests but also in
00:23:42.080
languages that are not like in a in a functional language you
00:23:47.760
i think it probably works a little better when you're building in a functional style because there's less side effects things
00:23:54.320
like that so you you kind of know that if you say you get a list in and you get back an integer
00:24:01.679
like when that when that type system or the type signature like passes
00:24:08.080
and the compiles you're pretty much sure you have count or length
00:24:13.520
because you can look at the code and say it's not returning zero which would be something that would work
00:24:18.640
but like it's returning length that's what that function by the type signature
00:24:23.679
it has to be it has to be like and so yeah it's a it's it's interesting
00:24:30.799
i'll be curious that i've not tried out rbs at all um because i i like the freedom and
00:24:39.440
i saw the talk it would be called and i was like thank you i was basically like i can ignore them
00:24:46.799
and and i think they'll come in really handy with like you said it tightens things up and so it
00:24:53.600
it hardens it in where one of the things i like about ruby and
00:24:58.799
this is why it's so hard to like be very like what is an exclusive ruby thing
00:25:03.840
is that all of i think so much of the parts of ruby
00:25:09.120
work together to make a very uh it's kind of a freewheeling lifestyle
00:25:15.200
when you're writing ruby and it's just it's different from like there's some languages that are
00:25:21.279
that are like wild west i hope i don't get shot whereas ruby feels like just a free
00:25:28.000
wheeling like i'm out of having a good time
00:25:33.200
feeling when you're doing it and so much of it uh comes in like being able to define
00:25:39.520
methods on the fly i like that um do i do it a lot
00:25:44.559
no but it's nice to be able to do that and like being able to loop over so one of
00:25:51.279
the one of the things that i love to be able to do and this goes into where the meta programming and programming are
00:25:57.840
it's all just programming is that case where you need to write a test over
00:26:03.840
uh like you have five different values you need to test you could just make a hash that has the
00:26:10.720
value in the expected or the the expected value oh yeah and just write that and then go
00:26:16.640
to dot each and then inside your block go does it and so you can
00:26:23.360
write your tests inside a loop and because it's all running at the same
00:26:29.360
time it's fine like the the it is not some special thing like you
00:26:35.120
mentioned earlier it's just a function it's just about we we have we have the power we don't
00:26:41.440
have macros but we can get the same functionality through meta programming also we have a question from st
00:26:46.720
recruiter and then a comment from abigail so santa coder says what was the project you created that
00:26:52.480
made ruby click for you
00:26:57.840
danny do you have one i was about to say like i'm still you know waiting for that
00:27:03.760
click to come but it was really fun to build a battle battleship
00:27:10.000
we built battleship in ruby and that was really cool to see like all the different relationships um between classes and and just really
00:27:17.679
like and then building something that looked pretty bad and then abstracting that and making it into
00:27:25.600
its own little separate classes and then trying to remember even how you play battleship was kind of a challenge
00:27:31.760
in itself you learn all of the side rule like the
00:27:37.200
edge case rules oh yeah yeah i was like okay well um
00:27:42.640
for this game you uh can sync with one hit
00:27:49.360
did you um did you generate the map uh yeah we generated the map so it
00:27:54.880
printed out on the terminal um i like that that's fun yeah it was fun
00:28:01.039
i i think so so the first ruby code i ever wrote
00:28:06.080
was um was actually our spec like a friend of mine was like i was
00:28:12.880
good friends with david chilemski and whenever i would see him just a
00:28:18.000
low-key flex well this was back in this was like 2004 we all were like
00:28:24.080
there was no like you just like i don't need like you started this by saying i don't
00:28:29.840
need our spec like it's not important we get halfway through and it turns out i don't need our spec because i wrote
00:28:36.000
part of it i could just well i didn't put the parts that i want let me rephrase that i didn't write art
00:28:41.360
of ours back um david was a friend of mine from before our spec days
00:28:47.679
and whenever i would see him like i lived in cleveland he lived in chicago and we would go to conferences agile
00:28:53.600
conferences and stuff and we'd see each other and whenever we would see each other
00:28:58.799
he would he always coded like he was always coding he was always stuff and i would walk
00:29:05.360
over and it was inevitable that i would say hey what you doing and he would say sit down and then we would pair for a
00:29:10.840
while on it and that's how i learned about ruby really was what are you working on and
00:29:17.440
he's just like oh i'm working on our spec and so he kind of taught me the initial stuff about ruby
00:29:25.200
and this was when i was doing c sharp full time and then that kind of got me out of c sharp i got a job doing
00:29:32.480
um ruby i i spent a year learning ruby and rails and then got a job at a
00:29:39.279
startup doing um rails and wrote some horribly c-sharpish ruby
00:29:47.200
because i had a very set i had a very very a sort of established style in c sharp
00:29:52.880
and wrote some really bad stuff got fired from that place um not because of my code not because of
00:29:58.880
my code but so i what i think was the one that that like clicked like i was like i know
00:30:06.320
ruby pretty well is um the first sort of startup i did the
00:30:15.679
um this was in 2010 so my partner at the time who's now my best
00:30:22.799
friend she and i decided to build a tool called mercury app and it was
00:30:28.960
it was based on something she'd written before and what it is is it's a way to track how you feel about things over
00:30:34.480
time and there's a website um you sign up and you said here's the topic
00:30:39.679
and it would email you every day and say how are you feeling today about it you you would respond with a number
00:30:44.880
and then it made nice graphs and then you could leave notes and stuff does that work does that website still
00:30:50.159
exist yeah yeah it's it's yeah if you go to mercuryapp.com
00:30:55.360
bringing it down pretty soon should we check it out it's been up for a long time i would say
00:31:01.840
don't use it because of the fact that i keep threatening to just drop it down or to take it down because
00:31:09.039
it's it's uh ruby 187
00:31:15.120
and i think it's rails like 3-1 because rails had just come out or like
00:31:23.519
rails 3 had just come and so we we shipped in that
00:31:30.000
but we had we were building it together and um she's a developer
00:31:36.399
fantastic fantastic developer and
00:31:42.000
that's where like building that really solidified ruby for me because it was just the two
00:31:49.600
of us and us we had to build all of this stuff out so we had to learn
00:31:55.679
really how to be effective at rails um and so i would say that was the one and
00:32:02.960
it goes along with that thing that everybody says which is find a project and work on it like find something that you want to
00:32:09.840
build and build it would you suggest working on a project with a partner
00:32:15.360
because i amend you to that because i'm just learning and my girlfriend is a very good rails
00:32:21.840
developer and i can just see in her eyes like ah you type really slow
00:32:29.919
um yes what yes so the things i learned um
00:32:37.519
this was my first like startup that i had done as well and hers as well and things i learned about we had we
00:32:45.279
were we had actually worked on a project a side project before called the stickies project
00:32:50.960
and it was building a uh basically an online sticky paper app
00:32:57.039
and she had built a version of it before and we were like let's rebuild it and um so we'd worked on that
00:33:04.159
and the the lessons that i learned over the first two things we built where
00:33:10.559
always make sure you're on the same page as to why you're building this because when we were building the
00:33:16.320
stickies uh project it was you know sticky papers and when you drag a sticky paper onto
00:33:21.360
another it would stick and they would move together and all that and i was just having a good time writing code she wanted to get it done
00:33:29.840
and so i would like write something we would well we would write something because we were pairing and then the next day i would come back
00:33:36.320
and be like you know what i want to rewrite that
00:33:42.320
which is frustrating when your partner is saying that and you are like your goal is to finish and
00:33:56.159
and so it would be constantly coming back with like i don't like that way and like i had started building i built a
00:34:01.760
a spy test double frame or library for it and was doing all of this stuff which is
00:34:09.520
so bad and then we laugh about it now of not knowing like now you know what
00:34:15.839
10 years 10 years 12 years on we laugh about it but yeah um and then yeah did that to danny
00:34:24.480
on tuesday i dragged him through like a refactor of our ruby galaxy of like the ruby galaxy site when we
00:34:30.720
were supposed to just be updating it to reflect like version 3.0 oh god yeah
00:34:35.760
and i was it was just like you're familiar with liquid tags right i'm like yeah no yeah i got i got you and then
00:34:43.119
like i was trying to work on it last night and i was like hey i'm just gonna just tweak the html
00:34:48.879
i'm not really figuring it out right now and i just need to push these changes and rachel's like
00:35:01.040
that corey did i was like we want to like rewrite this and you're like no we need to get this done because we've got a thing tomorrow
00:35:08.079
yeah it's so easy to do that but like if you're on the same page and like
00:35:14.800
i we have i have tons of stories of of startup mistakes with a partner but
00:35:22.000
um you know 12 years on we're best friends still so it's kind of like in the end it
00:35:28.000
worked out but doing a startup is hard all normal but it's harder when you live
00:35:35.280
with the person that you're doing it with and you have different expenses
00:35:41.520
my girlfriend works for a startup and uh previously she had worked for like a pretty established company and the
00:35:47.760
startup i could just see like the intensity of intensity level changing
00:35:53.200
and her always wanting to get things done and i can't imagine the two people working in the same company under the same roof
00:35:59.359
just being like bouncing around like we need to get this done when you get this done we're gonna get this only like saturday night at midnight like hey
00:36:05.280
maybe uh we can watch like a tick tock video or something
00:36:10.640
you
00:36:17.359
she was like looking all cool she's like hey um i've only worked for this company for about
00:36:22.480
five months but guess who just hit their 200 commit mark and i was like cool that's impressive
00:36:30.320
yeah that she cut them correctly yes yeah yeah that means they're small focused commits
00:36:36.720
yeah yeah a nice thing though is that if you're with your partner like we started
00:36:41.920
working on mercury app her mother lives in connecticut in a cabin sort of this small town in
00:36:49.839
like two acres or something and we went up there for a week and sat on the balcony
00:36:56.000
and like that's where we did like rails knew so we just spent the spent a week in the
00:37:02.240
summer in the woods of connecticut building together which is a fantastic thing to do and it's even
00:37:09.040
more fantastic when you're with your partner i hear these stories about like the
00:37:14.079
golden days and i'm just like where have all the good days gone like i
00:37:19.920
keep working at these companies that are like here we need you to work until like very late at night don't worry you have a limited vacation but we need constant
00:37:26.880
like prs out of you and all this sort of stuff but i'm just like i want to go to a cabin i'm gonna go to
00:37:32.320
a cabin and write some code also we have been neglecting epic arches here's well thought out coming oh yes
00:37:38.640
okay i always had the feeling ruby has more built-in methods for all objects than other languages i've tried but i have no
00:37:44.880
clue if it's true this actually when we were talking about our favorite parts about ruby is one of my favorite parts is
00:37:51.839
innumerable in string it's just it's got everything yeah
00:37:58.560
yeah and it because it bounces between like being a general purpose language
00:38:03.839
but also a scripting language there's things in it that you're like
00:38:09.440
why is this here but it's like oh it makes sense in a certain
00:38:15.599
context and it makes life super nice like like integer has a next function
00:38:24.480
um like that's awesome and how often do you use it not that often but but when time comes
00:38:30.960
yeah it's like and i want to i want to do like a
00:38:36.160
group buy a property or something and have it turned into a hash like
00:38:41.920
it's there um tally i you know tally's i think new in two
00:38:48.240
seven um tally will take on and
00:38:53.359
it basically is how many times does a certain value appear in your array
00:39:00.000
it returns you a hash of the value and the count oh my gosh and it's like these these
00:39:07.280
things it's like they sat there and they said we know you're gonna do a group buy we can make it even easier we're just
00:39:13.920
gonna go ahead and go to the final like we're gonna wrap group by and just go ahead and do the count for you
00:39:19.359
i love it this is i think one of the really um great thing one of the great things
00:39:26.320
that rails influenced on the ruby community and like back i mean they're kind of
00:39:32.400
very similar now or overlap but active support was so focused on
00:39:40.640
really useful things that you're going to do and a lot of those things got brought
00:39:48.240
back into ruby into the core library um and so having that
00:39:53.920
this is really interesting because uh being just new and needed like new to ruby or have
00:40:00.079
learned ruby a lot of the things like with learning a language as a beginner
00:40:05.119
for me i found that i assumed that just like other languages had these things
00:40:10.560
like i just like oh they must just be a different ways of typing stuff like i didn't i didn't
00:40:16.800
realize that there's like unique things to specific languages like this where i was just like oh i thought
00:40:21.920
javascript just had different syntax no no capitalize something in javascript
00:40:28.000
and you'll understand there's an entire library called underscore in javascript that basically
00:40:33.760
recreates enumerable and that's is so great
00:40:39.200
and just the pipelining of things and you don't get that like um
00:40:45.920
python doesn't really have something as smooth as that because python doesn't
00:40:52.000
have blocks and so it's harder to do that and so
00:40:58.960
it's the same sort of thing of like if you compare languages that have a pipeline operator which
00:41:06.800
lets you basically pipe data through functions similar to numerable but not quite um
00:41:13.920
and if you have a language that is that that does like currying by default
00:41:21.280
then the pipeline operator is just a function that takes takes two functions or it takes a
00:41:27.040
function of that data um but if you have a language that doesn't have curry by default
00:41:33.040
then you have to write a macro for your pipeline so like elixir has to have a macro for their pipeline
00:41:39.440
operator which runs at a different time than everything whereas like
00:41:45.040
elm or or other functional languages have it on there and it's just a different feel it's not it
00:41:51.200
i you know i like it better when you have querying by default but it's not like it does it's not objectively better but
00:41:58.000
the feel is a little bit different and that's the same with like ruby having
00:42:03.599
all of these built-in things is you can get them or or a reasonable
00:42:09.680
uh thing or facsimile in other languages because they're all just languages
00:42:15.119
but they don't they're not as smooth and they're not necessarily as integrated into the language itself um
00:42:24.240
and so it's it's definitely a um a ruby thing
00:42:32.000
that's a ruby thing now that i think about it the blocks and the uh the ampersand colon method ones oh that one's my
00:42:38.560
favorite i love to drop like a nice little map on an array and be like pull this value or this attribute
00:42:44.800
and like the thing that is frustrating i'm sorry a catnip banana
00:42:53.119
they all they're just all lying around my house i'm fidget with them um the thing that
00:42:59.359
frustrates me is that there's not a really streamlined syntax for use a method from my surrounding
00:43:07.119
scope so when you do like an ampersand colon it's saying this is the function
00:43:12.400
or the method i want you to call on the the object that's coming in the argument to
00:43:18.319
the map but oftentimes i'll have a function
00:43:24.839
outside just in in that context that i want to apply so
00:43:30.079
i want to apply this function to it to everything in there which um is not as the whole block yeah
00:43:37.760
um and so that's actually one of those things that if you if you do it a lot
00:43:45.839
ruby makes it easy to build like write a little function you know write your own sort of map-ish kind of thing
00:43:52.880
that lets you do it but um yeah it's just not as it's just not that
00:44:00.240
that's something that when i need it i'm always just like ah
00:44:05.680
but that being said um 2.7 now has like the underscore one
00:44:12.160
underscore two for the positional arguments in your map so you don't have to map and then
00:44:19.440
like in pipes put the name of your parameter which is always the single the like singular version of
00:44:27.680
the plural of what it you you don't have to do that anymore you can just call the function and put underscore one
00:44:33.520
and it i use that in the advent of code stuff and it really cleans it up a lot cleans
00:44:39.920
it up quite a bit um so i like that and
00:44:45.359
one might argue that that's a nicer solution than being able to reference um thing
00:44:52.640
one might i don't know if i would but i might i might depend on how i feel because it actually
00:44:58.160
looked really nice i i i did like that a lot and having it not look the same
00:45:03.520
as i want you to call this on each thing that's coming in
00:45:10.000
but rather i want you to apply it to each thing coming in if those were similar syntax
00:45:17.440
it might be confusing about which one you mean so if it was just like instead
00:45:23.200
of ampersand colon it was star colon or something like stars taken by argument uh
00:45:31.440
locations yeah maybe up arrow up arrow yeah something like that yeah like you
00:45:37.440
have carrick collin and then a method but then i bet i'd get grumpy about it because it looks like ampersand is just
00:45:44.160
like it's not the same you know what though like um you don't necessarily know what parameters that
00:45:50.400
method accepts yeah i think i think that's the problem like if you've got one or two parameters
00:45:57.040
or something like that yeah so i kind of like that explicit it was the first time i'd really done it
00:46:02.160
um and it made just like long you know chaining innumerable functions along made it really pretty
00:46:11.119
um says is it worth writing a dsl in ruby just for fun like for the learning experience i
00:46:17.760
feel like i should yes i never want to say should very
00:46:23.359
judgy i always feel judgey because i always say [ย __ย ] about myself and then i don't do it because i'm lazy
00:46:31.680
from my vocabulary i always try to not use should um tangentially
00:46:38.720
stop using should in your test descriptions on our spec
00:46:45.200
it's expect it's it and then you put does something because
00:46:51.440
the expectation is that this is green and that this is a statement of fact and if it's green it shouldn't it
00:46:58.160
shouldn't should do it it is doing it yeah maybe it maybe does this
00:47:05.599
it's a statement of fact it's an example that's why it's called an example it's like this is an example of how it works
00:47:12.240
it's not an example of what it should do so just say it blah blah blah it does
00:47:18.240
something write it up anyways back to the question yes
00:47:23.520
it is valuable to write a little dsl find a an interesting problem that you
00:47:30.079
have an interesting domain not a big one but just a small one and
00:47:36.839
um write out on paper how you would like to solve this problem
00:47:43.280
like if and this is again back to that wishful thinking of write out the syntax that would make
00:47:49.520
this nice and then slowly incrementally build that
00:47:55.040
dsl um are liquids are you familiar with
00:48:02.079
liquids corey no maybe no what's liquid they're used
00:48:09.839
in shopify and they're used in def dot 2. um oh and liquid probably have answered it for like the
00:48:15.280
guests here anyway so what liquid time is you have like your curly braces your
00:48:22.000
modulus and then you have something like twitch and a clip id and then you'll have something like
00:48:27.440
github and then a github url and then you'll do something like gist and against id
00:48:33.040
so with these liquid tags what happens is they embed a different template based on that is that technically a dsl
00:48:40.720
that's used specifically for templating and formatting yeah absolutely
00:48:46.160
i never thought about it that way i was like this is its own unique concept separate from the rest of
00:48:52.559
programming but no it's just a dsl that's a dsl that generates something it's it's
00:48:58.160
um and the thing is is a dsl's not something magical it's just codes
00:49:05.520
generally it's code that maybe generates other code or it's code that just runs in the
00:49:11.280
background it saves you time the nice thing about this like idea of building your own
00:49:17.440
is that you can you know build out the syntax you'd like and there are so many examples like look
00:49:24.640
at look at how jekyll does its stuff look look at examples of how um the liquid tags
00:49:31.839
underneath like how it interprets these things um because i it's been a long time since i
00:49:38.000
wrote a liquid tag but i think it's just a class that has a like a it is like a method with the
00:49:45.760
parameter yeah and it you you write ruby
00:49:51.119
behind the scenes and that's a really nice way of seeing that like it's it's ruby it's just there's something that
00:49:57.599
comes through um you know maybe it uses like a method missing and looks and sees like
00:50:06.000
oh you're calling something i don't know do i have a tag register that is that name
00:50:11.520
and if so i can instantiate that object pass the parameters and call your function and then whatever comes back
00:50:17.680
out i just plop onto the page and so you can do these really nice things and the
00:50:24.880
thing about writing your own is that a lot of times you end up writing
00:50:31.920
your own but just not like this full-blown i'm writing a dsl but you like you don't think about it you don't think
00:50:38.480
about it if you write a helper function to do something that's
00:50:44.240
it's the beginnings like i don't want to get into definitions of dsls and all that but that that's kind of a deal you name
00:50:50.559
something it's the first step like it's a function that does something for you um that's a first good thing and so if you
00:50:57.200
wrote yourself a small dsl you would learn techniques that you
00:51:02.319
aren't going to learn by like writing a rails app but those techniques can come in and be really
00:51:09.200
handy when you need to pull them out of your toolbox and you're like ah i need to do this
00:51:15.680
great this ties back to a lot of the stuff you've done with code retreat danny are you familiar with curb retreat
00:51:20.839
no
00:51:26.480
do you want to describe it i was like i was like i don't know if they heard
00:51:37.359
practicing um the idea of like uh going too far with
00:51:43.359
design techniques and like we say things like don't use a lot of if statements or don't have
00:51:48.960
long methods so like what if we go too too far and like have line
00:51:54.319
functions be two methods long or no if statements and code retreats a day-long workshop where we
00:52:00.400
uh practice those things and you pair up and you um swap pairs and stuff and so it uh
00:52:09.119
it happens a lot they've actually started the big one nowadays is that there's an annual uh
00:52:15.440
day where a lot of people do it a lot of cities do it together but a lot of places around you can go to i don't have
00:52:22.640
anything to do with it anymore so um i don't have a steak or anything but
00:52:27.760
it's a really good fun workshop day so if you ever if you're in especially
00:52:33.200
in europe they happen a lot more in europe now because there's there's a lot more people there that are driving it uh-huh
00:52:40.000
never mind he fixed it we had a momentary visual bug there
00:52:47.520
yeah that was uh but we're all good now i i appreciate you breaking down a code retreat for me
00:52:53.599
um i thought i i now have this idea of like trying to build my own dsl
00:52:59.760
so well the reason i wanted to like ask about and kind of mention code retreat
00:53:06.240
is i know in the past you've talked a lot about how code retreat trains you to use
00:53:11.599
those techniques in the future yeah and that's the thing is like if you can if you do
00:53:17.599
if you try these things and you do them over and over again in a in a uh sort of a constrained
00:53:23.680
environment the i i like to say that the the techniques that are really your own
00:53:30.319
the ones that you can say this is how i program are the ones that you use when you have a deadline approaching
00:53:37.760
like everybody falls back to that and everybody wants to build beautiful systems but when it's got to
00:53:43.599
get done today you fall back to what you know and the way that you can improve
00:53:50.000
that is by practice like if if you have written in a certain
00:53:56.559
style enough times then you don't have to think about it i always one of the things i say is it's under your fingers
00:54:03.599
it's like if you're playing like i've been learning piano for the last few years and there are certain moves that happen
00:54:11.760
now that i don't even have to think about like i can i can give you a g
00:54:17.119
chord in every inversion without thinking about it and i don't have to think about what the
00:54:22.319
notes are because i've played it so many times that it's there under my fingers right but at the
00:54:27.520
beginning i would have to think about it and when the pressure was on to play
00:54:32.559
something i couldn't just play g yeah when everyone was over for dinner and they're
00:54:38.079
like oh you've been learning piano play something like um okay everyone stand over there turn around yeah
00:54:44.559
and it's the same with techniques oh yes tell the story
00:54:50.799
i've told this story before i learned happy birthday and i spent two weeks practicing
00:54:56.000
it to go play it for my friend but under pressure in the moment like two weeks wasn't enough my friend
00:55:02.160
was a music teacher and i'm playing her happy birthday on my ukulele and i couldn't like get it right
00:55:07.200
like i didn't have the timings off and so literally at her birthday she is like coaching me through how to play happy
00:55:21.440
what you're saying about like training those techniques so that in the moment you aren't embarrassed at your
00:55:27.200
friend's birthday party yeah and like like i always reach for
00:55:32.400
innumerable my preferred style is
00:55:39.040
taking problems and looking at them as data transformations and so i have like when when everything
00:55:46.000
comes to head i will just start chaining the numerable functions together
00:55:52.240
um i saw that in your advent of code solutions yeah it's like i don't and this is the thing is like a lot of people are
00:55:58.319
uncomfortable with with like foal which is reduce or inject whichever language you're in
00:56:03.839
um people are kind of uncomfortable with it which is one of the reasons that ruby got each with object because people were uncomfortable
00:56:11.760
with fold i think um no i think you you are absolutely right like i have
00:56:18.880
been writing ruby code for like four years now and to this day i cannot write reduce and have it do
00:56:24.799
what i expect it to do every single time i write it it turns out wrong
00:56:30.559
and that's the thing it's like i've used it so many times that my mind goes to it and i know
00:56:37.280
i know how to string along a bunch of innumerable methods you know
00:56:43.200
maps and folds to get to what i want and that's that is
00:56:48.880
almost always and it's interesting because i never i will say i never reach for a for loop
00:56:55.599
when when the pressure's on because i get confused around for loops
00:57:00.960
because i've not i've not used them in so long not like i used to use them but i've not used i've used the innumerable
00:57:07.440
methods of ruby for so long and that those are the way that i oh you mean like an
00:57:15.040
actual for loop not in each loop yeah yeah yeah like a four loop i don't know this i like i i've had to look up
00:57:21.359
the syntax for a ruby this is true i don't think i've ever used like a proper for loop
00:57:26.880
like i've been doing ranges with each yeah um i don't use each that often
00:57:34.319
which is which is interesting like i move towards i tend to use map over each
00:57:41.839
um but and and not to leave that like it's better
00:57:47.280
but more that that's what i've done so much it is better but i've done it so much that that's my
00:57:54.480
tool that's the tool i use when the pressure is on and different people have different ones
00:58:00.480
but that comes from practice that comes from understanding it and so
00:58:07.599
yeah so write a dsl a long loop back to the answer write it
00:58:14.319
it'll teach you what you need write more of them and last but not least
00:58:25.119
and the thing i would say is find the small thing learn how to write
00:58:30.799
it delete it learn how to write it again delete it and get to the point where you can just
00:58:36.880
write it without thinking about how to write it yeah yeah the piano keys
00:58:42.799
that's yeah that was a big thing i had to learn for myself was just i spent all this time on this code if i
00:58:48.319
delete it it's gone forever but it's like no no code is cheap it's fine you can just
00:58:53.760
wipe it and then do it again one of the lessons one of the lessons in code retreat that the big lesson was you delete your code
00:58:59.520
every 45 minutes and so like
00:59:04.960
lots lots of people over the years had trouble with that but at the end of the day most everybody was like oh i feel so
00:59:10.480
great the leading code so awesome make sense
00:59:16.880
uh corey where can people find you great um i am on twitter at corey haynes and
00:59:22.880
pretty much everywhere on cory hanes um and also if you're
00:59:30.559
interested i'll talk my little side project newsletter that i'm doing
00:59:35.920
yeah i'm doing a weekly short newsletter where i'm
00:59:41.200
learning lesser known languages and writing about what's cool about them
00:59:46.400
that i'm learning what's cool about them um so i'm currently on a language called
00:59:51.520
icon this is the first one i'm doing and it is awesome and so i'm just writing every
00:59:58.880
week a short thing about like here's the cool thing um unsurprisingly
01:00:05.359
the next couple weeks are writing a testing library and it's because i want to write a json parser but i need a testing library and it doesn't have a
01:00:11.920
testing library so i've got a right one and it ends up being a rabbit hole of
01:00:17.520
course so from the very beginning with the javascript testing library to now
01:00:22.960
yeah thank you so much for joining us thanks for having me good talking to you hi i'm here and have fun