value the api key and the field And just like the http way we will create a new feed for this every sensor value So application I want to be talking about application How many of you have seen your home meters home power meter? Everybody has one. How many have seen it? All right, that's about 10 of you. This is how my home power meter looks like And by the way, I moved into a new house and this is the latest I believe How do you think meters are red? Pretty manual nowadays. I think they are trying to do it automatically, but I think by and large it's pretty manual And this is you see it's 2015 is by last year But imagine one day we add a cellular connectivity to this And every few hours we just send this tiny little value From your home power meter to your power's utility and from there it just propagates as data to all your accounts Or all your mobile phones Imagine how much aware we will be of the energy we are using in every day of our lives I think that has an impact directly on our behavior and the planet we care for So iot iot platform at the end of the day. It's all about data. Sure. We can go and Plot charts about it. It will already give a visibility of our usage of our consumption But what are we going to do with the data is an even more important question Are we going to stop something reset something do a physical manual deployment to the site Notify social media trigger a rake task Generate a pdf create an email trigger something Or change something about ourselves at the end of the day iot platforms Have a huge impact on every possible industry around us, whether it's logistics energy transportation And so I thought I should end with a quote The wheel is an extension of the foot The book is an extension of the eye Clothing is an extension of the skin Electric circuitry is an extension of the central nervous system The extension of any one sense displaces the other sense And alters the way we think the way we see the world and ourselves Let's explore the senses around us. Thank you so much I would love some questions Yeah, we have some questions from the audience, please Are you doing this sort of work in on professionally right now or just uh playing currently it's a hobby and that's a great question You know like this graph I showed right at the beginning You know, um, so I feel in terms of iot We are kind of like at an inflection point And if you remember the era of web or web or personal computing There were a lot of hobbies that got started first and then the industry kind of came together Like I said, there are a lot of industry protocols being made But I'm personally doing it as a hobby. Hope to make it a career out of one day But you know as engineers, that's what we do first, right? Anything new just just go on and have fun Thanks for the great question. Any other question? Hello, hi, okay, uh I'm a beginner to Trying to hack in my way to Some stuff. Can you suggest any? starter kits to yes, so You see my slide link here at the end Right, and I have three more slides here I've linked all the hardware links here because that's the most frequently asked question So I would highly recommend you to go to eta fruit or spark fun Like I said, there are deaf kids here and it will be so easy to just get started just for yourself Yeah, check out the links here. My slide link is also here. I hope if not talk to me Thank you Any more questions? Yes So south yong our keynote speaker from yesterday works at sing power and I would love To have him attach our power meters to the cellular network so that we can hack it You can you can tell him Okay You started So it's going to come true no more manual Thank you, sashong. Thank you. Thank you Thank you, saini once again for your very very well thought out of talk So now we have yasuko She's the president of every leaf corporation in japan and she has written two books on ruby in japanese Thank you Please Thank you I'm talking about our fight against super bad patterns in legacy lives apps. I'm yasuko over I'm living in tokyo japan and I'm a programmer I have been using ruby on rails since 2006 And before that I have been using java for seven years And I have an experience and of other languages too And I'm president of every leaf corporation in japan And please call me oba san just oba san or an yasuko san or yasuko Please do not call me oba san Do you know the meaning of oba san? It's a bad name and for middle-aged woman in japan And please do not call me oba san It means an old lady in japanese, so please just call me oba san or yasuko san My company is every leaf corporation And We develop web applications for our clients using mostly ruby on rails Since 2007 So it's almost 10 years And we are 19 people and 11 are women Oh, thank you so 57.9% are women and 46.7% in engineering So it's a bit worse than Travis CI But I think this percentage is pretty higher than the average of japanese technology company I started the company for myself to keep coding Because I love to write code very much But of course I have to do management works these days too I put stickers and bookmarks from my company Near the job support This is my family and This is a picture of three-year-old ceremony in a local shrine in last year when she was two actually They are just flying to singapore just now And my hobby is Carlta I suppose Nearly no one knows about Carlta This picture is from the movie of Jihaya Furu in japan, which is kind of popular manga in japan And Carlta is a game That the reader reads the Poem and the player takes the read card a red card as fast as one can And we have products for that in both iphone and android Then there is an english name the 100 japanese poems and here I can Demo Like this and this application and acts like the reader So if you are interested in this game, please check it Hello, singapore This is the first time for me to visit singapore And of course attend red dot ruby conf And this is the first time for me to travel to a foreign country alone and First time to have an english talk longer than lightning talks so Thank you very much I'm really happy to be here as a speaker and Thank you so much. And this is a big adventure for me caution I must say a or ma instead of bell. So please replace in your brain And I must say ten instead of point for numbers Sorry about that and I have a lot of slides here. So maybe it might be a busy talk. Sorry Okay And I like the outline of my talk is here I'm talking about two topics The first topic is what we generally have to do to upgrade ruby and rails in legacy applications And the second is Introduction of four super bad patterns we've found Okay, let's start from ruby and rails migration When I use the word migration, it means upgrading Upgrading not the rails migration of active record And I won't talk about upgrading rails from four to five I think it's not difficult This talk focused on the most difficult part of rails migration, which is from two to four And how many people have used rails too? Thank you. Maybe 30 percent And how many people have experienced the migration from rails two to three or four or five? Thank you Maybe 20 percent or this Rails too have been used widely in Japan at least So I'm afraid that many old rails applications remain waiting to be upgraded So you might meet them someday So knowing about how to upgrade ruby and rails can be some help for that situation Is it possible? Yes Even with no old testing The answer is still yes We did this But is it better to develop an application from scratch? It could be But not always I think An existing system being used reflects its real needs It should be respected You can never remove its essential complexity by programming techniques That's why migration and refactoring make sense Let's look at how to upgrade ruby and rails Let me introduce our case. This talk is about the real experience of me Our applications is kind of health check service P2B And it has been handed over to our company from the other development company which originally developed the system This is our project goal We have three applications up one is for administration up two is for end users and apps three is Also for end users, but it's for english users And up one and up two is using rails 2.3.5 and ruby 1.8.7 And up three is using rails three And we need to Draw it away from radian cms and up Draw up two away from radian cms because it was developed as a extension of radian cms It's not that simple rails application And and after that We need to upgrade to rails 4.2.1 and ruby 2.1 And merge the apps three to up two And then we can do refactoring ancient code And we need to add many new features The total schedule was like this We did this from august in 2014 to may 2015 it took 11 months And there are three companies and working around here our company is the black line So the point is we needed more than two months for migration I drew a map of right on the map of rails of rails migration Let's start from rails 2 And we are going to rails 3 Between them there is a river of tears Okay, then and we are going to rails 3.1 Between them there are the mountains of modern rails And you can easily move to rails 3.2 And please say goodbye to ruby 1.8.7 here And to go to rails 4 There is a strong parameters force Now you're safe. Maybe you can do upgrade further more This was a real migration schedule of us We upgrade we upgraded two applications at the same time The point is we first upgrade rails from 2 to 3 This is hard Then we upgrade the both ruby to 2.1 and rails to 3.2 After that we migrated to rails 4 After that we started to replace some gems for example for example file uploading page nation and so on We have a button from rails 1 actually And if you have this kind of definition in your root rb It is hard to remove it because we have to write each request specifically To do that Ah, sorry Sorry, you need to and know all actions to do that Let's see the roadmap from rails 2 to 4, but we have no time so I must hurry up The river of tears the first point is active record chain number query language So you need to say goodbye to conditions and its friends In rails 2 we write like this to search do search And the condition is here and its friends is here And conditions and its friends reside everywhere And if you have some manipulation of conditions hash it makes things worse You need to know all secrets sequence intended Condition manipulation is like this You manipulate the string and the parameters separately But now we can write like using where And we have we found a small bad pattern here The prior developer liked the pattern to do search first and manipulate the result But it's slow and hard to maintain so We have to replace to chain queries instead of array concat And the second point an obtrusive JavaScript We write ajx code if it uses all rails helper methods And the third point is helper and views you need to add equal and rewrite all of all all the helpers which supporting which is supporting blocks and remove h And maybe need to fix w escaping sometimes And the fourth point is validation In rails 2 we write validation like this validates presence of but Sexy validation has come so we can write like this now And the other point you can write your root rb much simpler And you can use bundler And there's a good point about commands in rails 2 If you type rails my app It means rails new my app And you can type rails c or rails c in after rails 3 But in rails 2 it was different And what happens if you run rails c in rails 2 environment? So we don't have to create applications named c or cs anymore I used to create c or s applications twice in a day When I go back from rails 3 to rails 2 it was very confusing Okay, go to the next step We are in rails 3 And we have to go over the mountains of modern rails The first point is asset pipeline And move files and configure settings and redesign css and js file structures And good and it's a good timing to use a css so on and it takes much time And you need to know all about all asset files ideally And the second point is default js libraries changed To bj query from prototype js So you need to rewrite javascript code if you are going to switch the library Okay, then you can move to rails 3.2 It's easy and you can now you can use plug and unique for distinct c code And how about upgrading ruby? And I think it's quite easy You just need to care about string encoding and hash things Okay, almost done We are in rails 3.2 Then the strong parameters falls The security check went to controller from model So you need to remove attrack protected or attrack accessible from your models and add parameters Add parameters check in your controllers I love string Sorry string. No, no, no strong parameters Because it's very flexible and readable but adding Parameter checks and adding strong and supporting the strong parameters is really hard and a boring job You need to know all parameters for all actions And others and maybe you want to use hammer and Replace and of course, you need to replace many gems and rewrite monki patching in config Internet lasers And maybe you need to care about time zone Gems You need to replace gems through the rails migration generally I think in modern rails Such as rails 4 or 5. This is the main job of migration. It's kind of getting much easier Congratulations, welcome to rails 4 or 5 So how to upgrade rails from to conclusion It's not only rake rails update You need to change so many places For that you need to know You need to know well about your app You need to know about all actions to remove default routing and all parameters of each actions For applying the strong parameters strictly and like and you know Sorry, you need to know about right looks of all pages To fix helpers and escaping and problems And you need to know all seagulls to replace conditions and chainable query And you need to know all asset files for using assets by brine effectively And you need to know all monki patching Making for making them work in modern rails So It's really tough but not impossible step by step By the way, why didn't we have automated? Why didn't we have automated tests? Because we had abandoned tests given from the prior company So according to the yesterday's talk We have improved our tests right And those tests did not make sense at that time What to test were really wrong and or extremely difficult to change I know this is dangerous However, having bad tests could be even worse than having no tests The distinct company helped us a lot fortunately And we had tried to write feature specs, but the old ruby version is courageous less We wanted to use capybara For example This is capybara So we decided to write many good specs after migration After a year we have many nice specs happy Okay, what minutes I have? All right Thank you And and let's move to a super bad pattern in layers Our apps have been developed by beginners of rails Coming from java And we found many bad patterns there We love good patterns So we have easy access to the good patterns How about bad patterns? If your team is modern and nice It's hard to find natural bad patterns if you're in your daily work It means you might miss some chance to notice what to avoid in programming That's I want to share these bad patterns here In my opinion And natural bad patterns are like gold mines In other words, I'm going to teach you to fish in cloudy swamps Let me introduce four major bad patterns in the project One too many layers Two dreamy method Three global hash Four mass housing in one controller One too many layers We have been fighting against too many classes and layers I suppose it's familiar style in java And I like java It was like this We have many seen active record models And we have spaghetti but non active record classes And these non active record classes Use these active record models very procedure And of course controller is using these classes very procedure And typical overmatch was one to one relation models Like company, company address, company something So on And these models are in relation of one to one So maybe there is no required to separate them And the other overmatch is facade proxy So wrong reasons to separate models Which I I guess is here They have slightly different meanings Usage is different sometimes And the worst one is I would like to avoid changing existing classes for my safety Oh my god Separating models costs very much And facade proxy so on And it's no problem if it's well designed of course But in our case these seem to be the result of that result That developers could not use active record properly They they look to not to trust active record Okay, we did refactoring for this First we unify the model And remove the medium layer classes And add features to a simple and one single class Make it rich and modularized active record model And use the model directly in most cases from controller Okay, two dreamy method Dreamy method is ready to do everything Here is the dreamy method do everything for you method It takes that I and I didn't fire and then it provides everything Of course, you know the right pattern You can write a simple method separated methods Or you can use inheritance sometimes Like this But are you sure why this dreamy method pattern sucks? It's hard to read You can you can recognize that okay you mean doing constant two job here So it's not really bad, but how about this? This is the variable so oh I need to check what value is inside And this pattern is very easy to start You have a method without argument But some time Some time go Sorry, but You need to change this behavior in my case. Sorry. I need I need to change this behavior in my case so Well, let's add an argument here and add if This is very It's not a rare case. I've seen this pattern many times in review code and code reviews And it grows like villas There's a here and using do everything for you And I need to add the new logic after this So let's add a new method having the same identifier Okay, you have now the second method it takes and I didn't fire So like this and I did fire travels over methods classes and layers everywhere like this It's nightmare And another little but but pattern here enum like hash constant, but it's like this But it should be like this Or you can use some enum pattern Why I think this is bad because situation who It's not Sorry situation who does not cause an error So you can't notice something is wrong Ali and you need to remember or check what key is available ID can do nothing for it And if values are integer you need to remember both name and value And it's difficult to search you can use variable as a key And hash contents can be changed too easily and with the combination I'm dreaming method and this hash in a constant here So wandering around looking for something is very painful So separates things and gives them good names three global hash Global hash hash is loved. I think everyone like Hash and hash feels like not scary. You don't have to create a new class And it's flexible But it can be a monster It starts like this Okay, you are in active users controller and search action And you receive the parameters and and It's hash Sorry, it's hash and you You use that hash to search search or you store a session Store that in session But it grows like this in you You are in another controller now and you add such similar to the prime prior one and This time you receive The search option, but it's including an extra options And you want to make a searcher know this is for new users not active users and and you add third controller And including extra options and much simpler and Such a know this is for special users So in decision research or such you face a global hash Well, you are a great data anyway And everyone can use it and look some of them Check one key Add something for my friend and retrieve it. Just store all of them in case So nobody knows what contents are expected for each purpose exactly chaos We had a long battle to defeat them We replaced the part of hash to be an object by each features Like this So the conclusion is hash is scary It's too flexible to be used widely for human beings And for mass housing in one controller That it and the problem was like this There are three features But only one controller Action provides three features A controller code was like this So many when But actually it was worse than this because it was using hash and enum like hash constant And the better design should be like this And have separated controller for each features And you may notice that this is the combination of two bad patterns So dreamy method and global hash And With mass housing in one controller pattern. It is extremely difficult to change just one feature You need to chase the identifier not to harm other features Okay, then what to do to avoid these bad patterns Too many layers Use active record if you can Doubt one to one relation Think about maintenance costs Dreamy method Write a different method for a different need Doubt adding an argument and if Extract common parts if you need Use polymorphism And step this stop this pattern in every stage. This is very important And global hash Feel free to add a new class Use hashes locally Conclusion I showed what you need to do to upgrade rails from two to four in general Good luck And then ask me if you need And I introduced the natural bad patterns in rails we found let's avoid the traps Thank you Thank you And the one question I don't remember the lines, but it was quite big So 30 I think 30 controllers or For 40 models or And that's for one application. So Much more Hello, do you think it's worth it to upgrade from two to four for rails because I saw that you take about 10 10 months or 10 months to upgrade. So do you think it's worth it or do you have any Reason to do that Actually we we are sorry The question is why we need 11 months. No, no, no, no, but I'm weird. Yeah That's the sorry All right The question is about schedules and And the migration only a month only I'm not sure but it took just More than less than three months and we Yeah refactoring was very hard But there are many features already. So if we Develop this in scratch We can't do this in this time We we We changed whole things and and then released that because We need for the testing companies and work. So It's it's easier for us. Angie will be The first speaker of our lightning talks. He will be talking about the benefit I am glad to talk here now and To be honest, this is our first time to make a presentation in english more than two people Today I would like to talk about blogging benefit through my experience This is my talk is for beginner engineers. There's no code in this presentation At first who am I? My name is Kenji Mori I have been a ruby programmer and Japanese tech blogger for almost four years I work at m3 ink m3 ink is a japan-based global company focused on improving medicine and In japan and worldwide developing services for doctors I became a web engineer and started the blog in 2012 This is a snapshot of my blog At first I started the blog as a public memo to be able to remember ruby's usage and keeping the log of my experience The public memo of my blog Provides great benefit to me The page views count of my blog is over 2.4 million from 2012 Fortunately my blog is fairly well known in the Japanese ruby community Through my blog one or two companies contact me With job offers every month Now I'm a lead tech engineer at my workplace Thanks to my blog Sorry Thanks to my blog I have gotten this opportunity In japan we have a proverb that says that three years on a cold stone will make the stone warm What it means is that you should not give up that The perseverance and patience will bring good results Someone asked me why I was writing a blog Writing private local memo is easier than Making a public blog article, but I told him that a tech blog is a source for an engineer If you want to get a good job, you should be well known in the tech community A tech blog provides them with helpful information You have a chance to grab their attention Your tech blog is your skill showcase Blog audiences can understand your powerful skills by reading your blog To me my blog provides another benefit The other engineers who are helped by my blog thank me Their appreciation motivated me to learn new technologies To increase Pageview count, I always often write two types of articles. First Someone who has a problem will read my blog. So try to help him or her by my blog articles Secondly, if I collect some information for a topic to solve a problem Another engineer may need their information too. Summarizing information is useful for everyone I usually make a blog from some Sorry, I usually make a presentation from some blog articles In this section, I would like to introduce The reason for and the merit of making a presentation At first, why do a presentation from some blog articles? The reason for making a presentation From my blog article is to organize my knowledge A blog article is helpful to solve a problem, but sometimes the information is not organized Through making a presentation, you can convert ambiguous knowledge into systematic knowledge I think Teaching is equal to learning Research of the following URL shows that one of the best learning methods is to teach other people If you prepare a presentation, you will consider how to describe a topic to others You may prepare to answer possible questions after your presentation Above all, you should concentrate more on preparing for a conference or workshop More than just attending If you want to practice and make a presentation, try to hold a workshop with co-workers My co-workers and I have five minutes of writing talks every week We all use the same technologies at my workplace, so we are good teachers to each other If you don't have enough time to prepare, you can present your blog articles. It's easy to start After your presentation, you can discuss the topic you tackled You can understand other persons know her You may get to know an engineer who has a similar interest as you You can confirm the evaluation of the topic by their feedback I think this evaluation can allow you to understand the next step for self-grossies Writing a blog was a good first step for me to become known by other engineers But it is just one example Another example is a control building OSS, creating web or smartphone apps or something Try to find the output style with which you match Thank you very much Thank you, Kenji. I also have a blog, but it's all empty Okay, hello everyone My name is Jack. Today I'm going to talk about growth from small simple steps So learning from Amazon the name can be shorter growth from S3 Yeah, today I'm going to walk you through one of my pistol experience contributing to an open source project Which was not going really well Surprisingly the problem is like this. The library name is called active record imports So how does work once you need for example import 10 books records into a database at the same time All right instead of writing 10 different sequel statements And 10 different 10 database connections You can write one and just say book dot import books and then all the data all the record Insert into the database, right? So it helps a lot if we need to insert millions of data at the same time Yeah, and but now Some problem comes once we use enum in Rails So enum is a feature since I think rails 4.1 Basically, you can define the enum attributes with some for example the status here must be either Jrafted finished or published But somehow the value saved in a database Is always integer. So so default so but so jrafted is zero finished is one and Published is two However to you to do the assignment you can say Dot status equal to zero or dot status equal to jraft Yeah, only integer is saved Sometimes in the migration you need to have you want you want to have like default value To the status But once we use that again boom As the argument error says integer zero is not a valid So my first question is Looks like I'm not I'm not sure why the integer zero is used instead of So why the string is used instead of the integer? Then I look at How does it work in the proscracical because I was using proscracical and find out there's a method called pg get expr and this is a method to get the default value And the output is actually a string. So that's why we get a string zero instead of the integer And then I think reels must be smart enough to do the typecasting and we can always assign integer attributes with string and it should be automatically do the conversion But somehow in the in the import methods in the library It just use read attributes before typecasting So it basically just read attributes from the instance without doing any typecasting and then the place the place Racer error is the the the one we call the method since k equals to v Yeah, and this is a place because zero is not a pre defined string and Yeah, so so there's an error And I was also asking why the test all the tests go to past If you still take about it's still a single test. So this is a model file inside the spec It basically defines the enum status once the active record version is larger than 4.1 For active record version 3 1 3 2 4 4 1 and 4 2 Does anyone find the problem? What's wrong here? Yeah, the 2i Because for 2i at the most it converts the version to 4 point just Convert to 4 and the value is never larger than 4.1. So the enum attribute is never defined Okay, so I get the problem. I know what's wrong. I got the fail test case. Now I roll up roll up my sleeves Okay, work hard overnight And then I received a lot of encouragement And at the end Okay, sorry, I go back I'll go back sorry so yeah and and I received a lot of encouragement and and at the last The the author of the repo and it says it is the best pull request I have ever seen awesome But it didn't happen at all so the the reality is okay The reality is I sat down and was not sure what was wrong the first I thought Okay, it might be a problem with postgres sequel, but it turns out. Okay sequel rights and my sequel Are the same and then I think okay It might be a problem because the rails I think rails must be smarter than this But maybe way way because enum it accepts strings like drafts and it never should be Convert that the string to to integer automatically And at last I define. Okay. I I want have a full request to replace read attributes before typecast with read attributes which basically Do the typecasting and then the first maintainer comes here say, okay, why why In our library read attributes before typecasting is used. Hmm I'm a bit confused because I thought this is a question. I should ask him and he should told me Right. Uh, I was gonna be confused and then here comes another And here comes another commuters. He said oh actually the code was back to 2007 and But but go ahead go go to use reels read attributes if that got test case passed Really 2007, you know, there was rails 1.2 Oh, I got really sad about this and then here this comes another The the first can be a commuter actually come back and say, okay, actually the typecasting is handling somewhere else But but go ahead to to use read attributes And I was even confused because it's not logical at all If there's the typecasting is handled somewhere else So why need to use read attributes to do the typecasting duplicated? Confused confused and then I tell them, okay, read attributes. It is actually slower for the typecasting 50 times slower Because I think my pull request was actually not that good When I was still thinking there was another commuter actually comes In in another pull request actually made a very simple fix and I kind of get all the text pass And he just basically changed the model docent k equals to v with model scrap bracket k equals to v I thought these two are the same, but somehow they're not Because the scrap bracket equal sign basically is The same with writes underscore attributes and which does typecasting as well I'm thinking, okay, it's it's working, but not very good either But at the moment when everyone is Was stuck The the the maintainer say, okay, I want to close this. I want to merge your pull request Go ahead, but I'm going to create another pull request and merge the changes Of both of your your your pull request So this is Yeah, this is kind of the the story and through the entire story I had no much like positive emotions And and the result was not very good. My although my pull request got merged But I don't have much code to contribute it But even this I get some takeaways and the takeaways is really something I'm going to talk about today So the first I know much more about the active record connection Adapter it is a good design to support your application support multiple database types And which is scalable and the second I understand more about different types of assignments in active record and typecasting And also I understand how at least the default value works in post-crack sequel And the library itself is actually pretty good. The people are amazing. This is a good example Or library to As a showcase how to support multiple ruby versions and database adapters at the same time And of course, no rails, you know more And and here's what I take away. I come here to for you. So the first don't believe in stars So for this library, it has more than So for this library, it has more than 1500 stars and it is updated very frequently But even for this there was still some mistakes I think most sort of beginners can fix And so in second don't think you're making a perfect pull request at the first so learn from the conversations from others And the last I think contributing to open source project Sometimes is trivial like small simple steps But sometimes even the small simple steps is not that easy is sometimes not smooth Sometimes the reality is like this So my so so my first my my sorry my last suggestion is like go ahead. Don't compromise. Thank you Question for you guys Why did the developer leave his company? It's because he didn't get a raise. Okay. Uh, next we have, uh, Yuki Yuki is my colleague from Pivotal Less all the way in Tokyo and he's the creator of the did you mean jam Thank you. Um, hi everyone My name is Yuki. Um, I'm really happy to be here today. Um, I'm going to be talking about uh, 28,000 techniques that you can use to make yourself more, uh, productive Let me talk about myself. Um, this is me again. Um, I'm on the ruby called 10 I maintain a jam called communari, which is a Ralph Pajnatter I'm the creator of the did you mean jam and basically what it does is, um, If if you have any typos in the in the method and it tries to suggest suggest to you why it should be So it is basically the club before ruby. So someone someone calls Someone calls his jam the club before ruby Anyway Um, I work for a company called Pivotal. Uh, we have obsessed in Singapore, Sydney and Tokyo So if you want to interested in working at Pivotal, uh, just let me know Um, going back to the main topic, um, before I really start, uh, I'm going to speak really fast So I'm going to upload a slides letter so you can take a look at the slides letter Okay, the first one is actually actually from the did you mean jam? If you install did you mean 1.0.2, you can require, uh, did you mean experimental which enables, um, Did you mean experimental features? Uh, let's take a look at this example, which is, um, There's a typo in the instance variable name and what's going to happen is really try to call the method on there So you get an error But if you require this you mean experimental, um, it tries to find the right correct, um, instance variable name for you Um, let's also take a look at this example You have a hash and you want to get a value out of it And there's a typo in the key name and you get a key error But again, if you require this you mean experimental, um, it will try to Correct the wrong, um, king of wire Another another example would be something like this, um, notice there's a typo in the word initialize And this is tricky because you define the method called initialize and what you really call is new So it's a really hard to realize that there's a typo But if you enable, uh, did you mean experimental it will display a warning So it's going to be a little easier for you to notice that there's a typo Okay, number four, uh, bundler conflict gels, um, it allows you to Install gems in parallel using threads um by default it is set to one and Let's say if we install about 200 gems and it takes about three minutes actually But if you set it to like 16 it only takes 30 minutes, which is a lot faster Uh, the next one is making a request on rails console If you are on rails console, you can actually make a fake request to the controller by saying After get a path, uh, you can also say, um after post or after delete So this is really handy if you want to process a controller action Okay, the next one is power set Let's say you have a task and then that's failing and you don't know what's going on and what it does is, uh, it displays Um, it just creates a social message for you So this is really useful if you have a mysterious failure in your tasks There's also a javascript implementation. So if you have a javascript route, uh, project You should definitely consider using this too The next one is a watch command. It executes a command periodically Let's take a look at this example On the right side, I'm running a break test and there's a failing test and on the left side I'm going to change a file and save it and in the watch command. We want break test and I and here now you can see green Usually you I have to stop emacs and go back to the terminal and run the test But if you use watch, you don't have to do that, which is great Okay, the next one is a new thing of get depth This is actually new that new thing that came out last week Which is called compaction heuristics I think you've seen something like example on the right side, which is quite not right But if you set compaction heuristics to true then the get will be a little a little smarter to display the diffs The next one is breath expansion. Um, I think you have Most of you know that you can use you can move a file by using um md But you can also use something like this to move a file, which is a little shorter This is called breath expansion and you can also use this with a lot more commands like cp The next one is history, um terminal actually remembers The command that you ran before So if you said history then it displays all the commands you ran before And here it is some numbers and what you can do with them is that to run a specific command that is associated to that number You can also say uh ban ban to run the last command that you just run like this And sometimes you don't really remember the whole command But if you if you only remember the first or second character You can say uh control r in this example I'm trying to run break test something something something which I don't really remember But I just but I just have to hit control r and hit break and then the terminal will give me the right command that I That I would like to run The next one is three. It's like los, but it also displays the directory tree So it so if you don't know what's inside the directory, this is really handy You can also find a file if you use it with grip The next one is ag it's a card searching tool a similar to an act, but it's a lot faster Here i'm trying to find files which which have the word literal And the results looks like pretty much the same as what Act provides, but it's actually a lot faster than act So if you think act is slow, then you should definitely consider using ag The next one is agdp pi. It's a it is basically a better version of curl Like I said, I make a request to it will be gems and you get a result like this, which is not really readable But if you replace curl with agdp, then it's it will pretty far the json. So it's it's going to be a lot easier to read the json But sometimes you don't want to install agdp pi because it's a pattern implementation And you don't want to install a pattern just to be able to see json And that's why jq command comes really really handy So how can we use it? You make a curl request and you can just pass you can just pipe the result to jq And it will just pretty far the json result for you and what's not so what's not so about this is that If you want to know what's inside dependence its development, it will just filter the results So if you have a really really json result, you don't have to like Scroll down to the bottom you can just say jq like this array or and this property something like that. So it's really useful The next one is pigment types, which is a syntax highlighter written in python I used to use more before but it's not really pretty so I started using pigment types So if you use it, it colorizes what's inside the file So it's going to be a lot easier to read and I have this address on my personal computer So if you so I don't have to think about what client I should be using to display colorize results So it's going to be like this Sometimes you go to stackable for a little server fault and then you copy it past the command But you don't know really what's what it's really doing In that case, you can just go to explain shell.com and pass that command and hopefully it's going to explain What it actually does it doesn't it's not actually 100 percent smart So sometimes it doesn't work then if this is open source project So if you think you can improve then you can just go to github and it's a pull request The last one is shift it Sometimes you want to see you want to see two windows side by side But it's a little hard to adjust a windows manually and what it does is if you hit a Certain command it will position the window on the right or left on the bottom or bottom or top So it's really useful if you want to see two things Side by side. Okay. That's a 20 tells. That's it. Thank you so much Thank you yuki for the lightning fast tips Uh, next up we have, uh, steven steven is a full stack coder and then a jowl coach He hosts the monthly ruby meet up in hou chi min vietnam Hello, okay. Okay. Hi guys, um, steven. I'm gonna talk about building real-time apps with blah blah blah blah blah Okay, i'm a singaporean I'm a singaporean. I'm from singapore. All right. I'm actually currently serving my national service Uh, that's why I couldn't join the ruby conference yesterday and this morning Yeah, uh, and I only managed to actually sneak out this afternoon through the jungle as you can see in the picture over here Just to deliver this talk to you guys All right, okay Um, just it's just joking for the record of this video in the youtube Uh, I've actually approved a clearance for my commanding officer to come here for the talk. All right. This is for the record. Okay All right a little bit about me. I'm steven. Um, this is my my my profile. I'm a programmer myself Consultant. This is the company I will aim. We do awesome ruby on real development. Just like you guys here I also host a Saigon rb the ruby meetup in hou chi min So you will do it on the first Tuesday of every month. So if you're in hou chi min, please come and look us up All right. What is the real-time app? Basically just define at that user that doesn't need to actually refresh the app to get new data Okay, and the first thing that we need to do right is to actually get the web socket up And this can be easily achieved in rails 5 action cable. Okay But that's just not all there's other challenges Some of it that we actually phase right is actually updating the view using j query You need to do all the pre pre pre pre pending a pending changing the inner html and it's really very troublesome and messy and Next thing that we need to do is doing all the broadcasting when you broadcast the right message the needed changes to the right clients And we also need to look at chain reaction when the application is sufficiently complex There will be things like one view updating a model which update another model and then after they upskate another model again Another view again. Yep. And all these challenges arises because we're trying to Sink the data with the view. We're actually trying to control the flow and the mutation of all the data and With all this right, there's actually another way to solve all this problem We can try to do decorative programming Which is actually trying to describe the end result without describing how to achieve it We don't need to care about how the data or the view is actually mutated So let me give you some of the example like in the view we use reactjs Okay So this is a sample. This is a code about reactjs. So on the left, I have the reactjs component And what this does is that it simply renders out the messages that it was given So we just need to say if there's no messages, I will just return no No messages available and if there's messages, I will just list I will just iterate out Yeah, and given An array will the react component will always render according to the array and when your array change reactjs will automatically change it Yeah, so this is very decorative We just need to say how the end state needs to look like and we don't have to care how the DOM is actually being manipulated Okay, so decorative approach to our views and then we don't have to do all the troublesome thing of prepending A pending adding here and there changing here and there and then we can see our view end state very clearly very easily All right, and then we can and we move on we need to handle a lot of different data and state in our front end All right, and we try to use redux which is a javascript idea all right, so so like in this example In this example, um, we take a very functional approach to us our front end state management And whenever we have a change, which is what we call an action We write a function What uh, call a reducer they will mutate the state correctly and return it like in this case right Given a new change call add message. We will simply add the message into a state and just return it and we let react Uh render it accordingly all right and Using this decorative functional approach towards our front end state management We make our front end state the data or the mutation very easy to understand and it also makes it very easy to test Okay, and can we actually apply decorative style to our back end The answer is yes, and we can use it to actually solve broadcasting messages problem in real time app Yep, so in real uh in broadcasting messages Um in order to create update and delete operation with the database you often need to update the views What are the different changes for the clients? What is needed and all these broadcasting messages will be found in your active record active job callbacks All over the shop. All right, so we we work with reading db it provides us a decorative style to Broadcast the messages and this is a sample code in our action cable channel room Okay, we tell reading db for any changes in the message table that has the current If the receiver has the current User id please stream to me all the changes All right, just broadcast to me all the changes. So we just say what we need and that's decorative approach And this is a sample that what reading db will actually stream it to us You tell us what's the new value and what's the old value And then our redux will take care of the state state change management And then after that you pass a new state over down to our react js and they will render it accordingly So everything is decorative So in um reading db we take a decorative approach towards broadcasting changes And we can we can keep all our broadcasting code in us inside our channel subscription and it makes everything very tidy Okay, and it's very easy to understand which client which user role needs what kind of changes Okay, so wiring all of them up we have our react js which is a Almost like a pure function of the view Okay, and then we have a redux which is like a single source of truth because it contains all the state and you Manage all the state and then after that we still have our rails doing the back business logic and holding the web socket connection And then we have single reading db which is like a single source of broadcasting Okay, and with all this we have the benefit that we are able to reason our bug very easily Styling errors data errors logic errors Broadcasting errors we can we know where to find them and then it makes Doing real-time app development much more easier And when it's easier it is more fun. Please some resources for y'all. Thank you very much Thank you Stephen once again for rushing down all the way from national service Yeah, I was expecting to see to see him come here in uniform, but Yeah, a bit disappointed Next we have sing Tian Sing Tian is a graduate of the tag ladies boot camp in singapore All right one more round of applause for sing Tian Hi, everyone. My name is sing Tian. I consider myself as an intermediate beginner. I just started coding Not too long ago So today I'm going to share a bit about my journey of learning ruby on rails Two years ago. I was kicked out from nus master program and myself confident was at all time low So a friend of mine introduced me to the concept of programming and show me what can be done with code So I was intrigued and soon I become interested in all things tag and start up To me what attracted me to code is not coding itself But the magic of being able to turn any idea into a useful product So like a lot of you I learned html CSS and javascript on free online resources by myself However, it came to a stage that I did not know how to proceed further and apply what I have learned to creating a real life application So it was after I joined a hackerspace event that I found out about tag ladies So tag ladies is a community for women who love programming And one of the activities that they do is tag ladies boot camp where women learn how to code By creating products for non-profit organizations Under the guidance of volunteer coaches So I applied to the coding boot camp immediately and was super excited when I was accepted This experience was a life changing one So for the pioneer batch Nine of us were selected over 120 applicants And each of us come with our own stories and motivation of wanting to learn how to code Some of us aspired to become a software engineers and some of us want to build our own startups So we work on three projects over a eight week period Through this through this experience There are a few things that I found really useful if let's say you are helping a beginner to learn how to code Let me quickly bring you through that Firstly, theory versus practical Computing lessons and collecting badges from code code school and cokademy only brings one that far So what's next? What I have learned is that the best way of bridging the gap between knowledge and practice Is to dive head first into a project and solve real world problems So working on the tech ladies project for engineer.sg Breach the gap between theory and practical for me Engineer.sg is a non-profit organization That helps to documents the Singapore startup and tech scene and they are the one that flaming this conference So my team's project was to improve the app's user experience So I have to pick up ruby reels and programming concept and all other tools that you can see here and apply the knowledge on to Engineer.sg app So working on a project really helped me to see all the programming concepts come through life Secondly, mentorship is important I'm sure all of you here can relate to having a mentor or a role model in the tech community or at your workplace So as a beginner in any field, having a mentor is very very important Like me, a lot of us today had someone who was willing to give us a kick in the right direction So our tech ladies coaches was very helpful and I improved tremendously under their help From my coaches, I learned practical advice Programming best practices and non-technical knowledge such as working and communicating within a team Just a quick side note If you or your company is interested in paying it forward Tech Ladies is a community led initiative and it's always on the lookout for support Please come and find us at the booth outside Or you can actually send an email to Elisha, the founder of Tech Ladies For sponsorship and coaches Apart from programming, one thing I have learned is the importance of community A community helped me to learn from each other and that is definitely important because each of us have different knowledge set So I'm constantly being inspired by the determination and perseverance of my fellow Tech Ladies So after the bootcamp has ended, I found that there wasn't an environment for beginners to present their work and learn from each other So a fellow Tech Lady and I kick-started an initiative called Tech Ladies Tech Talk This series of events features beginners sharing what they have learned or built With this, we hope that beginners will gradually improve their skills and build confidence in programming So coding has completely changed the way I approach problems I'm now being able to communicate effectively with my company Tech team in order to stop the issue faced by my department So one day in future, I hope that I can I'll be good enough to create a real world application that can bring values to others That's all for today This is my first time speaking to so many people on this stage I really hope that you have enjoyed it. Please feel free to drop me an email if you have any questions. Thank you Thank you very much, Shing Tian So We are supposed to return here by 3.45 from the break, but I don't think that's possible In case you guys Couldn't catch up with the nighting lightning talks. We have them hosted on engineers.sg Say hi to Michael For hosting them We also have digital ocean stickers at the registration counter and refreshments outside right now I hope to see you back in about 15 minutes at 3 55 Yeah, we have refreshments outside Gotcha I'm making slides for all the speakers Uh and since your talk is right before my talk, okay, is there something I should put for your talk Like what? Uh, well, some of them are jokes some of them are kind of just like the tldr stuff It kind of depends on the talk like the more technical stuff tends to be a little harder Because it's like a bunch of information. Okay Or like is there like basically like a key takeaway. There is a very cool idea which I'm going to present So I familiar with chat ops and lots like lita and who got so for all of them you define a comment with a regular expression and We have a lot of comments and we decided that regular expression is not the best developer experience for that So instead of so in our chat box, you don't need to write any regular expressions And you just have a special like Yeah Nice So when appropriate slide be when you use a regular expression, you have two problems Hello Next up we have uh kia kia is uh Engineer from shot at Shopify. Uh, I also realized that he actually has been to many many countries and He coached at rills girls in finland. He's from russia and he now works at canada. So, uh, round of applause for kia, please Can you hear me? Can you hear me now? Yeah So my name is kyrsha trough and my talk today is called building a chat ops framework A bit about myself, uh, so my name is kyr I work at the developer acceleration team at Shopify I'll talk about more about this team. Uh in my in my talk, uh I live in canada. It's where Shopify is based And uh, we may probably have worked together on some open source projects like rails kipastrano, uh, rootbench And that's me with the cat Um, so let's start with chat ops. Uh, please raise your hand if you heard about that Cool Um So with chat ops, you can move your technical and business operations into chat Into a conversation with your team And uh, this term was first introduced by github And they they first started to talk about that on conferences. Um, they first made a chat ops framework And uh Yeah, it also connected to a term conversation driven development Uh, as you probably heard there is test driven development behavior driven development and many other kind of German developments and uh with chat ops and conversation driven development Uh, you can bring all of that into a chat with your team And a bit about Shopify, uh, we have quite a lot of developers Um More than 300 Yeah, so if you don't know about Shopify, it's a e-commerce platform for small and medium business and When you have so many developers, uh, you need to build Tools for those developers so the developers could be productive And my team, uh, where I work is called develop acceleration And we build tools for internal tools for our developers To make their productivity better and the chat ops And all that kind of automation, uh, is one of the things that developer exploration team is working on So for you to have Better idea how All of that looks Let's start with with an example So in Shopify, uh Every developer is responsible for shipping His or her own features That means, uh, we don't have any kind of release engineers who push, uh comments of other people So if you made a feature, you're responsible to deploy this feature to see That it works and it doesn't if it doesn't work to roll it back Or do something about that So imagine you made a pull request, uh, you are about to merge it You merge it if everything is okay with the with the ci And in a few minutes, uh, you get a message From a chat bot that your Your feature your comet, uh in the master branch is ready to be shipped And you tell about okay Let's ship it And in the In the group channel in slack, uh, we use slack Everyone will see that you're deploying something what comets do deploy And also the result of this deployment. So it's usually, uh, It's usually succeeded, but it can also fail Like on on this slide And this is how deploy work So right after Deploy or after you committed something, uh, sometimes it happens that we have an accident For instance, if Sign up is down for example Someone comes to this the same chat and starts An incident an incident is a special procedure to To manage some kind of Bad thing that happens in production And it includes actions like updating, uh, status web page and, uh, investigating what's wrong And we also have a Chat command for all of that Another example is, uh, monitoring the most, uh The most heavy skill queries or the most heavy customers who who, uh Who bring a lot of load on our service And another example of automation is creating new repositories So if you work in a small company in small team, uh, you probably have, uh CTO or someone who is admin in your github organization who can create a new repo for you But if you have hundreds of people, um, there is no there can be no special person who Who has, uh, a responsibility to create a new repos for someone and, uh Another aspect is that as a developer you don't even know who to ask to create a repo for you We have special, uh, events, uh, called hack days, uh, where we have a lot of internal hackatons at showify And on these days we create a hundred new repositories during a couple of days So this is an action that should be automated as well and, uh Speaking about chat ops. It's all about, uh, it's also about the interface If we would if we would take another, uh Another path would probably create a web interface in bootstrap or Or something else and To give developers, uh, all actions all to give developers ability to trigger all those actions and script That automated But with chat ops is just another interface which is chat, uh, which has a lot of advantages, uh, for example, your team, um We'll we'll see what's happening and what actions are you taking to do something Now we come to, uh, the next part of my talk Which is about frameworks About chat ops frameworks that exists and about our own kind of framework That we wrote and reasons why we wrote it The first Framework is called Hubot. It's the framework invented by github, uh, that I mentioned Hubot, um Is written in coffee script, uh, which means it's in javascript in Node.js And as a ruby developers, you're probably, uh Maybe some of you don't like Javascript, uh And there are many ruby developers who don't like javascript, but in case of chat ops framework, uh Javascript may be a good thing because it brings, uh Uh, a lot of asynchronous support to your code Which is important in case of, uh, chat ops framework because comments have to be asynchronous and one heavy comment shouldn't block comments from, uh from other people Another framework is called Lita. It's written in ruby and it's very well extendable It's two years old Very good framework and it's fair to mention that, uh Both of these frameworks have different adapters to every chat provider um We use Slack, so uh Slack is the the only adapter we use but if you use some very, uh rare, uh Chat solution, uh, you can uh, you can find existing adapter or write your own adapter Let's see how, um how Chat scripts, uh, and how DSL, uh looks like So this is the Lita DSL. Uh, you just define, uh Small ruby class, uh, which has a macro code root In this macro you describe a regular expression with The comment that you would like to trigger So with this handler if I go to slack and write Echo something the bot will, uh, will catch this, uh phrase and uh reply with The second word that comes after echo and the the Hubot syntax, uh, is very is very similar to Lita You also define the The regular expression that, uh the bot should, uh Should wait for and uh send a reply If we take a closer look we will see that, uh, both of these DSLs are Based on regular expressions And uh, you should write a regular expression, uh to Tell the bot what comments to detect And uh, why regular expressions? Um, it is the the the easiest way to, uh tell the bot What comment to watch And, uh, this approach have a few disadvantages like, um It cannot detect, uh typos It cannot, um Uh reply with, uh This comment was not found maybe meant something else It can also it also cannot do Input validation like if the comment was, uh Uh was right, but the argument, uh was was wrong and that argument may have not meshed By the regular expression and this comment won't be found and, um Having regular expressions in your, uh chatbot, uh means that, uh all developers should, uh Should be really good in regular expressions And it's always easy to make a mistake And find a regular expression that will Uh conflict with the different, uh script regular expression So, uh, we we Thought that maybe, uh, we could do something else without regular expressions and, uh Yeah, here is an example, uh The first option, uh To write the comment syntax with a regular expression and the second one Is to write it with some kind of, uh Partural language And, uh with echo, uh the difference is not that big But with a bigger comment like github add user name to team name The regular expression becomes, uh quite long And it's quite easy to make a a mistake there, as I said So we we thought that maybe we can improve that Um that experience of writing chat, uh handlers and, uh What we wanted to uh to have from that Solution we want to be friendly for both developers and the user, uh by Being friendly for developer it means that developer wouldn't need to write a regular expression And friendly for user means that we would suggest write comment if a user made a mistake We're also, uh We also have a lot of, uh ruby Infrastructure code written in ruby at Shopify. So we we decided that we want to stick with ruby After we tried both, uh Litan who bought in production And we wanted simpler and more powerful gsl That would provide a better argument support Uh, so our solution, uh, we we decided to to make it on top of leta With the custom command router and custom dsl And uh, this is how this dsl looks like First of all is very similar to leta But instead of defining the regular expression Here you define, uh special pattern And you also define a help And uh Right after this pattern is matched. It's dispatched to ruby method with a keyword argument And in this case, it's very simple handler. It will reply with the same command So let's take a look on a a bit more complex handler. It has two arguments one of them is Yeah, this handler is for displaying some chart from your lake Uh, the first variable is application name and the second is format A formant, uh, is a yinom filled It can detect daily or hourly value And help and it should be uh converted into a calling of ruby method Which is kind of uh simple So this pattern Would match all the following User inputs Can be my app. So hourly is the default value for the format variable You can override it here and here and you can also define it in the explicit way Which is useful when you have More arguments And maybe you don't remember the order of them So We also wanted to have the explicit format and we To be able to work without regular expressions We we tokenize this pattern With different kind of tokens first to our static tokens so The user inputs to start with a neural egg and chart and then there is a Simple variable and then there is a variable with default It looks like this. So this comment consists of four tokens Our next goal is to convert The user input of neural egg chart my app daily into calling a ruby method Actually, yeah instantiating the neural egg hender and calling That method with those keyword arguments And This may seem as a As a task As a difficult task Until we discovered The class in ruby standard library, which is called string scanner Yeah, it's a class in a ruby standard library. Please raise your hand if you heard about that class Yes, and not too many people Um So string scanner works as a scanner. I'll have an example now So you initiate an object With with a string In this case string is the user input and You there is a method called scan and you give just Just the token to that scan command and Yeah, so It scans and if this user input would start from something else It wouldn't scan the string at all. So if it would start with GitHub or some other Command it it wouldn't be scanned Then we have the next token which is chart static token It is also scanned so we can go further Uh, then we scan for a variable So that It's scanned And then the next variable and we get The The values for those variables So it wouldn't be honest So it's not very honest to just to say that we completely got rid of Uh regular expressions, but the end developer of Of a handler doesn't have to write a regular expression, but we we use some regular expressions under the hood Yeah, so more than that we have Type coercion So when defining a handler, uh, you can You can declare the type of variable For instance the target This is the comment used to Tell to the infrastructure that some Server will go to downtime That means that maybe we are going to restart the server or repair it somehow and there are two arguments one of them is a target which is a Chef node it should be a valid chat a chef node address and then duration duration can be One minute or one second or one hour Or just any duration and we also declare that So the first one types chef node second types duration and when the root method receives So when we call this review method inside this method, you'll have duration as a active support duration and Target will be a valid chef node. So we can be sure in this method that both of these arguments are are valid So this comment will Will be valid for the first input, but for the second input It won't be valid and it will Return an error and This this method won't be called at all So when writing code in that method, you will be sure that you get the the right input After shipping This DSL to our developers money developers could Could write their own chat handlers to automate their their workflows And we we got to the number of more than 200 both scripts handlers and more than 60 More than 600 common invocations on a busy day in Slack So this became A part of infrastructure that we had to scale As I mentioned where we based our framework on on lita So it was just the next On top of lita and that means so lita is written in ruby that means that it didn't have Any support for asynchronous workflow which meant that if you ask a bot for some common that takes a minute Working on comments from other users So the bot was blocked for that minute and it couldn't accept Comments from other users, which was super bad especially in the scale So we decided that we will As as one option we can Make a new thread on every comment and do all the operation in that thread to not block receiving new comments from slack and Ruby threads are not Are not so good in some kind of in most kind of operations, but in in our case when most of the handlers for chatbot were only making htp queries or They were invoking Some other kinds of systems They didn't they didn't do any calculations on the bot side So they just requested data from other systems. So in this case ruby threads were were quite efficient And this approach helped But we we thought that maybe there is some other approach and we went with With a master process and redis and when the master process received a comment from slack It pushed that comment to redis and we had a pool of workers And we could have multiple machines that are that work as workers So we could scale it scale that horizontally And it works The same as a sidekick or delay job Worker queue having that approach we could have active and passive instances of the bot server running And slack would make a callback to a load balancer with the message for a bot And then the load balancer could determine to which To which machine to To root the message And that comes to the availability problem So if you remember and at the beginning of this year github was down for like for three or four hours That was a pretty big downtime and one of the reasons for For that such a long downtime was that github is heavily based on on their chat ops scripts And but but chat ops was down as well because of some network failure So they they couldn't use any of the chat ops scripts to recover the system because Chat ops setup was down as well And we know that problem a short five We we also had This problem when our bot was unavailable or slack was down And in this case we we couldn't do anything So we decided that we'll build a special offline or rescue mode in our bot So you should be if you have this bot locally on your laptop you just Launch it with a special beam command and you will have Exactly the same interface in your common line as you would have interface for a bot in chat But it works even if slack or Something else is down summary This is very important. So probably you you Learned a bit about chat ops and how it can automate things And you thought okay cool. I'm going to try that in my team in my company but I would like to say that it's it only makes sense when if you have a very big team Because when I worked on In smaller teams in smaller companies I would say that we didn't need all of that just because It wasn't on such scale That that we needed to automate things with with chat ops and in this case It's really easier to come to your cto and ask to create a new repo for you instead of Bringing more code and more infrastructure to keep the chat ops running So if you're interested in working on such a big scale systems Welcome to check Shopify careers and I had I have mentioned a lot of projects in ruby a lot of gems and Some other things so you can go to my twitter and The last bit is a gist with with all links that I mentioned today I wish you're welcome to check. Thank you. Thank you very much here. Any questions for him How many of you use a some form of bots on your favorite tool? My favorite slack bot is the flip table bot So whatever you type in it inverts it with a raging guy If there are no questions for here Round of applause again for everything Our last keynote of the day He's also very well known for keeping his Cap on So Yes, so I'm quite curious. Why why are you always wearing your cap? Mike check, uh I wear the cap because it makes it easier for people to find me Uh, I haven't found there's a lot of people who wear a blue a light blue cap around so it's worked out well Sure. Uh, good afternoon everyone. Uh, thank you for making it all the way to the end. Um, This is my second red dot ruby conference Um, probably the third time I've been back to singapore So I want to thank the team for organizing this entire conference and then once and I guess for reaching out Inviting me back to singapore. Um Hopefully this talk will be better than the one I did in 2012 Um, so I'm tarence lee. Like I said, I go by hone zero two on twitter Um I come from austin texas, uh, where we do really really good tacos. I like to call it the taco capital of the nation Um, if you're ever in town and I'm also in town Reach out to me and I'd be happy to take you out for tacos Most people don't actually Hold me to this but I have actually done this for people. So It's not a empty offer I Known for my blue hats. I do also have blue hat stickers So if you do want one, I'd be more than happy to give you one Uh, probably after party. Um as you head over there Like nat said I work for heroku And I'm just excited that For all the stuff we've done for ruby and the opportunity to kind of do all the stuff that we've done So today's friday, uh, and That means that we have to do the friday hug so Um for people who aren't familiar because you're new to the ruby community and you haven't heard of it Um, I believe it's a thing that erin paterson started He worked remote and he would basically take a picture himself hugging the camera and then people would tweet photos back out and I've gone around to various conferences and basically Done this with the entire crowd and it's been I think just cool to have a collection of these friday hug photos So if everyone would stand up I would appreciate Given the chance to take this photo.  If you don't you're doing probably just look at the person next to you They probably know what they're doing So ready One two three happy friday Thanks everyone I'll tweet a photo of that When I'm done with my talk I also learned recently that uh godfrey who you heard from yesterday Is doing this thing called solo selfie while wearing this awesome han solo shirt So I asked him to come on stage to do yet another photo Where we will demonstrate doing a solo selfie so you can then do it at the after party with him while he collects all these photos So definitely catch godfrey at the after party if you haven't gotten a solo selfie with him. I know he's Trying to create a large collection of them Uh, the other thing that I like to do at conferences besides friday hugs is uh ruby karaoke And I've been very fortunate that we've been able to successfully do one For basically like the last year and a half at every ruby conference that I've been to um, and so this is us doing ruby karaoke at ruby conf last year in the us and If you've never done karaoke, it's totally fine Like godfrey said, um But uh, in fact most people who actually come out to these things have never done karaoke before And so it's usually their first experience at karaoke And I've never had someone who has complained to me that they didn't have a good time Uh, and if you're scared about singing, I think the point of karaoke is that you aren't good at singing and that's like half the fun of it um and You also won't be pressured to sing so you can just come and have fun and kind of just enjoy the company of your fellow rubious In a totally different light um And this is just a picture of us doing this at yoruko last year and that's uh, pj hagerty who goes by asplenek on twitter And he has been instrumental in just making this happen So shout out to him and so we'll be doing it at 10 p.m. Tonight, uh, I guess in the middle of the after party I got approved from wenson from stealing people away Uh, we'll be doing that k-box in china town. It's about a 10 minute walk or so So we'll be leading a crowd of people if you want to join in uh, feel free to come join us And it will be probably Winston booked a room, but I think around 38 per person So come join us for karaoke. It'll be a pretty good time And uh, so this is my third conference. I've actually closed And when I first started doing it, I asked erin who's done a bunch of these like What are you supposed to do for these things?  Um And so I first wanted to congratulate, uh Just like the local singapore ruby group like it's pretty amazing that it's been around for 10 years I know that's not true for lots of other ruby communities out there Um, and it actually makes me feel pretty old because I've also been doing ruby for 10 years. So It's pretty awesome that this group has been this healthy and this strong for so long So yeah And so with the opening keynote matt's talked about soft typing a bunch of other things But I was super happy to find out that uh in the ruby community we can cross off naming things because With the soft typing inference now we don't have to name these types. So that's pretty awesome In jason's talk when he talked about slaying the dragon He showed that you can actually build like a lisp language like very quickly, which was really cool And I was pretty amazed that you can actually just use this single and for doing a tokenizer thing Like this is actually not a very long regular expression. So the first time I've seen something like this. So that's pretty awesome For the ruby golf talk that joy did it was really neat to I guess learn all the ways I should probably not write my ruby code, but it was definitely neat to see like all the different secrets I I did not know Numbers two to four at all and I definitely think she's right like number four is really neat The fact that you can pass that regular expression in is very cool Prophet match did a great job of talking about all the changes in rails five testing I didn't realize that all these changes have actually happened But I think the conclusion for me was that I've basically been doing controller tests wrong Like the fact that we should not be doing them So I thought this meme was appropriate there Godfrey talked about uh software education And I think it was great to kind of a like kind of tackle that up front with both the boot camps and computer science And I think he really cracked the nut of it that What we're trying to teach is how to think about things abstractly And abstractions are a great way to kind of form a mental model for things But of course like any abstraction they'll leak and so being able to figure out how to To deal with the fact that things will eventually leak as you go forward and Like how to deal with those issues is an important part of I think That career road path for being a good programmer in this industry Next slide, I think I also can't pronounce Gregor's first name, but I like to just take away that your API is probably fast enough and I think that is great, but apparently Okay, there we go Sorry technical problems And also enjoyed his advice. He gave us a lot of great advice for how to do things with like CDNs and whatnot But I I did enjoy his advice about don't be a smart ass with that Onto the lightning talks for the first day, Joe did a great job of talking about why people are leaving Companies in general. I think the turnover rate in tech is astoundingly high I think like if you make it up to like a whole year at a company, that's like you're basically really old and a veteran at that point Which is kind of crazy But for me, I learned that basic google is filled with lies Which is news because I thought everything on the internet was true And that people don't leave because of managers, which is something that I never thought of So that was neat to learn Shabata san talked about How to eat how you can easily contribute to ruby I think it's nice that he highlighted in a single place that you can basically Like run the test with six simple commands. Um, and the other thing that I learned was that uh, documentation is really hard and ruby, uh, which Is nice to know because I feel like that's the common advice you get oftentimes about contributing to open source projects like oh, you can just contribute documentation, um, and Like actually understanding how all that stuff works can be difficult Uh, and kita talked about speeding up the test suite But I did appreciate in the beginning she gave a bunch of advice, but uh, the fact that Man these slides are not changing. Okay. There we go that uh, If you have no tests there will be no slow tests. I thought that was pretty neat. Um And then next we talked about Basically like flexible authorization. Um having done some authorization stuff in the past, uh, this can definitely be challenging But it was neat to kind of see The like forward progress in making a better authorization system that allows I guess more power to the end user and not have to kind of step in and dive Uh towards those things. Um, and I also didn't know there was an open standard. So that was new for me Uh xac ml And uh, then tim gave a talk about kind of next generation web apps And it was neat to see how you can basically build an architecture of stuff where Like the ability to easily change things is kind of at the Uh, core front of it, uh the forefront of it. Um, so just having Uh, like a positive architecture that provides maintainable sustainable and joyful development Um, and I'm pretty sure people who have dealt with uh, legacy rails applications Are aware of kind of the issues that come from dealing with older code bases So seeing something that tackles those problems up front, uh, was really neat to see Uh, and then sao, uh, sao shiang Had this great talk at the end of the first day where he showed us a bunch of simulations. Um, and I think I was just amazed by When he actually opened the code of how simple it was and it was neat to kind of see like Oh, it doesn't actually take a rocket scientist to do like kind of these crazy simulations Um, you can actually do it inside of ruby and uh, kind of run your own experiments. So I thought that was really neat so For the opening keynote today Aaron talked about a Reference to my talk, but that's kind of weird because i'm doing my talk now So, uh, I took a picture of him doing this so we could have a circular reference At this conference Smears talked about scientific computing and ruby was really awesome. Uh, I thought that the iBook thing was Um, just kind of just a really impressive demo that you can just do all that stuff in line. Um, But for me, uh, the thing that I learned was uh about daru and Uh, in hindi that it meant alcohol. Um, so I thought I would put up a thing for the singapore sling Which was what I think about for alcohol when I come to singapore um I thought Constantine did a great job of just kind of disrupting salary stuff in general and and kind of the Thought process behind how travis reached the point where it did. Uh, and I mean besides Currents like foreign currencies being really hard and I thought that gold example was Kind of crazy for the uh, prudeems, uh, just like salary stuff in general was really tricky So, uh kudos to travis for paving a better way forward And i'm looking forward to kind of how all that stuff works out and as they get closer to Open sourcing and having those discussions Um Vipple uh talked about a bunch of stuff about speaking up front and I learned many things that were actually happening in rails 5 And I talked to him after and he said oh, yeah, that's only like kind of the tip of the iceberg of like all these changes They're actually happening. So looking forward all the things are coming in rails 5 And but uh, it's nice to know that we can now cross another thing off part of things in computer science because uh from all the catching stuff I remember back in the day when russian doll cashing came out dhh was saying they solved cashing So decided that we've now crossed off like two of the hard things in computer science um As siganese talks about, uh, the internet of things it was just like really impressive to kind of see Uh all the stuff and how approachable is I I don't believe seen people talk and about it a lot at various Well, not a lot, but I've seen a few talks about it at ruby conferences And I think the crux of it for me the takeaway was Now that it's becoming more consumer friendly and more developers are digging into it like How what are we going to do with the data and like how we handle all that data is going to be really important in the future with both like machine learning and other things and big data and it'll be neat to see how We as a community kind of tackle those problems Um uh, yes, suko did a great job of Uh talking about upgrading rails One of the things one of the quotes for me that really stuck out was I think it's very easy when you talk about legacy systems to kind of throw all that stuff away and One of the things that you who does told me A lot while working with an open source is like It's dangerous to just throw away like that old legacy code And I think this quote from her from her talk Really highlights that is that like the fact that this system exists and it's solving real problems means that there's probably Things that are in this code base that you may not understand But is actually solving real problems and you should think twice about just like Starting stuff from scratch and throwing all that stuff away because there's a lot of intelligence and knowledge built into that code Um So on to the blog posts, uh, I really enjoyed this Japanese quote from the blogging thing Or the proverb I guess uh three years on a cold stone will make the stone warm But I mean I think that supplies beyond just blogging like perseverance and kind of dedication to something Really pays off in in order to either learn a new language Or you know really want like if you want to contribute to rails It definitely like takes a lot of effort and time and having that motivation to keep going. I think makes a big difference there I thought that made the kind of whole story that jack gave of interacting the maintainer Is unfortunately not a rare thing But it was sad to see like the results of that ended up the way it did But i'm glad that you learned many things from it, uh, but Yeah, I definitely don't believe in the stars on github It can definitely reflect different things and um I think the other key takeaway from that talk for me was that PRs can be used as a Conversation opener and you shouldn't make them like kind of this absolute perfect thing I mean you definitely put work in front for them But definitely use it as a way to start a conversation with the contributors and maintainers that project to then Work towards a eventual thing that would get merged Uh Yuki talked about a bunch of stuff. I actually had no idea about the experimental stuff. So that's neat to see Hopefully we'll see that stuff soon in a new release of ruby. So I don't have to Require a specific thing for it But he talked about a bunch of different tips some of them I've heard before and many of them I didn't But I definitely most excited about the explain shell.com. Um, because there's definitely a lot of archaic things I think in Shell that it would just be nice to have someone kind of tell me what those things are and what they're actually doing um Stephen did a Cool job of just talking about react and telling why people really flock to this framework and how you can kind of apply those paradigms down into your rails itself. Uh, I think it's neat to see with both functional programming languages like elixir and phoenix uh framework phoenix be on the rise, uh That these kind of declarative paradigms allow you to easily reason about where problems are in your code base and like how How to make sense of all those things and where you need to look, uh, which is really neat And welcome to the ruby communities and uh, it's nice to see people I think one of the great things is just seeing people always being welcomed and joined into this ecosystem. Um and for sure like The stuff in those code schools are very far from what things are in reality. Uh, but I think just this whole journey is pretty magical of just having that feedback loop and having access to mentors and Being part of a large community. Uh, so good luck on your journey there and uh, thank you for taking the time to give that lightning talk And uh, finally for the keres talk Of course, uh, regular expressions are really hard. Um, and I'm glad that We're pursuing stuff where as an end user, I don't have to write very fragile code And I'm looking forward to seeing how those things progress Uh, so Yeah, so that's kind of what I had for all the other talks for mine. Um Uh, so let me get to I guess like my story and uh, I guess the crux of Uh, the the talk itself so Before I get to my ruby story, um The first real programming language that I learned was pearl Um, and I really enjoyed pearl at the time. Um, but then when I went back and actually read my code I found it really hard. So I think the moniker of like a right only language started to make sense to me Um This relates to kind of the ruby golf things like all those short hands and things could make things Very unclear to write, but it was really cool. I think pearls like one of those like epitome like Golf kind of languages like the amount of stuff you can do on a single line is kind of crazy Um, but it was great for scripting. Um, and then when I got into web development like I went towards php And I think there was probably many of us uh back in the day in ruby who dabbled or did a lot of php. Um But we were definitely left like fairly unhappy and I heard about rails, uh, which was kind of this holy grail In my mind at the time when I was young and I was like, oh, this is like the silver bullet That's going to solve all my web development problems. Uh, so after hearing a bunch about rails I Picked up this pickaxe book uh back in 2006 and starting learning ruby And uh since then I've it this was a language that really spoke to me And I've been very fortunate to be able to work on various different open source projects uh in addition to having a full-time job that Paid me to actually use the ruby language every day, which was really cool So, you know, like I got to work on bundler for a few years and then maintain rescue for short stints Uh mats for some reason gave me commit to ruby and then I've helped with uh, I know rails girls used to have uh a strong following and singapore that's now changed to its own thing, but uh, I was um Hope with open sourcing the the rails girls guys, which was a really cool kind of just experience to see that whole community there Um, so, you know kind of after doing this for 10 years Like why am I still using ruby like there's so much other stuff that's happening and so much interesting tech that is happening around us um And I think first and foremost for a lot of us like the ruby community is a really special place, uh There's a lot of I've met so many amazing people in my journey for the last 10 years That are now like really close friends of mine But even beyond that like every conference I go to I always meet really cool people that are doing some pretty amazing things and The fact that rails bridge and rails girls are both successful in the community Means that we've done at least a decent job of trying to be inclusive and trying to make it better The fact that we care about things like diversity is just really neat to see we're at the forefront of a lot of that You know, we're not where we want to be but like the fact that it's an open issue and like people talk about it Is really great to be in that community and it's something i'm very proud of um And then even beyond just like that stuff, uh, I think it's really neat that we In the community itself like encourage people to explore other languages and go learn and do stuff and not just do everything inside of ruby itself I know matt says he can't uh leave ruby But like I know he examines and does research on other languages too And you know for some people they leave and they don't come back They find greener pastures elsewhere and for others they do stuff and then bring stuff back and make ruby better Um, I think it's great to see ruby conferences Like bake this into a thing. So like at rails comp this year, uh, brian carrella gave a talk on phoenix This rails like framework inside of elixir and the fact that there was this alternate framework track That is like sanctioned as a part of uh rails comp and Is just like great to see that you don't see in many other languages um And one the and one of the things that ruby has been around for a long time is that it's not considered cool And I think you know like the this blog post by uh, jared freeman really kind of hits that point home a little bit that like Oh back in the inflection, I think around 2014 ish Like no jess was more popular Search term and like it's climbing and skyrocketing while the popularity of rails is kind of diving down and Uh in his blog post he talks about how if he was to start a new company He would not choose ruby or ruby and rails as the Kind of language and framework of choice to kind of base your technology on um But on the flip side of that coin is that you know, like we're starting to become a more mature ecosystem I think rails came out in the first risk release of rails was in 2005. So it's 2016. So it's over 10 years old And a lot of these things have means that for web development specifically like we have all these efficiencies and uh Being able to do like if you're gonna build a new app in and something like rails It's actually fairly quick. And I think it would be hard. You'd be hard pressed to find something that Uh You could do just as well as ruby. I think that's something we do really well um And and and like uh, like math's talking about just like forgetting like I don't want to worry about small things I think there's something really unique about uh, the re ecosystem and community and like one of the values we have that I think other communities don't is that we have this Uh unique attention to detail that we care about we care about the developer experience like I think the tools that we generate in our community care about air messages like that air messages are good That like you don't have to do extra steps to do things And so uh, this is a quote that you could have gave me when I was talking with him The other day just like coming back to ruby and doing some things every now and then it feels like a fresh A breath of fresh air. Uh, so if it isn't something you get to do all the time It feels really nice to come back and and use this language and the tools that are in this ecosystem Um But of course there are also Downsides to doing stuff in ruby. Um, not everything is on this golden path. There are less Well-traveled paths that aren't as well developed. Um, and so I'm kind of I'm gonna go for the meat of this talk into Like three different use cases that I think ruby has maybe not done as well over the years. Um And uh, kind of explore like what we can do about that uh So I think probably the biggest sticking point that most people talk about is that people think ruby is slow. Uh, and um at this point, uh Definitely at paroku too like Fast as a feature like people want things that are performant. Um and I I think like as a community we've taken that to heart right like At folio and mats have gotten together and started this ruby three by three initiative, which I think is really great I'm excited to see when ruby three actually lands Um, and to see kind of all those performance gains. Um, but even before like ruby three hits, uh I'm very happy that paroku has sponsored mats koichi nobo for the last I think like five years. Uh, and um I think the stuff that we've seen in the ecosystem from that is that we've had, uh, Like regular release cycles like every christmas now since 2o right like 2 1 2 2 2 3 2 4 coming out this year. Uh, most likely we'll land on time. Um, and we've also seen actual iterative improvements that we can use on a regular basis, right? So like and 2 1 we got the generation garbage collector and 2 2 we got the incremental garbage collector Both of those koichi worked on um and 2 3 there's a bunch of other performance improvements and kind of the start of some Like ahead of time compilation stuff that koichi is exploring and it seemed to see that this isn't stuff That's like you have to wait when ruby three lands It's stuff that you you get to use and is free to use by just upgrading your ruby. Um, which is great Um, so thank you to the ruby core team. Thank you apfolio. Thank you for oku and everyone else who's contributed to kind of make this a Just better runtime and so i'm super thankful that that is stuff that is Things that we don't have to do and we just get better performance But the perception of ruby being fast is still a thing that we have to tackle There has been in the last five years or so a handful of companies who Have started off in ruby or had departments that started off in ruby and have moved off one example this is linkedin there's no one that was group on and specifically for linkedin they moved uh from Um, ruby i believe to note and the reason why was because of The fact that no does such a good job like uh in keres talk we're talking about Leveraging like io performance So looking about doing like micro web services that maybe call a bunch apis or do a bunch of database calls Um, and you have all these micro web services that do this work And node from the ground up does a really good job of doing all these things. Um So when you're building a micro web service to do that like as a technology stack node makes a lot of sense like you have in your standard library Non-blocking evented io libraries and functions, right? Which is not the case in ruby and I am thankful that in ruby when i'm doing stuff that this is not a thing that i have to do But it does make a lot of sense when you're building these kind of apps Um, and so i don't know how many of you are familiar with the jbm ecosystem It sounds like some of you because pitbull i know is doing a bunch of that But there is this uh, michael framework called rat pack. Um, and uh, I think we're really fortunate to have a bunch of different vms like j ruby out there that allows us to leverage basically the entire jbm ecosystem, but still do stuff in ruby and rat pack um rat pack is a Uh htp framework that is invented from the ground up and it leverages netty if you're not familiar with which is um an event driven uh networking engine at the low level that allows it to be highly performant so A lot of similar things that make like node great, uh And so I said reactive like and so what what does reactive actually mean? Um So I think for most people it means the non-blocking communication so the ability to Kind of do that work like in the chatbot where you don't have to wait for the server Or for the i o for some call to come back while you're doing i o and just block the whole time And I think a really good we're real world example of that is like if you're calling customer service So I think the standard case is like you call you call like customer service and you get put on hold and you basically have to wait there until like the next Customer service representative is available And that is the example of like a blocking call But there are some customer service Places that actually just take your phone number And then you can get off the phone do whatever you want and then they eventually call you back And so to me this is like a very close example of like what a real world Blocking versus non-blocking looks like And so rat pack gives us the ability as we're doing any i o in it to have this async non-blocking communication Um, and we're able to leverage the concurrent libraries inside the jvm to To kind of do this and have all this non-blocking stuff from the ground up um, so What's nice about rat pack and doing it inside of jruby is that we can write code So this is a simple hello world that looks very similar to sanatra Not knowing like any rat pack stuff. I'm sure you could read this and more or less understand what it's doing Of course, this is very simple, but uh The handlers block basically allows the handlers inside of rat pack It basically defines like all the asynchronous non-blocking code that we want to do um and inside of that we're just Uh Setting up the various routes that we're gonna have so you have a chain for get and you can use any of the htp verbs And then as a parameter to that you just pass the path that you want to do so very similar to how sanaturas get and post and all those things work But where rat pack really starts to show a difference versus doing something in sanatra Is the fact that you can do streaming super easily So you can do streaming and leverage the fact that this stuff is async So you're not going to block on the stuff like you would inside of rack And not have to use like rack mallow or something like that And uh, so in this example, what's nice is that uh while we're streaming we're consuming work On the server by any time that it blocks that it has to basically wait for stuff like another another, uh route can get processed or That stream while it's waiting can work on another thing. Um, and so that allows us to achieve a lot more concurrency And throughput while writing fairly like understandable code And so to set up a simple benchmark to show what kind of performance you would get from doing this kind of stuff I wrote a very simple Thing that simulated basically like doing some type of iocall Like fetching results from a database. So in this case I'm just sleeping for 300 milliseconds. And then I'm just returning some response back And when I compare this with basically the comparable code in node, which I'm not showing but I'm happy to show anyone After the talk we see we actually get fairly comparable performance numbers. Uh, the rat pack stuff looks better, but I would just Go and say that you can get comparable performance writing this kind of J ruby code that is fairly easy to read and understand especially as a rubyus And not have to reach out to something like node when you want to build micro web services Uh, so to me, that's like very exciting because this is stuff that you can use today This isn't some like future tech that is around. Um, but you can Use rat pack today with j ruby write write stuff in ruby itself and Do things that node is really good at And if you want to learn more you can go to this link There's a blog post that basically details all these slides and go walks through kind of explaining rat pack more And the things you can do with it and kind of setting you up running it and deploying it to heroku Um, so that's there. I'll publish the slides and tweet it so you can um, you don't have to write in that stuff down So we talked about io for a little bit. So now let's talk about like cpu bound performance So for this you're probably like you would think of like number crunching machine learning any kind of intensive algorithm for that kind of stuff And I think this applies beyond just that kind of work like this like what you would think is the quintessential like Thing you would do for cpu bound work and in ruby itself when you're doing a rails app Same saffron in this poor request actually posted this graph of the kind of the cpu time of the call methods And at the top that he highlighted in blue you see blank, uh, which is active support blank And he said that it marks basically like almost 4 of the total cpu call time to process this request Which if you think about like that's actually kind of crazy like blank is not a very complicated method Uh, so this is the implementation of blank. It basically just checks if you're if the string is empty Or you have white space characters and if it does it returns true or else it returns false Like not a very complicated method, but the fact that it consumes almost 4 of like a Request is um a lot of cpu time So what can we do about it? Uh, I think the standard solution to any kind of cpu intensive thing is to write a native extension so Of course, that's what sam did And so he wrote this thing called fast blank and this is the code. You're not expected to read it And uh with that he was able to actually achieve like Pretty nice improvements, right? So when you're just doing a normal, uh Benchmark against it. He was able to get 20 20 times up to 20 times performance improvement over the active support implementation of blank Um, and then on some natural macro benchmarks. He was able to improve the performance by 5 5 Which think about for just a a simple micro optimization like this is actually a lot of performance Uh for a running rails app um But the problem with that is that writing stuff and c for I think a lot of people is not easy and actually learning Like learning the language to see it's not tricky. It's like becoming good enough to feel confident about the c code that you've written um so as an example that uh, this is nokah gary, which is a if you're not familiar a rapper round lib xml 2 And just going through and searching for it You see that there are issues that come up for just seg faulting and issues with using it That come up. Um, so even like seasoned veterans of Like libraries that basically that's all that this library does Run to problems. So like doing stuff and see it. I think for a lot of people it's non-trivial and can be very tricky to write save code So let me introduce you to rust, uh, which is a systems programming language Kind of meant to tackle these kind of issues and problems. Um, and so This is a copy and paste from the if you just go to rustlang.org Of what it is, but I think what makes it really neat is that it tries to tackle these safety concerns that people have with doing stuff in systems level programming languages and also introduces like higher level primitives that we're used to inside of ruby like iterators and macros and things like that So for instance When you actually compile a rust program The the compiler guarantees that you won't actually run into a seg fault in the future at runtime So this is really nice because as people who are used to not dealing with small things like This kind of stuff that you have to do with c is definitely Like a lot of small concerns that you definitely don't want to deal with So that level of confidence and uh, the other nice thing benefit of doing something in rust is that You have these this thing called zero cost abstractions And what I mean by that is in ruby every time you define a method or your factor something into something cleaner Like we saw throughout this conference. Um And there is a minor performance hit to doing a method call you put on the stack and you have to call it And generally this doesn't matter, but if you actually care About the performance of that thing like every little bit counts, right? But in rust you don't actually have to make this trade off because you pay that cost at compile time But the compiler is able to see these methods and kind of optimize the code in that way Where we're not able to do that in interpreted language like ruby Um, and I was talking about higher level primitives like each and map and things like that and It goes so far that When you do something like each and map it actually gives the compiler more information So you it's actually faster than writing the loop by hand with like a for loop And because it doesn't actually have to do any of the bounce checks, which you would have to do with a for loop So it's nice that it actually encourages you to use these higher level primitives that we're used to using in ruby So in ruby like it might be slower to actually like do something like these fancy things, but in rust it's actually not So that's what I mean by zero cost abstractions um And so the implantation of a blank versus that c code the kind of corvette is this so Not knowing any rust at all if you're to read this You may not know everything that it's doing But this is actually fairly readable code like there's pretty high level primitives that are here where like is white space The fact that it has this all iterator So it uses uh, you know parentheses instead of curly braces And it is statically typed as we see because there's signatures of stuff there But this this code isn't actually that crazy as ruby is reading it not knowing anything about rust And so uh Godfriend you could actually ran some benchmarks of this implementation of blank versus fast blank and of course ruby and You can see that versus the c implementation of fast blank We actually get fairly comparable performance, which both are simply faster than doing an impure ruby And This this code in yellow are the codes that I put on the slides that Were earlier and all the other code and so that that's like kind of the unique code that kind describes solving that problem And the gray code around it is kind of the boilerplate code that you have to write to get this ruby jump to actually work So as you'd seen the rust case it it's kind of a fib to say Oh, like it's not actually that much code because we're writing all this other boilerplate to kind of make the rust part work So That's not that great if we actually want to do this on a more regular basis to have to have to copy paste and do Those things all the time So Let me introduce you to this other project that It's called helix they work on this project called helix, which is kind of named after this bridge in singapore So I went out actually on wednesday night to take this photo so I could put this in the slide And so this is a picture if you don't know of yehuda and godfrey who are actually working on this project And what helix is is it's this bridge between Rust and ruby that allows you to kind of remove all that boilerplate code all that stuff in gray So you can just focus on solving the problem that you want to do in rust And so you can actually define like ruby classes inside of rust that do the work that you want to do so uh All that stuff can be replaced by this simple slide here And this is all the code that you have to write in rust to make that happen Um, so it's definitely smaller than that code from uh a few slides ago And what what makes this really exciting is kind of having something like helix Unlocks a lot of different opportunities I think if the cognitive load of actually writing sd extension is sniffing lower You can start talking about doing it for other things beyond fast blank, right? Like even for a specific app that is not like a general rails thing you could Start profiling your app like regga talked about and uh, if there are things that Are called a lot or take a lot of cpu call time You can actually re implement those things using helix inside of rust to get the performance you need And uh massively improve the performance of your application Uh, there's also talk of like inside of active support like stable apis that would make sense to Reimplement in rust to kind of get performance and kind of extrapolate those kind of things out I think there is a really exciting future where we can do more things like fast blank Um And where all you have to do is basically include some type of gem like turbo blank or turbo whatever and Actually, you just get that performance for free because we're running inside of a native extension If you want to learn more about that, uh godfrey did a talk at rails conf which is on uh confreaks.tv if you look up for look it up under rails cop 2016 or you can actually go to This blog post where he kind of deserialized that talk into a blog post That kind of describes all this stuff in more detail Um and the last kind of big problem that I want to talk about is packaging and ruby And you know like in java where you have stuff like wars and stuff But in ruby you kind of have to you know deploy all this source code and then bundle install and do all this stuff Just to deploy your app And uh to kind of illustrate this story I wanted to talk about the broken tool ballot and if you aren't familiar with it It's the cli command line that you use to kind of to interact with horoku Instead of using the dashboard, uh, you can do stuff on the command line And it has a long history. Horoku has been around for I don't know like nine years or something at this point. Uh, and when we first started, uh Trying to build something like this we started with a ruby gem So you would gem install horoku and you can still do this today though. I don't think it's kept up to date and this was kind of a decision at the time because Horoku started as a ruby company for ruby developers And it made a lot of sense to build something that was native for rubious to use So you would just gem install horoku and then you know you create a horoku account you log in you're kind of off to the races um But it had its own set of problems, uh as we uh became polyglot um and started supporting other stacks and languages Uh, it was an issue because as a python person In order to use horoku. I had to now install ruby just to gem install horoku to then use this product where I had no interest potentially in ruby at all um, so that was an issue for us, uh, and beyond that, um Even for rubious like it became a support issue because people could have totally different versions of ruby And then this was uh, even before like rbm was a thing So most people were using like system level rubies So like if app you were running a different version of os x you potentially got a newer version of ruby Uh, so then we had to make stuff always compatible with ruby 187 because that was the oldest version of ruby that apple kept Keeping around for a long time. So, uh, we could never use any of the nice like syntax and things that came out in ruby 19 so then to solve that problem we decided to Package the ruby runtime inside of like a tarball itself and distributed that um in and of itself And that was really great because it solved that like what ruby runtime are we using? What are we supporting? Uh, but then it kind of turned all this work of actually packaging into our hands So then we had to Have like actually a separate windows box that sat under someone's desk with like, you know Like windows licenses and things and and build that ruby binary with the package and distribute that We had to do the same thing for os x and then when apple decided to Add like all the signing stuff like it broke like that whole tool chain. We had to go fix that Um, and then same thing for linux. We had to do special things for linux and then you run to all the distribution problems with Linux being fragmented too and so as you imagine this is like not a great experience And it made it hard to actually like package and release new versions of the tool belt Whereas before like publishing and doing stuff inside of ruby gem is actually easy. You just like Publish the gem you just run a single write task and you're up and running Um And since then there has been uh a project and so now the current tool belt is a mix of like go javascript and uh ruby though the ruby code's being removed And at the start of that was this project called hk that a parochial employee Worked on and the main there was two really big motivating factors for that one of them was that uh Like I was saying fast as a feature and so the speed of the hk binary was simply faster than doing stuff inside of ruby So if you just look at this top benchmark here running haroku version On the ruby cli at that point took over a second and then the go version Mainly it did less things was like 16 milliseconds. So if you want something that's like highly interactive You can imagine that that kind of sucks to have to wait a second Every time you're trying to do something with uh your product And part of the crux of that is that like require and ruby is not very fast So like as we modularize the code base because we didn't want to have like one single file That was huge that had all the commands and things we broke stuff out. Um Like you have to actually pay that cost every time at buda and so then We did a bunch of work to kind of minimize all that stuff So we don't require the files that we actually needed Um And then the second part of that was go was able to basically create these stackly compiled binaries that were portable So we could compile specific ones for each of the different language versions that we needed So that made a lot of sense and Even beyond the haroku case. There are examples of Like inside of hashi corp.  They had ruby cli's And I think vagarin is still ruby cli but all their new projects now are written and go for cli's because Of just the benefits. I elicit like it just makes a lot of sense when you're distributing this to actual customers um And I kind of found at the end of the day that there aren't Any real great packaging stories like there's traveling ruby. There's other things out there But all these things are kind of this manual process where you have to trust on them to build these packages for you And if you kind of stray off that golden path, you're kind of out of luck So, uh, I started a project called mruby cli that was really focused on trying to tackle this problem And at the crux of it is this project called mruby that matt started which is a yet another ruby vm And it's an embedded ruby that is meant to be embedded in other languages which Provide a lot of benefits, but also had various trade-offs. So it's a lighter weight ruby It uses less memory, but also for goes like all the i o and kind of other things that are associated with Uh platforms a lot of things that you're used to inside of standard lib don't exist And the fact that it also doesn't have a standard lib um And we had a bunch of design goals when working on this project the first one being I want to be able to write stuff in ruby I don't want to write like ac li and go or see or something else And so inside of mruby mruby cli mruby uses this mruby lib directory and we generate all these files and you can actually just write this ruby code and You just write straight up mruby and it looks very much it pretty much is like regular ruby code minus a few differences um Fast as a feature. I know I've said that a bunch of times in this talk, but it's true And specifically what I mean for this case is the boot up time right like how fast can I get to actually executing ruby code and um In this case an MRI here's the typical like hello world MRI use case And uh, this is a few versions old. So I think this is like ruby 2 2 It takes like 41 milliseconds just to print out hello world to the screen Uh, and then when I was able to do this in mruby cli, we can get get it down to three milliseconds, which Is a significant speed improvement and fast enough where it Doesn't make a difference. Uh, like you don't have to get it that much faster to make that experience good Um And how we do that is inside of mruby. There's no require So all the stuff is loaded up front at uh in memory. So you're not paying that cost of searching the disk because it's compiled into the binary Um And then we also want to have like you go this portable solution that generated a single binary for every platform So uh with mruby cli when you run the compile command you get a 32 bit and a 64 bit binary for both For linux osx and windows. Uh, so you can package that up and distribute that to its customers to your customers And then we also want to file size that wasn't massive because we're packaging the entire mruby interpreter And it's meant to be small. Um, so the osx version of mruby cli is under a meg. It's like four and 21 k um And then for people to actually use this like it has to be pretty simple So uh to set up all these cross compilers to actually build these binaries You don't want to have to do all that stuff by hand like in order to get started have to download All these various versions gcc have to download them in gw have to download all these things to get started So we actually set up a document container That has all this stuff set up for you That will cross compile from linux to linux itself linux to mac and linux windows And and kind of tackles of all that set of work that you have to do up front to get a working system So using this thing Here's what a hello world example for just running through the workflow is you download mruby cli from the mruby cli project It's just a binary. You can put it anywhere on your path and just run it With the set of command. It's like rails new and it generates a bunch of files You go into that directory you run the compile command with docker And then you're able to just execute the command and then you see hello world So that's all it takes to really get started there and here all the files that we generate I think rails does a good job of like making sure we don't have to bike shed on stuff So we want to provide a similar experience there So you don't have to set up any of these things by hand And then all you really have to do is you have to edit this file And this is really the hook into how you run stuff inside of mruby cli So there's this underscoring is for main underscoring is for that You can just write whatever code and then any class or whatever that you put inside of mrb Lib will become available that you can call and then the arg v Is just like the standard array of arguments that are passed in um, and so you can learn more at mruby cli.org And After I gave a talk about mruby cli. Steve gave this talked about this tweet about Kind of just like it's great to learn on the languages. I don't think you should stop Exploring and learning those things But it's also good to recognize like what ruby isn't good at and if we want to continue doing stuff with ruby We kind of have to look at these weaknesses and and look at actual solutions because people are running into these every day in the real world are causing people to leave and I've been doing this for 10 years at this point ruby specifically and i'm definitely Super excited about the future of ruby and i've never been more excited about Kind of where things are going Both all the things i've seen with ruby 3 The ruby 3.3 project the projects that i've talked about in this talk like being able to work on things that solve the iobound problem The fact that i mean helix isn't totally there yet But like a future where being able to write native extensions that improve the performance of my running ruby app And the fact that we can start looking at packaging things and making that a better story is really neat um And uh even uh This year, uh, there's this index that kind of measures the ratings of like engineers and kind of searches for the language itself ruby went from 16 all the way to 8 last month Which is really cool to see it like spike up again. And so it's the highest it's been since kind of the peak rails hype um So that's also exciting that there's kind of this resurgence of stuff in ruby itself and uh, i implore you to keep writing stuff in ruby and Without the fear that you're going to hit some wall because it really sucks to pick a technology And then be forced to move away from it because of some technical limitation I think we're getting to a point where there's going to be a future where that won't be true anymore. So Thank you red dot, uh, i'm really excited to be here and uh, thanks for having me So we don't have time for questions Uh, thanks tyrants for your wonderful talk. Um, it's been a while since I practiced some ruby and I think I'm getting a bit Nice, uh, we have uh, I I think I believe we had question time for questions for tyrants I see people moving to the mic Yes, I have two first question when you were doing the example of the blank method in ruby c and rust um, just kind of like Slammed into my head. Why aren't we testing for a blank string of first? return true if the string is blank and then create the regular regular expression or whatever only if we need to I don't have I feel like god for you could probably tell you a better answer I don't know if you want to come up and answer that I I guess it's slower Rails rails five actually the the example on the slide was actually Was actually the rails for implementation for simplicity. I believe I I believe as of this very moment The version on rails five on master actually has the empty check in front There are some ongoing. No, it does not according to them. Okay, so there are there basically people try different things and then like the current version is More fast in the in a general case, like you can get different Very long string very short padded strings and stuff like that, right? And I think it's hard to the takeaway is it's hard to do it Generally for a lot of cases Okay, thanks. Thank you. My next question is will rust work on j ruby Uh, this was something I was actually talking to god for you about I don't I think there's a way we can get it to work with j and i in helix And making that code work But probably out of the box Not yet, and if we were to do any of this stuff inside of rails like You we would probably maintain both the I was talking to matthew draper about this actually had this speaker's dinner last night We we would probably maintain both the ruby version to fall back to if your platform didn't support it and then we would have the rust thing to For the cases where we could get that I think j ruby specifically is significantly less affected by this problem the MRI because of the vm itself and also When you're writing stuff and then like if you wrote a native extension inside of java, you're probably able to achieve The performance delta would be significantly smaller than it would be an MRI Writing the extension in rust is great. A lot of us don't really know see but I try letting rust and I ran through a lot of harm speed speed bumps with The borough checker. So do you have any tips for people like that? Uh for basically fighting the borough checker. Yes, um I definitely have had to read the The in rust lane basically the borough's documentation a bunch of times I think that's just a thing that Will be a thing for a long time for anyone who's learning rust But I think that's also kind of a huge benefit of rust the fact that there is the borough checker Because the whole point of the borough checker is that They didn't let you compile that code because you're doing something that's unsafe Um And so that's just a thing that you know like over time you'll have to learn I don't have any great tips. Uh, I also run to I still fight the borough checker all the time Today as well. U