00:00:04.760
it works right yeah that's great because if if one thing makes me nervous
00:00:10.590
in talks then that the technical stuff not the other stuff like the social stuff this is the last talk for today
00:00:19.140
and I hope you guys enjoyed the wonderful presentations we had today
00:00:27.350
because I did I also enjoyed something amazing last night it's the thing in
00:00:36.239
Singapore um I don't know if you I don't know if you know them Julian Dorian or whatever it's
00:00:42.960
pronounced so I get this email from the from the organizers tell me like hey
00:00:47.970
Nick you please join us for dinner tonight which is amazing and really nice we're going to have do Rihanna so I am
00:00:53.760
automatically assumed that durian is like something like a dinner for example
00:01:00.260
so we had we went to this place and had dinner and they warned as I hate don't drink beer with durian okay we're going
00:01:07.200
to have durian so I thought I'd hit it it's like dim sum or something like I'm sorry so I thought I thought we
00:01:13.499
gotta have the dinner and it's called durian so I did not drink beer for the beaten for the dinner and I was talking
00:01:19.469
to Antone like man that's had a sneaky beer after the dinner so because we're done with the durian and then so we we
00:01:27.779
kind of had one beer M and the gas awesome and not durian is coming up now
00:01:34.289
like why do you drink beer IKONOS not like I felt really we went to this place and yeah I mean it smells
00:01:42.209
interesting it's dangerous word in their culinary lingo so we of come in of course I
00:01:51.479
respect local traditions I tried it and it's kind of like soft and a bit of like
00:01:58.439
like threats it's a bit like a mango that tastes like has anyone haven't had
00:02:03.749
a durian before well there's many of them maybe I shouldn't spoil the feeling
00:02:09.479
okay I'm not gonna I'm not so basically yeah that was my response so I had this
00:02:17.900
durian and I suddenly felt like RIT like something was going on in my stomach it
00:02:24.110
was because of the one beer I had and I could feel like oh god I had to like do something I jumped into my Ferrari I
00:02:30.560
drove off to my helicopter launch pad and flew to the best hospital in Singapore to the doctor team brought me
00:02:38.870
to the emergency room I gather and then second they put some surgery tools on my belly and started like you to dig in and
00:02:45.950
I was like this is harder mister oh my god your stomach is totally fine and so
00:02:54.370
before I before I asked before so I was trying to find out what's the problem
00:02:59.599
with with a beer at durian is it a miss or not I got three different answers from three different people from
00:03:06.019
Singapore you get really hot you're I don't know you get really sick drunk and your
00:03:12.079
stomach is going to explode I don't know about this but today I was really tired
00:03:19.340
and hungover I blame the durian so I stopped laughing stop laughing this is
00:03:28.639
the moment where the sound system should play a funeral march because I have
00:03:36.379
terrible news Ruby is dead
00:03:42.250
exactly in case you didn't know it is that it makes me sad it should make you
00:03:49.489
guys said it should actually make you question why are there videos on YouTube
00:03:56.769
discussing why Ruby is dead Ruby is also so dead that it is the last
00:04:02.629
I don't know position on the last position on I don't know like languages
00:04:08.930
ranked by programmer jobs the first language is SQL which is a famous programming language so that's how
00:04:16.729
that's how dead Ruby is it's also funny that Ruby is for some strange reason on
00:04:22.760
the very top of program and Happiness index so it's totally dead I actually I mean I
00:04:28.250
leave that because I I went on the internet and I tried to find out why is
00:04:34.490
Ruby dead and I landed on reddit the source of truth and it linked me to some
00:04:43.340
amazing blog posts on the so called PHP block org with the title don't believe
00:04:52.730
in Ruby why I don't believe in Ruby and you shouldn't either
00:04:57.820
it's a really interesting post you should read it so you get enlightened
00:05:03.100
that we are on the wrong side of the tracks and then I had so there's like
00:05:08.210
interesting scream cause like Ruby is no longer cool these days it's JavaScript
00:05:14.560
in case you didn't know that or what's better is a ruby was a hipster code a
00:05:20.330
community of 20-something year old nerds who are now 30-something nerds sorry so
00:05:35.090
it's a I was devastated reading PHP blog I actually subscribed it on my ass s
00:05:41.840
feed and I'm gonna follow it totally because I mean Ruby is definitely slower than PHP and that's actually true but
00:05:48.410
it's some absolutely compelling reason why Ruby said it Ruby apparently sucks
00:05:55.430
at concurrency my experience with concurrency was okay some people have
00:06:01.400
complained about it there is definitely languages with better concurrency that
00:06:07.630
Ruby is also object-oriented programming which is also terrible like you have to write everything in a functional
00:06:14.000
language Haskell otherwise the language is dead so it's like and of course
00:06:20.450
Ruby's also messy like you don't create messy code in like elixir or in Oakham
00:06:25.850
oh it's only Ruby that it's messy and also Ruby is the reason why rails exist so it takes me up okay so now that we
00:06:34.820
know that have a look at this black slide and just cry for a little bit because we came together here for a
00:06:40.940
deadline which not the best feeling for me let me tell you some interesting story about my
00:06:47.729
current job so because I don't really like the PHP vs. ruby thing I mean X
00:06:53.699
find it kind of amusing and slowly but at my current job we actually had to
00:06:59.099
face that reality that people still like think about are we going to use Ruby or PHP and and because I work for the
00:07:07.349
police at the moment not that police and also not that police more like that police so the are you consulting for
00:07:15.169
Ruby software let's put it in a very generic way and so they had a big
00:07:21.930
project coming up and they are wondering should we use a PHP or should we use
00:07:27.210
Ruby again because we have lots of successful application Ruby but Ruby's dead read it says so so let's have and a
00:07:35.069
consultant find out for three weeks if it's good or not to use a ruby so I had
00:07:41.939
lots of meetings with this consultant that was paid free this is actually a video because I might lose my job so I
00:07:50.909
was having a lot of meetings with this consultant and he's great so he actually
00:07:56.099
introduced me to Gartner hype cycle you all know the Gartner hype cycle it is
00:08:01.289
like the the flow of I don't know what's
00:08:06.509
it called like the expectations for a programming of a technology in general so like firstly of this peak of
00:08:11.939
excitement it runs a year let's use ruby is awesome then after some years they find out on my code is so messy and
00:08:17.520
object-oriented and slow but it says concurrency so it's totally like it sucks and then people started like come
00:08:24.149
up with new technologies and new gems of whatever like new libraries and it kind of oh here we go this is actually the
00:08:30.120
way we should have done and then you're on the plateau of productivity and this is absolutely how every programming
00:08:35.279
language can be categorized my the consultant also added some new flow from
00:08:41.789
here and he called it like the I don't know like the ebiz or something like that because and he was wondering if
00:08:47.880
ruby is at this TRO of disillusionment and on the way to go even down further
00:08:55.010
after 25 years of being successfully installed in the software industry and
00:09:01.580
so and yeah we we kind of figured out okay these we are talking about two equally strong powers yeah ruby is huge
00:09:12.750
yes PHP is also huge so this is not a good thing like we have to find
00:09:18.570
something else how to find a metric is Ruby going to be the language for the new project or not and so he explained
00:09:25.050
me a actually he's a really nice guy I'm just thinking like the she little bit so
00:09:31.110
he was telling me okay like a so proper engineering usually means should mean the code has to be maintainable
00:09:38.870
comprehensible so other people have to understand it and actually already under forgot the third point here yet so and
00:09:46.770
we kept like talking about this generic stuff so I was so I don't know we we talked about generic stuff at some point
00:09:53.400
I realized hey men actually like this is just an example for architecture it's not that important and so actually what
00:10:00.600
we talked about is it doesn't matter if something is a huge or not huge in the
00:10:06.030
in the economy or if something is in the TRO of disillusionment or not what we
00:10:11.310
talked about is is my software maintainable does it have a good architecture so it boils down to like
00:10:17.880
fine grained architecture how do i model a software to make it something that you
00:10:22.890
want to work with in ten years because that for me is good software and I think
00:10:28.320
both PHP and Ruby can provide a nice architecture but we had like two or
00:10:33.450
three hours of fighting about this architectural point until he said okay maybe you're right maybe it's not the
00:10:39.960
language itself because what I am because I mean there's so many frameworks in PHP and they're excellent
00:10:47.250
I'm not kidding that provide you huge abstractions and lots of different
00:10:53.040
layers you can use for implementing complex applications doesn't have to be web and that's the same for for Ruby
00:11:00.990
like rails and Hanavi and get great and Rhoda and I don't know I could add like 500 more and so that is not the problem
00:11:07.860
we have technology what I am realized after some after some hours of meeting was that if
00:11:15.450
you visualize the PHP stack at the police I'm not going to say which police
00:11:20.850
and you can totally not tell by my accent which country so if you visualize the PHP stack like all the other
00:11:27.420
different applications we have it's a really really colorful thing like they use a thousand different frameworks they
00:11:33.510
use different abstraction layers in every application they don't have any abstractions they're building their own
00:11:39.330
MVC they use laravel so it's like a super hit heterogeneous I don't know how
00:11:45.000
to pronounce it how do I said yeah so we
00:11:51.720
get this yeah an image of the PHP world at this at this job yesterday it's like
00:11:57.209
thousands of projects and they all look completely different and then when it comes to Ruby at least even though it's
00:12:03.240
slower and sucks at concurrency and also even if it looks more boring to you but
00:12:09.270
more boring in this context means it's better because we have the same stack in every application its rails it's not
00:12:15.150
everyone's favorite stack we use trailblazer as an additional abstraction
00:12:20.250
which is not everyone's favorite abstraction here and we have the same concepts the same abstractions in every
00:12:27.630
product so you go to those application a and you will find out okay I don't understand it you go to application B
00:12:33.120
okay I don't understand it or you go to application a and you understand it and that means you will understand all the
00:12:38.220
other applications so it's like a homogeneous he called it a homogeneous system yeah and that is much more
00:12:45.540
valuable for software development than a like some some some like a crazy fast
00:12:52.410
language that you can't maintain okay and we figured out that like just something is in PHP doesn't mean that
00:12:58.709
the other project also in PHP is the same and the same with Ruby like I mean some project in Ruby can be completely
00:13:05.579
different to to to I don't know like a rail stack is completely different to a Sinatra application something like that
00:13:11.220
yeah and so we we boil it down like maybe the language is not the actual
00:13:17.430
problem what we talk about is the architecture yeah the tools we have the abstractions to write
00:13:23.820
applications and the problem in both PHP and Ruby is that the tools we have are a
00:13:32.750
little bit primitive in some cases yeah for many languages it's the same problem
00:13:38.670
so sometimes you have a tool that you actually want something way more efficient and you know this massive
00:13:45.269
power tool exists but it's not available in your language so if you build it yourself this is not a problem but this
00:13:51.060
consultant finally concluded that am that he doesn't want my choice
00:13:57.420
he wants to build his own toys so he decided that he's going to build the entire stack we had a ruby in PHP yeah
00:14:05.910
that was one of my successful consulting gigs last month now I would say I don't
00:14:14.940
know I I just talked myself up a little bit it's a warm knock I would like to
00:14:22.019
ask um is it like would you guys like to like hear some more ranting about like
00:14:29.880
programming languages or Ruby or rails or would you rather I don't know help me
00:14:34.949
be like super smooth into the next topic I mean I would say let's raise your hand if you want me to rant raise your hand
00:14:43.920
if you don't want me to rent yeah so that's like that's like it's really
00:14:51.449
close but I'm sorry I'm sorry they're renting part the more aggressive part of the audience one I used to trump's
00:15:02.390
electoral vote system to count them though it's absolutely it's absolutely
00:15:09.000
fine okay so AM how how else would you start
00:15:16.620
a rent if it's not a tweet from vhh so
00:15:23.160
actually so and do make this transition from I mean I think it out in this in this talk with this consultant that the
00:15:29.880
problem in in software development is not the actual language it's not is it
00:15:35.399
also concurrency or is it kind of okay it's not like do we have 500 database
00:15:40.529
adapters or just one the problem is more like what granularity of architecture do we have
00:15:46.199
in this language and what kind of granularity does this language allow me
00:15:51.209
to introduce okay so and I don't know I actually don't know why I put this into
00:15:58.079
the top because I I read this tweed yeah like it's lovely when activesupport can serve as an experimental lab for future
00:16:04.019
core features in Ruby 2 point 5 so actually it's about the array prepend method in Ruby 2 point 5 and I don't
00:16:14.759
know like I read this tweet and it's kind of I kind of see this tweet is the
00:16:22.019
Ruby community's problem in a nutshell like I don't have a problem that anyone is like happy that some of their
00:16:27.540
features get into Ruby core even if it's active support it's it's totally fine if
00:16:35.550
you like I don't know tell people about this their efforts and everything and I mean my respect for their code but it's
00:16:42.329
I mean this is like another method on top of 328 methods of array that does
00:16:50.670
the exact same thing as shifts or unshifted and here it comes this method name is actually is actually
00:16:56.040
understandable it says what it does I never remember and shift shift what it
00:17:01.110
will pop she whatever but um the problem is in Ruby this is actually
00:17:06.480
not really our problem like we I mean so I don't know I like I wrote this response okay who needs strict typing
00:17:14.100
pattern matching modern concurrency method overloading better keyword arguments macros real namespaces and packages functions not closures and end
00:17:21.209
to monkey patching insanity removal of all the loading once and for all well please in a new fair world or when
00:17:27.419
you can have array prepend and I didn't tweet it because it's cute it and
00:17:35.220
and also I forgot immutable data structures so it's like I don't know it
00:17:40.500
kind of like the problem is not that we don't have a rate prepend in Ruby the problem is how can we extend the
00:17:46.770
language and make it easier to have good architects I'm going to show some examples later so the other reason I
00:17:53.310
didn't tweet it is because Twitter only allows 134 characters I learned some
00:18:01.560
important thing from that tweet that never happened just take an hour break
00:18:07.770
and then tweet and then you probably not going to tweet because it would have entered in some stupid discussion anyway
00:18:13.910
yeah I this is hospital works reddit is way better if you want to have
00:18:19.050
intellectual discussions so so my problem is that we have enough
00:18:25.770
syntactical sugar in Ruby okay this it's like amazingly simple to write good stuff what I would like in Ruby in the
00:18:32.220
future is more abstractions on an application level yeah and I'm going to show some examples of what I mean and
00:18:38.580
I'm going to keep I'm going to keep saying this I don't want toys I want two of this sounds like really arrogant when I say toys I mean syntactical sugar when
00:18:45.150
I mean tools I mean higher level abstractions in the language itself and I'm going to show you some of those
00:18:50.190
abstractions and right now in my favorite programming language called PHP
00:18:56.150
hey we all started with PHP come on and actually PHP I mean it's it is well
00:19:05.580
known in the Ruby community for being like horribly complex a complicated
00:19:10.620
language and you add like you can add code into like templates and in HTML and and like we always laugh about TVR come
00:19:18.240
on he's like PHP developer and actually PHP has improved a lot in the last
00:19:26.130
couple of years and not trying to tell you switch to PHP otherwise I mean if you do you can work for the police that
00:19:33.570
Sam let's let's say I mean do you know what the cool is the thing about PHP is the website is php.net
00:19:40.299
I knew this is not going to work and okay so in PHP there's some pretty
00:19:49.149
interesting stuff happening since 5.3 or something I actually learned I think much said that PHP 6 got cancelled I had
00:19:55.419
no idea thank you so what they did they copied a lot of Ruby stuff in PHP which
00:20:01.119
is pretty cool for Ruby so for example they have modules they call it trait and you can basically define a trait like a
00:20:08.679
module in Ruby and then you add functions and then you can what is it use that trait in a class and it
00:20:16.089
automatically imports those methods in in the class I don't know if it works
00:20:22.239
trade interests I think it also works so they basically added modules from Ruby
00:20:27.459
to PHP which is cool because modules are kind of helpful if you use them in the right way and with discipline right they
00:20:35.259
also have lambda so you can pass dynamic code to to a method and the method will
00:20:40.419
yield that lambda I had no idea this is happening in PHP and I'm actually impressed they also have anonymous
00:20:48.159
classes it's not that much of a like author of a ripper as the Australian say
00:20:53.759
but if you do DSL and if you do if you do a meta programming you need an
00:20:59.529
anonymous classes and anonymous objects and they kind of integrated that into PHP five something and what I really
00:21:06.969
love and we I would love that in Ruby is they have interfaces so you can define an interface say this has method
00:21:13.149
whatever and method whatever else and this is my signature and this is my other signature and then you can say and
00:21:19.299
then you kind of apply this interface to a class and the class has to implement
00:21:24.399
that interface or breaks and you can also use that interface for it something else which is pretty impressive and I
00:21:30.820
had no idea PHP 7 has typing so you can't actually say my function wants an integer and I
00:21:38.049
don't know okay this is the simple example I my function wants two integers
00:21:43.570
and if you give the wrong parameters it'll say uncaught type whoops oh actually can you guys hear me that's
00:21:50.829
great so you get an arrow that is actually meaningful Laura wood would be really
00:21:58.539
happy to see that because you now know okay this is actually a wrong type and not something on nil you can also do
00:22:05.769
stuff like hey my method should have should receive an object with that
00:22:10.779
response to a specific interface and this is amazing I mean I'm just thinking of it from a gem author perspective like
00:22:16.480
if we could say you can only give me objects that do this and this and this that'll be amazing because I will just
00:22:22.360
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
00:22:27.639
happening and and you can also say what type is going to be returned from a
00:22:32.980
former function so that is actually I don't know it's pretty impressive so I can say oops sorry I can say this
00:22:40.090
function returns an array for example and I got really excited reading all
00:22:45.879
about those PHP features PHP ha ha ha ha actually it's not that funny anymore
00:22:51.429
because it's like becoming a proper language and it has features I've missed in Ruby in all fairness
00:22:57.730
but one reason not to use PHP is they also introduced go-to and I don't know
00:23:06.100
about that but I think we don't have go-to Ruby right because someone told me how we also have that Ruby I've never
00:23:12.279
seen it but they introduced that in a recent PHP version and that is I'm sorry
00:23:18.009
but go-to is like basically saying I have no idea what I'm doing please go somewhere else and so I was
00:23:24.730
reconsidering my PHP like my PHP plans after learning about the go-to and so
00:23:32.710
you see PHP is not that hahahaha PHP ridiculous as you might have thought it
00:23:39.429
is if you have questions of a PHP 7 you can ask vizac he just bought a book what
00:23:45.669
does it say in Japanese I can't read it Aaron you speak Japanese right okay the
00:23:55.330
book title is no no J is let's have a
00:24:00.789
quick look at Java it's also one of my favorite programming languages because it's really really popular everyone
00:24:06.700
is it Java is well-known forum like you tied to some huge IDE that makes you do
00:24:12.280
stuff the way you don't want it and it makes you configure things and you have
00:24:17.560
to do like lots of xml and love like that's like the thing java developers wind you barrel then then you have
00:24:24.460
massive architectures with like a thousand classes that I don't even like because there's too many objects and it's actually yeah so the XML a
00:24:32.290
configuration part is massive so there's no not that much configuration at convention over configuration and it
00:24:38.830
actually makes people write books like Java ruin my life which is literally depressing Java has obviously typing so
00:24:48.370
I can also say my method is going to receive objects from this side and it's going to return objects from that type
00:24:53.980
which is a really helpful feature I'm going to discuss that in a second in Ruby context it also interfaces of
00:25:00.640
course I mean I know all that from university like five hundred years ago because Java is quite old so you can
00:25:07.480
have interfaces you can you can say this class needs to implement the following
00:25:12.520
functions and Java knows ok this class actually does provide those functions we have method overloading which is pretty
00:25:18.700
cool so you can have two different versions of the same method name like - user with different argument chains and
00:25:25.810
each Allah will automatically pick at runtime what what what the version you wanted which is pretty cool for like gems or
00:25:32.110
something if we had that in Ruby looking at math because say you can't deprecated methods for example really easily just
00:25:38.350
by overloading it I'm dreaming of this I'm gonna dream for a little bit more I guess they also have something like
00:25:43.720
dependency injection built-in I have no idea how it works but the way basically
00:25:48.790
you kind of say this method is supposed to be ready for dependency injection and
00:25:55.870
then Java can inject arbitrary objects at random I have no idea how it works and doesn't matter but you see there's
00:26:01.150
lots of features in languages we kind of I don't know we kind of laughed about I
00:26:06.370
have PHP so funny like people writing HTML and weird code with dollar signs
00:26:11.860
and Java that's really funny because people have like XML files and all this but they actually have really cool and
00:26:17.800
tools to to write proper stable software and you can see that
00:26:23.170
that's a ruby so in Ruby and I mean don't get me wrong but in the last
00:26:28.870
couple of releases we had like Ruby wants you the fix time is deprecated
00:26:34.600
like this is shattering in the auto local variable and this variable unassigned si but not use this kind of
00:26:40.360
like innovation happening so actually it's really annoying for me because I have to change all my code so it's giving me all the warnings and we get
00:26:47.320
the 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
00:26:55.150
care of that so you call this method with named arguments and Ruby will kind of handle those and assign it to local
00:27:01.720
variables it's a great thing and we also have refinements which are pretty awesome there was a talk two years ago
00:27:09.550
here in Singapore the worst feature you ever loved by Paulo pirata the guy who
00:27:14.680
wrote them Ruby metaprogramming ruby that title
00:27:19.870
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
00:27:25.870
have some class with a method and then I write a refinement and I override that method and then I can eject that into
00:27:34.120
the runtime environment somehow and then see the new sorry cedar fool will
00:27:39.160
suddenly behave following the refinement and not the original version but it only
00:27:44.680
works like if you look at the documentation it's like you may only activate refinements at top level not
00:27:49.900
inside any class modular method scope so it's kind of I don't know how that is helpful at all and they are active until
00:27:56.290
the end of file or evil string so it's kind of like you know only valid in the
00:28:01.540
lexical content of the file so I saw that talk by Paulo pirata and we all were more confused than we were before
00:28:07.060
like refinement is a feature I don't understand why is this like I mean it's
00:28:12.070
great that people work on solutions but shouldn't we I don't know like and so
00:28:17.890
the problem in with refinements is we are trying to override so basically you call a method call method called method
00:28:22.960
that's kind of what a refinement does it overrides and ejects code at a specific point and maybe the nesting idea in Ruby
00:28:29.800
is wrong maybe if you want to write if you want to execute something pass the result of the next one the next one person result of the next
00:28:36.150
one maybe a pipeline is way more what we need in that context and you could
00:28:42.000
inject logic like for refinement in this case at any point of the pipeline and it's completely obvious what's happening
00:28:48.300
so I would love to see more efforts in the Ruby community to work on I don't
00:28:54.240
know like distinguishing do we need that feature yes we want some way to inject
00:29:00.420
logic how can we achieve that and just because we have this include module
00:29:05.880
inclusion thing happening doesn't mean that it's it is like their and you
00:29:12.930
have to use it all the time because I actually get confused and I own modules in my gems as well so I often switch to
00:29:18.480
something like a pipeline you know like the pipe operator and elixirs a good example so they picked up they had a
00:29:24.960
problem we want to inject code let's change our abstraction and I would love to see that in Ruby because the concept
00:29:31.170
of calling super super super super is super hahah is super confusing and
00:29:37.070
another example is the face navigator
00:29:42.330
also known as the Keanu Reeves operator you can see it as does matter so the
00:29:48.840
save navigator is basically replacing long lines of code like this like user
00:29:54.210
profile and if the profile is there and if the some things are there and if the latch is there then return me that
00:29:59.580
result so in and rails which was actually a cool idea they introduced try and I'm actually I mean I'm not a big
00:30:06.150
fan of try using that the abstraction is cool because it allows me to do the same without having the end end end end end
00:30:11.400
and then Ruby pick that up and kind of abstracted that into a new operator which is also an abstraction and so now
00:30:18.570
the same line is like this I'm I'll leave it up to you if you use it or not
00:30:23.790
I think it's not the worst idea I just am not sure if I support those kind of
00:30:29.550
calls in general and if we should have more decorators or something built into Ruby actually um
00:30:37.070
typing in Ruby is basically this so in
00:30:42.270
Ruby and I don't know how many undefined methods for nill class I had in my whole
00:30:47.460
life I think 500000 are not enough so I would love to see typing in Ruby because it
00:30:53.510
will help us to write way more stable software without having to do anything
00:31:00.140
and that's my whole point about them the granularity I'm talking about I want features that are tools that help
00:31:06.740
me to write code without having to create all those instructions himself
00:31:11.750
that would be great ok and I spoke to too much many times and he has some
00:31:18.260
great ideas and I'm actually still very positive about Ruby I think we're on a
00:31:23.720
good way and what's crazy great about Ruby is that we can create all those abstractions ourselves yeah so for
00:31:31.550
example we had this beautiful top item Riley this morning about dry RB dry B is
00:31:37.220
a fantastic project bringing bring you functional style dialect into you
00:31:43.100
Ruby applications it has a bunch of great gems like I don't know dry
00:31:48.650
validations Roo super popular then we have I don't know dry mature dry a view iOS use dry container it's fantastic for
00:31:55.850
dependency management so they have lots of little libraries that you can use without using the entire stack and they
00:32:01.850
also have a fantastic website which is pretty uncommon for an open-source project and so for example at the API
00:32:09.830
they create a super like it is so intuitive because it's simple yeah like the dry validation gem gives you a form
00:32:16.280
and in the form you can write a validation and then you apply that validation to a hash by using the call
00:32:23.000
method and the validation will say you everything is fine or it will say you're like there was an error and the error
00:32:28.340
was the following so it's kind of a an abstraction of validation we have validations everywhere and drive
00:32:34.730
innovation makes it super accessible and you don't even have to think about that so dry validation the dry speck in
00:32:41.150
general is a great tool set for me and I love it I love to use it it is heavily
00:32:47.840
pushed in the reform gem the dry validation and it also is popular without reform which is surprising I'm just kidding
00:32:53.809
you can see it in the downloads they have like $300,000 in like one week or something which is basically saying that
00:33:01.040
people like and they have an amazing website which is pretty uncommon for an open-source
00:33:07.649
project you should check out this stuff because then the two set they provide is
00:33:13.409
very flexible and it does not interfere with your existing stuff the next thing
00:33:19.110
I would like to show you with abstractions is hanami hanami is excessive on the homepage the modern web
00:33:26.820
framework for Ruby a few months ago it said the complete web framework for Ruby I don't know why they changed the
00:33:31.830
mission I have an idea and I'm going to talk about it in a minute so hanami is also like a and really
00:33:37.260
interesting replacement basically for something like rails so it gives you MVC
00:33:42.360
but in a very very extended wait yeahyou has a survey of routing and all that so basically they also have a beautiful
00:33:48.480
website which is pretty uncommon for an open-source project and the website is
00:33:54.299
full of your great documentation so basically hanami works like rail and it does not work like rest absolutely not but it gives you like a generator you
00:34:00.990
can say hanami new bookshelf and it'll create you like the entire directory structure raked house everything you want then you basically have routing
00:34:07.799
it's completely different to Rails routing but it's beautiful it uses rec and all that kind of stuff you have
00:34:13.109
instead of controllers you have actions and those actions are specific to one
00:34:18.470
controller action yeah so it's basically like the guest create in a controller in rails is an attack class in hanami and
00:34:25.440
in that class you kind of run your business code if you want that if you like that so hanami gives you complete
00:34:31.080
new set of abstractions and tools for for web applications again I don't have
00:34:36.839
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
00:34:42.869
abstraction it uses dry validation gives you some more cultural models and repositories I just I think you should
00:34:48.659
look at the beautiful website that's really uncommon for open source projects and it also has stuff like generators
00:34:54.810
efforts mailers so it gives you all the what we call infrastructure to write
00:35:00.089
applications it also comes with a view layer herand you don't have to Jackie
00:35:05.910
it's a kit and so they also have a view layer they they basically give you the
00:35:11.609
full stack to write software actually not because it's we'll really undefined how to write a
00:35:17.940
business code in hanami so they give you these infrastructure they have great abstractions for the validation
00:35:23.369
everything but when it comes to how do I actually write the code that is going to be executed like I don't know processing
00:35:29.520
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
00:35:34.619
framework comes into play so this is exactly what basically the Trailblazer
00:35:40.950
framework which is the third of the three projects I'm going to demonstrate death so Trailblazer and does not bring
00:35:47.730
you routing credit it does not bring you mailers or generators or I don't know persistence trevor's is only focusing on
00:35:55.740
how do I write the business code okay so that's a big thing people misunderstand they they're like okay that's dry
00:36:01.830
there's Honami and there's relatively like competing it's absolutely not like that so we all kind of integrate into
00:36:07.500
each other traveller takes over the business code for for example for hanami so if you
00:36:13.110
like this is a beautiful diagram in hanami and it does totally not fit on the screen because my CSS skills suck
00:36:19.619
and my laptop I have no idea and the same is with rails or trailers also
00:36:27.180
works with rails so instead of I mean rails and hanami are not identical at all yeah I'm not going to say which one
00:36:33.090
is better of course but that trellis doesn't care if it's you know if it's
00:36:38.850
used in rails or a Nanami or Sinatra Road add you name it so thread is a
00:36:43.950
takes over specific layers of your application without interfering with the rest of the framework it's by the way
00:36:50.910
it's called an advanced business logic framework just saying it also has a
00:36:56.040
beautiful home page which is really uncommon for opens or project so you can
00:37:01.859
see there's like a battle going on who's got the nicest home page you know open source and ruby which is amazing because we all like you know competition is good
00:37:08.340
for the economy and so on and so on and so on so what trail is it does is it brings a lot of new abstractions but it
00:37:15.660
also brings like some kind of extended a directory structure so instead of pushing things into app controller app
00:37:22.080
model at view you push things into app concepts and then you order by concept and then by technology okay
00:37:28.980
going to show you an example in a second so it's new file structure it brings a lot of new abstractions like validations
00:37:34.800
and policies and it kind of lets you play with active record or with sequel or whatever so I'm not going to go into
00:37:40.560
the details the interesting part in Trailblazer is and that is what betsy was talking about
00:37:46.890
in her talk earlier today that we kind of have the same philosophy of why would
00:37:52.530
I mix a lot of business code into the controller which is really hard to test again thank you for the talk because it
00:37:58.470
excites me when people when we all use like advanced features like encapsulation and so in an intro there's
00:38:06.990
a huge you would have this service object betsy was talking about it would be called an operation for example blog
00:38:12.060
post create and the controller simply calls that operation passes in all the dependencies like parameters and does
00:38:19.020
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
00:38:25.440
this is what Betsy was showing that this cementec this interface can also be used
00:38:31.680
for testing so you do the exact same thing in a test without having to think how it has this piece of business code
00:38:39.119
you just run the operation you call it in this case and you test the result object okay so it's really simple API and it's
00:38:45.450
unbreakable because it's it's it's what we call encapsulation so this is a thing
00:38:51.000
that all then you in quotes new gems like hanami dry and Trevor they use this
00:38:56.580
kind of semantics where you call objects and they don't have any other public method so it's basically a functional
00:39:02.609
object that was explained by to riley today yeah so I can only call there's no
00:39:08.820
way I can run any other method on this thing whatever that is and if you wonder
00:39:13.980
what it does just read it blog post create so what is it going to do it's going to create a blog post obviously and so Trevor Isaac
00:39:21.960
kind of jumps into the into the gap where we don't know how to model
00:39:28.440
business logic it actually kind of takes over a little bit more than that so it kind of wraps or orchestrate validations
00:39:36.270
is models repositories if you want to like policies gives you eyes if you want
00:39:42.300
that it also has like slow control I mean like try to make it look really ridiculous because I
00:39:47.490
suck at design as well so try but it gives you a lot of abstractions and that are optimized for their business color
00:39:53.970
yeah I should have done this beautiful stack diagram to show you a beautiful
00:39:59.849
diagram because I learned from my meeting with my consultant at the belief that good-looking diagrams make people
00:40:05.460
amazed bad-looking diagrams like that one suck and okay so this just a really
00:40:14.760
quick example how that blog post creation would look in trailblazer so you would probably add a concept called
00:40:21.720
blog post and a folder operation with create dot RB file and yeah it's a we
00:40:28.289
this file contains an operation and to write that blog post we have the
00:40:33.599
following things to do we create a blog post model we assign a UUID so we have to generate a Yui ID we have to save
00:40:39.270
that model to the database and we have to update the total posts counter as it's just an example what to do this
00:40:45.270
could be any any kind of business code so in the diagram this would be a straight graph pointing from left to
00:40:53.369
right model blah blah blah update counter and what if something happens what if we have a W UID for example we
00:41:01.230
should catch that error in a diagram this would look like this yeah when I save the database we'll say hey there
00:41:06.450
was a UUID error so we kind of can't catch and treat that UID error in this
00:41:11.730
kind of box whatever that box is and let's say we also had a counter error
00:41:17.730
maybe the counter is only till 128 because it's an unsigned int I had that problem in an old project a few years
00:41:24.720
ago in PHP by the way and so we in the diagram this would be the counter error
00:41:30.210
can only happen after we update the counter so in a diagram we would have either this was successful all this was
00:41:36.510
not successful handle this counter error okay so red laser makes it really simple to have those kind of diagrams in code
00:41:43.589
without you having to do anything yeah and relax it is a diagram it's not
00:41:49.140
that thing okay so am to have this simple linear workflow for example in an
00:41:55.170
operation you would simply have this operation class user sorry that should be blocked posted user I my
00:42:00.480
talk suck and you add the steps that you want to have executed in the order you wanna have been executed you can call
00:42:06.870
that operation you get the result object you can ask the result of everything okay success or failure so don't worry
00:42:12.390
if you don't understand all the details because it is just an overview and yeah
00:42:17.970
so if success tells me Falls then something went wrong so in order to have failures or error handling in this in
00:42:26.220
this diagram I just use the failure method and add the steps in the order I want for error handling and this will
00:42:31.710
basically result in a slow controlled diagram like that so it's super easy intuitive to have complex workflows in
00:42:39.330
Ruby because I mean this is kind of readable and you can render that and it will show you the diagram which is so and it's kind of easy to understand so
00:42:46.140
the idea of further is your steps and steps can be methods or lambdas or callable objects and they just sit in
00:42:52.560
the operation or they just sit anywhere you want and they basically write to the options object which is the only mutable
00:42:59.520
object in trailblazer so you write stuff like the UUID to the options object and
00:43:07.100
then you can read that set from the result objects I call the operation on
00:43:12.390
the outside and I can say hey result what kind of view Rd did you create and like hello whatever so this is how you access state from the
00:43:19.680
outside from the caller perspective and to directing the flow error handling all
00:43:25.260
we do is basically it's a step returns false it goes to the error handling track if it returns true it stays on the
00:43:32.100
on the top track the one in the diagram we just saw so this is all like just an idea for you guys we understand where
00:43:37.860
this is going it's really simple to kind of have work cred as a control your flow well you only focus on the implementation here so
00:43:45.540
this diagram is is a like six lines of code including not including the
00:43:50.670
implementations for the actual steps that's only the basics and so the idea
00:43:56.670
is have encapsulated objects that you can't break you can just call them and they will do something and they will
00:44:02.280
give you a result and if or not they use this comp flow control is your problem you can test them in a really nice way
00:44:09.930
without having to know anything about the internals because you use the exact same API it means it's also going to do
00:44:16.319
the exact same thing it does in production which is amazing because you don't have to hope that your tests in
00:44:22.680
your production match you can also use operations as factories because I also don't like factory girl mm-hmm and it's
00:44:30.960
basically giving you an API and internal API for your application for free and
00:44:36.290
many people ask hey wait a minute damn this is way too many objects and isn't there to enterprise and when I think of
00:44:44.670
enterprise I don't think of the Starship Enterprise I think of like diagrams and everything is pretty cool and so
00:44:49.950
Enterprise is software that is used to satisfy the needs of an organization rather than an individual users
00:44:57.270
apparently we are all writing enterprise software as Ruby developers enterprise immersive Oracle and like certificate
00:45:03.750
and like huge diagrams that make no sense because you use like a shit-ton or
00:45:09.240
factory factory to create something and it is like yeah okay it's not the enterprise's kind of ridiculous but
00:45:15.150
actually enterprise we need enterprise patterns to write favor software because I am bio respect but three layers and
00:45:23.130
rails is not enough to write like complex software and I mean we end up usually with like huge models that kind
00:45:29.400
of contain everything from workflows to business code to persistence co2 validation code it's kind of I don't
00:45:36.030
want to say messy because negative and this is the last talk I want to give you a positive feeling so but it's not ideal
00:45:42.150
if you want to build something sustainable for multiple users also known as enterprise software and so the
00:45:48.660
idea of this formula is flows with diagrams is nothing new so we didn't
00:45:54.900
invent that there's something called bpmn business model process notation also people usually laugh ppm n is
00:46:01.500
basically boxes and arrows and it has like activities and thousands of like I
00:46:08.369
don't know like you tell me knowledge e words in the in the glossary it's really ridiculous actually it's I don't know a
00:46:14.280
BPMN is a diagram language to specify business processes so that the idiot pardon gentleman in suit and tie
00:46:19.950
understand them and coders can code them it's actually pretty cool and it shouldn't be neglected in Ruby a
00:46:26.450
enterprises not a bad word like writing stable software is actually pretty cool and of course I wouldn't tell you all
00:46:33.300
this if I would if it wasn't for trailer that now comes in two point one with ppm and support so you can have like
00:46:39.300
operations and wire them together and why operation in operators and so on and so on and so on and but the so the idea is that I'm
00:46:47.510
trying to communicate we have Ruby as a
00:46:53.220
language it gives us a lot of tools but they are all kind of low level so at the
00:46:58.530
moment we have to create those abstractions ourselves this is great I'm happy with it I mean I'm doing Ruby for
00:47:04.320
like 12 years old apparently I am happy I could have switched to PHP last week but I didn't and so but I would love to
00:47:13.530
see Ruby go somewhere where we have those abstractions built in like a native decorators for example in in Ruby
00:47:21.240
or native arrow objects in this kind of stuff so I would love to see more work on that kind of on that level of
00:47:27.690
building applications and I also
00:47:33.530
interrogated much a lot of hours at the rubicon Philippines about M Ruby I'm really excited about M Ruby it looks
00:47:40.080
like it's going to be kind of a fresh version of Ruby and that has ditched or
00:47:45.810
not implemented some of the features that were not really beneficial for Ruby like autoloading for example so our
00:47:54.300
favorite topic I'm actually really excited to go home and try M Ruby because it looks like there's a lot of
00:48:02.130
fresh and clean code that is ready for additional abstractions in the future
00:48:08.270
because we all want to write beautiful code and if you have questions I
00:48:15.390
actually did overtime on purpose because I don't want to answer questions as we
00:48:20.850
all oh the worst is like you don't have questions I'm standing here like so I
00:48:25.890
would say let's to read Twitter is like Instagram but you don't need a
00:48:31.619
smartphone to use it or we can just hang out tonight or tomorrow