 It works, right? Yeah, that's great. Because if one thing makes me nervous in talks, then that's the technical stuff, not the other stuff, like the social stuff. This is the last talk for today, and I hope you guys enjoyed the wonderful presentations we had today, because I did. I also enjoyed something amazing last night. It's a thing in Singapore. I don't know if you know Durian, or Dorian, or whatever it's pronounced. So I got this email from the organizers telling me, hey Nick, please join us for dinner tonight, which is amazing and really nice. We're going to have Durian. So I automatically assumed that Durian is something like a dinner, for example. So we went to this place and had dinner, and they warned us, hey, don't drink beer with Durian. We're going to have Durian. So I thought, okay, it's like dim sum or something. I'm retarded, sorry. So I thought we're going to have the dinner, and it's called Durian. So I did not drink beer for the dinner, and I was talking to Anton, like, man, let's have a sneaky beer after the dinner, because we're done with the Durian. So we kind of had one beer, and the guys told us, man, Durian is coming up now. Like, why do you drink beer? I felt really retarded. So we went to this place, and yeah, I mean, it smells interesting. It's a dangerous word in the culinary lingo. So we, of course, I respect local traditions. I tried it. It's kind of like soft and a bit of less like threats. It's a bit like a mango that tastes like, has anyone, haven't had Durian before? Well, there's many of them. Maybe I shouldn't spoil the feeling. Okay, I'm not going to, I'm not. So basically, that was my response. So I had this Durian, and I suddenly felt like something was going on in my stomach. It was because of the one beer I had, and I could feel like, oh, God, I have to do something. I jumped into my Ferrari, I drove off to my helicopter launch pad, flew to the best hospital in Singapore, to my doctor team, brought me to the emergency room, like, oh my God. And then they put some surgery tools on my belly and started to dig in, and then it's like, this is how I'm going to do it. Oh my God, the U.S. stomach is totally fine. And so before I asked, so I was trying to find out what's the problem with beer and Durian? Is it a myth or not? I got three different answers from three different people from Singapore. You get really hot, I don't know, you get really sick or drunk, and your stomach is going to explode. I don't know about this, but today I was really tired and hungover, and I blame the Durian. So... Hey, stop laughing, stop laughing. This is the moment where the sound system should play a funeral march. Duh, duh, duh. Because I have terrible news. Ruby is dead. Exactly. In case you didn't know, it is dead. It makes me sad, it should make you guys sad. It should actually make you question why are there videos on YouTube discussing why Ruby is dead. Ruby is also so dead that it is the last, I don't know, position, on the last position on, I don't know, like, languages ranked by programmer jobs. The first language is SQL, which is a famous programming language. So that's how dead Ruby is. It's also funny that Ruby is, for some strange reason, on the very top of Programmer Happiness Index. So it's totally dead. I actually, I mean, I believe that because I went on the Internet and I tried to find out why is Ruby dead. And I landed on Reddit the source of truth. And it linked me to some amazing blog post on the so-called phpblock.org with the title Don't Believe in Ruby. Why I don't believe in Ruby, and you shouldn't either. It's a really interesting post. You should read it, so you get enlightened that we are on the wrong side of the tracks. And I had, so there's like interesting, cause like, Ruby is no longer cool these days. It's JavaScript. In case you didn't know that. Or what's better is Ruby was a hipster coder community of 20-something year old nerds who are now 30-something nerds. Sorry. So it's, I was devastated reading phpblock.org. I actually subscribed it on my RSS feed and I'm gonna follow it totally. Because, I mean, Ruby is definitely slower than php, and that's actually true, but it's absolutely compelling reason why Ruby is that. Ruby apparently sucks at concurrency. My experience with concurrency was okay. Some people have complained about it. There is definitely languages with better concurrency. But Ruby is also object-oriented programming, which is also terrible. Like you have to write everything in a functional language, Haskell. Otherwise, the language is dead. Of course, Ruby is also messy. You don't create messy code in Elixir or in OCaml. It's only Ruby that is messy. And also Ruby is the reason why Rails exists. Okay, so now that we know that, have a look at this black slide and just cry for a little bit because we came together here for a bad language. Not the best feeling for me. Let me tell you some interesting story about my current job. So, because I don't really like the php versus Ruby thing. I mean, I find it kind of amusing. I'm sorry. But at my current job, we actually had to face that reality that people still think about, how are we going to use Ruby or php? Because I work for the police at the moment. Not that police, and also not that police. More like that police. So, I do consulting for Ruby software. Let's put it in a very generic way. And so, they have a big project coming up, and they are wondering, should we use php or should we use Ruby again? Because we have lots of successful applications in Ruby, but Ruby is dead. Reddit says so. So, let's have a consultant find out for three weeks if it's good or not to use Ruby. So, I had lots of meetings with this consultant that was paid three, this is actually on video, because I might lose my job. So, I was having lots of meetings with this consultant, and he's great. So, he actually introduced me to Gartner Hype Cycle. You all know the Gartner Hype Cycle. It is like the flow of, I don't know, what's it called, like the expectations for programming or for technology in general. So, like, first you have this peak of excitement, everyone's like, yeah, let's use Ruby, it's awesome. Then, after some years, they find out, oh, my code is so messy and object-oriented and slow when it sucks at concurrency. So, it's totally like it sucks. And then, people start to, like, come up with new technologies and new gems or whatever, like new libraries, and kind of, oh, here we go, this is actually the way we should have done. And then, you're on the plateau of productivity. And this is absolutely how every programming language can be categorized. So, the consultant also added some new flow from here and he called it like the, I don't know, like the abyss or something like that because, and he was wondering if Ruby is at this trove of disillusionment and on the way to go even down further. After 25 years of being successfully installed in the software industry. So, yeah, we kind of figured out, okay, we are talking about two equally strong powers. Ruby is huge, PHP is also huge. So, this is not a good thing, like we have to find something else, how to find a metric, is Ruby gonna be the language for the new project or not? And so, he explained me, actually, he's a really nice guy, I'm just taking the shit out of him a little bit. So, he was telling me, okay, so proper engineering usually means, should mean the code has to be maintainable, comprehensible, so other people have to understand it and actually already forgot the third point he had. So, and we kept talking about this generic stuff, so I don't know, we talked about generic stuff at some point, I realized, hey man, actually, this is just an example for architecture, it's not that important. So, actually, what we talk about is, it doesn't matter if something is huge or not huge in the economy, or if something is in the trove of disillusionment or not, what we talk about is, is my software maintainable, does it have a good architecture? So, it boils down to fine grained architecture, how do I model a software to make it something that you wanna work with in 10 years? Because that, for me, is good software. And I think both PHP and Ruby can provide a nice architecture, but we had like two or three hours of fighting about this architectural point until he said, okay, maybe you're right, maybe it's not the language itself, because I mean, there's so many frameworks in PHP and they are excellent, I'm not kidding, that provide you huge abstractions and lots of different layers that you can use for implementing complex applications, doesn't have to be web. There's the same for Ruby, like Rails and Hanami and Grape and Rota, and I don't know, I could add like 500 more, and so that is not the problem, we have the technology. What I realized after some hours of meeting was that if you visualize the PHP stack at the police, I'm not gonna say which police, I'm actually not tell by my accent which country. So if you visualize the PHP stack, like all the different applications we have, it's a really, really colorful thing, like they use a thousand different frameworks, they use different abstraction layers in every application, they don't have any abstraction layers, they're building their own MVC, they use Laravel, so it's like a super heterogeneous, I don't know how to pronounce it. How do I say it? So we get this image of the PHP world at this job, so there's like thousands of projects and they all look completely different, and then when it comes to Ruby, at least even though it's slower and sucks at concurrency and all that, even if it looks more boring to you, but more boring in this context means it's better because we have the same stack in every application, it's Rails, it's not everyone's favorite stack, we use TrailBaser as an additional abstraction, which is not everyone's favorite abstraction layer, and we have the same concepts, the same abstractions in every product, so you go to those application A and you will find out, okay, I don't understand it, you go to application B, okay, I don't understand it, or you go to application A and you understand it and that means you will understand all the other applications. So it's like a homogeneous, he called it a homogeneous system, and that is much more valuable for software development than some crazy fast language that you can't maintain, and we figured out that just something is in PHP doesn't mean that the other project also in PHP is the same and the same with Ruby, some project in Ruby can be completely different to a Rails stack is completely different to a Sinatra application, something like that. So we boiled it down, like maybe the language is not the actual problem, what we talk about is the architecture, the tools we have, the abstractions to write applications, and the problem in both PHP and Ruby is that the tools we have are a little bit primitive in some cases, for many languages, it's the same problem. So sometimes you have a tool, but you actually want something way more efficient and you know this massive power tool exists, but it's not available in the language, so you have to build it yourself, this is not a problem. But this comes out and finally concluded that he doesn't want my toys, he wants to build his own toys, so he decided that he's going to build the entire stack we had in Ruby in PHP. Yeah, that was one of my successful consulting gigs last month. Now I would say, I don't know, I just talk myself up a little bit, so I'm warm now. I would like to ask you, is it, would you guys like to hear some more ranting about programming languages or Ruby or Rails, or would you rather, I don't know, have me be super smooth into the next topic? I would say, let's raise your hand if you want me to rant. Raise your hand if you don't want me to rant. Yeah, so that's like, it's really close, but I'm sorry the ranting part, the more aggressive part of the audience won. I used a Trump's electoral vote system to count the votes, so it's absolutely fine. Okay, so how else would you start a rant if it's not a tweet from the HH? So actually, to make this transition from, I mean, I figured out in this talk with this consultant that the problem in software development is not the actual language, it's not, is it awesome at concurrency or is it kind of okay, or do we have 500 database adapters or just one? The problem is more like, what granularity of architecture do we have in this language and what kind of granularity does this language allow me to introduce, okay? So I don't know, I actually don't know why I put this into the talk, because I read this tweet, it's lovely when Active Support can serve an experimental lab for future core features in Ruby 2.5. So actually, it's about the array prepend method in Ruby 2.5. And I don't know, like, I read this tweet and it's kind of, I kind of see this tweet as the Ruby communities problem in a nutshell. I don't have a problem that anyone is happy that some of their features get into Ruby core, even if it's Active Support. It's totally fine if you, like, I don't know, tell people about their efforts and everything and that's, I mean, my respect for their code, but it's, I mean, this is, like, another method on top of 328 methods of array that does the exact same thing as shift or unshift and here it comes. This method name is actually understandable. It says what it does. I never remember unshift, shift, what, what, pop, whatever, but the problem is in Ruby, this is actually not really our problem. Like, we, I mean, so, I don't know, I wrote this response like, who needs strict typing, pattern matching, modding concurrency, method overloading, better keyword arguments, macros, real namespaces and packages, functions, not closures and end-to-monkey patching, insanity, removal of auto-loading once and for all, world peace and a new fair world order. When you can have array prepent. And I didn't tweet it because it's stupid. And also I forgot immutable data structures. So it's like, I don't know, it's kind of, like, the problem is not that we don't have array prepent in Ruby. The problem is how can we extend the language and make it easier to have a good architecture. I'm going to show some examples later. So the other reason I didn't tweet it is because Twitter only allows 124 characters. I learned some important thing from that tweet that never happened. Just take an hour break and then tweet and then you're probably not going to tweet because it would have ended in some stupid discussion. Anyway, yeah, this is how Twitter works. Reddit is way better if you want to have intellectual discussions. So my problem is that we have enough syntactical sugar in Ruby. It's amazingly simple to write good stuff. What I would like in Ruby in the future is more abstractions on an application level. And I'm going to show some examples of what I mean. And I'm going to keep saying this. I don't want toys, I want tools. This sounds like really arrogant when I say toys. I mean syntactical sugar when I mean tools. I mean higher level abstractions in the language itself. And I'm going to show you some of those abstractions right now. In my favorite programming language called PHP. Hey, we all started with PHP. Come on. And actually PHP, I mean, it is well known in the Ruby community for being like a horribly complex, complicated language and you add like, you can add code into like templates and HTML and like we always laugh about if you're like, come on, he's like a PHP developer. Actually PHP has improved a lot in the last couple of years. I'm not trying to tell you switch to PHP. I mean if you do, you can work for the police. But do you know what the coolest thing about PHP is? The website is php.net. I knew this is not going to work. Okay, so PHP, there's some pretty interesting stuff happening since 5.3 or something. I actually learned, I think Mats said it, that PHP 6 got canceled. I had no idea. Thank you. So what they did, they copied a lot of Ruby stuff in PHP which is pretty cool for Ruby. So for example they have modules, they call it traits. And you can basically define a trait like a module in Ruby and then you add functions and then you can, what is it, use that trait in a class and it automatically imports those methods in the class. I don't know if it works, traits in traits, I think it also works. So they basically added modules from Ruby to PHP which is cool because modules are kind of helpful if you use them in the right way and with discipline. They also have lambda, so you can pass dynamic code to a method and the method will yield that lambda. I had no idea this is happening in PHP and I'm actually impressed. They also have anonymous classes. It's not that much of a ripper as the Australians say. But if you do DSLs and if you do metaprogramming you need anonymous classes and anonymous objects and they kind of integrated that into PHP 5 something. And what I really love and I would love that in Ruby is they have interfaces so you can define an interface say this has method whatever and method whatever else and this is my signature and this is my other signature and then you can say and then you kind of apply this interface to a class and the class has to implement that interface or it breaks and you can also use that interface for something else which is pretty impressive and I had no idea PHP 7 has typing. So you can actually say my function wants an integer and I don't know, okay this is the simple example my function wants two integers and if you give the wrong parameters it will say uncalled type. Actually can you guys hear me? That's great. So you get an arrow that is actually meaningful. Laura would be really happy to see that because you now know okay this is actually a wrong type and not something on nil. You can also do stuff like hey my method should receive an object with that response to a specific interface and this is amazing. I mean I'm just thinking of it from a gem author perspective like if we could say you can only give me objects that do this and this and this that will be amazing because I will just assume in Ruby this object responds to this and this and this and I call this and it breaks and no one knows what is happening. And you can also say what type is going to be returned from a function so that is actually, I don't know, it's pretty impressive so I can say, sorry, I can say this function returns an array for example. I got really excited reading all about those PHP features. PHP, haha, haha, actually it's not that funny anymore because it's like becoming a proper language and it has features I miss in Ruby in all fairness. But one reason not to use PHP is that I also introduced go to. And I don't know about that but I think we don't have go to in Ruby right because someone told me oh we also have that in Ruby I've never seen it. But they introduced that in a recent PHP version and that is, I'm sorry but go to is like basically saying I have no idea what I'm doing please go somewhere else. And so I was reconsidering my PHP plans after learning about the go to. So you see PHP is not that haha, PHP ridiculous as you might have thought it is. If you have questions about PHP 7 you can ask Zeezak, he just bought a book. What does it say in Japanese? I can't read it. Aaron, you speak Japanese right? Okay, the book title is no. No JS. Let's have a quick look at Java. It's also one of my favorite programming languages because it's really, really popular, everyone loves it. Java is well known for like you are tied to some huge IDE that makes you do stuff the way you don't want it. And it makes you configure things and you have to do like lots of XML and blah, blah, blah configure. That's like the thing Java developers usually whinge about all of them. Then you have massive architectures with like a thousand classes that I don't even like because it's too many objects. So the XML configuration part is massive so there's not that much convention over configuration and it actually makes people write books like Java ruined my life which is literally depressing. Java has obviously typing. So I can also say my method is going to receive this type and it's going to return objects from that type which is a really helpful feature. I'm going to discuss that in a second. In Ruby context, it also has interfaces of course. I mean I know all that from university like 500 years ago because Java is quite old. So you can have interfaces. You can say this class needs to implement the following functions and Java knows okay this class actually does provide those functions. You have method overloading which is pretty cool so you can have two different versions of the same method name like two user with different argument chains and Java will automatically pick at runtime what version you want it which is pretty cool for like gems or something if we had that in Ruby looking at muds because you can deprecate methods for example really easily just by overloading it. I'm dreaming of this. I'm going to dream for a little bit more I guess. They also have something like dependency injection built in. I have no idea how it works but basically you kind of say this method is supposed to be ready for dependency injection and then Java can inject arbitrary objects at runtime. I have no idea how it works and it doesn't matter. But you see there's lots of features in languages we kind of laugh about like half PHP so funny like people writing HTML and weird code with dollar signs and Java is really funny because people have like XML files and all this but they actually have really cool tools to write proper stable software and you can see that that's Ruby. In Ruby, I mean don't get me wrong but in the last couple of releases we had like Ruby warns you the fix number is deprecated this is shadowing in the auto local variable and this variable is unassigned but not used this kind of like innovation happening so actually it's really annoying for me because it stops giving me all the warnings. We got keyword arguments which are awesome I love them so much and I use them everywhere so you can basically have named arguments and then Ruby will take care of that so you call this method with named arguments and Ruby will kind of handle those and assign it to local variables it's a great thing and we also have refinements which are pretty awesome there was a talk two years ago here in Singapore the worst feature you ever loved by Paolo Perotta the guy who wrote Ruby metaprogramming Ruby that title says it all so refinements is a feature I have no idea why it exists and why it was merged into Ruby so the idea is I have some class with the method and then I write at the refinement and I overwrite that method and then I can inject that into the runtime environment somehow and then C.Fu will suddenly behave following the refinement and not the original version but it only works like if you look at the documentation it's like you may only activate refinements at top level not inside any class, module or method scope so it's kind of I don't know how that is helpful at all and they are active until the end of file or eval string so it's kind of like only valid in the lexical content of the file so I saw that talk by Paolo Perotta and we all were more confused than we were before like refinement is a feature I don't understand why is this like I mean it's great that people work on solutions but shouldn't we, I don't know like so the problem with refinements is we are trying to overwrite so basically you call a method call a method call a method that's kind of what a refinement does it overwrites and injects code at a specific point and maybe the nesting idea in Ruby is wrong maybe if you want to execute something pass the result to the next one pass the result to the next one pass the result to the next one maybe a pipeline is way more what we need in that context and you could inject logic like a refinement in this case at any point of the pipeline and it's completely obvious what's happening so I would love to see more efforts in the Ruby community to work on I don't know like distinguishing do we need that feature yes we want some way to inject logic how can we achieve that just because we have this module inclusion thing happening doesn't mean that it is like the shit and you have to use it all the time because I actually get confused by my own modules in my gems as well so I often switch to something like a pipeline you know like the pipe operator in elix is a good example so they picked up there's a problem we want to inject code let's change our abstraction and I would love to see that in Ruby the concept of calling super super super super is super is super confusing another example is the safe navigator also known as the Keanu Reece operator you can't see it, it doesn't matter so the safe navigator is basically replacing long lines of code like this like user profile and if the profile is there and if the thumbnails are there and if the large is there then return me that result so in Rails which was actually a cool idea they introduced TRY I'm not a big fan of TRY but the abstraction is cool because it allows me to do the same without having the end end end end end and then Ruby picked that up and abstracted that into a new operator which is also an abstraction so now the same line is like this I'll leave it up to you if you use it or not I think it's not the worst idea I'm not sure if I support those kind of calls in general and if we should have more decorators or something built into Ruby actually typing in Ruby is basically this so in Ruby I don't know how many undefined methods for nil class I had in my whole life I think 500,000 are not enough so I would love to see typing in Ruby because it would help us to write way more stable software without having to do anything and that's my whole point about the granularity I'm talking about I want features or tools that help me to write code without having to create all those abstractions myself that would be great and I spoke to Mats many times and he has some great ideas and I'm actually still very positive about Ruby I think we're on a good way and what's crazy and great about Ruby is that we can create all those abstractions ourselves so for example we had this beautiful talk by Tim Reilly this morning about DryRB DryRB is a fantastic project bringing you functional style dialect into your Ruby applications it has a bunch of great gems like dry validation is super popular then we have dry matcher, dry view I always use dry container it's fantastic for dependency management so they have lots of little libraries that you can use without using the entire stack and they also have a fantastic website which is pretty uncommon for an open source project and so for example the APIs they create are super like it is so intuitive because it's simple, yeah? like the dry validation gem gives you a form and in the form you can write a validation and then you apply that validation to a hash by using the call method and the validation will say everything is fine or it will say there was an error and the error was the following so it's kind of an abstraction of a validation we have validations everywhere and dry validation makes it super accessible and you don't even have to think about that so dry validation, the dry stack in general is a great tool set for me and I love it I love to use it it is heavily pushed in the reform and the dry validation and it also is popular without reform which is surprising I'm just kidding and you can see it in the downloads they have like 300,000 downloads in like one week or something which is basically saying that people like this and they have an amazing website which is pretty uncommon for an open source project you should check out the stuff because the tool set they provide is very flexible and it does not interfere with your existing stuff the next thing I would like to show you with abstractions is Hanami Hanami is on the home page the modern web framework for Ruby a few months ago it said the complete web framework for Ruby, I don't know where they changed the mission I have an idea and I'm going to talk about it in a minute so Hanami is also like a really interesting replacement basically for something like Rails so it gives you MVC but in a very very extended way the survey of routing and all that they also have a beautiful website which is pretty uncommon for an open source project the website is full of great documentation so basically Hanami works like Rails it does not work like Rails, absolutely not but it gives you like a generator you can say Hanami, new, bookshelf and it will create you like the entire directory structure rake tasks, everything you want then you basically have routing it's completely different to Rails routing but it's beautiful, it uses rack and all that kind of stuff instead of controllers you have actions and those actions are specific to one controller action so it's basically like the dev create in a controller in Rails is an entire class in Hanami and in that class you kind of run your business code if you want that if you like that, so Hanami gives you a complete new set of abstractions and tools for web applications, again I don't have to think about routing, I don't have to think about rendering so what Hanami basically does is it gives you this router it gives you the action abstraction it uses dry validation, gives you some more code for models and repositories I think you should look at the beautiful website that's really uncommon for open-source projects and it also has stuff like generators assets, mailers so it gives you what we call infrastructure to write applications it also comes with a view layer Aaron, you don't have to duck it's okay and so they also have a view layer they basically give you the full stack to write software actually not because it's still really undefined how to write business code in Hanami, so they give you this infrastructure they have great abstractions for the validation and everything, but when it comes to how do I actually write the code that is gonna be executed, like I don't know processing an order or adding an item to a shopping cart or this kind of stuff it's kind of unclear and this is where my favorite framework comes into play so this is exactly what basically the trailblazer framework which is the third of the three projects I'm gonna demonstrate does trailblazer does not bring you routing, trailblazer does not bring you mailers or generators or I don't know persistence, trailblazer is only focusing on how do I write the business code, so that's a big thing people misunderstand, they're like okay there's dry, there's Hanami and there's trailblazer and they're like competing, it's absolutely not like that so we all kind of integrate into each other, trailblazer takes over the business code for for example for Hanami, so if you this is a beautiful diagram in Hanami and it does totally not fit on the screen because my CSS skills suck or is it my laptop I have no idea and the same is with Rails, so trailblazer also works with Rails, so instead of, I mean Rails and Hanami are not identical at all I'm not gonna say which one's better of course, but but trailblazer doesn't care if it's used in Rails or in Hanami or Sinatra, Rota you name it, so trailblazer takes over specific layers of your application without interfering with the rest of the framework it's by the way it's called an advanced business logic framework, just saying it also has a beautiful homepage which is really uncommon for open source projects so you can see there's like a battle going on who's got the nicest homepage which is amazing because competition is good for the economy and so on and so on so what trailblazer does is it brings a lot of new abstractions but it also brings some kind of extended directory structure so instead of pushing things into app controller, app model, app view you push things into app concept and then you order by concept and then by technology you're going to show you an example in a second so it's a new file structure it brings a lot of new abstractions like validations and policies and it kind of lets you play with active record or with SQL or whatever so I'm not going to go into the details the interesting part in trailblazer is and that is what Betsy was talking about in her talk earlier today that we kind of have the same philosophy of why would I mix a lot of business code into the controller which is really hard to test again thank you for the talk because it excites me when people, when we all use like advanced features like encapsulation so in trailblazer you would have this service object Betsy was talking about, it would be called an operation for example block post create and the controller simply calls that operation passes in all the dependencies like parameters and does not know anything what's going on in that operation and the operation has no idea what's going on outside, the cool thing about that is and again this is what Betsy was showing that this semantic, this interface can also be used for testing so you do the exact same thing in a test without having to think how do I test this piece of business code you just run the operation, you call it in this case and you test the result object so it's a really simple API and it's unbreakable because it's what we call encapsulation so this is a thing that all the new quotes, new gems like Hanami Dry and trailblazer use this kind of semantic where you call objects and they don't have any other public method so it's basically a functional object that was explained by Tim Reilly today I can only call, there's no way I can run any other method on this thing, whatever that is and if you wonder what it does, just read it, block post create so what is it going to do, it's going to create a block post obviously and so trailblazer jumps into the gap where we don't know how to model business logic it actually takes over a little bit more than that so it wraps or orchestrates validations, models repositories if you want policies de-serialize if you want that it also has flow control I tried to make it look really ridiculous because I suck at design as well so trailblazer gives you a lot of abstractions and that are optimized for the business code I should have done this beautiful stack diagram to show you a beautiful diagram because I learned from my meeting with my consultant at the police that good looking diagrams make people amazed bad looking diagrams, like that one suck just a really quick example how that block post creation would look in trailblazer so you would probably add a concept called block post and a folder operation with create.rb file and this file contains an operation and to write that block post we have the following things to do, we create a block post model, we assign a uuid so we have to generate a uuid we have to save that model to the database and we have to update the total counter, this is just an example what to do this could be any kind of business code so in the diagram this would be a straight graph pointing from left to right model blah blah blah update counter and what if something happens what if we have a double uuid we should catch that error in a diagram this would look like this when I save the database it will say there was a uuid error we can catch and treat that uuid error in this kind of box, whatever that box is and let's say we also had a counter error, maybe the counter is only till 128 because it's unsigned int, I had that problem in an old project a few years ago in PHP by the way so in a diagram this would be the counter error can only happen after we update the counter so in a diagram we would have either this was successful or this was not successful handle this counter error so trailblazer makes it really simple to have those kind of diagrams in code without you having to do anything yeah and relax it is a diagram it's not a bad thing okay so to have this simple linear workflow for example in an operation you would simply have this operation class user or sorry that should be blog post not user my talk suck and you add the steps that you want to have executed in the order you want to have executed you can call operation you get the result object you can ask the result object everything okay success or failure so don't worry if you don't understand all the details because it is just an overview and yeah so if success tells me false then something went wrong so in order to have failures or error handling in this diagram I just use the failure method and add the steps in the order I want for error handling and this will basically result in a flow control diagram like that so it's super easy in trailblazer to have complex workflows in ruby because I mean this is kind of readable and you can render that and it will show you the diagram we just saw and it's kind of easy to understand so the idea of trailblazer is you have steps and steps can be methods or lambdas or callable objects and they just sit in the operation or they just sit anywhere you want and they basically write to the options object which is the only mutable object in trailblazer so you write stuff like the UUID to the options object and then you can read that state from the result object so I call the operation on the outside and I can say hey result what kind of UUID did you create and it's like hello whatever so this is how you access state from the outside from the caller perspective and to directing the flow error handling all we do is basically if a step returns false it goes to the error handling track if it returns true it stays on the top track the one in the diagram we just saw so this is all just an idea for you guys so you understand where this is going so it's really simple to kind of have a work trailblazer control your flow while you only focus on the implementation so this diagram is like six lines of code including not including the implementations for the actual steps that's only the basics so the idea is have encapsulated objects that you can't break you can just call them and they will do something and they will give you a result and if or not they use this flow control is your problem you can test them in a really nice way without having to know anything about the internals because you use the exact same API that means it's also going to do the exact same thing it does in production which is amazing because you don't have to hope that your tests and your production match you can also use operations as factories because you also don't like factory go and it's basically giving you an API an internal API for your application for free and many people ask hey wait a minute this is way too many objects and isn't that too enterprise and when I think of enterprise I don't think of the Starship enterprise I think of like diagrams and everything it's pretty cool and so enterprise is software that is used to satisfy the needs of an organization rather than an individual user so apparently we are all writing enterprise software as Ruby developers enterprise reminds me of Oracle and like certificate and huge diagrams that make no sense because you use like a shit ton of factory to create something and it's like yeah okay it's not like enterprise is kind of ridiculous but actually enterprise we need enterprise patterns to write stable software because by all respect but three layers and rails is not enough to write like complex software and I mean we end up usually with like huge models that kind of contain everything from workflows to business code to persistence code to validation code it's kind of I don't want to say messy because it's negative and this is the last talk I want to give you a positive feeling so but it's not ideal if you want to build something sustainable for multiple users also known as enterprise software and so the idea of this flows with diagrams is nothing new so we didn't invent that there's something called BPMN business model process notation also people usually laugh BPMN is basically boxes and arrows and it has like activities and a thousand of like I don't know like terminology words in the glossary it's really ridiculous actually it's I don't know BPMN is a diagram language to specify business processes so that the idiots pardon gentlemen in suit and tie understand them and coders can code them it's actually pretty cool and it shouldn't be neglected in Ruby I enterprise is not a bad word like writing stable software is actually pretty cool and of course I wouldn't tell you all this if I would if it wasn't for trailblazer that now comes in 2.1 with BPMN support so you can have like operations and wire them together and wire operation in operation and so on and so on and so on and but the so the idea is that I'm trying to communicate we have Ruby as a language it gives us a lot of tools but they are all kind of low level so at the moment we have to create those abstractions ourselves this is great I'm happy with it I mean I'm doing Ruby for like 12 years so apparently I am happy I could have switched to PHP last week but I didn't and so but I would love to see Ruby go somewhere where we have those abstractions built in like native decorators for example in Ruby or native error objects and this kind of stuff so I would love to see more work on that kind of on that level of building applications I also interrogated much a lot of hours at the rubicon Philippines about M-Ruby I'm really excited about M-Ruby it looks like it's going to be kind of a fresh version of Ruby that has ditched or not implemented some of the features that were not really beneficial for Ruby like auto-loading for example so our favorite topic I'm actually really excited to go home and try M-Ruby because it looks like there's a lot of fresh and clean code that is ready for additional abstractions in the future because we all want to write beautiful code and if you have questions I actually did overtime on purpose because I don't want to answer questions the worst is like you don't have questions I'm standing here like so I would say let's tweet twitter is like Instagram but you don't need a smartphone to use it or we can just hang out tonight or tomorrow thank you very much you are a great audience