This video contains 8 individual talks

SF Bay Area Ruby Meetup - March 2024
+7
See all speakers
See all 7 speakers

Sections in this recording

SF Bay Area Ruby Meetup - March 2024
Irina Nazarova, Meredith Barry, Ben Sheldon, Adarsh Pandit, Marco Roth, Daniel Farina, and Vladimir Dementyev • March 28, 2024 • San Francisco, CA • Talk

Hey, Bay Area builders and tinkerers!

Whether you're weaving magic with Ruby or Rails in your day job, crafting the next big thing in your garage, or simply intrigued by the promise of productivity and sheer joy Ruby and Rails could sprinkle on your 2024 projects, this is where you want to be.

Learn from the talks, share opinions and make new friends!

https://lu.ma/r6d0lghm

SF Bay Area Ruby Meetup - March 2024

00:00:04.120 my name is Arena I'm the CEO Dil martians and I'm super excited for about
00:00:12.120 today's event I don't know why but it just feels overwhelming at the
00:00:17.359 moment I'm gonna say um a few words first of all this I'm I'm so
00:00:24.480 excited about this guys think about it right we had suchal
00:00:32.559 on break and um honestly I just moved to San Francisco in January uh but like the
00:00:39.559 first thing I wanted to do is was this so and you made it happen so I don't
00:00:45.079 know thank you so much super grateful yeah check out this website Ruby conferences uh.org there are more events
00:00:52.800 and new events are coming up and it's a Community Resources re resource so you
00:00:59.199 can contribute if you're organizing something definitely add it there there are more events on the west coast um for
00:01:07.280 example uh rails camp in August where you're supposed to go hiking yeah with
00:01:14.840 Ruby people but yeah we're GNA start in a second um I'll just give
00:01:21.759 you um if like a small piece of information about the stickers that you
00:01:28.360 can get grab over there so the company that I'm the CEO of is called evil
00:01:34.840 martians we are a product development consulting company for uh developer
00:01:39.960 first products we are pretty well known for our open source and our clients some
00:01:45.479 of our clients are on the screen we also build some commercial Open Source Products including image proxy and any
00:01:53.759 cable um and this is just a few of the
00:01:58.960 lugus of our open source projects you can recognize maybe post
00:02:04.680 CSS or uh test Prof U Ruby next many many of the things in um sort of Ruby
00:02:13.040 rails ecosystem and finally um something
00:02:19.120 happened and for some reason this year I'm given a keynote at
00:02:25.120 rails thank you and uh if you guys are uh work for a startup a you know new and
00:02:32.840 growing company built on Ruby I want to talk to you and um this is uh the link
00:02:40.159 where you can sort of schedule 30 minutes with me I'm collecting feedback
00:02:46.000 of like what's missing in the ecosystem what's helping what's useful what's lagging or uh to make to gather all this
00:02:54.920 feedback and Inspire the community to build more and better tools for
00:03:00.800 uh smaller and growing companies you know not just companies like GitHub but thank you
00:03:06.599 GitHub no thank you GitHub for hosting look at this it's amazing I'm yeah GitHub shout out
00:03:20.599 sponsor uh who supported the pizza and I'm gonna give uh the floor to Meredith
00:03:28.760 hello my name is name is Meredith I'm a recruiter for tech systems so I'm not a Ruby on Rails developer um but Tech
00:03:35.959 Systems is a global uh technology services company so we work with a lot of companies here in the Bay Area uh
00:03:43.159 like apple Adobe meta for mostly contract Consulting work um I've been
00:03:48.680 supporting the Ruby unreal space recruiting for the past couple years um
00:03:53.799 so support a ton of projects um over the past couple years in Ruby so would love
00:03:59.159 to connect with you um here is oh switch
00:04:04.519 this slide there we go um so this is a QR code for some of the job applications
00:04:10.120 I'm sure I've connected with some of you already or I've been in your LinkedIn DMS a few times so um we love to connect
00:04:17.639 with you and see how I can help you just in your job search or um if you need help with hiring needs Tech Systems
00:04:23.840 would love to to help you out too um one of my sales Partners man is here too so
00:04:29.199 um yeah
00:05:29.759 good stories but just about me um I work here at GitHub uh really happy to have all of
00:05:37.800 you here uh I'm the engineering manager of our Ruby architecture team uh Ruby
00:05:43.479 architecture we're the bridge between github's rails monolith and uh the rails
00:05:49.440 and Ruby core teams so we uh it's a two-way Bridge we do a lot of upstreaming of uh GitHub uh improvements
00:05:58.280 and then we do a lot of down streaming pulling into the GitHub monolith all of the great uh open source stuff that all
00:06:04.600 of you all contribute um I'm also the author of good job which is a
00:06:10.120 multi-threaded postgress based active job backend um does background jobs uh I
00:06:17.199 live in San Francisco and I'm currently fostering two very good cats uh and if
00:06:23.199 you stick around to the end of my presentation you will see a photo of them so that's uh the sweetener so just
00:06:31.800 briefly uh good job it's really good um
00:06:37.199 it's multi-threaded postgress based it does active job it's designed for active
00:06:42.280 job um it's built for rails it's built for postgress uh it has uh chronik
00:06:48.039 recurring jobs it has batches it has concurrency controls and throttling it has a really nice uh web dashboard uh I
00:06:54.960 think it's really good and just to like put it in the context here
00:07:00.400 um like good job comes pretty recently uh I released it in
00:07:07.080 2020 um it's pretty much built for active job like most other things uh
00:07:14.520 existed before rails had its own um adapter for active job and I even spelled it wrong there should be a space
00:07:21.080 between active and job sorry about that uh rails core members uh but yeah so
00:07:27.440 good job um it's pretty contemporary and it's built for rails and sort of like
00:07:32.599 what I'm going to be talking about here tonight is like a lot of some of the stuff that I learned while trying to build
00:07:38.080 it so in good job this is like probably the most popular feature request that I
00:07:45.280 got when I was developing it where people said hey I want to inq active
00:07:51.479 jobs on a recurring basis so that it can be used as a replacement for Kon uh if
00:07:57.319 you're paying attention to solid Q solid Q like just last week they launched recurring jobs um started supporting it
00:08:03.479 which is awesome um good job we've had a little longer but you know um solic Q is
00:08:09.319 great uh so was good job um but this was like how everybody wanted it to work
00:08:14.560 they were like I want to have my job class here where I Define my job and what it does and then I want to be able
00:08:20.159 to have the configuration for it where it's like for the cron I wanted to live
00:08:25.319 with my job and I agree it would be really nice to do it that way and I
00:08:31.200 didn't um the way the good job does it is you have this block of
00:08:38.000 configuration um in like your application RB in rails or a initializer
00:08:43.680 in rails uh but basically like pretty far away from where you're putting your jobs in app jobs um and uh you just have
00:08:52.839 this like block of nested hashes um and you have to like reference your job
00:08:58.760 class um with the string not the constant and then like the configuration
00:09:04.160 just to be really clear the configuration does not live next to the job that is being
00:09:09.480 configured um the way that then like good job works is we have like all of
00:09:14.560 these hooks where after your rails application has initialized we go through that hash um and then we like
00:09:23.480 schedule it so we say Okay an hour from now we're going to run this job and then only then does it look at that string
00:09:31.079 that is the name of your job and then it constanti it and then it performs it
00:09:37.519 later um so it enues the job and a lot of what I'm going to be talking about is
00:09:43.640 like why the heck did I do it this way and not what I think everybody wanted
00:09:48.760 and I agree which would have been super nice which was that way um so here's here's the answer uh we
00:09:57.760 all want rails development to be like really really really fast um and loading
00:10:04.399 files and constants uh you know just to read that little bit of configuration is
00:10:10.720 slow um and I think if you've been in the rails EOS system you've probably
00:10:16.320 heard all about autoloading and zit work uh and I'm not going to talk about how they work there's already a lot of like
00:10:23.000 really good uh articles and talks about how they work under the hood what I want to really talk about is like
00:10:30.360 how to use them in a way that you aren't messing up all of this goodness that they give you which is they make your
00:10:36.079 application boot really really fast in development and just just to be really
00:10:42.279 clear here like I'm talking about the development environment development workflows um so that's like when you
00:10:49.440 start up bin rails s on your laptop or in a GitHub code space um and you like
00:10:56.040 load Local Host 3000 and you click around um that's that's the environment
00:11:01.639 I'm talking about or like if you say bin rails test or bin rspec and you run a
00:11:07.040 test or you say like bin uh rails C rails console and you um open up that
00:11:13.639 like this is talking about development um production is like totally different
00:11:19.200 uh rails will it calls it eager autoload but basically all the stuff that in development that rails tries not to load
00:11:26.440 uh in production rails is like well you're going to need all this anyway so so we'll just load it all at once and so
00:11:32.120 like in your rails configuration that's like cach classes equals true eager load equals true um but I'm not talking about
00:11:38.560 any of that I'm really just like talking about development where um my favorite
00:11:44.240 style of development is where you make a change in the code and then you refresh the web browser and you see what happens
00:11:49.320 and then you change the code again um so this is really like that element of trying to get fast feedback from code
00:11:56.160 changes on your local enel development en so this um is how I think of a rails uh
00:12:06.600 application um so down here over here on the lower left um this is like your
00:12:12.680 framework what I'm calling framework configuration um so those are your rail
00:12:18.600 tie files your engines um active record not active record base which is over on the right
00:12:24.959 but just like active record the the core files for active record the core files for Action controller and action pack um
00:12:32.839 active job uh action text all of those things so that's your framework
00:12:39.199 configuration um you've got your application configuration conveniently in rails that is everything pretty much
00:12:45.959 in config uh config is configuration application configuration uh and then I call it
00:12:53.760 behavior um but like your application behavior is basically everything an app
00:12:59.320 your controllers your helpers your jobs your models maybe you use Services um whatever else is in your app
00:13:06.600 thing uh maybe you have an app lib uh or like if there's stuff in lib where
00:13:12.160 you're autoloading lib which is a new rail 71 feature that they came up with after I wrote a blog post that was
00:13:18.880 called Don't autoload lib and then rails core was like oh we're gonna we're going
00:13:24.000 to make that official um and then uh yeah lastly because The Matrix here um
00:13:30.959 like your framework I call it Behavior I don't know the core classes but it's like the active record based file that
00:13:37.720 the the models in your application inherit from uh so it's like active record base then becomes application
00:13:45.360 record and then becomes like user um inherit from or action controller base
00:13:51.720 or active job base um or the other things that you may inherit from so this
00:13:58.600 is like Matrix that I think of um oh yeah I just talked about that and
00:14:05.639 uh so like the configuration over here is uh required during boot so rails the
00:14:12.519 rails application imagines that you're like you know what any thing that you do in this application and development you
00:14:17.560 run a single test you're going to need all this configuration and framework application configuration framework
00:14:23.199 configuration so it loads all of that everything on the right side with behavior is autoloaded the idea here is
00:14:29.920 that rails is like only load what you need when you need it and what would be the fastest is if it just didn't load
00:14:36.440 any of that at all if you're running a single test unit test for a single active record model you don't need
00:14:43.040 controllers you don't need jobs you don't need helpers you just need to load
00:14:48.120 that thing so the idea with rails is that it's trying to not load all of the stuff over in behavior until you touch
00:14:55.320 it and that is in service of just like you making a SLE web request or running a single test or opening up the console
00:15:03.040 and like doing code reload and trying to make that really
00:15:08.440 fast and so a good application a nice application is going to load in this
00:15:15.279 order it's going to load your framework configuration and then it's going to load your application
00:15:22.199 configuration and some applications that is actually your rails application is now fully booted fully initialized
00:15:29.720 um right just over here on the left hand side um some applications maybe then in
00:15:37.800 order to get like fully initialized they'll have to load some of like active record base um but usually by I'm G to
00:15:45.240 run over here by this line your application should be fully initialized
00:15:51.079 and not have touched any of these and then when you actually load that first web page um in development or you run a
00:15:58.519 unit test it will then reference one of those and they'll get loaded and that code will load so this is this is an
00:16:05.560 ordered application a nice application this is the ideal uh thing that we should be
00:16:11.160 aspiring to because this is the fastest way to load and this is what like like bad
00:16:19.160 applications look like uh all applications are like good applications
00:16:24.319 but these need a little more help um and so in these cases um during application
00:16:33.360 initialization they start referencing uh models or they start
00:16:38.560 referencing controllers and when you reference say the user model the user model inherits from active record base
00:16:46.079 so the user model now has to load active record base um and then also sometimes like you know you may have concerns you
00:16:53.360 have may have modules you may have Mixon that also then load additional stuff and
00:17:00.480 so you just end up with a lot of stuff loaded and it gets hella
00:17:06.000 slow so hey github.com this is where I work um so this was something that I was
00:17:13.280 debugging uh with a colleague a few weeks ago um this colleague is John
00:17:19.280 Hawthorne who actually makes the amazing Vernier uh rail uh Ruby profiler and we
00:17:28.199 discovered that that when booting our github.com monolith we were spending 4
00:17:34.280 seconds and this isn't great we were spending 4 seconds out of like n seconds uh just like loading controllers during
00:17:42.880 application initial initialization during boot um so that was really bad uh
00:17:50.559 if you're just trying to run a unit test as a hubber developer um and you're like
00:17:57.360 unit testing something that is very much not a controller that is 4 seconds the of your life that has been wasted
00:18:04.440 loading controllers that you never need or going to use um and just oh yeah just this
00:18:12.320 command up here I mentioned verer is a great profiler um rails runner puts true
00:18:18.559 is like uh if you've never used rails Runner before it like boots your application and then run some Ruby so
00:18:25.320 this is like the most do nothing thing that this Ruby is doing but it's like just puts true and
00:18:32.039 then it's exiting so like just to be clear like nothing is happening in here
00:18:37.120 and it it's taking n seconds but we could at least cut it back to five seconds which is sort of
00:18:44.919 better so this is just to show like what I ended up doing with my colleague John
00:18:52.360 um is we went into our uh config application RB because once we profiled
00:18:58.080 it and we were like what the heck is loading all this stuff uh and this is like crazy big flame graph so we're like
00:19:04.159 let's just put callar uh in here so this is saying active support on load so when
00:19:09.720 action controller base is loaded we just want to like put the caller and
00:19:14.919 it uh will spit out like 50 lines of
00:19:20.080 like this required this required this required this and um we figured it out
00:19:26.280 and this is just an example of what it was um that we just found an asset path
00:19:32.039 that we were loading action controller base to set the asset host and we fixed it um by doing this active support
00:19:38.799 onload action controller based so basically this code in here doesn't get loaded until action controller base gets
00:19:46.200 loaded which is ideally someone else is loading it and not when we're just
00:19:51.880 trying to put true and exit um those hooks
00:19:59.360 are actually not well documented in rails I think this is the only thing that I will say is not well documented
00:20:04.440 as part of my presentation uh that you just have to kind of go look through the rails codebase to find all of these um
00:20:12.760 if you just search active support run load hooks uh you should go look for
00:20:17.799 that if you're trying to do the thing if you go back and you know take my presentation and you're like I'm going
00:20:23.280 to try this on my own application um you'll likely have to just search though the big ones are action controller base
00:20:29.919 um or active record active record base um most framework files that you may
00:20:36.280 want to load uh they offer these lazy load hooks um and like other gems rails
00:20:43.640 engines they also do that uh I just have an example here of devis um devis has
00:20:49.400 this run load hook this is these are all things where I'm just like you just have to go go look in the code base um for
00:20:57.360 these things um and the idea here is that you only like add these when when
00:21:04.559 the constant is first accessed uh not before so if you if you need
00:21:11.440 to do something like this you're just like don't access it until you need
00:21:18.520 it there's a whole bunch of other stuff that I'm just going to gloss over uh
00:21:23.840 here that are called initialization events um but you can just hook into different part of rails uh
00:21:30.799 initialization but the idea here is that like this pattern of wrapping your code
00:21:37.919 um with these like config before initialize config after initialize to
00:21:43.480 prepare um is like a super common pattern that you hopefully have all over your initializers in your application um
00:21:51.200 because if you don't it's probably loading really slowly uh and I just want to say like
00:21:57.919 this as a problem is super common uh devis is
00:22:03.679 actually not it's not my favorite for doing this um but if you notice like if
00:22:08.760 anyone here has ever used devis uh you put this devis 4 in your routes.rb file
00:22:14.720 it's config config routes RB um and then if you actually follow the code path
00:22:21.360 down into devis eventually gets to a place where it just constanti users so
00:22:28.000 if if your application I'm like you're probably adding at least 100 milliseconds right there as soon as you
00:22:34.559 add devis because it's doing that um and you know I'm trying not to
00:22:42.679 pick on anyone uh rails does this too I made this poll request um where rails
00:22:49.360 has had had a bunch of uh Cycles where
00:22:54.760 like active record would end up loading active job which would end up loading action mailer and um it was not trivial
00:23:03.360 to try to unwind all of these pieces so that um yeah you could do faster unit
00:23:09.520 testing and keep your rails development environment going fast all right um these are just some
00:23:16.840 code examples uh if you are thinking about your application uh that I wanted
00:23:22.039 to just share I'm a big fan of sharing examples so if you're just want to like
00:23:28.720 how fast does my rails application run uh you can just like time bin rails
00:23:34.200 runner puts true um recommend running it twice uh because Boot snap sometimes
00:23:39.760 will cash it so the second time will probably be faster uh just want to
00:23:45.120 really promote uh John Hawthorn's verer profiling uh gem it is like really just
00:23:51.520 really good really really good um further further debugging ideas
00:24:01.120 um again just trying to like I want to show folks I'm like look if this is a problem that you do have in your
00:24:06.200 application like these are some things that you can do there is uh no shame
00:24:11.279 inputs caller uh and just dropping some debugging stuff in there that's how I do
00:24:17.159 it I think I'm a serious developer um even more stuff if you want
00:24:23.400 to hook into zit work um this is a way to do that where you can pull out all of
00:24:29.120 the constants that are being loaded this is just like a script that you're running directly um you can pull out the
00:24:35.039 constants you can initialize the application and then you can go back and look and be like did any autoloaded constants get loaded which ones are they
00:24:42.919 and uh where where did they get called from um and I I ran this today I wanted
00:24:48.840 to make sure everything was working and I discovered that action text actually has a problem so now there's more work
00:24:56.480 to be done uh maybe I'll make a PR in rails but I discovered that action text was like loading content helper when it
00:25:04.200 shouldn't have been according to me all right so I'm going to finish up here um just want to say like you know
00:25:12.760 keep your rails application booting fast in development um GitHub we have like
00:25:18.799 40,000 Ruby files I think was the last time that I counted um we have like 800
00:25:24.120 developers working in that monolith uh it's these things add up milliseconds
00:25:29.600 add up so just keeping it fast I think is really important um don't design
00:25:35.919 interfaces in a way where you're like having to load those constants in order
00:25:41.080 to drop configuration on them or to read configuration into them and like you
00:25:46.559 know really really just don't touch anything in app uh in in your configuration in your initializers um
00:25:53.919 unless you really need to all right so just want to
00:25:59.039 uh the code and examples like if these things are interesting please reach out to me like I would love to make your
00:26:05.159 application faster um the slides are there uh and uh yeah please uh if you
00:26:13.679 have a lead on a home for these two good lads uh this is Cameron and that is
00:26:21.279 Monty which is short for Fairmont uh because we found him hanging around at the Fairmont Hotel uh
00:26:28.840 but they have an Instagram red carpet cats um but yeah if you have a lead on a
00:26:35.120 forever home for these two cats please let me know and if you want to make your rails application you know run faster
00:26:41.080 too uh also like reach out thanks okay you might have seen this
00:26:47.880 sticker over there um it's a any cable any cable is the product that we build me and Vladimir Dean who's the
00:26:55.120 author and um the announcement is about our version
00:27:00.360 1.5 but for those who don't know any cable iser uh was originally built for rails
00:27:06.720 as a drop-in replacement for Action cable it brings two things performance performance and scalability because it's
00:27:13.679 built in in um in go it replaces action cable it replaces all your kind of websocket infrastructure making it super
00:27:20.480 performance super scalable and it also gives you
00:27:25.559 reliability um something like delivery guarantees for web
00:27:31.039 sockets which is not present in other Solutions and also if web when web
00:27:37.320 sockets are not available it kind of falls back to other transport and stuff like that so the KNE
00:27:44.760 relas uh is something pretty cool because any cable used to be like I'd
00:27:50.799 say a little bit more complex on the deployment side because you needed to
00:27:56.080 have essentially three applications rails RPC and anying cable now uh we we can continue
00:28:05.200 simplifying any cable for more use cases now we have a standalone um mode that works for hot
00:28:13.000 wire so if if you just use action cable for hot wire uh you will have a super
00:28:18.159 simple setup uh for any cable um and there there's there's more
00:28:24.679 um uh essentially we provide simple pops up um kind of simple
00:28:32.240 abstraction uh yeah a few more details here but you can go you can find us on
00:28:37.880 GitHub of course and find out more there now adash
00:28:44.799 go ahead and and next up Marco than hi
00:28:50.279 everybody I'm a pundit I'm the executive director of Ruby Central if you know
00:28:56.159 Ruby Central um that great we have two main jobs we good jobs maybe um we put
00:29:03.679 on Rails comp every year and Ruby so all those events are one job and then the
00:29:09.080 other good job that we do is that we keep bundler and ruby gems working uh for all of you all day every day every
00:29:15.720 time you type bundle we make sure it keeps going um I would like to redirect that
00:29:21.840 Applause to all the people who actually do the work but um so that's what we've been up to and want to just say a couple
00:29:29.120 of things about that and um the meetups uh that we' that we've been investing in also so we have undergone so many
00:29:37.559 different changes in the last couple of years with the pandemic and um with
00:29:43.039 absorbing the um the open source work in Ruby jems and bundler and um it's it's
00:29:49.480 been awesome we've changed a lot about our team and the way we're doing events we did for those of you who are at Ruby
00:29:55.240 conf in San Diego uh we added a hack day or Community Day where basically open
00:30:01.559 source maintainers each held a table and you had a chance to pair program with
00:30:06.880 them close a bunch of um open issues things like that uh Gemma from um the
00:30:14.080 Ruby core team closed so many issues that the core team in Japan thought something went wrong and um so that was
00:30:21.760 that was her project and and we're going to do the same thing again at rails comp in Detroit my hometown in May it's May
00:30:29.000 I'm going to say 7th through 9th but all the details are at rails com.org uh
00:30:34.200 tickets are going up in price on April 1 and if uh so make your plans now the
00:30:42.240 flights are actually pretty cheap to Detroit if you haven't been to Detroit ever or recently it's very different
00:30:48.440 than it used to be when I grew up there it's a has a very vibrant art scene and
00:30:53.640 very kind of fancy food scene if that's your thing um there's a lot of really neat things going on so I strongly
00:30:59.840 recommend you check it out if you have any questions about that let me know we're are still just barely under the
00:31:05.639 cut off for sponsorship so if your compan is interested in sponsoring it railson please do let me know I can
00:31:11.360 direct you to the right people Ruby conf will be in Chicago this year in November so that's November 13th through 15 and
00:31:18.720 tickets for that will be on sale soon we have a sign up list for that at rubby com.org and we're also um taking
00:31:25.799 sponsorships for that so the conferences are really exciting and it's a great way to get um get together with rubius from
00:31:32.679 all over the world it's so much fun to see people in person that you only know on the internet just from their little
00:31:38.840 you know tiny circular picture um so definitely uh we'd love to see you in
00:31:44.399 Detroit and Chicago um so on the on the open source side bundler and ruby gems we've been
00:31:50.600 getting a lot of funding from different uh funding Partners to help us primarily
00:31:56.320 on security so for everyone's benefit in our community we're under we're adding a whole bunch of security features uh you
00:32:03.880 may have seen some of the changes and uh we also have thanks to the sponsorship
00:32:09.120 of AWS we have a full-time W2 uh security researcher and residence Samuel
00:32:14.720 giddens who uh is constantly working on security again for everyone's benefit so
00:32:20.760 that's pretty exciting news and I've been with Ruby together and Ruby Central as a board member since 2016 so being
00:32:28.600 able to get people paid to work on open source is is a really um exciting thing
00:32:33.679 for me um we have a lot more stuff coming on the way we have um you can check Ruby central.org and you can see
00:32:41.480 the news and see all the cool stuff that's going on and finally the Meetup scene so we know at Ruby Central as a
00:32:47.960 community nonprofit that the Meetup associations all the local meetups the
00:32:53.320 Ruby user groups across the country and across the world are so critical and they were all really devastated through
00:33:00.600 the pandemic and over the last couple years even before that there hasn't been a ruby San Francisco based Ruby Meetup
00:33:08.320 in a long time since fog City Ruby am I wrong I think that's right um so I'm super super happy that we're all back
00:33:15.519 together and we're starting again Ruby Central is sponsoring the meetup.com monthly SP monthly subscription for um
00:33:24.120 Meetup organizers in the us and our first trial is this one here in San Francisco so if you signed up on
00:33:31.080 meetup.com uh great please do that and if you haven't you can probably find it on meetup.com I am the current organizer
00:33:38.720 I would love lots of help because I have other jobs that I need to be doing so if you want to help organize the next
00:33:44.880 Meetup um please get in touch with me I'll be over there I also have stickers so that's another incentive for for me
00:33:52.279 and uh maybe for those of you who are less socially inclined that say you're a real gem so that's a incentive for you
00:33:59.159 to come chat with me but we're we're also looking for places to host so thank you to GitHub for for hosting here but
00:34:05.840 we're also looking for a host for next month and um speakers any of that so if you want to get involved please do and
00:34:12.679 uh thank you to arena for putting all this together thanks all
00:34:18.960 right hi Marco nice to meet you all if you haven't met please come talk after us after this to me I want to talk about
00:34:26.440 um an hot I've been working on the last few months or even years if you want um
00:34:32.800 so even though most companies are using react and other Frameworks for building
00:34:38.040 their applications and um building their uis there's always been this one other
00:34:43.520 alternative which is the Hotwire kind of way of building apps it's been the kind of fril way to do that for the last
00:34:49.960 decade or so and with rails 71 the all the things got default in rails and
00:34:56.320 there's more and more and iasm in the community to build more features and apps um using it but then again it seems
00:35:05.000 like there's not a lot of resources and how to build stuff really well or how to approach things and how to go about
00:35:10.920 using Hotwire in your rails applications I've been working on a bunch of related projects in the
00:35:17.359 ecosystem but as you know it's a little bit complicated to get started I feel
00:35:22.440 like um so what you want to do with the Hotwire thing is pretty much saying we want to use whatever we have in the back
00:35:28.920 ends and reuse that logic um for building our uis as well without having
00:35:34.800 to duplicate whatever we have on the front end so every where everything kind of
00:35:40.640 stays where it belongs kind of if you like building UPS on the server s side so this is super nice to build that kind
00:35:47.760 of um applications that way and I see a lot of people say that like Hotwire is kind of the way to
00:35:54.560 eliminate all your JavaScript but I feel like that's not the whole um motivation
00:36:00.119 to build ups that way I feel like it's just a way of reducing the amount of
00:36:05.319 JavaScript you have to write yourself and it's not um getting rid of it it's
00:36:10.359 mostly just using the right amount of JavaScript to get your stuff done and what we call this is like Progressive
00:36:16.520 enhancements and both stimulus and turbo make really good use of that it pretty much just means that you use um your
00:36:23.720 default HTML elements but then over time a progressive enance them with more
00:36:28.800 JavaScript and more like um interactive parts and there are some Frameworks to
00:36:35.000 do that like simulus to kind of add more stuff um more interactive stuff to those
00:36:40.359 elements but then again kind of what's lacking in hot wire right now um mostly I feel like it's um the framework
00:36:47.599 specific documentation if you use Hotwire before there's no real guide on how to use it with rails there's some
00:36:54.119 documentation but there's not a lot of it and that's super what missing and bothering me that I wanted to build
00:37:00.200 something for it there's no guides to kind of guide you through how to approach those
00:37:05.520 problems and how to discover what's available for you to use so if you look at the landscape of kind of the um terms
00:37:13.640 that flow around the ecosystem we can see some of them here which is kind of why I wanted to build something to help
00:37:19.720 with this and kind of um motivate people to also contribute and help um improve
00:37:25.240 those documentations that's why I build hot.io it's kind of a website Community Driven
00:37:31.079 to build guides and framework specific documentation to help people that want
00:37:36.440 to use Hotwire in their stack um all of this is not specific to
00:37:41.920 rails you can use this pretty much any um server side framework which is also another reason to build more integrated
00:37:48.599 documentation for other Frameworks as well so I feel like this is kind of the
00:37:55.079 server side the server jav ecosystem for server side
00:38:00.160 applications and we have been building out this ecosystem page where we show all the different projects that are out
00:38:07.280 there so you have an idea what's actually available and what exists but we also have these sections which we
00:38:13.000 call the use case sections that you know what you could do or use Hotwire for and have some guides for them as well and we
00:38:20.280 want to build more Frameworks for for guides for more Frameworks so you can get started in any of the Frameworks in
00:38:26.240 Ruby or in any other language you might be using um and then again there are a lot
00:38:33.520 of other Frameworks are making some use of it right now even in their own official documentation but there's so
00:38:39.319 much more that we could do even like um Ro we see um later how we can integrate
00:38:45.680 um hot in those Frameworks as well so all of this is pretty much based on community content and if you like to
00:38:52.560 improve whatever we have right now I encourage you to help or reach out afterwards so that we can build build
00:38:57.839 more documentation for this I feel like awesome ecosystem of um way of building
00:39:04.240 um R applications so if you have anything written yourself or want to write something in the future we love to
00:39:09.720 feature it here or if you want to write a specific guide for the um website
00:39:14.800 contact to me so we'd love to see your contribution um then another thing I've been working
00:39:21.480 on is the Hotwire Weekly Newsletter which as you my guess comes out every Sunday um so if you want to keep up if
00:39:28.599 is new in the Hotwire lands you can subscribe on hot.io newsletter or check
00:39:34.079 out the socials um online and that's pretty much it from my
00:39:39.560 side yeah thank you I've been building uh infrastructure
00:39:46.640 clouds uh for a long time and if you want you can get these slides at slides.com FDR FDR fora Daniel Robert
00:39:56.200 twice um and I'm founder of UB cloud and what is it it's a a new iaz you can
00:40:04.079 compare it to AWS or gcp or Azure uh it's also an open source R program you
00:40:09.480 can take a look and um it's focused on core products you know 10% of the
00:40:15.520 features 30% of the price right now it's more like 3% of the features and 30% of the price uh but just wait a little
00:40:22.520 while um and it's written in Ruby which uh I didn't really think was interesting but but then when I tell people that
00:40:28.599 they say that's weird um and are you sure you want to do that and um did you learn anything in
00:40:36.680 the last 13 years uh and other things of that nature in fact it's a surpris to me to hear that it's like oh a startup is using
00:40:42.800 Ruby I'm like okay I seem to recall it's a thing people did uh I just never
00:40:48.240 really thought about it um so I've actually written a lot of these systems
00:40:53.839 uh the first one was at the Heroku Department of data which if you use Heroku that's lot of could I wrote uh probably
00:41:00.640 refurnished by now and then um I left and I was said Okay that was a pretty good job so I guess I'll make the same
00:41:07.200 job at cus data where I met my co-founders and that's was a data rousing startup on postgress as well and
00:41:12.280 I think that was the biggest I managed to shrink kind of the improve the conciseness by maybe double uh SI data
00:41:19.400 probably because I knew what I was doing um and then I went to crunchy data which is a really good hosted database
00:41:25.040 product you should use it uh on all three clouds if you have any problems with RDS or
00:41:30.880 similar uh and then eventually one of the co-founders UB Cloud says I have
00:41:36.240 this idea I think You' be good for and I said okay what is it he said I'll let you know in a year I said okay and then
00:41:42.680 uh he said well I think we should make an IAS and that's um now what I'm doing I mean it runs instructions and loads
00:41:49.640 huge huge pages so it's the same as post right I mean that's just same thing um so the background I kind of
00:41:57.000 wanted two things uh one was I wanted to talk about Roa HTP routing uh because I
00:42:02.640 thought that there should be enough code in a code Meetup it just seems very important but then I kind of wanted to
00:42:08.440 address the question I always get which is uh why are you so strange uh because it happens all the
00:42:14.240 time and I was trying to figure out what do Ruby Community people uh think about I went to Reddit and people like is Ruby
00:42:19.880 dying all the time uh I'm like okay not something I was really looking for all right you know um so I was just like
00:42:26.680 what are people thinking about and I kind of thought that my very unusual experience using
00:42:31.880 Ruby uh I don't it's make you feel better or worse but make you feel differently okay so Roa we'll start the
00:42:38.920 specifics uh that's the fun part uh it's a routing tree framework and so what is
00:42:44.760 the routing tree here it's actually just a series of nested blocks and you could
00:42:51.000 see this as an alternative to before filters I think both Sinatra and rails
00:42:57.640 have before filters well you just write code that's the before filter you're
00:43:02.920 like okay you know you basically proceed from top to bottom and when something matches you go on the Block and when it
00:43:09.400 doesn't match you you don't go on the Block so if you want before we'll see an example of this um so let's take uh one
00:43:17.559 example here if we start with a request and it's on item SL whatever and we go into this arm and then it supports types
00:43:26.400 to match each fragment at of time you know between each slashes and here we load an item instance variable which is
00:43:32.480 available to templates and all future code because remember just top to bottom right and so here if it's a get we match
00:43:39.079 gets we're inside this arm here we can render item and if it's a delete we can delete the item this is presuming a
00:43:45.359 somewhat normal you know orm so it runs a delete statement but if it didn't match items at all we can match any
00:43:51.599 string and say hey here's a string you sent me this is uh I hope this conceptually sort of might be seem very
00:43:59.200 simple I would say Jeremy Evans the guy who wrote this use Sinatra for many years and then thought I think there's a
00:44:05.440 way to improve on he didn't I don't know he said this to himself but he just said he started developing Roa and actually
00:44:10.640 my colleagues were saying I wonder why he's doing that could possibly be worth it uh this is what he
00:44:17.440 did but that's a little bit of a toy so I want to kind of show you uh what very
00:44:22.760 framework intensive Roc code looks like uh it's the the conceit is exactly the
00:44:28.200 same you get a request now instead of familiar symbols like maybe on or is
00:44:33.680 where you kind of get the idea and then doget uh we see public and assets and
00:44:40.000 then on web hook that one we saw a little bit before and then this plugin hash branches and then check Cerf very
00:44:45.480 important to check your C surfs uh and then we do some and so you can see here
00:44:50.559 the composition of the framework this is not how most of the code works this is the very top level application where everything comes in and you can infer
00:44:57.599 from this is well the first thing we do is we check for unauthenticated assets like public or
00:45:03.240 assets um web hooks don't have Cerf ramification so we do that uh and then
00:45:08.680 we do Cerf and then we start loading rodo a library by the same guy to um get
00:45:15.200 the current user handle and then we do stuff like um check if they have a member me set load the session and then
00:45:22.079 finally um if you're at the root we don't render we just redirect you to login at root otherwise require
00:45:27.640 education and then we run this H branches thing um so it's all the same conceit
00:45:35.280 but the power of the composition of the framework I think is a little more obvious where uh in a very small amount of code
00:45:42.280 you kind of get all your before filter type stuff um and you can just have branches and just write Reb
00:45:50.000 code uh here's what the leaves of the application looks like this is what most
00:45:55.520 of your code looks like it looks aot lot more like uh the example I showed you
00:46:01.160 the the toy which is actually part of the appeal um but something is interesting here you
00:46:08.480 might notice here and here everything's reopening a single class Clover web we have Clover web and clover API why is it
00:46:15.400 Clover I'll get to that later um and what we do here is there's a
00:46:21.599 thing called hash branch which is a very unusual plugin uh that I think is very important
00:46:28.000 if you're going to use Roa and anything that's even mediumsized and all it does is if you might think to
00:46:34.599 yourself uh G isn't it inefficient if you have you know 50 routes to fail to
00:46:40.119 match 50 routes and then find at the 50th route 51st route that you proceed into the into the uh block and you're
00:46:47.240 right it would be inefficient so uh what you do is you use hash branches which is
00:46:53.040 a little less flexible it just lets you directly when you say not hold the block and then it jump to it and that's
00:46:58.960 exactly what it does it sticks if you look at the source code all it does is take the block sticks it in a hash table and then uh when you see the project
00:47:05.720 fragment it just jumps there so you get o of one dispatch um I would say that's the one
00:47:11.720 weird thing about Roa that and the uh the reopening of classes to organize
00:47:18.040 applications once you know that you pretty much know all the stuff and you could look at the source code uh in UB
00:47:24.240 cloud and if you really were like how you guys actually doing a bunch of stuff um you know in this case we uh this is
00:47:31.720 how we load projects to show your virtual machines and things and you know if it's a get we show you all of your
00:47:37.680 visible projects and uh otherwise uh if it's post we create a project simple as
00:47:43.680 that um so how many times can you reopen and the answer is you could do lots of times uh probably as this product grows
00:47:49.599 I would guess there will be hundreds just I mean we want want to build 10% of the features but that's still a lot of
00:47:55.839 pages um but it's a fair question why do things that way and it's actually just a
00:48:03.839 lot faster um some people who have used Roa I've seen use one Roa app to make
00:48:09.800 zit work work uh and I was a big fan of Zite work in a previous
00:48:16.319 um version of this uh but I was looking
00:48:21.520 into why things were done this way and I realized that re like there's special reloading code that makes has branches
00:48:29.119 extremely I mean it makes it it reloads extremely fast so since we just had a talk about how fast you can it your
00:48:35.559 application uh it really matters for the reloading time he down here uh 50 milliseconds compared to multiple
00:48:42.200 seconds uh and you can see here that Roa in general Jeremy who's also I believe a ruby committer is very aware of the
00:48:48.880 second order effects of what he's doing on Ruby performance so as a result pretty much anything he writes is very
00:48:54.559 fast for the functionality you get here it's cons considerably considerably faster I don't really use Roa because it's fast I was actually okay with
00:49:00.680 Sinatra but it's always nice when things are
00:49:06.640 faster okay does anyone have questions about R Roda did I make it very
00:49:11.960 confusing sh
00:49:18.520 cohort your class iner from R and then you reopen it and it doesn't inherit from Roda like I know it works like
00:49:27.839 well I mean it's really just defining one class in 10 files right because it runs the hash branch block and it just
00:49:34.440 runs it over and over again it does each time you give it kind of its name I mean uh because you know when you
00:49:41.480 reopen classes it's our own application class it's not in Roa but we reopen our own class continuously does that make
00:49:48.119 sense like we have 13 files all of them Define one
00:49:55.400 application so I don't know usually like if I say forance let's say I say user
00:50:00.680 inherit from application record if I reopen user I have to inherit from
00:50:06.559 application recall as well like uh sorry com again no like you know
00:50:13.680 like you you in anyway anyway anyway anyway oh well I mean it ends up being
00:50:19.720 pre repetitive uh it just so happens that for imp Ruby implantation reasons
00:50:25.000 that you can just reload hash branches is very accurately so as it turns out um
00:50:30.359 there's also a project that he writes called rack unrel loader and um it has
00:50:36.160 it gives you more control over the reloading behavior and That's essential to making that work and I actually
00:50:41.559 switched from Zite work to that but it required a little bit of programming for me so anyways this is the weirdest part
00:50:46.839 about Roa I think is larger programs use hash branches uh and open S class over
00:50:52.319 and over again it's a little bit unusual besides that I don't know like once you get used to it there's nothing
00:50:58.040 really I mean I don't know it jumps here and then you can do your code it's fine
00:51:03.880 you know I mean it's kind of in the Sinatra family of design conceits is that does anyone use Sinatra anyone all
00:51:12.160 right great does this look familiar or kind of okay this just tracks at all okay good any other
00:51:21.040 questions it was designed from Sinatra as the base of it must be better than
00:51:26.839 like so it came from someone who liked Sinatra huh bridgs using Roa for their
00:51:33.599 back end oh really yeah think okay it's good right yeah exactly you should
00:51:38.960 consider using it we'll get into why you should consider using it there are besides the sheer expressiveness of it which frankly we barely use because we
00:51:45.319 just kind of do the same thing because that's the good thing you repeat a model that works and is concise okay so why Ruby that's kind of
00:51:52.240 getting into that um so now that we spend some time some code uh as one does
00:51:57.760 uh I want to talk about Ruby uh so personally I haven't ever given a talk at Ruby conference I just kind of used
00:52:04.760 it um I found it practical uh and I always reviewed
00:52:10.440 Alternatives every time I had a new project to write which so far this is the fourth one and nothing looked as
00:52:16.000 practical so I kept writing Ruby um and as was alluding to earlier
00:52:21.119 some people they're surprised they're like you know investors are surprised people who write Ruby are surprised
00:52:26.960 people who don't write Ruby surprisingly or less surprised people write Ruby have a lot of anxiety about
00:52:33.559 popularity um which maybe you'll feel better about I don't know if you have that
00:52:43.799 um yeah I mean that's what this is about okay so let's I want I kind of want to look for I never written any rails I
00:52:50.559 don't know a single thing about rails I've never seriously worked on a rails application and in fact it wasn't even really my uh choice or decision
00:52:57.440 it actually to do with one of the people or two people in the acknowledgement section um so I kind of want to look at
00:53:02.480 this stack where I have this very I try to be value neutral legend about key dependencies and things I used in those
00:53:09.000 four projects and there's Ruby SQL Sinatra postgress and then 2024 there's that's like you know 13 years ago and
00:53:15.960 then 2024 there's Ruby SQL postgress RTO and rodo um okay so what's different uh Ruby
00:53:23.359 was hot no one questioned you for using it for anything but you know things were might be very strange uh in 2011 and I
00:53:30.799 think it's uh hard to relate but in 2011 postest was extremely strange like the
00:53:36.000 fact that like at Heroku people say you know rails is in my SQL project and every once in a while there's these
00:53:41.760 annoying bugs that happened and you're a rails company so what the hell are you doing uh why are you rolling this
00:53:47.200 Boulder uphill and um investors because I worked at a previously a fork
00:53:52.480 postgress company they would say well maybe if you based on my sequel you'd be more successful
00:53:57.720 um so in my view like my weird Factor has basically just switched places into two dependencies and maybe got even a
00:54:03.440 little weirder because I think sonra still has a little bit more you know history and knowledge than R up and the
00:54:10.599 question is uh you know did it really matter to how I perceived the engineering of either project and its
00:54:17.119 effect on my life and uh the short answer is uh no that's why when people
00:54:23.079 said oh it's weird you're doing that I said doing what uh I was just doing the same thing
00:54:29.359 um so if Ruby still is very good then why did it become weird for people uh
00:54:36.520 and did something bad happen and frankly I don't know uh because I never get much
00:54:42.079 thought to being popular I was very used to using unpopular dependencies unpopular databases unpopular web
00:54:48.640 servers unpopular RMS right the only thing you know I only get one popular thing at a time maybe two if you count
00:54:53.920 Linux sort of popular uh um in fact I would say that my life has
00:54:59.680 basically gotten better which is one reason why I stick with the project and um I think one thing that's important to
00:55:07.240 maybe understand about you know I mean you could say me personally although it's not personal is I came from a very
00:55:14.720 different set of priorities uh than Ruby I in 2011 I came from the postgress
00:55:19.760 world postgress and Ruby were not except in Japan not yet married um and uh you
00:55:25.319 know postgress is a very conservative project uh and that was that was not
00:55:31.520 what ruby was in 2011 um it you know like 18 to one n was very
00:55:39.520 painful and um you know rails was always breaking
00:55:46.000 stuff uh I mean it was just not it didn't really seem like the right fit uh
00:55:51.520 intuitively um but over time I think maybe my
00:55:57.119 perception of it is just very different than people who have been doing rails for a long time uh so let's look at the common
00:56:04.000 interpretations of Ruby uh some of which are laudatory some of which are the
00:56:10.000 opposite and some of which maybe are both or come from the same thing and people often use terms like inspired
00:56:15.920 artistic or you know romantic terms it's you know productive uh about happiness um they also say it's slow
00:56:23.960 okay it's still a little slow all right I'm not going to it's not like as slow as it was but it's um you know it's not
00:56:29.079 the fastest thing or and maybe less goodly it was wild or in principled um
00:56:36.280 and that maintenance was impossible and it's good for prototyping but do this ring a bell to anybody does
00:56:43.039 do you hear this a lot yeah okay see see some nodding um and that's really not the lens at all
00:56:50.039 which I executed my Ruby life uh so I would like to suggest or perhaps have
00:56:57.520 you think a while about a reinterpretation of what ruby is good at and in my mind it is stable it's
00:57:04.559 rigorous or it's useful in rigorous operations it is prudent it is quite
00:57:10.079 restrained and it's economical and yeah it's still a little bit slow I'm sorry it's not the best thing but it's not the
00:57:15.480 worst thing for a certain kind of work um and some aspects of the slowness are hard to fix actually come come into the
00:57:21.559 advantages that's what makes it so devilishly difficult uh so i' like talk about
00:57:26.760 language stability and restraint so in 2011 I started buying Ruby and you know
00:57:32.039 there's 1819 and there's like rails is breaking all time and then um but around 2013 I think this is a key year keyword
00:57:38.640 arguments were introduced to the language and then it didn't change a lot
00:57:43.680 keyword arguments like at the moment you reach the stability of course you don't know it because next year there could be
00:57:49.160 something else but there wasn't uh keyword arguments not only made the language better and it's fairly
00:57:55.359 conventional feature it also started slowly to make code be written in that way so code started to normalize the C
00:58:01.799 arguments and I thought that was just an improvement rather than throwing hashes everywhere
00:58:07.240 um and then things kind of stopped 2013 is a very important year I think in this story uh and in 2016 I guess the Ruby
00:58:14.760 core people decided that actually working on the less legible very difficult system features like
00:58:20.599 performance and multicore were important and Ruby 3x3 begins and I'm pretty happy with that because like okay you know I
00:58:25.880 basically okay with the language but faster is good and you know probably need to figure out how to do some code generation and in 2021 uh yit got into
00:58:34.280 Ruby and it's not only was The Interpreter faster over the years but that made certain workloads considerably
00:58:39.440 faster it's not as fast as JavaScript uh you know compilers with like a jillion Engineers on it but it's pretty good um
00:58:46.920 aside I'm actually very impressed with Shopify they produce surprisingly good open source artifacts uh I've used
00:58:51.960 tapioca as well I don't use survey right now but the previous one did they seem to have a knack for producing Things
00:58:57.720 That Go Upstream sorbet if you notice is very captured by Stripes priorities um you always feel like if
00:59:03.839 you get a new version of Ruby that works it's like a charity somehow um I'm just waiting for the day
00:59:09.839 when it doesn't happen uh but somehow you know I don't know what they're doing but they're very good at it you know
00:59:15.799 just a little shout out I guess um besides language stability there's
00:59:21.119 stability and key libraries here's the timeline uh 2007 sequel actually it's not not written by Jeremy Evans to begin
00:59:27.359 with uh it's written by someone else he tends to do this he adopts other people's libraries with he thinks good ideas um by the time we started using in
00:59:36.359 201 that's right you know it's already four years old and 2014 he has Rod off
00:59:42.079 to his little Empire and then uh or sorry Roa and then the year after that Rod off
00:59:48.599 um now it's impossible not to discuss this man uh while actually understanding
00:59:53.799 the situation uh he maintains all of the and he has a lot of presentations on all of these and there's a reason why they
01:00:00.680 all work together normally micr Frameworks you know you glue things together they don't really I mean if they work together this year they may
01:00:06.000 not work together next year well he does all these um we were actually so puzzled
01:00:12.000 within one year of using SQL that we invited him and this is the only person we've ever asked to do this uh from
01:00:18.240 Department of data to give a talk at Heroku as to what exactly was your developed
01:00:23.960 methodology um you should review his talks especially about his work at the State uh and the
01:00:30.920 libraries uh carefully and there's a reason for being careful because if you
01:00:36.039 blink you'll miss something very important because he's kind of doesn't
01:00:41.160 like to you know pump up his accomplishments and um here's this
01:00:47.160 little phrase as not focused on all this interview where he says it gives me a sense of accomplishment to be able to fix bugs and rubies that have been known
01:00:53.559 but unfixed for many years that's a situation doesn't happen my open source projects now you must think surely this
01:01:00.480 is a matter of degree or interpretive statements fact check
01:01:06.599 true always zero always hours days sometimes if it's really hard and you
01:01:12.119 might think well 1,200 closed that's not must be because no one uses this I'm like well I would think that too but let
01:01:17.920 me tell you it's the weird one where it's just has a lot of features it's quite complicated and very few
01:01:23.520 bugs uh he does this for all of his projects He also answers all the mailing lists all discussion threads all the
01:01:29.680 stack overflows all the irc's and he also maintains a multi 100,000 L web location at the state I don't really
01:01:36.680 know how he does it um anyways yeah it's I've been trying to
01:01:42.359 figure out how he does his thing for like the past 13 years uh also he has monthly releases
01:01:48.799 this is squel and every month there's a release they're not all big in fact they're all
01:01:55.079 very small and then I just click the yes button on dependabot and then nothing happens it's great people say oh rails
01:02:03.319 is new rails is coming I said I don't care you know uh I think
01:02:09.200 I've had five regressions sorry three regressions maybe one year every five I'm waiting for the next one every five years maybe
01:02:16.520 uh usually pretty small uh yeah it's very weird I mean I think
01:02:23.680 to appreciate you have to appreciate the weirdness of just how unusual this is uh
01:02:31.200 in any kind of software in any language uh the other weird thing is plugins in his uh software plugins are
01:02:39.160 not peripheral pieces of behavior they're closer to configuration or options this is sqls plug-in list I'm
01:02:44.359 not sure if I got all of it because I thought it would just be completely unclear it's actually a web page that this is a screenshot
01:02:49.400 of uh there's a lot in there does all sorts of options all sorts of optional things he's very sensitive to
01:02:55.039 distributed cost that's why Ruby libraries are quite fast so he only loads code you absolutely want to need
01:03:01.039 and sometimes actually this is one area where generative AI has been very helpful sometimes says hey there's a
01:03:06.640 ruby plugin for that does what you want I said or for SQL first party I said really and then you know as we say it at
01:03:13.799 work Jeremy EV thinks of everything um something important to know use those plugins they're not
01:03:18.920 peripheral they are like configuration almost uh now the problem with
01:03:24.000 microframeworks is they don't really have any opinions on how work together and I guess someone uh asked Jeremy to have an opinion and so look up this repo
01:03:31.119 it has the somewhat uninspired name Roa SQL stack this is a link by the way if you go to the you know you can click on
01:03:37.599 it if you find the slide okay so I would like to go move on
01:03:44.039 from like the personal because it is very important to understand this Trio projects uh how it's released and why
01:03:50.039 they're being cohesive and also their bizarre level of quality uh truly a mystery I mean actually uh so but one
01:03:57.599 thing I copied from him which he himself copied in SQL from the previous maintainer is 100% at the time line
01:04:03.960 coverage and then uh eventually Branch coverage when Ruby could support that uh
01:04:10.839 now when I was taught computer science was I taught when I was educated when I
01:04:17.640 when I was singing through classes there we go I was singing through classes in computer science and the conventional wisdom was okay once you do 80% or
01:04:24.520 something like that be in coverage you get marginal returns uh that's probably true but something very special happens
01:04:31.640 at 100% where any piece of code you write it's very clear immediately what is not tested the inspection process
01:04:37.960 becomes trivial and actually in Ruby more so than most languages because of dynamism which also makes it
01:04:44.400 slow uh you're able to inject um pretty much whatever you
01:04:52.039 need anywhere to get the 100% fairly inexpensively uh so I would recommend giving it a try
01:04:58.200 and in fact I would do it a file at a time if you have a big application just choose one file put in the 100% regime
01:05:04.359 and leave everything else alone at one file at a time it's much more important to automate inspection than it is to raise the arogant number Pro tip perhaps
01:05:13.000 uh so I've been doing this since cus it's easier than you think and I think it wor worth more than you think
01:05:20.200 too when I tell people this who don't use Ruby they say is this a crutch for not having stag typing
01:05:26.400 and the answer is no uh and I think I could say the answer is no because not only did I uh write
01:05:35.480 you know static PR static languages I also wrote a survey program for a while and what I realized is that test you
01:05:42.640 static typing can catch a class of bugs but really when you're writing you know control plane software for you know databases VMS you get all sorts of
01:05:50.079 really obscure behavior and you need to be able inject faults in very weird combinations any way
01:05:56.520 everywhere affordably without torturing the program being tested you will never be able to meat the quality level if you
01:06:03.240 mercilessly add those tests from lessons in production which are very expensively
01:06:08.319 learned um so no I think getting the dynamic Behavior exactly way you want it is actually extremely valuable so it's
01:06:16.279 not a crutch for laack typing so try doing 100 if you have quality
01:06:21.520 priorities is stag typing interesting for Ruby I think it is for cross referencing code is big I use emac
01:06:27.279 because I'm old uh and LSP and it does improve the economy of like typos and
01:06:32.760 simple defects but you just can't get the really complex stuff without the tests okay I'm getting close to how am I
01:06:40.359 doing on time hopefully all right uh I like to discuss rigor and economy and
01:06:46.200 operations people often associate rby programmers as being very loose I'm not sure if that's a 2012 conceit but it's a
01:06:54.039 common thing and my statement is the reple is
01:06:59.200 key uh the reple is essential for teamwork not taking an archival because
01:07:05.599 you can show a very complete transcript of exactly how a decision was made or an operation was performed both input and
01:07:11.839 output and can convey it to your colleagues and have it archived when you're going over how wrong you
01:07:17.400 were um instead of waving your hands or working through and I see this happen
01:07:22.559 like go programs for example like in you do SQL statements because it is an interpreter to control the program just
01:07:29.400 use the symbols in the program you hack every single day this is this unification I think is key to the cost
01:07:36.119 effectiveness of all four operations um also you can do reporting
01:07:42.839 it's pretty complicated this is purposely really really small because it's actually a very complicated report
01:07:48.400 where I'm doing stuff with the GitHub API and the database and yeah you can do
01:07:54.640 pretty complicated stuff in the rapple that's throwaway and very cheap very important for figuring stuff out rigor
01:08:00.559 it's actually very good in Ruby to write to operate systems uh that need to be rigorous uh you can learn a lot more a
01:08:07.599 lot more cheaply and Ruby is just much better at
01:08:12.880 this than similar languages um and I want to discuss a
01:08:18.799 little bit why it's actually very short near the end like there's other languages reples they kind of have a similar philosophy why is it better
01:08:26.159 and it's blocks and you say what is this 2009 you're going to tell me about blocks uh sure when I first encounter
01:08:33.719 blocks I thought they were an interesting variant of Lambda uh you know like when you take scheme and okay
01:08:39.480 don't do that anymore but when you learn some you know basic lamb to calculus stuff they're like oh you know these are
01:08:45.480 a weird Version of First Class functions and in fact there's also first class functions and you think ick you know
01:08:51.719 this language has two very nearly similar things that are not the same and that's not orthogonal and you're like
01:08:57.480 this breaks all design rules and what is this garbage okay that's me from like 2011
01:09:03.839 um but I come to appreciate that the way that they influence control flow a l complicated and the way they interact
01:09:09.960 with methods being more special than just you know like a PL like a PL theorist Lambda calculus is actually
01:09:16.679 essential to how they work uh that and they are wh space and sensitive enough to let you Cate stuff into the prompt to
01:09:24.839 make a humane to chain very large Expressions so blocks that's really the reason I do it um so the end uh and
01:09:33.480 conclusion I think Ruby fits my choice of problem very well and has gotten
01:09:38.719 better over the years uh concision with blocks uh cap you know being able to
01:09:44.600 capture knowledge through tests from horrible things in production uh very Rous documentation
01:09:51.640 and teamwork through copying reppel transcripts and very high quality of key libraries du to one really weird guy uh
01:09:59.199 you might be surprised how often that happens there's a guy named Tom Lane on postgress he's kind of essential
01:10:05.360 um and all those virtues are really about you know you could say oh develop productivity but it also translates to
01:10:11.199 revers reduced personnel and the thing about reduced Personnel is not only it cost less but software does not scale
01:10:17.920 linearly with Personnel more Personnel makes the software go mad one Personnel at a time so if you can cut 20% of your
01:10:24.760 personnel you a much more sane piece of software and um these are not I think
01:10:30.360 the standard ways to analyze Ruby they're related but usually people talk about expressiveness and things of that where I'm like okay you know basically I
01:10:35.760 can get more functionality in smaller space and I think higher stability than
01:10:41.040 what you get in I don't know rust or typescript I mean typescript I feel like everything changes every three years um
01:10:48.719 and you know maybe that's kind of not what people were thinking in 2013 when people formed their opinions
01:10:54.560 but that's how I've experienced it thank you we got time for questions does anyone care okay the slide oh uh
01:11:02.320 slides.com FDR FDR like the president
01:11:09.760 twice uh other questions any of you use SQL before
01:11:16.600 that's probably Roe okay oh okay there's like four did you any of you realize how weird it is as a software
01:11:24.320 artifact any of you any of you invite him to give a talk at your place you should do that
01:11:30.120 I mean he might actually do it my name is Vladimir working with Arena martians
01:11:35.360 I don't have like about slides for this Meetup you know that's more like for conference stuff and for this event I
01:11:42.440 would like to be less formal uh but actually the number of people is greater
01:11:47.960 than at some conferences which is like a bit not stressful but anyway
01:11:53.280 uh yes I'm you know I'm a rails fan uh you know I have a lot of rails
01:12:00.400 stuff uh and today I'm going to make rails kind of suffer a bit and you sorry
01:12:08.440 but uh we will get through that okay let's talk about rails and bus web
01:12:16.239 assembly okay uh we're going to progress slowly so rails rails is a web framework
01:12:24.760 uh that's a actually quote from the official website right uh what's interesting here is like everything
01:12:30.719 needed to create database backed web applications interesting right uh if it
01:12:36.679 sounds like you cannot create a rails application without a database which is not true but yeah raise your hand if you
01:12:42.679 ever created a rails application without a database yeah you see like a lot of people doing that I think we should tell
01:12:50.199 uh you know rails Foundation to remove this database backed web applications from the website we're losing our you
01:12:57.679 know uh audience okay uh web assembly or vas uh I don't know how to corate it
01:13:04.440 actually it's C but let's go with f um okay it's a binary instraction format
01:13:09.960 for St based virtual machine you know how we kind of starting to make everything more complicated in this talk
01:13:16.679 from like web framework database back applications and write into virtual machines instructions and all that stuff
01:13:23.920 and that's good question like what do these two may have in common right like
01:13:29.639 uh why do we need them to play together so uh let's start with the
01:13:36.000 second part and talk about why we should care about web assembly at
01:13:41.440 all I I'm a bit biased because I've been working with this technology for a while
01:13:46.880 and I don't know how to answer this question honestly so I asked a good friend of mine uh to tell me some like
01:13:54.560 you know short explanation like why we should take a look at the web assembly why we
01:14:00.159 should worry about it and so on and there is some interesting points here let's let's let it finish uh before we
01:14:08.880 jump into the bit that you know uh I was surprised the most yeah yeah pushing the boundaries of
01:14:16.480 what's possible in web some items they're kind of correct we're going to talk about them but this even python you
01:14:24.080 know even python could could be compiled into web assembly in used anywhere I like why why like okay I understand like
01:14:31.480 C rust whatever all the compiled languages but even python so that's why
01:14:37.239 I'm here today to get rid of python and replace it with Ruby and rails and
01:14:42.639 demonstrate you that actually that well maybe even make more sense than putting
01:14:47.719 python everywhere stop doing this okay uh web assembly pushing the boundaries
01:14:54.840 what is like three key features of web assembly as
01:14:59.920 a how would suppos like instruction uh format whatever for ver
01:15:05.600 stack based version machine so basically it's intermediate code and we're going to talk about it in a minute uh using
01:15:12.280 web assembly gives us performance portability and safety by Design but it's actually could be easily
01:15:20.120 uh broken especially with newer editions uh what we talk about perform
01:15:25.239 performance and portability uh we need to take a look at
01:15:31.199 how web assembly Works what is it so web assembly is this uh
01:15:37.000 wa module so instruction set uh your program compiled like transformed I
01:15:44.560 would say like it's intermediate b u it's not even binary it could be binary anyway intermediate
01:15:50.560 representation of your program or in any language but uh compiled into to instruction sequences uh for stack based
01:15:58.880 virtual Machin anyway so it's kind of intermediate presentation that could be put in some was runtime that could be
01:16:05.199 there are many of them and the performance comes from the fact that the runtime can use these instructions and
01:16:13.120 transpile transform them into machine code and that's how you achieve performance that's how uh Bas in the
01:16:20.920 browser work works much faster than JavaScript that's why it's used uh and many cool uh projects like I think the
01:16:29.159 most famous one is figma for us V in the browser so that's how they achieve the
01:16:34.840 performance by using vas there are many vas round times outside of browsers yes
01:16:40.679 web assembly is probably the primary target and that's what you think of when talking about was but we also have other
01:16:47.520 runtimes tons of them they all have pretty much similar names and you
01:16:55.080 probably heard of some of them but uh mostly they used under the hood of the technology use somewhere on the
01:17:01.440 serverless uh platforms maybe within other uh systems as embedded scripting
01:17:08.360 engines and so on and um another thing to talk about so
01:17:13.520 there are many run times that we could Target and most of them could be embedded into other systems as
01:17:19.920 well uh the big thing uh uh like I think the big step step forward was made uh
01:17:27.560 like uh four years ago about with the introduction of web assembly system
01:17:32.800 interface standard that's basically was the movement of of from of going away
01:17:39.199 from this browser based philosophy to being a universal format for pretty much
01:17:45.600 anything because originally web assembly was buil for browsers like to so performance and sandboxing problems but
01:17:51.400 then uh it turned out that it's useful as a embedded and sandbox environment
01:17:57.280 pretty much anywhere but and we need to make the API for the runtime independent
01:18:03.320 of the JavaScript run time that's how system interface appeared and um I'm
01:18:09.080 talking about it because now uh uh that's something that is related to Ruby
01:18:15.800 I don't think like u a lot of people noticed this part of the ru 3.2 release
01:18:21.880 note even though that was the very beginning of release note and pretty huge explanation what has happened but
01:18:28.320 Ruby got uh system web assembly system interface support and Ruby 3.2 that
01:18:36.440 means that now Ruby C code the one that we used to write Ruby
01:18:42.719 VM MRI uh I'm specifically talking about this one uh it now could be compiled
01:18:50.600 into uh uh format compatible with this new standard that required some changes
01:18:56.480 into Seco like some adding some hacks around it um I have no kind of a
01:19:02.239 relation to it I only read W code not write it uh but anyway that made it
01:19:07.440 possible to compile Ruby itself into web assembly the whole Ruby VM and and use
01:19:14.120 it for example in the browser that's what the first use case like running IRB
01:19:19.159 in the browser and that's how we got better support for Ruby and the on web
01:19:24.760 assembly because we cannot say that that's the beginning because prior to that it was possible since Ruby is
01:19:30.199 written in C and it wasn't great and still is a project called mcrip and
01:19:36.120 which allows you to compile pretty much anything written in C C+ pass into web assembly uh and it's
01:19:45.520 I don't know what like right now it's also Universal but it originally targeted browsers as well but that was a
01:19:51.239 bit hacky way of like compiling blackbox thing into web assembly now Ruby itself
01:19:57.600 knows about web assembly compatibility it makes it more efficient and less
01:20:02.960 hacky to use it so Ruby on R so we can run Ruby on web assembly why why do we
01:20:09.719 need it like okay that's a fun uh you know achievement I think that's cool but
01:20:15.960 what it matters um there are many reasons for running Ruby on web assembly
01:20:23.960 uh we can build interactive playgrounds Learning Materials we can embed and so on and so
01:20:30.080 okay I'm not going to recall it everywhere I want to highlight the last item from the list it's uh prism Ruby
01:20:36.080 parser it also shaps as a web assembly model it it itself is not written in
01:20:41.360 Ruby it's written in C but that's a good example of web assembly portability
01:20:46.840 because now you can if you want to pass Ruby code in your language it's highly
01:20:52.199 likely that your language already have support web assembly runtime you can load prism uh vas into your runtime and
01:20:59.520 parts Ruby code without using Ruby all and it's tiny web assembly model that you can use anywhere like in Java in
01:21:08.080 hcll uh rust whatever so you can parse Ruby with any other
01:21:13.560 language okay um about Playgrounds there are already many projects using Ruby in
01:21:19.840 the browser the official try Ruby Lang org website where you can just go and
01:21:25.480 play with Ruby uh and the web browser and a couple of uh more interesting
01:21:31.199 project I would like to probably demonstrate right now uh let me just figure out how to share my web
01:21:41.280 browser okay I think I should stop the presentation
01:21:46.960 and yeah
01:21:58.679 oh whoa sorry
01:22:07.080 that's um going to bit tricky maybe oh yeah that's better
01:22:15.280 right can oh nice wow this is great
01:22:20.800 developer experience so this is Ruby in the browser and what's good about this particular uh okay I need to navigate
01:22:35.280 here yeah okay
01:22:40.920 we yeah no okay Ah that's another
01:22:46.400 oneor so uh what's cool about this project it's not just running Ruby the browser it's uh also supports installing
01:22:54.159 Gams right in your browser using bundler so hey we have
01:22:59.280 oit and we can run bundle install it will probably and you see you
01:23:05.400 know the logs you usually see every day when you run bundle install in your like system right but it's all happening
01:23:11.719 within the browser there is no server behind this uh functionality and we can uh okay go to
01:23:19.840 the main RB okay please someone tell me your GitHub nickname and we're going to learn something about
01:23:26.400 you maybe your company your name
01:23:32.920 anyone stand
01:23:39.679 are have you that's it that's you T of tons of fun okay please
01:23:50.400 type thank you
01:23:55.719 oh tons of fun okay I'm not responsible for the content
01:24:02.320 of this account sorry just for the record uh X let's round the code uh yeah
01:24:08.199 retry Mew wow that's interesting okay let's wait for it to run why it's so
01:24:17.040 slow yeah tons of fun it's just cool company Neil that's not true well yeah
01:24:24.760 we can go install this parad try Jam if we want but it works you can play around
01:24:30.440 with this uh I'm going to show some cool examples later with this project so that's an example of running
01:24:37.920 Ruby V in the browser and also kind of a implementing the typical flow of using
01:24:44.400 Ruby installing gems like somewhere in the virtual F system uh and running code
01:24:51.800 uh let's take a look at and some other examples yeah we have
01:24:57.840 this Ruby next okay now we have the same problem so that's one more time what is
01:25:05.920 Ruby next that's a that's okay anyway so rubex is a transpiler for Ruby so we can
01:25:13.239 take uh any Ruby code written for future Ruby so here we for example use it it's
01:25:19.800 a better matching we can Target some other uh version like 2.5 we can call
01:25:25.159 transpile and we can see what's going to be H yeah transpile P matching looks ugly but it works uh believe me the
01:25:33.840 instruction sequences for the real pet matching looks uh even worse so if we
01:25:39.880 change the version we can see that okay that's much better we can even run this code and we have some interesting
01:25:45.960 examples like for example I like this uh okay if not operator have you heard this
01:25:52.440 joke about C adding if Operator just because like if not is not cool so we
01:25:59.159 can do this in Ruby and the cool thing about this example that we use refinements so just I want to highlight
01:26:06.040 this is real Ruby VM in the browser there is nothing like limited almost we're going
01:26:12.480 to talk about limitations in a minute but it works keep on working yeah okay it's not it's Friday no it's not Friday
01:26:20.320 anyway yeah there are other some some other examples we're going to talk talk about it next month in Japan like
01:26:27.480 memorized analyst methods how do you like it do you know what it's going to be how it's going to look like it's
01:26:33.280 going to look like this is just a instance variable mization uh embedded
01:26:38.320 into method definition there was original proposal it was rejected no worries so it's not going to come to
01:26:44.040 Ruby but that's fun thing to play around with and we can do this not leaving your
01:26:49.440 browser okay uh let's
01:26:55.719 okay Switching to this one oh the recording going to be fun
01:27:02.440 um oh yeah so that was about
01:27:08.440 playtime lauran Ruby uh couple of cool projects uh already available almost
01:27:15.440 already okay available online uh so Ruby K by Jim recently published as a web
01:27:21.560 version using the same Ruby bom techniques and you can play it online you can learn Ruby fruit Ruby Warrior
01:27:28.880 who knows what ruby Warrior is who played it okay uh let me show you
01:27:35.679 something because that's hasn't been announced yet because I just CED it you know uh
01:27:41.520 yesterday um I think I need to do screen mirroring let me figure out how to do
01:27:48.360 that um uh
01:28:05.000 okay okay nice and now we
01:28:13.600 have so um I think it's just death Lo
01:28:21.159 host yeah oh this is make it better this is web version of
01:28:28.000 Ruby Warrior it's a game also a that aims to teach your Ruby let me show you
01:28:33.679 how it works so it's loading uh yeah you see we already have some stuff here I
01:28:41.760 played okay let me restart and with a new player okay
01:28:49.520 o c no okay anyway um yeah so what is
01:28:55.719 Ruby Warrior it's kind of text base game when you write code for your Warrior to
01:29:01.840 react to some events or and reach stairs in labyrinths so uh this one is pretty
01:29:07.679 simple Warrior walk and we just need to walk to the stair let's run we can see it's so
01:29:16.239 it's down here so it's working and boom we won Next Level we need to fight all
01:29:23.679 let's play one more and we can continue with our interesting and boring
01:29:30.520 parts so I actually reach on level five
01:29:35.600 haven't made made it to the final uh uh you know BS or
01:29:42.480 whatever is going to be okay otherwise I guess we need to
01:29:50.760 attack and let's run uh we can take a break and put it on P something
01:29:57.520 that's not available actually in the original game um I will share the code
01:30:03.080 maybe today or tomorrow I'm going to open source it because I think it's fun because you can play it so here we're
01:30:09.560 fighting with some sludge I know have idea it dies and we go forward and we
01:30:16.880 won again so the thing is uh let me show you the code probably because uh to
01:30:25.560 highlight how it works originally it's a common line based game so you just run Ruby warrier and update your file in
01:30:32.440 your file system and it kind of shows you the step the progress and uh with this web version
01:30:41.119 what we did is basically what we're doing is load in the game and like let's show the play
01:30:48.119 Method I think that's most interesting okay
01:31:00.679 so what I'm doing I'm just running within the virtual Ruby machine this Ruby Warrior Runner it's a entry point
01:31:08.199 for the CLI and passing some uh arguments to it and some
01:31:14.760 stops for standard output and standard input to interact with them that's
01:31:20.199 basically I'm not writing any code to implement the game itself I just took the game written in Ruby for the command
01:31:26.480 line and added a couple of like monkey patches to extract the output and that's
01:31:32.239 it we can play it in the browser with I think kind of more um convenient interface okay let's
01:31:40.159 go back yeah if I do it like this we s some
01:31:47.639 examples so that's probably mostly pad projects right but they still fine okay
01:31:54.040 five time we did it demo time okay yeah
01:31:59.199 so now I would like to start the actual life coding and show you how to get
01:32:04.679 started with Ruby on uh and for that I chose another
01:32:10.199 project another cool project that's all also kind of distributed as a common
01:32:16.840 line utility uh it's a it's called ctran ctran it's named after some jazz
01:32:24.960 musician and um it helps you to figure out you know scales chords for different
01:32:31.280 instruments and just print it print it uh to the output like uh we can try uh
01:32:37.480 Ruby vas it's a project U created by Ruby core and turn it into web vers uh
01:32:43.960 to into web application and uh for
01:32:49.440 that okay the boring part starts I'm going to start a new project because I
01:32:56.320 already have one completed cult
01:33:01.800 live so what we need what do we need to start let's start with a jam
01:33:14.159 okay maybe copilot knows something no no it is okay I going to just copy it so
01:33:21.880 what we need is Jam call train and let's install it I how
01:33:30.679 to
01:33:38.880 okay see how it works so now we have it installed and we
01:33:46.800 can uh normal
01:33:52.840 an
01:34:02.280 okay yeah so this is for example what it can
01:34:10.840 do different cord I know which is your favorite cord so we can communicate with
01:34:16.960 it and it shows as kind of some music theory so yeah there are a lot of stuff after
01:34:24.280 you what I want to do I want to turn it into B application just to sh in qus we
01:34:32.320 okay we can close this one and we can close this one oh that's actually rubic cones I mentioned
01:34:38.080 before so you can check them online so this is stack
01:34:44.280 blades I promised to show you some stack blad stuff what is St blades uh do we
01:34:50.639 have a reserved slot for announcements for after my talk because I don't we have someone from seglet here I'm not
01:34:58.040 the best person to explain what is it but actually it's a fully in browser IDE mostly targeting right now JavaScript CR
01:35:05.520 times but uh not only but mostly so it's
01:35:10.920 it us a cool feature called web containers I guess it's also built on web assembly and allows it to run both
01:35:18.560 uh JavaScript server and a client within the browser again without leing it so
01:35:24.440 it's like it's cool I'm using it for my JavaScript stuff all the time so I added
01:35:30.639 some example like stop to to avoid like dealing with um you know JavaScript CSS
01:35:38.960 and and so on so we have the interface we only need to connect it to the rails
01:35:44.840 applic or Ruby not rails Ruby application to show the actual meaningful information here let's figure
01:35:52.199 out how to do that so we need to um turn
01:35:59.080 our Ruby application into B module I'm going to use Ruby vas Jam here uh which
01:36:12.040 rbas which gives us some tooling to pack Ruby application and Ruby and
01:36:18.400 dependencies okay it's Ruby V guess
01:36:26.119 yeah so uh the basic command we can run here
01:36:31.920 is um the command itself is RB vasm code
01:36:37.440 build and some output file let's go Ruby vas why
01:36:42.639 not oh it's G to take okay it's G to take quite a time uh let me make it a
01:36:49.480 bit faster by copying some intermediate code uh from existing
01:36:59.600 projects so what it does it it download the Ruby source code uh at some
01:37:06.199 additional utilities and compiles everything including your dependencies into single vas module the process like
01:37:14.320 for the first cold start uh is not that fast but it's
01:37:21.119 much faster when you just iterate wait on your own code after you installed all the
01:37:26.360 dependencies okay still copying okay and now it's going to be faster let's see
01:37:33.360 yeah so we already have some stuff pre
01:37:39.119 compiled um why I want to show you all the steps because I want to show you all the pitfalls and problems you're going
01:37:45.639 to encounter around the way because you know it's not going to be easy uh but there are few things to know that could
01:37:53.880 help you to achieve pretty cool results so first thing yeah uh we need
01:38:01.480 I'm waiting for it to fail okay so we failed we failed because it tried to
01:38:08.080 compile uh some native extension and more specifically big
01:38:14.040 decimal the cool thing about Ruby vers is that it only tries
01:38:19.960 to like uh turn your Ruby code in dependency into V module it also tries
01:38:25.880 to compile native C extensions because some not every C extension but some C
01:38:32.159 extensions are vasm ready so we can actually compile them to vasum as well
01:38:39.920 and and if all the offers of gems with C extensions would think about vas a
01:38:45.480 Target we might have everything compilable into us but here we have a problem big decimal why I don't know why
01:38:52.199 actually I don't it's not my problem we need to somehow we don't need it actually for this project it's just a
01:38:57.520 part of the bundle because it's a default gem we can't tell rubby B to exclude default gems and have a minimal
01:39:04.840 version of Ruby BM but I don't want to care about which default gems I used by
01:39:10.679 this project or not so I going to hack around and the way to do that like very
01:39:16.840 dirty hack I just remove this from the jam file lock and let's try again
01:39:26.280 yeah okay that's that's cool that works um yeah so Herby B just what takes
01:39:35.800 a look at your jam file log because it it should be the source of truth but the
01:39:42.920 truth is not objective thing so we have a bundle a bundled uh application it has
01:39:50.080 all the dependencies we need to run cultr and uh we know the size the size
01:40:02.199 no okay uh I know why so one more the
01:40:08.520 size 55 megabytes that's just Ruby and a single dependency like in some default
01:40:15.679 gems there is a thing called B op or whatever so there are some tooling
01:40:22.280 around optimization further optimization of the instructions since we deal with instruction there possibility that there
01:40:27.800 are some there is some de Cod elimination possible not sure I haven't tried with Ruby don't think it's going
01:40:34.320 to work because we need to support the whole VM but anyway worth exploring if you care about megabytes H now we have a
01:40:40.800 bu modu what we can do with it uh before we upload it to stack blades uh we can
01:40:48.320 try it to run it locally and for that I'm going to use the tool called was time so was time is a also and then
01:40:55.880 another run time for web assembly so we can just uh call vas time run and then
01:41:03.119 we call Ruby vasm and then um that everything after
01:41:09.760 this Ruby vasm is basically the same command options that accepted by the Ruby command so it's calling Ruby vasm
01:41:17.520 is similar to Gard Ruby on your local machine and we can actually check first with Ruby so let's let's try uh running
01:41:33.480 train that's a bit tricky but we GNA fix it um and
01:41:40.840 yeah okay let me just copy the example code because it's bit
01:41:47.960 verbus okay yeah we also need this yeah that's so we okay let's this
01:41:56.280 no it's
01:42:16.239 I'm going to show you one more time so this is we this is how we okay um
01:42:24.960 who knows how to move it up in vs code I don't know uh but anyway let's sorry
01:42:32.239 about that so this is how we can run uh directly using rubby code this CTR and
01:42:39.119 um print the result in the output now let's do the same thing with our fast
01:42:46.080 module so last time run Ruby V we need to set up
01:42:52.239 bundler and I think everything else should be the same let's
01:42:58.480 see and yeah first run is kind of cold start while some time must compile our
01:43:04.679 model into machine code and then it runs whenever we're going to run it one more time uh it's much faster so it's like
01:43:11.239 native code cannot load bundler setup
01:43:19.119 why yeah that that that's slash is important actually let's scroll up a bit
01:43:26.760 uh where is the history we lost it okay okay yeah serious question who knows how
01:43:32.040 to move the terminal app so you're going to see it better because I think it's not
01:43:37.760 usable okay let me try to move terminal new window we can do oh
01:43:45.280 new window never tried it better because I think it's not like a
01:43:52.400 sample command for that okay let's try to build it one more time to see the output it's
01:43:58.560 going to be fast we have bundle ah bundle not bundler
01:44:04.360 okay that's I always H you should do something about it like you know bundle
01:44:09.760 bundler that should be or Ling this stuff or renaming to something
01:44:16.199 else okay and now okay we recompiling it again
01:44:27.480 yes uh let me try one more time to show that it's fast we have problem it's
01:44:33.480 cryptic uh kuna determine Os from host OS V yes so the library relies on some
01:44:40.679 UI library from Shopify which do some like uh Weir and high calculation of the
01:44:47.360 terminal based on the operational system and since we running not an operational
01:44:54.159 system it fails to identify what's we using actually so what I'm
01:45:02.320 doing where it is tricky okay
01:45:07.440 so which project it is wait don't minut um let me just copy the hack we need to
01:45:14.599 tell uh colr it's here yeah that our hosts is Linux it's kind of more like
01:45:25.320 B I think now we need to update our code a bit to include this
01:45:35.400 piece I don't worry about this stuff
01:45:43.920 um no oh okay it should be done before we require call train UI uh
01:45:52.040 callr c train c train is bit different thing right
01:46:09.040 okay slow down
01:46:18.800 okay yeah wo thank you
01:46:24.239 um yeah that's basically everything we need to run
01:46:31.719 our like everything we need to know about the implementation of our web service now we need to make this code
01:46:38.360 web compatible uh whenever we build with vum as is we get
01:46:45.760 the uh web assembly system interface compatible module but it has now know
01:46:53.520 of the host system which is Javascript our Target host system and it does not
01:46:59.639 expert any functions we actually cannot interact with it anyhow except from just
01:47:05.440 running it and like you know good old CGI way of passing standard input and getting standard output but that's all
01:47:12.080 we have luckily uh there is a gem called
01:47:17.880 JS not a bad naming good naming I think but anyway like JS I think it's fast JS
01:47:26.159 or whatever but uh we we need to add it to the bundle run
01:47:38.119 it has some C extensions which Define uh inert and out and expert interfaces for
01:47:43.320 our Ras binary and if we try to run this again with this new Jazz uh
01:47:50.880 knowledge of the awareness of our web assembly model it's going to fail um it
01:47:58.080 says like oh I don't have this iner canonical ABI whatever that's that's
01:48:04.560 because it's not implemented is Bast time Bast time is like pure V run time
01:48:10.000 without anything uh Beyond like basic uh CIS goals uh implemented but we need
01:48:17.080 this um interoperability with JS no problem we're going to upload this code
01:48:22.679 um um V model into stack blades and then we're going to run it with JS run time
01:48:29.760 because it has some interesting stuffs too
01:48:34.800 so let me check the time okay so what we need uh what I'm going
01:48:41.000 to do is uh something like that uh I'm G
01:48:46.080 to copy some boiler plate code from one of my previous projects because I want to write everything from scratch one
01:48:52.119 more time and we have some uh let's see rails and pass
01:48:58.119 probably yeah maybe this one so we have this
01:49:05.040 rails B assembly yeah okay that's enough
01:49:13.080 so let's add a new file call it c train culton and here we're going to do the
01:49:21.040 following stuff okay we need some dependencies did I add it down here not yet so for JavaScript part we need to
01:49:28.040 add a couple of things so we need to add Ruby B
01:49:33.080 vas I'm G to call it vas anyway um use npm here yeah npm install save there
01:49:44.719 no I'm not a JavaScript developer is it work going to work yeah nice and another
01:49:51.320 one is called browser Wasim it's basically the implementation of this
01:49:57.639 functions we need from the JavaScript because in JavaScript it's still uh the CL standard is not uh naturally
01:50:05.639 implemented fully at least it's implemented in njs by the way and other
01:50:10.840 njs like R times but not in the browser so yeah we have this stuff and yeah the
01:50:17.880 cool thing about stag blades is it doesn't allow you to upload files more than 10 megabytes at least for free so
01:50:24.520 that's why um I'm going to use AWS and download the file from there and let me
01:50:32.000 just copy the actual URL from the final
01:50:40.440 project and it's going to be this okay so we have our vas model
01:50:50.159 already available online we're going to fetch it and we're going to initialize the the default how can I how Okay the
01:50:59.639 default Ruby VM the default means like without any specific settings for it and then we need to write our code here we
01:51:08.920 need to move our hacks so we need to add
01:51:13.960 this host as
01:51:19.960 hack then we require
01:51:33.159 colors to paint stuff right we don't want it okay
01:51:44.960 uh we can even I don't know Define some Global function right uh like
01:51:51.639 show cord cord
01:51:57.320 representation so to not type all the stuff all the
01:52:03.000 time okay going to copy this code uh
01:52:09.920 put know we don't need to put we going to read it from
01:52:15.400 there uh okay
01:52:21.040 and here we have okay cor
01:52:27.400 representation so we have Ruby 3.3 under the hood so we can use this amazing
01:52:36.400 syntax what's what's else okay so we have a VM we want to initialize it and
01:52:42.440 we have a method to call let's see so
01:52:48.679 um let's keep so VM yeah right VM
01:52:53.840 let's add a VM local variable to hold a reference to the VM once uh we want to laely
01:53:01.800 initialize it on the first attempt of showing the hord and now uh so this is a
01:53:15.040 VM we just need to import in
01:53:21.520 it
01:53:26.599 MH yeah yes called like that D wait in
01:53:35.480 it and that's it and now what we can do we can
01:53:41.360 get present okay output just go output uh BM eval show cord and
01:53:57.719 yeah any strings
01:54:05.679 cord and representation okay and inner text
01:54:16.040 output let me think about it um that looks like that's it
01:54:33.719 try what's wrong with it you script TR how I run it ah death
01:54:43.840 okay and we have it here I actually don't know how to open
01:54:49.840 the amazing console in in with uh like embedded into stack
01:54:55.920 blades um but I want to
01:55:04.239 check oh no it's usable H okay this
01:55:10.199 one type error I don't see any
01:55:16.760 logs okay we lost you see anything okay let's try to
01:55:22.440 oh okay we we lazily do that yeah so where is our
01:55:31.239 output yeah oh it works anyway never mind it works we just needed to wait and
01:55:37.920 now we can like I see okay Guitar let's now let's open a new window because it's going to be much
01:55:43.760 better um it could be but it's for some reason it's okay
01:55:50.239 let's try to restart I think it's something about authentication with this new window
01:55:56.960 right no let's try again
01:56:04.880 no the whole app okay thank you for your
01:56:12.880 support Yeah so basically what we edit is just the buet code to load and
01:56:19.000 initialize the Ruby app some you know Global method but we don't care because
01:56:24.079 this is our application and yeah let's open it
01:56:30.760 and okay yeah anyway it works here we can just
01:56:36.440 uh how can I hide this St I want be wider and let's show what's
01:56:45.480 your favorite cord I don't know yeah the first one is longer because it downloads
01:56:50.920 everything and but now it works you can see guitar I like piano a lot so
01:56:57.040 this is all powered by the Ruby Jam existing Ruby Jam existing tool which has been developed for years and it
01:57:03.920 carries a lot of knowledge I guess and I don't want toite into JavaScript for example to achieve the same result right
01:57:10.800 I can just upload it here and use so this is our Ruby
01:57:17.520 demo uh it went well actually pretty fast and we have we have some time maybe
01:57:23.639 20 minutes okay uh I think other other part is going to be faster so okay let me
01:57:32.199 take this one and do a short break from laptop yeah so that's what we just
01:57:39.480 did we learn about the first problem actually the only problem we hit during this uh experiment is dealing with
01:57:47.000 dependencies C extensions and that stuff we fixed it quickly and also then some
01:57:52.320 platform specific code that has no knowledge of BU yet that's what we accomplished and now
01:57:59.840 let's talk about rails the actual topic um so rails is not Ruby right and
01:58:09.679 uh that what we just did with uh an existing Ruby project U is doable uh for
01:58:17.719 rails but that would require uh the whole Meetup to live coding I guess so I going to just show
01:58:24.480 some important points here and some code without actually trying to write it
01:58:30.400 luckily uh just 30 minutes ago I finished doing all this stuff so we have problems same problem
01:58:38.159 with C extensions but in the rails applications we have thousands actually of them in the rails itself we have I
01:58:45.800 don't know five six seven whatever uh even if you don't use them they're
01:58:51.119 bundled into your application uh now let's remember that rails is for database backup
01:58:57.119 applications and what about database in the browser that's also solvable uh that's
01:59:03.040 an interesting Challenge and we're going to talk about it in some details we actually need an HTP server because
01:59:09.079 rails is a web application so we need something to serve web requests in the
01:59:14.239 browser well we just sell stack blades and they have web containers and that's actually kind of problem
01:59:20.560 solved um but but there are other options too but that's something to
01:59:26.280 consider um okay we have Freds and we in most cases we need to perform outgoing
01:59:33.560 HTP calls to communicate with something else and that's a problem with web assembly there is no fret support yet
01:59:42.480 similarly there is no HTTP support in the standard that doesn't mean that you cannot use at least HTTP with frats we
01:59:50.000 can do some mockery fibers which are kind of working but uh
01:59:56.560 fully functional threading is not available you need to implement it somehow differently and HTTP could be
02:00:04.159 delegated to the host system for now uh that's how for example R ruid def the
02:00:09.440 project I demonstrated first with oaid works it just created uh we just created
02:00:15.199 a faraday adapter implementing like delegation to the JavaScript Fetch and that's it and it complies with the fire
02:00:22.280 API I can use it interchangeably um we need to De with
02:00:27.480 assets and user uploads I'm not even talking about like processing files
02:00:33.400 although I think I I'm not sure but probably FM is available on Bas well
02:00:38.960 well maybe that's an option but uh yeah uh we need to just think differently
02:00:46.280 background jobs um we needed them for master applications what is a background
02:00:51.400 job on V and real time of course even if you don't really need it um it it's probably
02:00:59.239 not needed for the vas application running isolated in your browser but if it has some background processing and
02:01:05.280 need to send updates you still need this real time functionality and it used to be demo time but I think um I just going to show
02:01:13.480 you some examples instead of uh painfully doing uh rails on vest and
02:01:21.079 then we're going to do some summary okay Switching M
02:01:27.159 again ouch so rails on v
02:01:33.599 um let me show you the initial application first uh it's not on Bas
02:01:39.840 it's just uh
02:01:45.360 um just a ra application with some real time stuff some databases whatever
02:01:52.840 okay let it start
02:02:07.560 anable demo with some I don't know the mix of chats and Trail like boards when
02:02:12.840 you can do some stuff uh it everything is fixed okay this one no
02:02:20.800 no not to today uh you can add items you can chat whatever uh so everything is
02:02:27.000 synchronized between clients I'm not going to spend time on showing that so what do we have
02:02:32.719 here we have a database originally it was po resc but uh for the vas version I
02:02:41.239 just going to use sqlite because um I had no time to implement fast kale
02:02:48.480 adapter um up to this point we have some real time what are we going to implement
02:02:54.280 work around and um we don't have any background jobs we have Gs bundling CSS
02:03:00.599 bundling stuff and what else um yeah we have some dependencies with some C
02:03:06.320 dependencies let me just uh start showing you uh the final rails code and
02:03:13.520 changes related to it let's St the application and
02:03:20.360 um maybe we should just take a look at the GitHub diff and walk through that
02:03:26.800 instead of I know trying to anyway um let me switch to the final
02:03:37.079 solution so and show you how how do I work with this application when it's on
02:03:43.360 vas so what we have here we some have some changes in the g g file um It's
02:03:49.559 Tricky so what do we have uh yeah I replaced pogress with
02:03:54.920 cite and I added some new groups
02:04:00.159 of uh gems first uh there is an active record Nob adapter that's very useful
02:04:06.559 adapter which helps you to reach boab ility of your rails applications
02:04:12.800 application without touching any database stuff so for me it was an
02:04:18.760 option to T that I have all the dependency that the application boots that it could
02:04:26.559 handle the web requests but I don't care about the database because database is going to live somewhere else not within
02:04:32.880 the vest so I'm using this Nob adapter and we have uh Ruby vas as well um one
02:04:40.239 thing interesting thing that we need uh to add this time zone infold data Jam
02:04:45.920 which is usually uh required for Windows machines but in was we also have know
02:04:51.800 knowledge of time zones so we can just install this gam within the V module and
02:04:57.840 that's going to make active support time zone St work and we also have Js Jam in
02:05:03.559 the group JS why we have this strange groups like Ras and JS because we want
02:05:09.159 to use these gems only in this context and want to make it possible to switch between them uh another interesting
02:05:16.559 thing uh to show uh to point your attention to is how we actually build stuff
02:05:22.520 and uh I use a wrapper over Ruby vas command line
02:05:28.040 interface which allows me to specify the list of gems I want to exclude from the
02:05:33.800 bundle so that's an alternative of you know manually editing gem file lock because that's not a good way so here we
02:05:40.199 just keep a list of Gams that I know that are not compilable to us I don't care about them because most of them are
02:05:47.360 not you not going to be used in Bas context Al for example for boot snap and Puma you
02:05:54.320 can try to be more strict with your groups in Jam file and like separate
02:06:00.840 them uh even more to avoid hitting either Bas or JS groups but
02:06:08.280 that's still like kind of a hack I expect like Ruby B to support this ignore feature out of the box soon so
02:06:16.320 you don't need to worry about it a lot and having that we can build our application so when now have uh been
02:06:25.000 B build let's say test
02:06:30.360 v um yeah so it also includes right now it
02:06:37.800 includes all the test gems for some reason I don't know uh so anyway they
02:06:43.400 compil so uh we have 100 something for a smaller rails application just to and
02:06:50.360 give you an idea what's going to be the the actual size of the Rails app so foru we have twice
02:06:55.920 less uh important thing to point to that this
02:07:01.800 test fasm only contains Ruby virtual machine and your dependencies it does
02:07:08.679 not contain your Ruby code because it's it's like we haven't told uh Ruby Bas to
02:07:16.520 do that but still we can run it we can run it with B time
02:07:23.440 again run and was time allow allows you to do
02:07:28.559 some uh file system mounting so we can just Mount current directory into the
02:07:34.040 rails folder and now test fast and let's see
02:07:39.199 what we're going to do so first we want to require bundle set up and um what
02:07:47.840 else uh we can try we can try to for
02:07:53.000 example require rails config environment RB this is how we load our rails
02:07:59.920 application and now we can I don't know put uh rails version
02:08:08.559 stream check which rails version are we running let's
02:08:20.520 check
02:08:34.119 problem uh we compiled the Jaz version for some reason I don't know why there is JS Jam yeah there is JS jam looks
02:08:42.119 like our doesn't really
02:08:50.440 work we don't have ch true bundle
02:08:57.119 only okay let's just remove it from here for now need for a quick
02:09:16.639 fast and we can try one more time
02:09:31.159 okay so what do we have here oh we don't have a sucket yeah that's true so the
02:09:37.239 socket class is not defined at all we cannot require it so that's why we have
02:09:43.159 this um for now is just a folder in the project um okay I call rails fast
02:09:51.000 machine and it comes with several things first it comes with many uh blank files or
02:10:00.079 almost blank files with some stops for some classes some interfaces which we do not have uh like just empty so require
02:10:09.320 going to work there are other ways to do that but we just keep files for now so
02:10:15.000 that's where you just try fail add a new file to be kind of safely loaded and we
02:10:21.880 have this rail sham St we can load it into uh around time as well let's do it
02:10:30.440 first okay well actually for that we have a specific entry point so yeah
02:10:37.760 that's an example of how we can also kind of disable some requires by just
02:10:45.639 adding then to the loaded features um array so it's not array actually but
02:10:50.840 anyway uh so to prevent them from being required and that's another hack could
02:10:55.920 be used and here we have Nob adapter secret keybase which is required loading shames and Runing the
02:11:03.079 environment so let's load this file instead uh
02:11:15.119 Hey rail SL demo
02:11:22.880 okay ra down no okay okay okay and uh yeah we see it's
02:11:31.199 loading some warnings and we see it it's 7 wine 32 like we can actually disable
02:11:38.880 warnings remember it's just a ruby executable it's not this Val it's synex
02:11:45.760 oh whoa wow something went wrong oh I think
02:11:51.119 it's just a okay level is not the same okay it's just a verbus wording level
02:11:57.239 anyway so this is how we can cck around some things that probably compiles or
02:12:04.760 included in a bundle but still not going to work because they require uh like sockets FS whatever so we just tab them
02:12:12.679 uh with custom files which are loaded before actually there is also some
02:12:17.920 interesting things so this is how we make them load first this is how we disable top level Jam
02:12:24.599 method which checks that the jam of the specified version is present and this is how we kind of mimic threats with
02:12:33.040 fibers um it's required to hack around the active record connection
02:12:39.679 Reaper so that's another step so then we need to compile it we had JS we compile
02:12:46.079 it to JavaScript version and the final part how we can add file St for for that
02:12:51.480 we use uh another tool called also developed by the same person who's
02:12:56.599 building uh Ruby Bas it's called vce VFS virtual F system so basically what it
02:13:02.920 does it takes uh uh vas model as an input and just adds a ton of files as
02:13:10.760 you specified them to it and result in a new model which has internal file system
02:13:15.960 with all the files included into it and this is how we comp while the
02:13:22.760 final uh like application vas module that actually looks pretty similar to
02:13:29.400 how we build Docker images because we first get the base version with just
02:13:34.800 Ruby for example then we do bundle install layer and finally we do the like
02:13:41.000 source code layer that's the process is pretty much the same so because it
02:13:46.440 allows us to cach intermediate results so we don't need to recompile everything every time we change a file and mounting
02:13:52.760 files and like packing is pretty fast so it's like seconds and this is the binary
02:14:00.320 binary vasary vasary probably uh we're going to use in the web application and
02:14:07.960 now I'm going to run the web application to kind of almost the end of the talk
02:14:13.639 almost I promise so my rails application lives
02:14:19.760 here okay
02:14:25.760 it's very similar application to what we had uh yeah any cable rails down so we
02:14:31.920 have rails module with it's not too big uh so the same
02:14:40.119 defa Ruby VM any cable demo we compile it we set up all this stuff yeah there
02:14:46.960 are some additional hacks I haven't included into the app itself but patched
02:14:52.000 right in the JavaScript version just to for faster duration we have some hacking
02:14:59.400 around uh any cable so we using any cable here and uh to send updates to all
02:15:06.199 the clients because it works in multiplayer mode we just call a global
02:15:11.320 JavaScript function which is performing in broadcast for us for any cable so we
02:15:17.239 hacking around any cable HTTP adapter and delegating it exec ution to the
02:15:22.440 browser um yeah so web sockets leave outside of the browser we don't need
02:15:27.559 them and we have the cite free basm adapter few few words about this stuff
02:15:42.679 a uh kind of a extension of the official cql light adapter and that comes with WP
02:15:49.880 support basically basically what we need is to implement this uh delegation in the exact function of the database
02:15:56.239 external connection uh and we pass some parameters and we implement this function on JavaScript site which do all
02:16:03.400 the things we need to query the database there are some things we need to implement like uh some apis transactions
02:16:12.679 whatever um yeah that requires some work but it's just like 150 lines of code the
02:16:19.119 original code for SQL light free adapter I think it's like almost 10 times more
02:16:24.639 so we try to reuse rails as much as possible thankfully rails is designed in
02:16:31.679 a way that it's kind of easy to extend uh up to some point anyway so we
02:16:38.599 have this custom adapter that just use JavaScript and let's go back to our JavaScript code and here the important
02:16:46.639 piece is service worker that's where we going to inter accept our requests made
02:16:53.120 by the application and serve them through the V module for that we use so
02:16:59.160 yeah so this is our external interface functions SQL ride for rails nothing
02:17:04.400 simple uh just a yeah database is uh SQL light on vas so it's not persisted right
02:17:12.160 now so it just lives how you have this page open similarly for any cable we
02:17:17.559 just use fetch here and this is how we intercept fetch request from single worker or service
02:17:23.599 worker do some stuff here and that's uh a bunch of code for
02:17:30.840 converting JavaScript request object into W request what is Rec request it's
02:17:36.559 like Rec environment it's a good old Rec an which we just create manually and in
02:17:43.120 the end uh we call rails application call request that's how you can
02:17:49.440 programmatically perform request within the web application then we get the rec
02:17:54.519 response uh we collect it back to something usable in JavaScript special
02:18:00.639 care of images because we cannot well technically we can but it requires some
02:18:07.679 deeper knowledge of how B work with memory access binary data I'm just passing strings around and we don't care
02:18:13.920 about performance everything is local and that's pretty much it and then we respond uh with this data back
02:18:21.360 to the browser let's see in action
02:18:28.440 um
02:18:37.200 okay okay uh we have a running and one thing to point is that since we're using
02:18:42.920 service workers we need to run it with htps uh so I'm using pum here uh yeah
02:18:51.479 this is the same application and it runs fully in the browser we can do some
02:18:56.920 stuff we can open uh let's open another window just to show that it's
02:19:03.000 also how can I okay
02:19:09.200 maybe hello well we can check some check
02:19:18.080 boxes and it works and since it lives and ser worker so the database is alive
02:19:23.599 as long as the service worker is alive and yeah that just
02:19:36.599 of the talk but I want to keep you for like five minutes I have
02:19:41.960 slides okay I'm gonna share links more because uh there are more cool stuff because this is another demo of a
02:19:48.120 different application running fully within stack blades and it's also rails application but it's uh using kind of
02:19:55.840 expressjs within web container to intercept requests and serve rails data
02:20:01.640 through basm uh it's also available online it use the same principles as the service work one let's go back to the
02:20:08.600 theory and some uh not so boring stuff
02:20:14.840 okay you can start cutting the surprise yeah the surprise okay just to recap the
02:20:22.280 challenges and the ways to overcome them we have databases and the good thing is
02:20:27.600 that sqlite is available on V so we can run it in the browser pogress is also available on L and it's progressing like
02:20:34.560 every week like it just PG light has been announced like month ago even less
02:20:41.120 and now they H going to add support for extensions pretty much soon so I haven't
02:20:47.280 tried yet but that sounds cool we have persistence options so
02:20:53.080 right now I'm dealing with in like just in memory in process memory uh stuff which is not stable of course but there
02:20:59.600 are options to store databases row data in index DB or in the more modern a
02:21:06.880 feature called uh open private file system so yeah I think I I'm not sure
02:21:13.800 about pidilite it definitely support xdb some sqlite implementation support both
02:21:19.640 so was checking uh the thing is uh but as we said in the beginning browser is
02:21:26.399 not the only target for VB assembly right you can run it in desktop applications or server applications
02:21:31.880 wherever and there you have no limits on how to use database you just need to implement interface for communicating
02:21:37.200 between Ruby and your runtime HTTP servers so we just seen uh
02:21:44.439 that we can use service workers in browsers they work pretty good like stch blits built on top of service workers to
02:21:50.319 do this all the HTP emulation and we can use in other run
02:21:56.960 times we can just write HTP proxies like Express JS example I haven't really uh
02:22:02.720 showed you but it exists uh the cool thing is that someday in the future uh a
02:22:10.319 new standard U HTP proxy probably be part of the system interface and that
02:22:16.000 would allow you to just Define a common API in your rails vasm and plug it as a
02:22:23.120 universal vasm into anything that could serve uh F HTP proxy applications so you
02:22:29.479 don't need to write all the glue and code we have right now um background jobs Bess is on vas so
02:22:37.720 it's a good job we can run it there I think it's going to be I'm not sure they support list and notifi features but
02:22:44.399 that's not the only way to do that so yeah I think that's that could be done at least at the kind of a service layer
02:22:51.800 but uh we still need something to communicate between workers because background jobs makes sense if you have
02:22:57.040 multiple V models running your applications and running background jobs within the same browser and we can use
02:23:04.120 like broadcast channel API for example or something else like there are many
02:23:10.080 options for that HTTP so right now the best way to use
02:23:16.399 HTTP in Ruby vas in the browser is just to do this trick with JavaScript uh
02:23:24.040 delegation and external interface and call in Fetch and in the future there is also
02:23:30.359 standard for HTTP Comm and preview free and that's probably going to be
02:23:36.720 solved cables um if you still need them there are other options like we can use
02:23:42.040 other transports we can use any cable we can embed any cable into your host application if it's not a browser for
02:23:48.200 example if it's a go Application it's it's like a no-brainer um why do we need rails on us
02:23:55.399 except from speaking at the meub uh I think again as with Ruby as at
02:24:04.120 least for me the best use case is to make the loop of trying learning and
02:24:09.319 reproducing stuff much smaller so to make it possible to do things faster uh
02:24:15.920 for example I have I managed to make Ruby reproduction script for Action
02:24:22.279 controller uh work in run Ruby Dev even without any custom compilation just within the browser so instead of like
02:24:29.920 downloading the script running it locally installing R rails or whatever it just go to the web uh page write your
02:24:38.080 use case in the template run it where make sure it fails and send it in the
02:24:44.520 issue the rail scare team like please fix it here is a reproduction everyone could play with it everyone can run it
02:24:49.800 run in the browser or maybe even fix it uh one use case I keep in mind that
02:24:56.120 is something like uh ultimate privacy and uh owning your data so you can build
02:25:01.399 application that do not share anything with the outer world that could be useful for I don't know I like Financial
02:25:07.920 tracking noes whatever you have you can selectively sync data with the outer
02:25:13.880 world but keep the most important pieces on your device uh that's uh another kind of
02:25:21.200 version of it as local first applications like like the ones we seen
02:25:26.359 here uh another use case is using the same code for different contexts like
02:25:31.439 running rails app as a CLI to give a CLI interface but using the same rails code
02:25:37.160 inside for business logic or like web or whatever and finally what I call it like
02:25:42.920 offline first 2.0 is actually having everything and data and the application
02:25:48.960 living in the browser and implementing some cool like partial synchronization
02:25:56.200 mechanism with the alter world to share data when it's needed so I think that's
02:26:01.560 cool use case we just need to figure out the storage and replicated storage mechanism for
02:26:07.279 that uh yeah there are multiple run times I already mentioned them but the
02:26:12.319 most exciting I guess except from JavaScript and browser would be desktop
02:26:17.399 apps written with story or whales which is like Tower written and go I would say
02:26:23.120 uh you haven't heard about it and some cool stuff which we don't have yet so in Ruby uh not everywhere
02:26:31.880 but mostly in Ruby so components components is a way to combine uh vast models together
02:26:40.120 without any intermediate glue in code and telling which um methods to export
02:26:45.200 to import and what does the signatures and so on so that's kind of cool thing that's already aailable on V but not yet
02:26:52.600 available for Ruby preview uh number two includes HTTP it
02:27:00.160 has been kind of finalized just a few weeks ago it's not available in Ruby as well but I think it's going to be
02:27:07.040 available soon and it' be nice to have more compatible extensions as I already
02:27:12.080 mentioned so the evolution is kind of fast this
02:27:19.040 days um I think uh we need to we G we we expect more schol stuff coming in the
02:27:25.680 future and uh I think preview number three we will come with everything we
02:27:31.680 need to build full featured rails on vasm and someday we probably have this
02:27:36.960 single command no hacks around just run rails pack W and you have the same
02:27:42.200 application running within W and ship it anywhere uh the question is uh when and
02:27:49.399 we will be live at the end but I know I think the Horizon is like three years for the
02:27:57.359 final pie if we made it till that that would be cool if not then it's not going
02:28:02.920 to be needed at all thank you for
02:28:08.160 waiting
02:28:13.319 um yeah so this is the blog post it's kind of good for making first steps with
02:28:20.439 Ruby onest we don't have anything written on Rails onas I just have some repositories um but we're going to
02:28:27.120 publish links as soon as we publish talks I guess maybe earlier so if you want to ask me anything about this stuff
02:28:34.920 please do that after we finish all the official things here in at GitHub and
02:28:40.840 move to some other place thank
02:28:46.600 you
Explore all talks recorded at SF Bay Area Ruby Meetup
+24