 Hi everyone! Welcome back to the Red Dot RubyConf 2016 Hey So once again, I'm Nat. A lot of people can't remember my name and I'm so sad So for those of you who were wondering yesterday, I actually also work at pivotal as a software engineer Okay, and next Thank you for adhering to our code of conduct Please stay nice. We're very happy that you guys are so awesome Next, Wi-Fi. If some of you have problems with Wi-Fi, please I suggest for getting the network and then rejoining it Next up would be our drop spot So I hope all of you have taken a look at the drop spot. If you're hiring, please don't forget to attach yourself there Oh, and I also found something cute Yeah, what are you doing here? It's a new Java Next up the appreciation bot. So Our organizer Winston, he has mentioned that he doesn't need any tanking any more tanking. So We should also probably just use this bot to tank the jam creators and open source contributors like We use bundler almost every day and it will be we use factical for our testing and use device and the list goes on so I'm sure you have some people You might have at the edge of your mind that you want to thank So I urge you to go there and put their names up At the end of the day, the organizers will go through each of them and tweet each of them how much we appreciate them And you know since most of us live off internet points, so please keep us alive Yeah, if I could put my cheek heads up there, I would but they don't have to turn and they don't write gems And also I would like to thank all of you here who turned up thoroughly in the morning. Thank you very much Lastly if you want to contact us or you want to post anything interesting, please tweet us at red dot RubyConf Lastly I would like to thank our sponsors again, and I believe pusher Has something to say Is bannon Still outside Okay, I will probably get him in after After I'm in stock Okay, okay. Oh, I guess I'm using this mic. Hello. Hello. Hello. Good morning. Good morning. Happy Friday First I want to say thank you to everyone. Thank you to the organizers Thank you all of you for being here today, even though I know it is the morning of the Second day, which makes it a lot tougher to get here So thank you for being here It is a great honor to be here. I think this is my fourth year here I think and I love coming every time. So thank you Today I'm gonna talk about Taking out the trash This is the title of my talk first. I'm gonna introduce myself a little bit. My name is Aaron Patterson I'm also known as tender love if you don't recognize me. This is what I look like on the internet So my avatar looks a little bit different than me, but that that really is me So I work for a company called the github You may have heard of them. I'm not sure I've been working for the company for about three three months now and it is the first legit company I've ever worked for So like I said, I've been I've been working for the company for about for about three months and it was really weird I had to go down to I live in Seattle I had to go to San Francisco for a week to do like training or whatever and it turns out that at the company everybody refers to each other by their github nicknames and Like in person And this has never happened to me before all these people were calling me tender love and I just thought it was really awkward So I mean if you if you want to call me tender love you can but you know, please call me Aaron That's fine. That's fine, too. I'm happy with my I'm happy with my real name So I should have called this I should have called this talk cats puns and Friday hugs because it is Friday And I love puns and cats so I'm gonna show you I'm gonna show you some of my cats is one of my cats This is choo-choo her her Her tongue is too long for her mouth. So it always it always sticks out. This is a more famous one This is Gorbachev puff puff thunder horse My wife likes him better than the other cat This is he's trying to hide in this photo here like he thinks he is hiding he is not This is choo-choo again. I really I really like her She likes to sit on my desk while I'm programming and she always makes this face Which is like the same face that I make when I'm programming Anyway, so, you know, I I also love cats and code just like our emcee So I want to go over I want to go over a few things that I've learned so far at the conference So first off I learned about some new ruby features We were taught like Matt's was talking about typing and ruby and we learned about gradual typing And I want to so I I want to demonstrate it here today. I have a live demo for all of you So I'm gonna demonstrate gradual typing. Okay. You ready? I did it on stage and now soft typing soft typing Anyway, this is a mechanical keyboard. So if you want to talk about mechanical keyboards, you should come talk to me later Okay, also, I learned that we don't care what what Dynamic typing. Yes dynamic typing. This is very dynamic. I was also gonna do static typing where I don't move my hand the keyboard Anyway, so we don't we don't care about small things, which is why in Ruby 2.5. We're gonna remove the downcase method. So no more no more small things Also, I thought it was like I thought it I was watching the presentation I thought it was really cool that we're gonna have like upcase and downcase and they're gonna support UTF-8 characters. So we have upcase and downcase But I was thinking about this. I'm like, well, we've got up and down We don't have we don't have widen and and narrow in that doesn't like we're missing those So I I put together an implementation of that. So you can call widen and narrow and so look look forward to this in Ruby 2.5 If you want to get this Functionality today go ahead to my github repository. You can get this jam and have those I also learned that there are no no durians allowed at this Conference, but that is too bad because I love durians. So I will eat them anyway and Sorry, I'm trying to work in a durian pun somehow. I Appreciate all of you for enduring my puns. We also learned about teaching people to fish. I'm going to teach you all how to fish Go ahead and look in your email today all of you you have an email from me Just enter your bank account information So also I learned I learned from today At this conference I learned from Terrence that learning a new language can keep me from getting rusty So that was an important thing I learned from his talk today All right, so let's let's move on to the real topic of conversation I'm gonna talk about GC today. I'm gonna talk about GC specifically. I'm gonna talk about Godfrey Chan So I asked him I asked him, you know, what is your what is your favorite memory and he said that it has been collected? His favorite food is pizza and I asked him on the bus this morning. What is your favorite color and he said that it is ruby? Actually said it was orange, but I fixed that for him Okay, no, no, no, no, I'm I'm I'm actually gonna talk about the garbage collector today And this is this is a very exciting topic and I'm so happy for all of you to be here at at 930 in the morning to listen to talk about a garbage collector You know get ready to have a nap this morning. It's okay. You can sleep in so we're gonna talk about I'm gonna talk about the GC and MRI I'm gonna talk about GC algorithms, but I'm gonna talk about them specifically With regard to the algorithm algorithms that we use in MRI So I'm gonna talk about some some GC algorithms, but I'm gonna focus heavily on the algorithm algorithms we use in MRIs GC, but I think I'm also gonna talk about two sides of the garbage collector I think it's interesting when you see people give talks about the garbage collector. They typically talk about Collecting collecting memory, but they don't really talk so much about allocating memories So I'm actually gonna cover both sides of that the GC is the GC is Responsible not only for collecting memory, but also for or also for allocating it. So we're gonna cover that So we'll look at collection algorithms how Ruby actually reclaims memory And then we're also gonna look at allocation Algorithms how we actually create objects in Ruby And I'm also gonna touch a little bit if we have time I'm gonna touch a little bit on the introspection API like the GC introspection API and MRI so you can actually get statistics about Objects in your system So I'm gonna talk first about the collection algorithms in MRIs GC So let's let's describe a little bit what What type of collector MRI has the type of collector we can we can describe it as? Mark and sweep collector it's Generational and it is also incremental so we can use these three three adjectives to describe the garbage collector So we're gonna cover each of those a little bit more in depth But first I want to step back a little bit and talk about you know what what exactly is a GC So what you know we know that it's it's it's a thing that that frees up memory for us But at a high level, what is that? What does that really mean? If you think about the objects that are in your system So if you if you look at the objects when you you're creating objects in Ruby You'll notice that they form sort of a tree thing here So for example if you look at this Ruby code on the left You'll notice that it kind of forms a tree where we start at the at the root And the root references an array which is that that a variable and then that array references a hash and the hash References a key in a value pair so we can think of it as kind of a tree data structure so when you're creating these objects in Ruby you're creating kind of a tree a tree data structure and Let's say let's say we change this code a little bit and we assigned a nil into a We actually cut that line up there with the root Now the root is no no longer holding a reference to that array and hash Etc. So this these objects are going to get collected. So Essentially what our garbage collector is doing is saying, okay We're gonna find everything in this tree that isn't referenced from the root anymore And we're going to we're going to free that memory up So we can think of all of our objects as a tree and we can think of the GC as something Is trying to find find things that are not available in that tree anymore. So Few terms that we can learn from this or we have a we have what's called a root set Which is our vet that very top root root thing we have garbage objects Those are ones that are no longer reachable from the root And then we have live data which is all the all the objects that you can actually reach from the root in that Tree so our GC's entire job the entire job of the GC is to find those unlinked nodes and Then free those up. So when we talk about GC algorithm algorithms All we're really doing is talking about how do we find those? How do we find those unlinked nodes, right? How do we get how do we get those what is an algorithm for finding those and releasing those nodes? So the first thing we're going to talk about is Mark and sweep. This is a very simple GC algorithm and it has two distinct phases Mark and sweep Which is why it's called Mark and sweep garbage collector So if you look at the if we look at this, let's pretend we have an object graph that looks like this What happens is we go through a mark phase and the mark the mark phase goes through walks every one of these arrows and Actually marks that object is something that we care about so it starts at the root and follows each of those arrows through the tree So you'll see that it'll follow through a It'll follow through all these all these arrows until it marks all the objects and then we go through a sweep phase and What happens in the sweep phase is any objects that we're not marked. We actually just free up those objects. They go away And we're left with we're left with the actual live objects And at the end of the sweep phase we go back through all those objects and unmark them all So now we're back where we started and we can continue on with the program So Right now the mark mark flag has been cleared. So the mark and sweep algorithm is very it's very easy It's a simple algorithm But we have some problems with it. It's a little bit too slow We have to actually walk every one of those arrows every single time look at every every object mark Whether or not it's alive and then sweep through the whole thing and another problem is that we have to actually stop the world when we When we do this collection, you may have noticed in older versions of Ruby if you're especially if you're running a long process You'll notice like it'll just stop for a second and then do you're like, oh, it's just pausing Maybe my iTunes is playing too much or something. No, it's not your iTunes. It's fine It's actually the garbage collector just pausing doing the mark and sweep phase and then continuing on So the other problem is that we have to visit objects every single time We have to visit every one of the objects in the heap and mark all of those every single time and this is not very fun So We have to walk every object every time So this one way we can get around this is if we introduce what's called a generational garbage collector And the idea behind the generational garbage collector the theory behind it is that objects in your system will die young So typically typically objects they're going you're gonna allocate them and then they'll just go away very quickly So the idea is that if we divide objects up into old and new Objects so if we have old objects and new objects then maybe let's only look at the only look at the young objects only look at the New objects so the way this Generational collector works is say we have a say we have a object graph that looks something like this We do the same Mark and sweep phase where we say okay. Well, we're gonna mark here. We mark B and D and then We sweep A and C So those go away, but once that happens then we take we take B and D and we move them Generations they go into the first generation right now Let's say the program continues on and we allocate some new objects those new objects are gonna get allocated in the young Generation or generation zero Then we go through the same mark and sweep phase so we mark F and G. We also mark D Then we know that E goes away and then F and G get moved into generation one Oh go transition. There you go And then we do the unmark step again or we clear that mark bit now the interesting thing that You may or may have not may or may not have noticed is that when we're doing that mark phase when we walk We're walking those arrows. We actually didn't have to touch the B node We didn't go to be because we knew that that one was old So we're not dealing with B. So the nice thing about this is that we don't actually walk those old objects every single time So we can speed up that mark and sweep phase because we're only we're only looking at old objects once in a while We only consider new objects frequently, but there is one slight problem with this with this Algorithm and that's that let's say we have let's say we have a graph It's like this B and D are in the old generation and for some reason something happens such that that D actually Allocates a new object E Right that new that new E object is in the young generation And when it's time to do the time to go through our mark and sweep phase We don't actually walk that arrow up there because we know B is old Right. We know B is old So we we don't go through that go through all those arrows and what happens is at the end of the mark phase We say well, you know E is E hasn't been marked So we're just gonna GC that and now we've got this we've got this bad connection here So so your program will crash. We've we've freed up an object that actually is being used. It's actually live so The way that we fix that is we introduce something that's called a right barrier a right barrier and a remembered set And what a right barrier is is when we write that when we write that connection between D and E When that that arrow gets written we keep track of that we keep track of that connection inside of what's called a remembered set So when that arrow gets written we remember that we put it inside a special set so that we know when we do our mark and sweep phase We say oh well, we're gonna go look at that remembered set, too We need to mark E and then E goes into the old generation and we're Free of our we don't have this bug anymore So we have a couple new terms from this we have we have a right barrier Which is just keeping track of those interesting what we call interesting arrows Which would be old generation to new generation arrows and we have a remembered set Which is that list of those interesting interesting arrows, so? Generational garbage collectors are faster It's it's faster because we don't have to walk as many nodes as frequently, but it's not quite as easy We have to implement this right barrier, so it introduces some right barrier and a remembered set so it introduces some some complexity to our garbage collector now unfortunately We still have to stop the world with this with this algorithm even though we're walking fewer nodes We still have to stop go through that go through that cycle and then continue on So to get around this problem We've introduced what's called an incremental garbage collector and an incremental garbage collector is what it says It's something that you can do incrementally and we'll look at how that works the way this algorithm works is that it uses an algorithm called tricolor marking where you have three colors These names are so imaginative I love it all right, so we have three we have three colors white black and gray now White those those objects are objects that we're going to collect Black objects there they have no references to white objects, but they're reachable from the root and then gray objects are Reachable from the root, but they haven't been scanned yet, so we'll look at we'll look at how all these these colors work together So the way this algorithm works is we pick we pick an object from the gray set and then we move it to black We change that over to the black set now for each objects each object that that one references We move those into the gray set as well, and then we just repeat step one and two Until the gray set is empty, and then we know that everything that's left over that's white those can be those can be garbage collected so An example of tricolor marking Let's say we have a we have an object graph that looks something like this We start out with a and f in the gray set because a reference from the root We color those we color those black then all of their references go to gray Then we color those black and now we know that we're done We don't have any more objects inside of the gray set So we can take all the white objects and GC those we can free those up. So those go away now The advantage of this algorithm is that we can interrupt any one of those steps So we can we can take a break at any time So we do we do the gray to black coloring and we can just stop right there We can continue on with the program. So what this means is we can perform each of these steps incrementally, which is why it's called an incremental Garbage collector. So what this means is that our halting time is actually reduced what we what we do is we say, okay? We'll run the program for a bit now We're going to do one step of this incremental GC and then we're going to continue on with the program so Our program halts for less time But there's also a problem with tricolor marking and that's very similar very similar to the Generational problem, which is let's say we have these these gray colors here now We let's say we halted right right now. We're gonna. We're gonna pause the program and We do this we do the first step we pause the program We let the user code continue so the GC pauses and then your code continues and somehow F This F object creates a new object. It allocates something new so it's pointing at a G object now We have this new object now Let's say the GC starts up again, and it says okay well now We're gonna take all the gray objects, and we're gonna color those black So it colors all the gray objects black, and it says okay. We don't have any more gray objects So it's time to GC so we collect that G object, and now we have a bad reference again That G object should have been live, but it is no longer live So in order to fix this problem We actually introduce another right barrier, so we say okay when when we write from F to G We're actually gonna save that off, so we have another right barrier and a remembered set so we do exactly the same trick we were doing earlier we Just keep track of that, and then we know that we can color that one gray later, so Interesting things from this the glossary to learn from this is we have Incremental GC which means that we can halt the GC at particular times. We have a right barrier Again, which keeps track of rights to objects, and then we have a remembered set which is those interesting interesting connections Now all these algorithms the idea behind all these is that we want to actually minimize Tracing so we want to minimize the number of arrows that we traverse We're gonna reduce those as much as possible, and we also want to decrease halting So that's those are our biggest things We want to reduce the number of arrows we walk because that's less work We have to do and we want to decrease halting because if the program halts It means it can't be doing other things like servicing your servicing requests from a user or something now Things that our GC is not which I want to talk a little bit about Our GC is not parallel it means we're we're not able to run this mark-and-sweep algorithm in another thread We can't do that. We can't do it in parallel It's also not real-time Which means we can't we can't run MRI on things like That require real-time feedback for example like I don't know Maybe you're building a robot or something you might you might not want to run MRI on that You might want to use something like mruby or something that has a more real-time garbage collector The other thing is that it's not compacting We don't actually take these objects and move them around and I'm gonna talk about that a little bit a little bit later Those objects when we allocate them they stay in one particular place in memory. So we'll we'll look at that When we talk about allocations All right, so we've covered we've covered the way that we do Object freeing in MRI now. I kind of want to look at allocation algorithms and The thing I want to look at first is I want to look at our heap layout So and we have a heap our heap contains all of our objects now When a Ruby object is allocated we don't actually call Malik every single time We we actually allocate that into a page and the reason that we do that is that Malik isn't free You're killing me I know it's early, but please I'm so proud of this one Alright, so thank you. Thank you All right, so Malik is it Malik isn't free when we when you call Malik at cost time So what we try to do is we want to we try to allocate one large chunk of memory We allocate a large chunk or we call it a page or a slab I prefer to call it a slab though I think we it's referred to in the code as a page and The reason I like to call it a slab. I'll get into a little bit later Now we allocate one large chunk of contiguous memory this page memory is contiguous so and each one of these chunks of memory contains a linked list and Yes, I should advance the slide so each page holds a linked list now This linked list each member of the linked list is what we call a slot so nodes in this linked lists are called slots and Though each slot is actually a Ruby object, so to make this a little bit more clear When we do an allocation will allocate a page and it is just a big chunk of memory like this and When we when the garbage collector allocates an object It'll just put one of the objects inside of the page So each time we allocate an object we get a new object one after another oops Yes, there we go. So we have a linked list inside that's stored inside of this page This list we call it the free list So all we have to do to allocate a new object as we find the next slot That's open in the free list and then hand that back to you as your Ruby object. So If we actually fill up a page, let's say this page is filled with objects when we go to the free list We see oh, it's filled So let's just allocate a new page and now we have a bunch of other places to store objects now Each one of these pages Actually one thing I want to talk about is when we're when we're looking at the top of that the top of this link list Where we actually pull that pull that object out when it's time to allocate an object. We call that our Eden Our Eden so that's where objects are born So when an object gets garbage collected it's actually pulled out it's pulled out from this list So we free it from that we free it from that list and that actually leaves a hole in the page Which I want to talk about a little bit later, but let's say we let's say we actually Free up all of these objects all these objects get gc'd if that happens then we'll actually free up this page So the page will go away so we can free that Oh, I want to talk about this. This is exciting. I love this part. So I want to talk about some interesting allocation hacks now Not every object requires allocation. So Matt's talked a little bit about this yesterday with integers Now not every object and you may or may not know this but not every object in ruby actually requires us to pull something off of that off of that page So I'm gonna try and walk through how that actually works here. So one page one page in ruby is about 16k This is just a size. It's a fixed number at the 16 16k page size now one object in ruby is 40 bytes Okay, so we got a 16k page and we got 40 by 40 by objects now pages are actually aligned there And what this means is that we say instead of malloc'ing the pages We actually do what's called an aligned malloc and what this means is we say we ask the computer Okay, give me a chunk of memory, but I want the beginning address of that chunk of memory to be divisible by some number Okay, so the address of that chunk of memory is going to be divisible by some number and we choose 40 So we choose 40 as our multiple now 40 happens to be the size of a ruby object Now what's cool is if you start at 40 and you print out Print out the binary representation of that number So we're gonna say alright 40 times 1 40 times 2 40 times 3 Etc as if we're walking through the size of those objects, so we're adding we keep adding an object to that list If you look at the binary values of those now if I I'm gonna just show you this here These are the binary binary representations of those numbers if you look at the last three digits You'll notice that those last three digits are always zero Okay They're always zero So what this means is we can actually use those last three bits to have add some meaning to the number So we'll say like let's use those let's use those last three bits to Indicate that that number is something special So What we can do is we can represent we can use that bit to represent integers without doing any allocation So for example, let's say we have the number let's say we have the number two And we want to represent that as a ruby we want to represent that in ruby What we would do is say well, let's let's have a flag of one for example And if we convert to to binary we know that that is one zero And if we shift that over Then we get one hundred and we add the int flag to that and now we have one zero one And if you look at that number Because those last three digits are not zero. We know that that was not allocated in ruby's gc If an object is allocated in ruby's garbage collector, it's always going to end in three zeros And since this one doesn't end in three zeros. We know that it's something special So what we can do is just take that number two encode it like this and treat it as a ruby object And then to decode we simply just shift that over shift that over one So using this information we can actually figure out. What is the largest Fix num that we can allocate without actually without actually pulling anything from the garbage collector So for example, if we do two to the 64 minus one You'll see that's what the binary representation looks like that's 64 64 ones But if we subtract one from that we get a big num class And that's because you know, we had to shift that over one. We lose one bit from that shifting So we we can't represent 63 bits And if we if we do 63 We still get a big num and the reason we get a big num is because the very first bit represents plus or minus Right, so if we actually do two to the 64 Then we get a fixed num So we can see that that's actually the largest fixed num that we can represent Now even if you add one to that you'll still get back a big num Now unfortunately, this is before ruby 2.4. If you go look at ruby 2.4. It's much more confusing. You can't tell the difference They're all just integers unfortunately, but But if you look at the object IDs, you'll notice they are very very interesting those top two ones there Those top two ones have very Big object IDs and it's because we actually use the memory address The address of the object as the as the id So you can tell those two objects at the top those two are Not allocated on in ruby's gc and the bottom two ones are And this technique this technique of using those Three bits those three remaining bits. We call those tag pointers So it's a pointer. It's some number stored in memory But that number has special bits in it. So I I love this hack. I think it's awesome. It's really Clever in my opinion now if you look at uh, if you look at the other objects in ruby many many of these objects Are tag pointers fixed nums or tag pointers? Of course, we don't have fixed nums in 2.4 Floats or tag pointer is true false nil symbols. So a lot of these things don't actually require Allocation from the garbage collector so I want to move on a little bit to talk about some allocation problems and these are these are problems that We've been seeing in our application Now one one problem that that the garbage collector has is we have an issue with poor reclamation So let's say we have let's say we have three pages that look like this They're full. They're filled with objects, right now Let's say the garbage collector runs and we and we reclaim some of these objects. So they go away, right? We've filled we've reclaimed some of those objects now Unfortunately, I mean what would be cool is if we could take these objects and move them Move them around like this then we could actually take this page and free it you go away Now unfortunately, we can't do that that does not happen in that does not happen in MRI We cannot move these objects So what ends up happening is we have these three pages that are allocated with holes in them And we can't reclaim that memory So unfortunately, this causes this causes some problems for us where we have we have Heaps that are too large. They could be smaller, but they're not Uh, the other issue is that we have copy-on-write We've experienced copy-on-write problems and where this comes from is I'm going to explain how these copy-on-write issues occur now. Unfortunately one A ruby memory page is not an os memory page Which is why I like to call those pages in MRI slabs So an os page is something totally different It's a page of memory, but it's not the same size as a ruby page So one ruby page is about 16k on os 10 and os page is about 4k I think on uh, the linux systems we have in production too. They're one os page is about 4k So, uh, one ruby page contains four os pages Now let's say we have a parent process and a child process Parent process fork to have a child process and they're both pointing at something that looks like this So they're they're both pointing at a ruby page that looks like this Now let's say the child process allocates an object sticks it in there now What happens is when we write to that bit of memory the operating system has to copy it So it's copy-on-write. We wrote to the memory. It has to copy it Now unfortunately the the operating system doesn't copy just that that little section It actually copies one os page So rather than copying those 40 bytes, we actually we actually copy 4k So we wrote 40 bytes, but we actually got 4k 4k copy So what would be cool is This is something i'm trying to work on and test Test on our application is if we could group old objects together such that we didn't have as many holes in our pages So for example, let's say we had let's say we had two types of pages One type is a probably old page and another type is just a regular a regular page Now What we could do is if we allocate objects at the time we allocate them if we know hey I think you're going to be old we stick that into the old page Then maybe we can group all those together so they don't get we don't get holes in them like that So we'll allocate an old object. We know it's old when we allocate objects that are unknown Then we just stick them into the normal pages So you might be thinking Aaron How do you know what object is going to be old? It seems hard. It is not that hard If you think about classes and modules in ruby all these things are objects And they're probably not going to get garbage-elected when you do a class foo It's probably going to be become an old object same with modules or constants or possibly frozen strings So we know we can have some heuristics to determine like hey when we allocate this object Let's put it into the old page Uh The other thing I was thinking about doing and I'm not I'm Just testing this now is if we could statistically determine which objects are going to be old and which ones aren't So let's say we have some foo object and 90 of the time we allocate a foo object. It becomes old Then the next time we allocate a foo object. Let's just stick that into the old page Uh Though unfortunately most objects becoming an old object is a rare thing So i'm not sure if this technique will actually work for us But that's why i'm just trying to implement it and see what happens in production Uh, so this will help us efficiently use space So if we we can group all these old objects together then maybe we can reduce those reduce those empty slots without having to move objects We could also reduce gc time with this with this technique because if we know that those objects are going to be old And we mark them old already then we don't have to go through those first two cycles of of Garbage collection in order to mark them as old All right So let's let's take a look at a little bit of some gc introspection tools that we have available to us We use we use a lot of these tools to debug object leaks and Just various gc issues in production. So MRI has a lot of gc introspection tools. So for example, we can look at gc info Now the way to look at gc info is just with the gc dot stat method and you don't need to read all these Just go run that method But one of the main reasons I went through talking about all these all these gc algorithms and pointing out the Glossary and those those particular terms is because each of those keys in this hash corresponds to That particular thing with the garbage collector. So if you know how the gc works when you read all these keys It's very easy to understand exactly what the gc is doing So Now that we've talked about all these techniques go run this run this code Take a look at all the keys and you should be able to determine what each of those keys means Uh, we can also get gc performance So sometimes we'll look at uh the performance of our garbage collector and that's really easy with just a gc profiler It looks the code looks just like this. You can just enable the profiler and check reports for it You can see how long each gc took Uh, so just call this method and then uh, call the report method to take a look at take a look at, uh The performance of the garbage collector We also use a lot of heap introspection So we'll look at what objects are actually allocated and my favorite tool for using this is object space dump all And what this does is it takes your entire heap and actually dumps that out as a as a json file And if you have a lot of objects, this can take some time So, uh, be careful when you use this when you use this tool, but this is one of my favorites to use You can actually dump one this dumps out your entire heap, but you can actually dump one object at a time if you want to You can just use object space dump to actually dump out one object You'll see right there. That's just the json json representation of that And what's neat is if you use this if you use this uh dump method, you can actually see See what happens to the object as you gc. So let's say we do gc.start three times Uh, you'll see that that object down at the very bottom After the three garbage collections It becomes old and uncollectable and marked So you can see you can see how these objects change over time, which I think is very cool Also, not not all objects in ruby have a right barrier and you'll see when you dump out a particular object You can see which objects do and don't have a right barrier Uh, so in ruby objects have three generations as we saw from this Uh, the last one is the third. We don't consider an object to be old until it makes that third generation Uh, so another another thing I really like to use when debugging when debugging Allocation issues is object space go check out all the methods on that that class especially Trace object allocations. I like to use this one. I like to use this one a lot If you call this if you look at this, uh, look at this method, you can actually turn on Tracing for objects so that every time an object gets allocated it remembers Where it was allocated what file what line So if you're having troubles determining where the some object came from Enable this flag and then you can ask it. Hey, where were you allocated? Um, hopefully am I I am out of time. I I don't know yet. I think so. Am I am I okay. Thank you. Thank you so much. I Oh Please use this hashtag If you enjoyed the presentation also, I have stickers of my cat. So come say hi to me I know I'm not supposed to have stickers. Apparently that's not cool anymore, but I do So come say hello find me later. Yes. Thank you. Thank you Questions from the audience. I know it's early, but you can do it Hello, yes, yes I don't think so. I mean we probably could though. I don't I mean, yeah, I don't see why not There's I don't think there's any significant overhead We could try it Seems seems like a good idea. Yes I've got a question. Yes. Hey, so you mentioned that Classes and modules are the objects that probably will become old and will not be garbage collected What if I use a lot of anonymous classes? Does it make it harder for gc to do its job and I should avoid it? No, I don't think so if you use anonymous if you use anonymous classes, that's fine We can tell so When we want to divide those when we want to divide those up we can tell like okay, this is This class was allocated via, you know class foo We know it was actually allocated in the source where if you're doing an anonymous class you're doing like class You're doing like class dot new or something or module dot new So we can tell the difference between those two those two types of allocations So I mean feel continue to do that feel free to do it Anymore questions? Okay. I did it. Yay We have Samir Samir is a student at Pune So while he's setting up Do you guys know what the object oriented way to get wealthy? So I've been going through the speaker's list ever since it was out And one thing that stood out was that I'm like the youngest speaker here today So I think this photo here over here describes me very well So it's a great honor to share the stage with some of my role models and It would not be an understatement to say that I'm here to just Yes, these guys speak I come before you as a cat amongst giants and I hope you will forgive any mistakes that I'm with So you're probably wondering who is this guy? And introducing myself. My name is samir deshmukh also known as wardrobe on github and twitter I come from the incredible country of India Which is Home to the lonely deserts of Rajasthan The serene and snowy Himalayas The emeralds in the Indian Ocean that are the Lakshavadi pylons And the monument that is described as a teardrop on the cheek of time the Taj Mahal Specifically, I'm the from from the city of Pune, which is a city of about six million people It's also known as the Oxford of the east because of around two million students studying in the city In about 700 colleges So, um, I'm also an undergraduate student in computer engineering at the university of Pune Most of my family has mostly consisted of doctors. In fact, my great-grandfather was a doctor My father my grandfather is a doctor. My father is also a doctor But somehow I turned out to be an engineer and look like this not too long ago I also play in a band called cat kamikaze. You can check out our music on soundcloud I also love cats And I like the Japanese too. So it's got kamikaze I am on the core team of the ruby science foundation So also known as sigh ruby The ruby science foundation is committed to making ruby a viable language for data science and scientific computing Which is something that ruby has been lacking in for a while now It's very popular for web development, but not in this domain as much So, uh, we basically make tools and infrastructure and open source libraries for this purpose Uh, I was first introduced to sigh ruby as a summer intern for google summer of code 2015 Later that year. I also received the ruby association grant from the ruby association And uh, this year I'm an admin for desock 2016 um, administering, uh, the admin the Manage managerial duties for sigh ruby and also mentoring a student for improving data science tools in ruby So the talk my talk for today will be scientific computing in ruby In this talk we'll go over a few tools that you can use In ruby for data science and scientific computing And I will follow up my slides with a short demo of these tools The first tool that we'll go through is called the i ruby notebook i ruby is a browser based ruby repl shell That is mainly used for interactive computing So this is what an i ruby notebook looks like as you can see it's running in your browser And there's an input shell in which you can put in ruby code and renders it very nicely in the form of html javascript to css You can also put in a form Inside the notebook and you can accept Input from users which you can use for input into any ruby script that you have in the in the notebook The next gem is called n matrix N matrix is an n dimensional array object similar to numpy and python It helps to interface n made it helps to interface ruby with a few high speed c libraries such as atlas or lapak for linear algebra calculations So this is roughly what an n matrix allocation looks like n matrix is not A dynamic object like say ruby's array, but it is of a fixed size So in the first argument i'm saying that The n matrix should be of size 2 by 2 that's a four size n matrix In the second argument i'm specifying the actual elements And then i want a matrix of 32 bit floating point numbers. So i specify the metype option as float 32 So n matrix supports eight data types currently ranging from 8 bit integers to 128 bit complex numbers And it also has three storage types Two of which are sparse storage types and one is the normal dense storage type By itself n matrix is more of a ruby container is more of a ruby wrapper over c arrays But what makes it truly shine is that It exposes a very powerful c api which can be used by anybody for Interfacing these internal c arrays with a variety of high speed c libraries So you can basically create a plugin for n matrix with n matrix as a dependency And use this internal representation and the n matrix api for creating your own plugins Currently we have plugins for four major libraries atlas and lapak are mainly used for linear algebra FFTW is for fast Fourier transforms and the GNU scientific library or GSL as you know has almost every mathematical function one can think of The n matrix is also coming to j ruby by august and it will have the exact same api as the n matrix for mri And it will use jblast for linear algebra The third library is called niaplot niaplot is an interactive plotting tool It basically generates interactive html and javascript plots that run in your browser and let you interact with them So this is a very simple sine wave plot generated by niaplot Uh, niaplot also sports a somewhat similar plugin-based architecture similar to n matrix It has map niaf for creating map visualizations niaplot 3d for three dimensional objects And bionia for Realizing relationships between genes The fourth library is called daru. So for most rubies from all over the world Daru stands for data analysis in ruby but In the national language of my country that is hindi daru also means alcohol I hope daru The library becomes as important to ruby says daru the drink is for indians I hope both of them become equally important to tonight's conference party It's a so daru is basically an library for analysis and cleaning of data You can say that it's primarily used for data scientists who are interested in analysis of data It provides some powerful indexing functionality And it also lets you read and write data from many different sources like csv files xl files SQL databases and even active record It works very well with wild data So it so happens that almost 60 percent of our data scientists time Is spent in cleaning data and bringing it to the state that That can be analyzed by conventional means And daru tries to make this very simple by providing functions for doing that It also has a lot of statistics functions which work with wild data as well The libraries that I've quoted right now niaplot i ruby and n matrix daru is able to leverage these For things like efficient storage of data visualization and interactive computing So daru primarily performs its functions via two data structures The first one is called a daru vector It's a one-dimensional heterogeneous array object And each data data point in the vector can be labeled independently with daru's indexing functionality The second object is called the daru data frame This is a two-day spreadsheet like data structure that can be indexed both on rows and columns I'll switch to my demo now So this is an i ruby notebook As you can see you can put either markdown or a code over here Now I'm going to create a form So I can put in the number of rows that I want for a matrix say four columns four And I want the number to be three inside it So to turn the hash and I use this hash to create a matrix A short demo of n matrix Now I want to create a four by four matrix Or consisting of 64 bit floating point numbers So I specify the shape as four by four and I specify 16 elements over here Now I want to create an n matrix with eight bit floating point eight bit integers So just for demonstration purposes, I'll use 129 over here If you store 129 an eight bit number, it will be reflected as minus 127 You can access any element in the n matrix with a simple ruby array like api So I want the 0th row and the third column So which is minus 127 You can also assign numbers So 0th row and first column I want to be 56 and do that But as I said it cannot be expanded like ruby array So this gives a range of Now I want to use the atlas plugin for performing some fast computations and we'll compare this with the ruby matrix class for To know actually how much the speed actually increases So let's benchmark this Now over here i'm creating an n matrix Of size of these sizes five to 200 And I do a dot product on them for matrix multiplication. So let's benchmark this now So as you can see it's instantaneous The for size 200 the speed is 0.01 seconds And i'm doing the exact same computation n matrix On ruby matrix, sorry And the time turns out to be quite a lot So as you can see it's magnitudes faster For the same computation Now let's do a small example where I'll solve a system of linear equations using n matrix By the way you can also use iroby notebook to represent latex equations Right in your browser like this So i'm representing the coefficients of this equation this way in an n matrix of 32 bit floating point numbers And the right hand side In a matrix called rhs Now I use the atlas solve function And it gives me the solution Now let's head on to a demo of nap plot So now I want to plot a simple sine wave similar to the one that I showed in the presentation Here i'm creating the data for the x and the y axis I create a nap plot plot object and add it to the line graph and add a line graph to the plot object Now I want two waves on the same plot So what I do is I want a sine wave I create data for that using the math sine function And I want a cos wave And I create the data for that with the math cos function The sine wave should be a line plot Which I add with specifying the line option And the cosine wave should be a scatter plot which I add with the scatter option The color over here is red and the color over here is green So as I said it's an interactive plotting tool You can actually zoom into this graph If you hover your mouse pointer over one of these dots It will show you the exact coordinates on the x and y axis So now we want to plot two graphs which interact with each other and change according to Input that you put into one graph So let's create some hypothetical data So I have four band names here And I create a nap plot data frame which is an internal data structure for storing data And I create So there's a popularity between 0 and 100 assigned to a particular band in a particular country Now I want to plot a histogram Which has the of the popularity of each band And this next plot that I want is a bar graph Of the frequency of Of the number of times the band occurs in the data frame So I just do it with add.df and I add both these plots to the nap plot frame So as you can see both these graphs have been displayed here Now what I want to see is the number of bands that have popularity between 0 and 20 in any country So I can just select it this way And as you can see the bar graph has changed to reflect that So if you see megadeth is three And in order to verify that this is correct Let's filter this data frame and you can see that megadeth occurs three times here one two and three And each time the popularity is less than 20. So this bar graph actually reflects exactly that So next up we'll have a small demo of daru so The daru index provides indexing functionality for The the the rest of the daru data structures. I'm creating a very simple index over here And you can select an element in the index with the box operator Or you can even select multiple indices by separating them with commas So now you want to create a data frame. This is a very simple case of a data frame I specify a b and c as the hash keys and you can see that they've been reflected as a b and c as the names of the columns of the data frame indexing also supports Most more type of indexes called multi index data index and categorical index Multi index used for hierarchical indexing of data So now over here. I'm creating a multi index with tuples and I use this multi index As as for indexing data for this vector So now I want to select the sub the sub indices of a comma b. So I specify it here And I get cdp and now I want the sub indices of just a So specify a and I get bq which is exactly what is here So now the datetime index is another index that is used for indexing data on timestamps Here i'm creating a datetime index from a range starting from the beginning of 2011 Up to the end of 2013 separated by three days each I create another hypothetical vector And I indexed it on the datetime index As you can see each day over here is separated by three days And now I want to select the data from first of january to the 10th of february Which can be done like this as you can see the last date is the 9th of february Now I want all the dates in 2012 And now let's take a hypothetical data frame, which has average temperatures of these given cities And I want them to be ordered by name and temperature. So I specify the order option as name comma temperature And it needs to be sorted on the temperature. So I specify temperature as the argument to sort Now data frame also has a where Based where clause based squaring syntax similar to error or active record and You can actually specify where data frame where Where the temperature is less than equal to 25 and it will show it to you instantly Plotting is also very simple So over here I'm specifying a bar graph and the x-axis is the name and the y-axis is the temperature And it gives me a graph. That's it for my demo and I have cool syrupy stickers So you can come say hi to me and I'll give you a sticker And I'd like to thank red dot ruby con for having me over This is the first time I'm stepping out of my country and I was quite blown over by the amazing infrastructure of singapore And the very hospitable and inviting nature of its people So hats off to singapore for being an amazing city and hats off to you guys for being an amazing audience Thank you so much. Thank you Samir Any questions from the audience please So it can export the diagram to either an svg Or a pure html, but if you export to an svg you won't be able to interact with it So it will just be a static diagram So Samir, I have a question So regarding your Your scientific do you do any scientific research? With the libraries that you have just Planning to Suggestions for any of us that's simple to implement Well you can start with the plotting Thank you so much. Thank you So right now we have a break. We are a bit early so We can go out and mingle. I I'm not sure if there's still food outside, but please head for the coffee Our coffee is really good and some of you are unaware. We also have tea at the station So, please be back By 1115 for the talk by Constantine Obviously when talking about celery Who was here yesterday for joe's talk the lightning talk? Yes, so that actually said that celery isn't that important. So this Talk doesn't know it did not say that celery isn't that important. It said it's not the reason that people leave I also think that this talk that i'm giving is not so much about celery but more about development and leadership or rather How we do things at trevis And I think it's an important aspect of that is that I'm trying to break a taboo here A taboo that people have been breaking previously Very famously with the talk pay hashtag and Some news articles and blog posts lately. It is a great taboo to talk about celery. I don't know how it is in Singapore I know in europe and in the u.s. It's not something people generally talk about With their friends with their colleagues But it's not just that it's also not companies companies I found Don't really talk about salaries either I mentioned that was the talk pay hashtag where People were tweeting their salaries their job some details and that Gave a lot of momentum to having a conversation about salaries There's also bots that do that anonymously so You don't need to reveal your salary And there are some companies a very small number that are aggressively open about their salary structure Most well known probably buffer who have published their salary formula and not just their formula They've actually published a complete list With names and everything of all the employees and the salaries they're paying The buffer also is trying to be a very very open Company about this which is quite impressive so recently they saw themselves forced to Let let people go because they couldn't afford from their budget anymore to pay that many salaries which also Brings us to to the to one important aspect of this presentation, which is looking at salaries from the employer side As well as just what people are making which actually is the site that as a co-founder at Travis I've Had to deal with more often than the other side But we're actually is in a salary and I think that's that's where one of the The major conflicts between employees and employers comes from or the major friction points or interpretation differences is the different view and interpretation Of what the meaning of a salary is Who knows these people? Yes. Yes. Is that a big thing here? The big bang theory So that's interesting. Let's talk about their salaries Does anyone know what they make? And how they're paid A lot Yes, correct. No, not correct depends on who you talk about of these five So they all renegotiated their salaries last year initially the three Main actors renegotiate their salaries To one million per episode Uh, so How do you pronounce it? Gaelic Gaelic Parsons and cuckoo playing Leonard Hofstadter Sheldon Cooper and penny Last name unknown or at least I don't know um Got a deal of one million per episode in august 2015 at a time where hellberg playing Howard wallowitz and Kunal Nayar playing Rajesh We're getting paid 100 000 per episode Which caused the two to try to renegotiate their salaries And they were aiming for getting salary parity with the other three Which was denied to them. They got a raise which is undisclosed at this point, which is supposed to be in the mid six digits But essentially the salary Negotiation ended with the studio's threatening to write them out of the series And this makes you wonder what does this mean? Does this mean That one's a 10 times actor 10x actor This is this is a phrase from that's very popular especially In the bay area this concept of the the 10x developer And this comes from from a strong belief In an actually misused word in that context. I think the belief in meritocracy That uh merit defines you're standing in an organization This rock actually has been changed for one That believes in collaboration, so I didn't want to do like github shaming or anything But in the bay area There there is as I said this strong belief in the 10x developer Quora is a great resource in general on such topics If you want to learn the difference between a full stack 10x generalist and unicorn programmer There are there other like if on this topic 10x engineers, there are the really great questions like What do mediocre people do in silicon valley? You gotta wonder as some of the questions are why are the best programmers 10 times more productive than mediocre programmers? But paid only three times as much another interesting question um Very interesting to me as well is how do bootstrap companies hire talent? I've actually once was asked by someone In a in a bar like you didn't take we see How do you pay salaries? um anyway Nothing against vc just saying there are bootstrap companies and they do uh pay salaries I actually work for one of these I actually founded i'm a co-founder of one of these bootstrap companies Who here has heard of travis ci? We bootstrapped uh found it in 2012. We have 38 employees at the moment That was my last count from slack or this morning I think we have some top talent. We're based in berlin, germany We're actually a Or try to be a remote first company. So we have employees In eight countries of 16 different nationalities. Also again, I tried to count it this morning. There might be something of um Other interesting things to give you a feel we we have a 54 percent women In our company in our engineering team. It's 50 percent. It's a one-to-one split with With a very wide range of backgrounds And we were actually planning to keep hiring in the future And salaries is an important topic for us From the company perspective Salaries currently account for 46 percent of our spending. I think in most companies it's actually higher At least most software companies, but our infrastructure costs are also very uh massive But that on its own makes it the biggest cost center if you just look at it from a budgeting standpoint So any conversation that we have there? Even if it's just changing it by a small percentage Has a big impact on our company finances Um salaries have actually For a long time been quite a mess at travers To be honest, we started bootstrap. We started with not essentially having any money And we started hiring in europe And specifically mostly in berlin, which by western standards is a really cheap city and Salary was based on So what do you need? And that has actually led to once we started hiring overseas for instance a very uneven Not well thought out distribution and You essentially got a raise when you said oh money is really tight. I need more money But no one ever ran like oh you've been here so long great work So we've been having a discussion for quite a while in the company on how to change that And we came to the conclusion and the result Is that we got rid of salary negotiations At traverse ci if you want to work at traverse ci if you're going through a job interview We do not negotiate salaries with you Instead we have a sinatra app That will tell us How much we'll pay you why do we believe before I tell you more about this app Why do we Why are we trying to to get rid of why have we removed negotiations from this process? well We think that negotiation skills don't reflect your value to the company which is the employer's approach to To how you decide on salaries if you remember That uh the three main characters were at one point at a salary That was 10 times the salary of the other main characters in the big bang theory that was not based on them being 10 times better actors This was based on them being 10 times more valuable to the production of the show So your negotiation skills are not the main value you provide to the company unless of course you're hired as a negotiator Then that's that's a different discussion The employees view on salary is different It's not it can be the value argument can be used in a negotiation or in Figuring out if it's appropriate, but the employees view is usually in financial needs base And your negotiation skills also don't reflect your financial needs But most importantly As one of our core values at Travis we care about creating a diverse and welcoming working space And we believe that salary negotiations harm underrepresented groups There is lots of evidence for this for instance women people of color Generally underrepresented groups Often are impacted from things like imposter syndrome. There has been a study for when Women and men look at a job at and there are five requirements listed and For women one of the most common approaches is like i'm not so sure about this one requirement I'm really bad at this I probably am not a good fit for this job and most men approach it with oh, yeah, I check up three of the five I can totally do this This is not any individual person. This is just a general Thing that is more dominant in underrepresented groups And there is also statistical data to prove the whole thing So salary negotiations are very likely to cause pay gaps within your company So these are some of the things We wanted to tackle And we've been working on this for over a year and we call it the Travis CI salary framework We finally rolled it out released it this march company internally And this here Is the very first time we're actually talking about this publicly so All the things i'm telling you Are not really known outside of Travis Let's first look at how again how other companies have solved this Buffer also has an app. I don't actually know if that's Sinatra or not Their approach is very very formula based. We also have a formula, but I get to that in a second And your plan actually access their app publicly You can go to buffer.com slash salary and then you can select your role experience location And it will tell you exactly What you would make when you were to join a buffer But let's get back to our our framework. So buffer was a big source of inspiration and figuring these out because they also have public explanations of all the things So we developed this framework for a full year and Very importantly to how we have Travis approach these things This is a conversation that everyone in the company Could take part in so a lot of this was actually discussing aspects of what is a fair salary for instance Or what should be in a salary? so we decided that We want to pay by value and we want to pay by needs by needs So we want to take both these aspects into account and we also want to Come up with generalized rules that apply to everyone And that also everyone could question. So in a way you can negotiate salaries But you cannot negotiate your salary. You can as an employee at Travis CI say I think This pay difference is too big or we should in general pay higher salaries And then you can give a proper reasoning Or we should our increase our salaries because the euro is taking a nosedive because the UK is leaving the EU or something like that But you can say I'd like to make like 500 bucks more a month. That's not an an argument you can use That's a screenshot of our app This is Confidential You're the first people seeing this outside of the company Let's talk about What goes into this? Are people taking photos? Is this being recorded? So let's talk about value. How do you measure Value or how do you quantify What someone provides to the company Buffer does that with a factor. So they say you have an experience factor of 1.6 or something That is something we we started off with with playing with that But we found really hard to what does that actually mean And then everyone talks about senior developers, but senior is such an overloaded term in the industry where there again is a massive mismatch between Employers and employees Uh, similar to what does a 10x developer actually mean? So we instead decided to Take an approach where we have levels And then on these levels we have certain expectations that are quite meta That when we have an employee at a certain level We expect them to fulfill these expectations one way or another so If you had the discussion How do you define a 10x developer if they even exist? I don't really know how you place them on our levels, but Let's just pick a level. Let's pick the the level 10 of our software engineering career path and that has expectation like Shows an intuitive grasp of situations analytic approach only use in novel situations, which is basically You see a problem. You already know how to fix it without having to analyze all these things It's self-motivated to the point that they create new work for themselves and sometimes others And understands business requirements does not just understand but also shape the big picture So these are very vague and then you're supposed to work with your team lead at Travis CI on a regular basis mostly through one-on-ones setting specific goals for yourself um to fulfill And reach the point where these are expectations the company can have towards you We currently have our engineering career path defined up to level 17 We do not have anyone at level 17 The main intention is To show people that there is room to grow While at the same time staying a software engineer and staying at Travis CI Because this is actually one thing we see happening in the industry so much It's like people reached this point where there's senior developer and damn what I guess Not just about salary. This is actually about Your professional growth career development and so on and not just about your bank account statement And then you often see one of two things happen Either people go to a different company to do something new and fun or people become managers And in both cases you lose your best developers In one case you might swap them out for potentially a bad manager um If if someone wants to be a manager like I'm not I don't want a bad mouth developers becoming managers like if someone is really passionate about that sure But becoming a manager because it's the next logical step in your career path is a really really bad reason And these levels we've constructed or tried to phrase them in a way That employees should level up about once a year So that it's also clear how often people can expect salary raises And most importantly we don't view this As a performance review that you get once a year That we can use to justify to not give people a raise But instead as a program for us To grow people internally If someone does not meet the expectations for the next level That needs an investigation of what's going on Is this Some productivity issue do we have other problems here that we need to address? Or are our expectations wrong? You do not fix productivity issues by paying people less The other aspect we take into account is needs We use a generalized needs model based on location This was actually a discussion initially where We assumed that the bigger discussion would be should you pay by location or should you not pay by location? Actually The opinion at Travis was pretty unanimously that you should pay by location The bigger question was How do you determine that those differences? But essentially even if we Wanted to not pay by location just pay everyone on level 10 no matter where there are the same salary We could either not afford that Or we couldn't hire in California essentially But then we have the goal had the goal that if we pay by location differences We want to be scientific about this. We want to be reasonable about this And we don't want to have someone Basically get a worse deal because they're in a cheap or an expensive location We don't just want to pay people in San Francisco more than everyone else essentially So how do you do that? There's one interesting statistic. That's a big Mac index. Has anyone heard about the big Mac index? So big Mac is a great thing because it's in so many countries And it's essentially the same supply chain, but it's different cost So you can compare countries Based on what the big Mac cost. We do not use this for salary determination by the way It's also it's a bit unfair to have India in there actually because it's chicken meat in India Which has different costs associated There is different conclusions you can draw from this like Big Macs are the most expensive in Switzerland But that doesn't tell you actually much about Switzerland because if you then compare that to Or Norway for instance is the second most expensive It's the cheapest in South Africa But if you compare it to how long it actually takes an average worker to work to get the money for a big Mac You see that Switzerland is still pretty good and actually Hong Kong is the best where it takes on average 8.7 minutes of work to get a big Mac Whereas in Ukraine in Kiev Ukraine. You have to work for almost an hour There are actually way better statistics to reason about cost of living one of my favorite is Numbaya, which is actually something that we used So we use Numbaya. We use the international labor organization. We use the bureau of labor statistics And we use shadow stats, which is basically going like oh those Bureau of labor statistics statistics aren't actually that great to look at This Numbaya is actually a crowd sourced Database that gives you very detailed insight into into living costs for instance for Singapore it uses 6,300 something entries You can see what a McDonald's meal costs as well, but also disposable income rent and so on When I when we started investigating I built a little web app Where you can basically enter which city you live in where you want to move how much you make And then you can calculate which salary you should aim for when you move there It doesn't work well for Singapore because that data on there is outdated and some models in there are outdated But works quite well if you want to move from san francisco to Berlin or the other way so Say you make 130k in san francisco means you should aim for Somewhere below 60k euros in berlin if you want to keep the same start of living That's living costs, but also Market rates are a big factor as well There there are some websites like glass door Where people can can Enter their salaries and then it can give you an overview of a location Pay scale is similar also Really nice to know they have like fifth and 95th percent or I actually think I think this is 10th and 90th percentile and Pay scale has that as well for the US Thanks to the open government campaign under the obama administration You can actually just access the data from all the visa applications. So, you know What people are getting paid when they get a visa for the US or a green card Important here is that you only compare data points from the same source Because the visa data points for instance tend to be on the high end of the salary spectrum So you shouldn't use that data point on its own But you can use it quite well to compare two cities and the same is true for our glass door and pay scale Where salaries at least in the US where I can compare to other sources Are more on the lower end So I use that I did a factor that's a comparison between Berlin and that city and Created a splatograph of the biggest cities in the world To see your correlation between market rates This is market rates compared to Berlin and this is living costs compared to Berlin And you actually see that almost all the cities are in a very nice line. You also see that Singapore is quite the outlier. So Living costs are significantly higher here than in Berlin, but salaries are Not proportionally higher as well And then besides that what we took into account is I think I'm running bad on time good so what we also said Or what what was more like the conversation went like this Um, so if we take living costs into account and rent and all these things Shouldn't we take income tax into account? and The conclusion was yes, we should but you can't really calculate the income tax for everywhere in the world And then okay, that's right. And then I spent a weekend playing with some ruby code and turns out you can Calculate the living car the income tax for everywhere in the world. I created a ruby library. You can gem install income tax You can tell it which country you're in. It doesn't do tax deductions or anything Even though someone emailed me and they want to do like a tax filing program for you. I don't know. I think they Actually never got back to them. Anyway, um, so you can tell it how much you make or salary a country and we'll tell you about gross income net income taxes and Important for us. You can also tell it a net income Like the income after taxes and it will give you a gross income Interesting things I learned there in molly. You can choose your tax rate Basically, you go to negotiate your taxes and they go like so we want to pay 3 percent You want to pay 30 percent? You can also bring a goat and use that as your tax payment Um And from that we calculate The the salary levels we have a baseline per country that's based on market rates And then a city adjustment for expensive cities that's based on living costs So we do take market rates into account for the us But we don't take market market rates into account for san francisco But we do take into account that the rent is really high in san francisco Here's actually the coat. I promise coat. There's the oh, there's it's been cut off the result Basically the rounded we have our own rounding method to Be more favorable to our employees so it's uh taxes applied on top of the Before taxes we apply of someone's working part-time Before taxes is a monthly value times 12 monthly is the the base value Um Plus the increase for the level you're at Times the level plus the city adjustment exchange to the local currency Yep That's essentially it if we would pay less than zero. We just pay zero We don't make people pay And with that we've actually calculated the rates for 3536 cities in 209 countries for four of these countries We also have 92 regions you might wonder 209 countries there aren't that many countries. I recommend to you this youtube channel I also found myself in that income tax gem to for the first time specify What this gem sees as a country and stating that this is not a political opinion, but just trying to model income tax best Currencies are very tricky employees that are Not in the u.s. Or Germany can pick their own currency we have Conference allowance converted to the currencies. I imported a set a list of currencies with exchange values Which I didn't know when importing this currency list included gold so If you work at travis ci and we pay you in gold you get 4.45 ounces of conference allowance per year I assume this is how you go home And we've rolled this out. We've used that for all our new hires for to replace salary negotiations We're very happy with it. It reflects what we set out to solve. We think the rates that come out are competitive based So there are some relation to market rates. They're comfortable. We think people can live of them. They're fair this has to do with the Rules applying to everyone for instance, they're feasible They're within the capabilities of our company and they're prospective. So people know there is A path to take and most importantly, I think it's a model that everyone Participated in and can participate in shaping how that develops in the future Thanks I don't know if there's time now otherwise hit me up later or treated me email me I also brought stickers But I absolutely know what you guys are doing So Can you hear me? Yep. Yeah What's your plan for bringing existing employees across this? Have you done it or is it going to be a gradual thing? So we actually started doing that So we've brought on So all of our engine Nearing team I think is now on the framework So we have this concept of people being on the framework and people being off the framework We started rolling that out. We don't have all the career paths done. So we have the career path done for Software engineers designers Support we're working on our administration career paths right now So that's why not everyone is on this now, but the majority of Travis CI is paid in accordance to the salary framework Yes, so we've actually discussed this releasing this public. First of all, we want to actually Talk more about this blog about this not just to like show off what we did But also to get a conversation started that goes further than just Travis We still need to figure out What work needs to be done so that we can actually release our app Which would probably also be quite interesting for people out there Yes, so This is uh, where do I have to slide the currencies are tricky So what we actually have is we have a Travis CI exchange rate Which means we picked exchange Behind the scenes, which is back end. I'll be speaking a bit about front and back end like back end Uh, a bit towards the end as well as front end. I don't know what this emoji was how to represent back end So I just flipped it I tried to search for it emoji for front because there was a back. So it should be there should be an emoji I spent some hours actually a day trying to trying to find this But I couldn't so I thought that hey, I should actually try to submit my emoji proposal And I ended up here, but I didn't have time. So Yeah, we are this is the front end emoji So today I'll be speaking Many progressions that have happened in the latest version of rails rails 5 One of the things is it has gotten a nice logo and this homepage. So yay for the designer who did that Which was after 10 years using the same one Uh, most of my references that I'll be speaking today are based on the block that we run on On my company, which is called as Which you can find here. We have around 60 plus Blocksy blog entries right now for all the various changes which have come in The latest rails version So let's begin first thing that I want to touch up on is prockets So sprockets is that part of rails which is used for actually serving your resources Your js and css resources There's a wonderful talk on how sprockets actually works if you want to go deeper into that Which was given at the this this year's rails con by rafael. So you should check that out I want to focus on some of the main things which help you out Which are the new additions right now in sprockets the sprockets come consists of all of these things which is sprockets sprockets rails sass rails exit js coffee rails, which are like peripheral gems which actually comprise of the asset pipeline Uh, so one useful addition which sprocket has seen is that of manifest.js So previously in your older versions of rails if you would like to have you know, use a different kind of asset Like let's say I have my payments page and on my payments page I want to have different styling and not embed that completely in my Application css. I could I needed to do this this kind of thing wherein my pre-compile needed to have payment css Advertising css etc And then on my page where I actually need to use that I would use this kind of tag Uh rails 5 Comes now with manifest along with support from sprockets wherein you can just define this kind of file It is by default generated on rails 5 apps And then here you can define Which file you actually want to pre-compile as well So instead of defining that list which is not kind of handy Like you always need to define that and make sure that it's actually in the pre compile pre-compilation So that it actually finds it in production in your apps You can instead do something like link And you can actually use this manifest file to define dependencies on all of these multiple different assets So we will say like Link tree and link all my images. So instead of specifying them I will say that hey, I need to access these images and when pre-compilation happens They should also go along like from this In the process of assets pipeline I can do link directory and link and so and so forth So here I see here you can see that I am doing link advertising css and instead of specifying that in My pre-compile and specifying it over here in using link After I do that I can then go ahead and start using that in my erb or Also in some other directory in some other asset as well So if I do this Like rails will like sprockets would automatically pick that up and it will autocom like Send it through the pre-compilation path Next useful addition which sprockets has got is that as folders as modules So if you if you notice over here, I have this foo slash index.js So this is a kind of a technique which is pretty popular in node based apps Where in you have this directory and you specify index.js and instead of having Including this this asset like asset path foo slash index.js instead of this you can directly just use foo.js and it will go and Import the index file. So this is pretty useful if you want to define Something like this So previously if you wanted to you know import all of your different assets in your directory What you would do is you would do something like require tree Require tree in that particular directory and what will end up happening is it will import all of those in an alphabetical way Problem with this is Problem with this is if you have such kind of a file jquery ui.js and min.js Problem with this is it will import alphabetically and then This file will be imported before Its dependency and you'll not you don't want to have this kind of scenario So instead of this now you can just import index.js and there you can specify the order in which you actually want to import a particular file So this is pretty useful The next thing which is pretty useful again for debugging debugging purposes is source maps So in the previous versions of rails on rails 4.2 if you try to do this You would see that On a request on your development side You have all of these resources being loaded So individual files Every single resource that you have it will send a new request for fetching that particular Resource also like jquery button etc On the latest version rails now actually Maps that similar to how you have in production. So in production you actually have just a single file Which is compressed and minified. So now in In the rails 5 apps you'll start seeing something like this which is application debug And what this means is it is it is trying to map the same behavior that you actually see in production Which is something that you would like to see Because it So that you don't have any surprises when it actually is how it is actually working in production So for so since you have this comprised thing like Compressed thing that is also being served in your development version Whenever you want to debug something it's pretty hard to actually find a particular line You know something goes wrong another is thrown from a javascript You don't know where that particular line is because it's not compressed So to actually find the location of that particular error or something like that We can now start using source maps So source maps are actually defined by this mapping this directive that you see over here So let's say I have this file application js Sprockets will create this mapping file that you see over here Which ends by just map And this mapping file will then be provided by these directives in the original file For see it for js. It is this way and for css It'll again provide a different kind of mapping file And this is pretty useful. So like In your request now you'll see these two files being served But on the on the browser end browser will detect these mapping files and then you will actually You will actually be able to find the mapping of these particular So if you want to actually trace back to some log or some error being thrown you can map that back to the actual sources again The next useful thing which At least for me, which is pretty exciting is be able support for sprockets How many of you use or no? es6 es15 A lot nice. So es16 has a lot of these Amazing things which i'm pretty excited about to use have started using Like the arrow functions lexical binding Classes and and has object or literals and a bunch of different things So by default now in the latest version sprocket ships with Babel support. So now you can actually start using es6 by dot es6 Extinction So this is pretty exciting again. I wanted to show this by this And I tried to search for this but it was like hey There are so many different things that you can actually show this for like rainbow unicorn poop as well Or something like this. So internet is pretty awesome If you try to search for it The other thing that I want to speak about is this 12x improvement that sprocket has seen in the pre-compilation process of asset pipeline so there's this nice blog which Richard Schneem's Which he goes by schneem's has written on heroku. So you should check that out which actually provides the whole listing of whole process of how this speedup has occurred so Here's the here's the actual flow of things that go into the pre-compilation process like you have your raw asset You try to you try to actually process that Based on which kind of you know sass or coffee script And then you try it is bundled together like all of your different files are bundled They are compressed then they are given a fingerprint Like a digest that you see after a particular asset which is for cash bursting and then they are minified and so on so forth In the previous versions of in the previous version It had actually had a bug if you see over here. This is the function which is used for actually finding the digest So when you pre-compile it tries to you know store that particular asset in your tm like asset tmp asset cash if you have heard of that So for actually finding so ideally you would not like to go through a whole compilation process because it's pretty slow To actually getting that asset so instead of that we have these fingerprints and then you use that to find that if that resource is already being Processed and is it if it's either already in the exists in the cash or not and if it does then just return that Problem over here if you see the path is being provided over here In the previous versions it used to pick the absolute path The issue with this is if you have if you use something like Heroku or if you're using Uh, like Capistrano in case of Capistrano every deployment will actually create a new directory So if you're using this Your cache is always going to find a new path. So it's not going to Refer to the original resource. So you are actually missing the whole point of Having accessing the cache versions. So this was fixed by uh, this fixed again by richard and he added this unload asset which actually tries to find the actual paths properly When it does the whole compilation for this digest and finding it actually in the cache Uh, the next thing I want to speak about is sri, which is sub resource integrity Uh, so it it has been added as an experimental feature right now. It has been present present for a while Uh, so what this allows us to do is we can append integrity through as an option to our application whichever resource that we want And that will create an integrity hash Uh, so now why this hash is useful is so let's assume we are have we have a page which has multiple different resources like I'm not always going to access a resource which is in my project like I would like to access The jQuery or bootstrap which is being accessed from some third party cdn or so and so forth In that case, I need to make sure that whatever the the resource which has been provided to me It actually matches the one that I wanted to access and something has not been injected into that particular resource So in that case, we have a use this use of our sub resource integrity Which makes sure that whatever resource we are actually providing actually matches the digest of the original resource Which you meant to actually access from a particular domain So you can start using that right now All right, uh, that's all about rockets Hope everyone is following me The next thing I want to speak about is all about headers in Your page So this is a typical header or the response that you see when you you know send a request to a page This is coming from The chrome browser it shows what are the response headers like you have you have your e tags date content type, etc So what I want to speak about a bit about is The how you can use them How you can use or manipulate these headers so that your resources are actually cashed on your browser in So one of the good uses of these headers is e tag So if you see over here, uh This there's a header which is which says e tag and it has some digest And then we also have this last modified over here. So using these two headers, uh The browser can negotiate with the server that hey Whether I have the latest resource on my particular like in my cache or not In the previous versions you could use like in the old like right now you could use it with fresh wind or stale And what essentially this will do is it will first of all find out all the items and then it will generate an e tag for those items And when you send this as a request So if you see over here I'm sending a request to find these fetch these items On the first request it will return 200 as a response On the subsequent request if I pass this e tag which was generated over here This e tag if I pass this to this request again It knows that hey, this was my e tag. I'm passing this in in this header if none match It sees that there is some e tag object Which is being passed to me and it tries to find that on the server And if it does match then it returns with 304 modified Not modified and just use the existing resource that you already have in your browser So this is useful so that you don't actually go to your database and try to fetch Your resources and slow down your request. So this speeds up That part of the thing So rails now Has support Jeremy added support for strong and weak e tags. What this means is So these are two kinds of e tags that you can actually have in your requests What this means is if you have a strong e tag Your request when you send a request it will try to do byte by byte matching So this is useful when you have some kind of a png or you know, you're streaming a video Where in you want to see hey this resource which was previously sent to me does it actually match To the resource that I currently have This is not so true in case of pages you are generated like all the default pages that are generated in rails app Which are dynamic and in which case they are not always going to change That's useful to have this kind of weak e tag Right. So in this case, it is just going to create a digest of that Of the resource and it is going to match with the previous digest instead of doing byte by byte matching of the whole Response because this is pretty useful to you know, not go through that render process to find out if the resources changed or not Another useful helper which has been added Is http cache forever So let's assume we had this home controller over here, which just serves this welcome tag Previously like if you if you always try to access this page What will end up happening is it goes through processing render and all that multiple different things the whole cycle of particular Serving of a reason like html page This happens for every single request Instead Now you can say cache forever It comes with a risk But now you can do something like this http cache forever public true And render the response that you want to actually send And if you do this for the first request if it will serve it in this way like processing so and so forth In the next request it will just reply with 304 What is actually happening over here is when you do public Caching it will set the cache control over the resource So your page will actually be setting this cache control max age a hundred years or so So use this with caution what this is useful is let's say you have a page Which is really static and it doesn't change a lot and it's never like it's you know that it's not going to change You can use this so to notify the browser that hey Don't always try to compute this resource just use the one that you already have Use this with caution because the only way to you know Undo this or get a fresh resource is doing a hard reset on your browser cache The next important thing that I found or that is that I found pretty useful was having support for custom asset headers So let's assume we have this request. This is a typical rails request wherein You have all these headers these are not visible thus but just take my word that there are lots of headers over here If you see over here If I want to specify a custom header in my request in my response Usually you can easily do that by saying response dot headers some header and then try to set some value over here And then this value will be served from the request problem with Problem with this is you cannot do that easily Or previously you could not do that easily in case of your assets Your assets only had or your dynamic assets only had this one header Which is static cache control and the only thing that you could actually manipulate in this case was this header Which will only set the cache control over here This is useful again for caching purposes. You will say that hey To the browser whether you want to cache it publicly or not and for how much time you want to cache a resource Before actually getting the new one problem with this is Sometimes like in case for me what it end up what it what it does is it some of the browsers do not actually Just depend on the cache control. You would like to have other headers like This is something that I got from page speed, which is a google tool for analyzing your How your Pages are doing So if you see over your page speed was warning me that hey expiration was not set for a resource So you actually want it it was saying that for some of the browsers Expiration header is also useful along with the cache Cache control so you I should be setting that But I could not do that easily since we can only specify a cache control as a specific as I said so This is a new thing that you can now start using On rails 5 when you can specify public file server and then It actually uses all of these custom headers like cache control you can specify for cache control You can specify for expires or you can specify other different, you know for controlling It so and so forth for your Serogate cache or cdn on so so and so forth So this is useful if you are actually using something like Fastly or if you're on heroku In case of if you have your own server like engine x this will already be taken care of by on the engine x side Uh and now if I after I've added this expires header In my like in my config Like the result is that you'll stop seeing that warnings and then you'll actually see start seeing that header which is being set to here This was actually done by yuki. So thanks to him for that The next thing I want to speak about is caching So apart from these things which you can use like headers or e tags for specifying Not to compute the resource you can also use a bunch of different things on the caching end of Action pack or action view There are a bunch of different ways you can actually perform caching in rails a page caching action caching etc You can find them all on the rails guide Today, I just want to speak about The new additions which have come into the latest rails release So one uh important work like important change which has come in is that of partial rendering from cash So if you see over here, uh, I have this to do collection And what I'm doing is I'm rendering that as a partial And here I have this cache which is using this to do So when it wants to actually like render this it will render it for that many number of times And then for every single cache it it will try to Uh actually fetch your cache entry for that this to do that you see over here Which is expensive if I have 100 of these it is actually going to send hundreds of requests to fetch This cached version of to do So instead of this now you can start specifying this cached true When you're trying to render the partial This was basically influenced a lot from multi fetch fragments gem And now you can start doing this and rails will Identify that hey, I want to actually render a collection and then Not do these multiple requests to the cache and just use read multi to Actually fetch all of these entries together in one single request Which gives you a lot a lot of boost so you don't have to do that back and forth to the cache And this is something that you'll see in the end result in the logs that hey It just fetched it in one single go Uh the author of this library like the original library which uh Actually, which which was from it which was influenced by this In in his usage usage it actually improves the performance for these kind of scenarios by at least 72 percent. So which is pretty good The next thing Which is kind of on the peripheral is that of action mailer fragment caching So now you can also use like make use of caching in your mailers You can enable this by perform caching true again for action mailers And then in your mail fragments what you can in your mailers what you can do is you can start doing this cache do And then it can also if whatever part you have of mail which is you know actually dynamic You don't need to do that. Uh, you know pre compute all those values. This is pretty useful because Uh In your mailers you don't have to end up spending so much amount of time to actually compute all of these things which You know are going to just be this part of the particular Mail is actually being going to be dynamic. Everything else is going to be seen So you can start using this now to use cache in your mails You can see over here how it is uh After you run this request it says that hey, it's going to fetch the cache digits for that particular part of your mailer Uh One another addition which is kind of useful which goes hand in hand with the fragment caching or collection caching Is that of support for collection caching on result sets? So active record relation now has uh support for cache key So previously when we were saying cache do you have to actually provide So we'll see an example for that. So if you notice over here I'm trying to find this Result set when I'm saying I need to find all the users who stay in city Miami The thing with this is if I'm not changing this particular query If no records were added or if no records were deleted This result is always going to be the same if nothing was changed This result is actually going to be the same so I can catch this particular result Now there are multiple different ways uh previously you you had to do that manually for yourself like for a result set You you needed to derive How you're going to specify this cache key? Our rails now has the support for cache key on these collections So what it does is behind the scenes it tries to find that based on the updated at timestamp and it has some restrictions But based on that it By itself it tries to find this cache key And then you can start using this cache key to actually you know cache users and it will automatically start using that cache key Instead of you specifying or you trying to generate a cache key for that collection, which is again pretty useful So that it gives you again this use of caching over whole resource collection of resource Finally I want to speak about layouts and tags Which is coming towards the end of how your pages should be structured So I want to get to first or I want to first get to refer to this async and defer which is kind of attributes that you can specify over your tags So here's just a legend of that I've picked it up from an example, which is here somewhere So here the green part is actually parsing halted downloading of a script and a script execution So generally when you just have this script tag Script tag with application import your Usual import what will happen is It will your page is parsing parsing parsing. It comes to your JavaScript include tag Then it will halt for a while it will stop rendering your page It will try to go and fetch This since it is a different file it will send another request and for this time it is halting Which is not pretty good because for that time of download nothing is happening on your web page After it is downloaded it will then go and actually execute that js which was imported and then it will really you know it will Again start rendering or processing the html parsing But this is not pretty good because This affects your page speed if your resource is slow your file is huge This is going to affect how your page is actually rendering Other ways that of specifying async If you specify async what will happen is this resource will Download so when it sees that hey this tag was async it comes over here Instead of stopping the parsing it will continue parsing. It will try to find this parallely And then it will stop again the the html parsing and execute that particular JavaScript or css resource The third thing that we have is defer Here what happens is the normal execution will go as it is whenever it finds this differ or It finds this javascript tag it will go and download it But it will not stop normal html parsing. It will do that towards the end So based on your usage How you're actually importing your javascript or css. This is pretty useful for Speeding up your page actual page paints This is useful for your page speed again So there's an ongoing pull request right now to have this by default in rails You can follow that over here. So this will actually be pretty helpful by default if it's enable in your real saps Towards the end, I just want to speak a bit about page speed So you can use page speed this tool we just provided by google for finding out different things that you can improve And this lets you know about how your placement of js and css imports are How you should import your forms analytics how you should actually have your analytic stacks and so and so forth So in a typical application a dot html file you will have a bunch of different things So I just want to end with this that How you should actually place all of these stacks Based on your execution it will actually slow down or speed up your painting of a page if you see over here I have my style sheet tag by default style sheet and js file js tags will be in the head In your new apps you should usually try to move the js towards the end so that the execution is not stopped You can also specify async and differ again so that execution is not stopped for your html parsing You might also have something like this which is for your Loading of external fonts, which is something. I don't like but you will need to have in your apps So you you should actually try to move that towards the end or actually try to use open fonts and just embed them in your assets asset pipeline Google actually says that you should have this style sheet towards the end So that it is not blocking again for fetching that file But usually this is pretty useful again because you don't want to have the page like you know All black page and suddenly you have that whole style coming So this is useful so that it appears that your page is actually pretty fast So the style sheet actually should be above So based on your usage you should have Your scripts execute towards the end of your page on page load and so on so forth And yeah, you can combine all of these different things that we have discussed today To actually speed up your page Which is something I like in the latest release of Rails. That's all I have for today. Thank you Thank you I would hate to hold you back from lunch, but does anyone have questions for him? Okay. No, everyone is hungry. Yeah Before you go, I have to make a few announcements. It's more reminder than announcements Uh So no food and drinks allowed Please be back by 140 fs. We have a surprise by one of our sponsors for sure And after that we will begin Sayani's talk on sense and sensibility at 145 shop Please don't forget to Visit the appreciation board Thank you Ben from for sure Has something to tell all of you Cool. Hello. Hi there. Thanks Cool So this is just going to take a few minutes. Um, but I just wanted to kind of ask Show you something quickly. Um, so Me and hamilton, uh, we're from pusher. Hello. Um, and we've come across and we're sponsoring Helping sponsors this which has been brilliant. Um, but so we've got a prize But we were supposed to have a raffle and we're supposed to gather names over the last couple of days But we kind of forgot about that So what we've done is we've So we've got this prize which is a bv8 Right, so this is like a kind of remote control. Um, bluetooth like very kind of cool little mini robot Um, so we want to kind of give this away and the way we're going to do that is we're going to have a live real-time Prize draw. So the way we're going to do this is I want you to all visit rcrdrc.herokuapp.com On your phone on your laptop or whatever you can And hopefully that'll work. Uh, but and what you should see is you should see, uh, a big circle Is that working? Cool, right. I'll give you a few minutes So the more people we can get on this page the better Um, uh, it should don't like it should manage up to a few hundreds Hampton, I think we're gonna need the Plan b Oh, no, no Right, so if everyone what we're gonna do is um, we're gonna change the colors of all the circles in this room And one person is going to end up with a big red dot and that person has won the bb8 Right, okay Yeah, no no no changes the css so, um We'll be checking I should have thought about that Okay, so what I want you to do is I want you to turn your laptops or phones towards the front So that I can see the the circles and they should all be Be white cool. We can see those Right, so I'm gonna select a winner and hopefully this will work Right, okay, so they've all gone black. Um, if they're connected so Hang on a minute. Hang on a minute. Um Right, so we're gonna cycle through some colors here. Okay, so now it's kind of flicking between different colors And now we're gonna introduce sounds to turn up the volume on your laptops Okay, so we're doing colors and sounds and we're gonna just randomize that a little bit And then one person is going to end up with red dot. Hopefully Is anyone got it? Oh, there you are How come everyone everybody can hear me? All right I am so so happy to be here This is my third time that I'm here in the red dot ruby conference And the first time when I was here. I was just a beginner Trying to learn the ropes or web technologies the ruby programming language and the rails framework But it has been a phenomenon and fun journey since then because of many of you in the audience the ruby community Of singapore and beyond whether it's people like winston Who has been so crucial about programming and teaching are people like huanito You know like spreading the love and laughter Or even getting some free hardware like this in red dot ruby conference just last year It has been a fun journey But being a beginner is not just a story of an individual It is a story told repeatedly By generations of engineers experienced engineers whether it is The integrated circuits of the 1960s or personal computing of the 1980s or even more recently the web and the internet Engineers have always taken on something new something unknown something messy Have kind of played with it and made it so usable to the people beyond That it almost became an extension of who we are And so I thought I should start 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 Today, I hope to share with you something that is an extension of our very own senses Starting with the sensors themselves and some of it I have right here I want to be taking you down from the extraction layers from the physical world the real world All the way to the application layer, which all of us are familiar with And I want to share with you exactly what is changing in each of these layers So let's start with the sensors their pressure sensors light sensors humidity sensors They are becoming cheaper and more compact than ever before, which means it's just much more accessible to us The next layer is the wireless communication stack, which the sensors will be using to transmit their values And all of us must have heard of nfc or even wi-fi Bluetooth and 4g which is kind of long range There are newer protocols coming up such as bluetooth low energy Or even 5g that will be coming up in a few years and these are especially Important for tiny sensors low power sensors for machine to machine communication The next layer is the access layer So all of us who are web developers here are very familiar with these protocols the http the html Jason and so on I also want to share with you two more protocols in the application layer, which is the mqtt and the co-app And these are very important for machine to machine communication once again And of course above these we have the web of things layer which all of you as rail developers or web developers will be playing with Now for today's talk, I will be specifically focusing on the bottom three layers focusing on the layers that will be communicating with the Physical layer the analog layer with the digital layer the application layer So before I get started, I want to talk a little bit about what is an internet of things platform So a show of hand how many of you are rails developers? Wow, that's about 70 of you I I agree with you not all of us are web developers. So we might be playing with ruby a lot So as web developers as rails developers, I'll be talking about this framework called thingspeak So if you go to thingspeak.com You can actually connect your sensors and play with it. So it is a hosted platform But if you want to look at the source code as developers, you can also go to github And you can also download the source code. So just a word of caution The source code in github is about a year Old so it will be based on ruby 2.1 and the rails version is 4.2 But nevertheless, I still feel that we'll be able to Catch on a lot of how the controllers are made the models are made and get a lot of ideas So essentially what is an iot platform? So it has four key features number one So you have a sensor out there in the wild and that kind of communicates Periodically to your ruby on rails server. So that's a key thing about what is an iot platform The second thing is When does the sensor send these values? It can be triggered by event which can be by a human And it can be by periodic like every few hours or so The third key thing is what do we do with the sensor data after it comes to your ruby on rails server? Typically, we will plot charts and graphs. So that's a very key function of this The last attribute is hooks and I think as rail developers We are very good at this like when we get a post request or a get request We might trigger a rake task or we might generate a pdf or an email So these are the hooks and triggers I talk about so now that you know what is an iot platform I want to be giving you three demos in the course of this talk and hopefully with these three demos They are tangible enough for all of you to take back something home Get excited and start playing with the physical world So I have three demos here. We'll be using wi-fi wireless protocol for this purpose I have three kinds of sensors or acquit actuators and being a red dot attendee I've used emojis as you can see the first one is a switch The second one is a proximity sensor and the third one is a temperature So let's get started with the first one. It will be event triggered So before I start with the first one, I want to be talking a little bit about the wireless protocol system So we are in today's world very familiar with Two kinds the wi-fi which is like within a room or the cellular which is like 2g or 3g So it's very important to know where is the device of the sensor and where is The kind of the central device that catches all these values in the case of wi-fi. It is the router So I have a little router here. So I've kind of flashed the firmware and connected it to the ssid of this little guy And here is the router and this is the sensor. So in terms of cellular, it is the huge cell tower Now what's happening in the last few years is this We are having more and more chips, which is the connectivity chips available to us So this is an example of a photon, which is a dev kit and over here I have a wi-fi chip made by broadcom bcm And it's all done up for you in a tiny little pcb that you can explore I have another example This is based on as a stm 32 microcontroller the switch is connected to the microcontroller And that's where I flashed the c program To kind of say how it will communicate and then of course it has a wi-fi chip on board Which is talking to this little router here All right, so that is the thing and with this wi-fi it kind of talks to my ruby on rail server, which is running in my laptop All right, so are we ready to see what it does? Okay, so i'm going to go here and this is completely wireless So let's see i'm going to turn it on Of course All right, so Let's go on and i'll show you the channels this time It's going to the switch So this is where you will see the public switch here the public view. So this is how Let me see whether we got it. No, we didn't get it. Oh well Well, even if you don't get it I'll come back here and then i'll show you the channel settings So what happens every time I turn this on and off? It basically communicates with the rail server right here and when it communicates it gets a post request So let me show you the api keys right here. So this is the api key you have here And then the channel settings over here You kind of set it up and then you say that in this sensor node right here You have eight different fields and one of them is a switch so let's turn back here and This is the api key Let me move on and show you where this can be used this little switch How many of you have heard of amazon dash? Many of you. So this is actually using the same Broadcom wi-fi chip as the amazon dash here So what it does every time you kind of switch or push the button It connects to your router at home and it basically creates a line item in the e-commerce cart of your amazon And the cool thing is a few months ago amazon even released the iot button And the iot button is available as a developer kit. So go ahead and play with it aws iot button So that's a brief about this But I want to go to the firmware and the rails code where the communication happens So I've basically kind of flashed the firmware right here And even though this is c code, I want you to notice three things about this Firstly, we have slash update Secondly, we have the api key right here And thirdly, we have the field which is the on and off of the field And of course, it's communicating to the whole thing which is my laptop here and the port So with these three things Let's go on to the rails and this is something I think all of you are familiar with So what happens in rails with slash update? It goes to the routes rb and it is kind of defined as Channels model and then the method is post data. So when it gets this data It creates a new feed. So feed is also a model and of course it checks the api key And then field one it kind of creates one line of the feed So that's the meat of it all So let me go to the second example. That is the periodic part of it And this time it will be not triggered by a human being with switch But it will be triggered by proximity or in terms of every interval So let me go on to show you this little thing So here I have a very similar case. So this is the ultrasonic sensor that you see here And ultrasonic sensor basically means that When you have a line of sight obstacle, it can measure a distance And this is a little different previously. I powered it up with a power bank But this time I'm powering it up with a lipo battery So if you kind of sleep and wake it up every few hours, this can last for let's say a month or so So this is an example of a proximity sensor, but it will not be triggered by me this time So let's see an example. So I'm gonna go to the channels And let's see proximity Let's go to the public view and let's see what's going on here And let me turn it on. Let's see whether it works even if it doesn't work. Well, it doesn't work All right, but I will show you something Let's see once again whether it works or not No, all right. So I'm going to show you right here And this part I want to show you the data. So if you click here Now things speak will give you How it's you can able to kind of communicate with it So if you want to do a post request you can do a slash update here And this is where you they will actually generate the url for to write in the firmware and communicate with the rails And then this is the feed json that you can see here. So I think it might work. Let's see. Why is it minus? Ah, it is working. So you see here It's minus one Let's wait a bit and you see 17 19 All right, so a bit far away And there you see So if we come back to the graph right here Number one if you go to the public view there, you see the plots are being charted with this little guy All right, wait a bit probably have to be very very near But you see if I show you one of the queries that it's kind of working with Where is it right here? So this is an example of a post request that's being done with the field It's minus one. It's very very nearby So there you see it's giving minus one. So it kind of updated the chart Now in this example, let's look at the data here because the iot platform is all about data So what i'm going to do is i'm going to export it to csv file and As you can see minus one minus one and then 19 and then minus one right here So it's immediately available in your csv format and of course it's also available as json right here So let me go back and explain a little bit about the rail structure. So Thingspeak uses things like device and whenever gem and many of the gems that we are very very familiar with But i'm going to be talking about three models That are very very specific for iot platform one of them is something called the channel So channel is something like this is a sensor node So it might have one or more sensors. So all these are related to one channel The second thing is all about the feed. So whenever this Sensor or more sensors kind of transmit something it will record in the database as one feed item And lastly of course is the api key So let me go and also say that api key in the terms of thingspeak is basically a 16 digit alphanumeric number And finally is the feed controller and this is where the data the meat of the matter is the data Here thingspeak, which is i think is really good is Kind of exporting five different types of data html of course is for the view json is very important if you want to be using it and kind of hooking up with apis with other types of applications And of course there's csv if you want to download and do some spreadsheet manipulation and of course text So let me talk a little bit about application. So yesterday if you Remember got free stock. He spoke about smart can So it's the same thing here. So imagine what can happen if you put a proximity sensor Not in a garbage can in a room But let's say in the huge garbage can underneath the buildings And there are many of them and public utilities personnel comes and collects the garbage And wouldn't it be better if each of these is Has a little bit proximity sensor connected to a cellular communication And it just gives a ping when the distance becomes Smaller than a threshold and then it says that hey, you know the logic six people or the The public utilities people go and go to this area and these are the exact Containers garbage bags that needs to be emptied. So that's the application the practical application of this So I have based my example a lot on things speak now There are nine platforms I've played with and I think you can also play with it You do not need to install rails or anything. These are all hosted platforms and then nine of them And whether you say ibm microsoft aws Google they each have a iot platform of their own and out of these guess what two are made of rubion rails So you can imagine some of you in this audience in a few years will be part of an iot platform Building team working with electrical engineers on the other side and interfacing with the sensors While you all will be working to collect the data and make sense of it So inafruit io is one of them and they also are basing their platform out of rubion rails I also want to talk about standards that are being done because standards are so important because right now iot Is a very very new technology. There are so many messy things going around It's crucial that we also follow standards and follow the conversation. So there's web of things standards by w3c I love to subscribe to their mailing list and kind of look at what they are doing They will talk about api endpoints and restful url things that are we are very familiar with it and also some new terminology So go and subscribe to the mailing list So this is the last example i'll be giving and this time i'll be using a temperature sensor And instead of http i'll be using mqtt. So how many of you have used mqtt? So that's like the last Layer of the application stack of the internet protocol and if you use mqtt That's that's awesome. I see a few of you like about five hands in the audience So before I go on to the example, I want to explain why mqtt So like I said http mqtt or even ftp dns these lie on the top layer of the application layer And mqtt and co-app are becoming increasingly important for machine to machine low power communication And the exchange model is a little bit different for mqtt It is based on publish and subscription as compared to http which is a request and response And I think as web developers we are very familiar with this So what publish and subscription model does is that you can do a many to many propagation So you can imagine many sensors connecting to a single mqtt broker and that kind of publishes Are subscribes to other reels service Now here's the interesting thing why is mqtt and co-app especially suited for low power sensors two reasons Firstly look at the header size http has a huge header size as compared to mqtt or co-app And secondly http is also based on ASCII or text whereas mqtt and co-app is based on binary So that really really does a huge effect on your battery So remember I said if you're doing a prototype you're having it at home Sure, you can plug in the battery power and kind of plug it back But if you're trying to do something urban like you know waste management system You have to ensure that the battery probably lasts in the order of the years And that's where using protocols that are made for low power sensor systems machine to machine communication is so important So let's go on to the last example shall we? Here I will be using something different. It's not photon. It's based on esp 8266 And it is the first sub three dollar usd chip. There's a wi-fi chip. So I have a little Uh temperature sensor here. What do you think is the temperature right now when I'm going to on it? any numbers 19 24 22 Who is right who is right? Let's see So I'm going to go here and go to my channel and And let's see So once again, I'm doing it every three seconds, but in reality probably you want to be doing every three hours So let's see. I've oned it Oh, there you go. It's happening You know the stage is a little warmer. I think So there you go. It's it's good. So it's about 24. Who's at 24? Winston Thank you miss. I owe you a drink anyway. Thank you for what you did for the community All right, so that's 24 23 and and So, uh one thing about data is that you might want to have a huge dashboard in your office And that's where web sockets come in also very handy. So once again, it did matters what you do with the data So I want to talk a little bit about mqtt. So in terms of mqtt Like I said, it is a publish and subscription model. So I'm running a mosquitos server Uh, which is a mqtt broker in my laptop here. So once again, I have already Kind of flashed a firmware in my microcontroller here and the firmware So here you will also see how the mqtt protocol works API key slash field which is very similar And then of course, I'm going to my host which is my laptop right here And I'm basically doing a client publish And it's of course talking to my router here And then my rail side will basically subscribe to this mqtt Sensor value and what it does is it will also check exact 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. Oh, sweet house lights So, uh, I guess just make Look like you're hugging a camera. 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? And he told me that you're supposed to try to actually incorporate every single talk in the conference into your actual talk Which sounded like a herklane task So, uh, what I decided to do was to try to Encapsulate before my closing talk all the other talks of the conference. 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've done a bunch of stuff in ruby. 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. Um, but I just recognize that's me doing something dumb That the compiler is telling me I shouldn't be doing And in c I probably would be able to just compile this code And then I would find out later in production that runtime that I did something dumb, right? Any more questions? Okay, uh It seems like uh, there's no more. Thank you tyrants again um so we've Come to the end of our last keynote But this is not the last talk. We also have a winston our organizer who'd like to say a few words All right How's everyone? Good How's everyone Yay Okay, I hope by this time, uh, you have already figured out what you know, the singlish word means Uh on the bottom of your name tag. If not, you still have the after party to find out Please do find it out from any of the you know locals I hope you know, you leave the country knowing at least a singlish phrase And uh, one more thing, uh, sorry about the t-shirt t-shirts are the most difficult thing to get You know, uh, prepared and done for the conference I know all of you maybe, you know, have sizes that don't really fit yourself But trust me from personal experience. You will grow into it in four years time All right. Yeah, I used to be an m now. I'm an l and xl, you know, so don't worry. You will get there All right So, uh, this is like the sixth year. We're doing a red dot ruby com Um, I want to really thank, um, a lot of people for making this Happen again in 2016 Uh, these are the list of people firstly. I would like to thank my co-organizer Please give him a round of applause Where is he? I don't know where he's right on top. All right And I also like to thank the following people for helping me, uh, do the blind selection for CFP this year, Sam, Ming Ting, Ting Li, Jason, uh, Chunkid and Shinglung. Thank you so much for doing the CFP creation Um, the t-shirt design the program booklet, uh, all the posters that you see on the wall. These are done by Gion. Thank you so much for responding so readily to my request. Thank you so much for designing all this wonderful stuff Lawrence over here for taking pictures All right, he'll be posting it up on Flickr. Once it's done editing them And Michael for doing the live stream as well for a lot of people, you know who are not able to come to Singapore to join us for red dot ruby com and The following three persons who helped me in the first day for doing registration Which was a little bit of a nightmare. So sorry because of the t-shirt. I know So Ming Ting, Ting Li and that thank you so much for helping with the registration. Thank you And of course Natalie, our emcee for two days. Thank you so much Sayani for being in the chat group to help, you know, guide Natalie Yeah, thank you so much Um, a loisias is not here, but uh, he actually, you know ran around helping me find an after party venue He was like running all over the places and asking every part and bar. Hey, can you support like 200 people 300 people? So really thank you to him. He'll be there at the after party later. So you can thank him as well Wanitou for helping me do a lot of random stuff including the chat room So I hope you guys had a fun time, you know chatting in the chat room That was powered by rails 5 and action cable I hope did it did it crash No, all right Melissa my intern, uh, she really helped me a lot, you know, taking care of all of the stuff and of course finally My wife, uh, she really helped me do a lot of things She basically sourced for the entire goodie bag that you have in your hands You know, uh, trying to get these done from vendors in china and stuff like that And also finding speakers in a location and stuff like that. So, uh, yeah, I like to thank my wife, of course and she's not Uh, the conference cannot be possible without the support of our sponsors So I need to, you know, thank all these sponsors again, especially our goal sponsors github Thank you so much Thank you hired Thank you pusher. Thank you so much And of course, uh, piptoe piptoe lab. Thank you Not to forget. We also have our silver sponsors flow hero sam. Thank you so much Uh, grain grain.com.sg. Uh, thank you so much. So, yeah If you are in singapore and you have, you know needs to cater for a healthy lunch Please go on to their website and look through their awesome menu And they have started to do like catering as well. All right, so go over to their website paypal. Thank you so much paypal And finally pocket math as well Thank you so much pocket math and pocket math also stand a lot of their developers here as well I hope you have met some of them, you know, chatter with pocket math and find out, you know What exciting work they are doing and hopefully, you know, it will entice you To join them too. All right. Thank you silver sponsors. Thank you so much Uh, and of course, uh, we have our official co-working sponsor to thank The impact hub some of you actually went over to the impact hub To co-work this week and in fact, uh, my sent you an email saying that uh, if you're staying in singapore, you know For a while more and you like, uh, to go to some place to work Can you actually have a one week free co-working pass out at the hub? So check out the latest email that I sent. Um, so thank you the hub and of course our supporting sponsors Take a mule and digital ocean. Thank you sponsors. Thank you Uh, besides the sponsors, uh, the conference wouldn't be possible without speakers. Thank you so much Mets, thank you for coming again. Um, thank you, Aaron. Thank you Thank you, Terence. Thank you. We were free, uh, south shong for responding so readily to my last minute request Thank you so much. Uh, and of course all of my cfp speakers jason joy prada mesh Kerr, uh, tim samir Konstantin, vipul, sayani, yasuko Greg, jo, shibata Um, Ankeeta, Giovanni, Kenji, Jack, Yuki, Steven, and Sintien. Thank you so much to all of you. Thank you Yeah, I'd like to reserve, you know special thanks again to to meds I think I might have said my story, you know a few times in many different occasions, but Eight years ago when no 10 years ago when I started my career. I was in IBM You know installing and uninstalling databases every day and resetting The password to databases, you know every three months Uh, I really wanted to you know find a new job Go back to the programming startup world and I had a choice to do php python or ruby Except for php which I had some experience with I totally didn't know anything about python and ruby I picked ruby because uh, it seemed to be the you know raging popular programming Framework and programming language and of course rails, you know the framework Uh 10 years of eight years ago And so I just went with my gut feel and joined a company that did ruby and of course it changed my life forever, right? I I didn't know programming could be so fun could be so easy the first day I tried to do a string tokenize. I was like, whoa, this is so easy. Just do dot split, right? The first day I tried to iterate and erase like whoa dot each. Oh, come on. This reads like english to me I'm like, whoa, this programming language is so thoughtful It's like better ux all together, right? So but besides that, you know, besides it being a fun and productive efficient language I think through the community through the ecosystem I also learned a lot of best practices processes along with, you know, the framework rails right testing ci Etc these are things that we sort of like do as a primary nature right now when we are doing a lot of our ruby projects But when I'm doing consulting and I go into companies that don't really do ruby you'll find that oh Testing is like a you know foreign subject to them all together like maybe do they do even do it at all so we sort of like have taken all of these things for granted but Being you know doing ruby and being in this ecosystem and community not only allow me to you know, enjoy coding as a career It also allowed me to level out as a Programmer so I would really like to thank max, you know for creating ruby and you know helping me Have all of these opportunities to be a better programmer. Thank you max. Thank you so So obviously I of course hope to see ruby progress forward, you know, so that I can continue to do my work in ruby as well right um, and I'm not sure if You guys have already discovered the easter egg In your t-shirt. So for those who have received the black t-shirt, actually I printed, you know, one of my favorite quote By max in the label, right? And this is the quote ruby is designed to make programmers happy So it's actually inside the label of your black t-shirt. So ask your friend to take a look for you Yeah, you see Is it there? Yeah, so I actually printed it inside because I really feel that you know Like this is the philosophy that I subscribe to and this is why I've been doing ruby all this year despite all these other new languages and You know and why I've been, you know Coming to take care of the ruby sg and running this great dot ruby conf all together So I hope you know, you'll enjoy the small easter egg embedded in the t-shirt Last but not least, uh, thank you so much for coming to red dot ruby conf Just to show off hands How many of you this is your first time here? Oh, wow, that's a lot second time third time fourth time fifth time sixth time Whoa Thank you so much It is my sixth time as well Okay, yeah, so thank you so much for for coming all the way here And you know listening to all these great talks for for these two days. Give yourself a round of applause. Thank you so much So two zero one seven Originally, I had this like They had a strike true Because I've been running this for four years already red dot ruby conf has been running for uh, six years altogether I was thinking that you know, I might need a break And maybe to sort of like refresh and reboot for a year Before, you know, we think of new ideas and get everyone excited again But I've some of the local community, you know have been Nagging at me like hey, this cannot die. Hey, this cannot be true, right? So they asked me to change the slides to Two zero one seven question mark And maybe just cancel out my name. So, uh, I do hope that it would continue to happen The local community if you really feel up to it and you like to step up Please do by stepping up. It really means you take on more responsibility, right? So please think about it. Do not indulge in the euphoria of the Celebration right now, right? Go home sleep on it. Think about whether you really want to take over this before you come talk to me I don't want you to regret it for, you know, the next one but In any case, uh, I really hope all of you guys had a great time. Uh, this two days this year And I hope you'll have a great after party later. Thank you so much once again. Thank you That's actually a photo of my third cat Okay, uh, so thank you Winston. Uh, we've come to the end of Where Dr. Ruby conference I would like He's not here, but I want to thank him for letting me be his MC and in fact RDRC with more cats Okay, so with this, uh, yeah, we've come to the end Uh, thank you all so much for putting up with me Uh, I've received information that we have some leftover t-shirts and it's for sale But all of them are really large like sizes. So if you have a thing for large shirts, please approach the registration counter They'll be on sale for $15 a piece Uh Now for some reminders, uh, the after party begins at seven The ticket is in your goodie bag and it's the program sheet It's at Tanjong Pagar Road Uh, if you cannot remember the address it's actually on red dot ruby com dot com And it's at the end of today's program So, uh, hopefully you've made some local friends in these two days If you haven't then, uh, please come and talk to me and I'll be your friend So the nearest MRT is at Tanjong Pagar. It should be about 20 minutes from here So, uh, lastly before you leave, please do not forget all your belongings your headphone your charger your laptop Uh, your cap Yeah, and your shirts, you know if you did then please, uh Ping us at red dot ruby com on twitter If you don't have twitter then Find someone who has twitter. Uh, lastly, organized, um, the organizers and speakers, uh, can have a photo over here in front If you want to but yeah, and that's the end. See you all at the after party