 Hi everyone, this is not actually a Elm like come and go with me talk because I've had back experiences with copy and paste workshop and then a lot of time is wasted or troubleshooting like editor or environment problem. So this will be more top and more programming so participate with my desktop. The topic is the red pill right. What's right. This, I call it the red pill because after I'm being introduced to it for maybe the past three years. I don't think I can look at other languages the same way. So, so this is this is a fair warning. Quotes from people who have worked with me in the past three years. My whole life is a lie so that the one is a more dramatic about me so that you know where I came from. Right. This is not like, yeah. So I saw this what you do in school and then pearls is more powerful see but simpler and Java everybody do Java. So, and then, after a while you learn about Ruby and the new OOP message passing is all Java is not Java OOP is not all that there is. And then I did that for like 10 years. So JavaScript Rails doing MVP and big website for the past maybe for a plus that's where I did go. And then I learned about Elm. So this is this is the cocktail of environment that mode the bigger cocktails that I'm working with other things like PHP visual basic included as well. So you can see type languages, object oriented languages, functional languages. So dynamically type language that I was happily working in with many years. So this is, this is what we may be using every user you're greeting and then you pull up name, and then you make an application from it, like simple code. But we will call it dynamic language. It's like a very positive way of saying things, but actually what what I feel is is that there is a type, but the type is expressed as a function body code. You have there's no summary of it. It's not saying that user is a dictionary a hash map with a name key. There's no summary of the type, but you have to read and interpret the function body to know actually, what is this function working with this example on on the screen is very short. But you can imagine a longer piece of code and you will have to read everything follow all the code to know what this function is working with. So I prefer to call it a hidden static type that doesn't change the code does require some some prerequisite, but it's just not stated. So, so let's say I'm using the greeting greeting function right and then this is, can anyone spot the problem with this code. Quick survey. Actually, this is a very common pull request review, you know, or another one that comes along a little bit like that right so please use single code, but still there's that everything is good right so review is happy you're happy. And then, right, you can expect trace. When and this like maybe when you're already running it on production already. So this is I feel this is where dark type. Got his name. Right. So, but actually what happens because it actually, it doesn't look like something is wrong right. It's actually correct. But whenever we talk about dynamic typing static typing then it always feels like a mistake. Who will make this kind of mistake right because of course you are using a user and a name and then you use a user and a name. But what we forget that that the simple the straightforward thing is programming. But software engineering when you add time, you know, the code is old, you've forgotten about it, and your other programmers, you don't know what they are doing. Then you have a lot of things to consider. So given this factory. No, no shortcut. So we, we can get pretty good at this we will and I've done this for a long time right so we go and look at the factory. Look at it because there's no other summary you just follow the code in reverse to trace and find where the problem is. This is good we get good at it. I'm sure people do this every day. But it would also be better. If I just know about it earlier. Imagine the feedback cycle that would have saved me. This is immense. And if I know of this small problem earlier, then I can just fix it if I if I didn't know who knows how many more I'm embedding before I reply. This will be an old argument. So tell me earlier tell me where so instead of telling me where the bomb exploded, like, okay, this is undefined. But yeah, but you can also tell me that a, you are saying you're passing name box to greeting, but greeting needs something and a first name. It gives us a clue already like, I think greetings was changed somehow to look at first name instead of name. And to string. So, so this immediately I know where to fix. Okay, when I'm when I'm using greeting or just first name, no problem. We think I'd be written by somebody else right. But a tricky thing that I must write types now to boring. That's the reason why I do dynamic type language right. So, not really. So let me introduce you to some old thing for type inference, which apparently happened, like really long ago, I think 58 to 83. And they within this time they saw that they have an algorithm that can look at code and determine what types they are. So even earlier by the tree, what the fellow did was that able to infer polymorphic types that in this case, this will be a string in that case that will be integer. So, and then the, I don't know why it was not picked up more, but this is the lay of the land. So what do you get from it. Look ma no types. Let's break it down this dynamic ish looking code greeting is a function user is the argument, and you give it a string hello from cabinet with string to lower user first name. So what the type inference did in this case was that it knows that string to lower needs to go with a string. So user that first name must be a string, which means user must be a type of something that has a first name attribute. That's that's how it gives you this. This thing. That's why you see that at the bottom last row you see a pipe with something with a first name string. So when you use it, greeting name box, something goes wrong. It doesn't tell you that inside greeting, something went wrong, it tells you that you are using it wrong. Right. So let's have another exercise. If that same error in your dynamic code gives you this. Okay, so what again what change this time. So you don't know, you go and take a look. Right. So can anyone tell me or you try just practice this right. Tell me what's the type expected by this greeting function. Right. It's pretty hard. I've given you like maybe 10 seconds already find 0.76 seconds. I can tell you that the user needs to be first name maybe three maybe three means that it could be nothing. The first name is optional. The language is a language. No, the capital letter. Yeah, it's actually type to a specific was you look at this code. The language is en or yes only. Right. And then you know that the last name is a string not optional and validation is also a string optional. So, look at these two pieces of code. I don't think it is too much a difference that's not. That's not much of a boilerplate that you need to do on one side and all the other, but they are same same or different right because on one end, I get the runtime era, and then it tells me where era happened. And I know the moment I use it, when I save my file on the editor, and it tells me where I made the mistake. So this is at 2015. Compilers as assistant, which is quite good. I think by just making the error messages friendlier, you're able to achieve that. And this is also quote from Rakuten after two years off. They call it compiler driven development you change part of the code and let the compiler error guide you through the rest of the past. Okay, so I'm going to show you a little bit here. The alley can go to the alley. Maybe I can. Maybe not. So what happens here is not this one. Actually, if you guys if your environment is not noisy, you'll be nice if you can turn on your mic. Otherwise, when I feel that it is this silence is really weird to me. Okay. Yeah. Thank you. Okay. Okay, this is not that this is my online. So some, some code that says you have something like name picture. And mean emails. Ignore the idea of the HTML if you're not familiar with it, but we can reflect that later. The idea is that yeah, you have some data, and then you're trying to render it right. And let's recommend for me actually, what I deal with applications that I do with application that deals with a web code. And it's very common that the provider tells you hey this is a sample what hope that you may receive, but doesn't really tell you what is optional what what could be what could be no what could be even a new field. So let's say you receive something like that. Well, maybe. Yeah, so this one is empty string. And we want to deal with the new data that we want to like okay since the data is like that, we do want to, we do want to deal with it. So what happens is that we will just copy this on the problem here is that this this user doesn't have email right and then you probably come in as a as a now. So we want to say that actually now the data is like that, but the app will now guide me okay the new the new reality is that not all users have email and deal with it. So we'll follow the compiler. Okay, so since this is nothing, the opposite of nothing is just something so this is a valid string. And then this is now maybe string. So we have our, we have our types done, but the rest of the code, the code that we are using our data is not updated. It could be your own code that you remember where to change, or it could be somebody else's code. So in this case, what happens is that right you're the are you already pointed out the bottom area. So this is that somewhere. Okay. The point out that actually is this template. But just now the screen that we were looking at was just listing the user. It was very obvious to us that when the data changes, maybe the rendering of it on that page, we have to change the code. This is like off the left. It is somewhere else that I have forgotten about. Oh, yeah, I didn't know that there was such a thing in our code base. So you also have to change this. So you in order to one way of doing it will be that okay you have a statement and then say that okay if email is not nail the variable is right here. And then you can you can do that. You can continue to do what we were doing last time, but if email is actually nothing, then actually I can't really if you an email. So maybe a blank string for now. Okay, then now you have to continue fixing the other places and say that over here you have your email also. So if this is, if this is admin, then I will do something like that. It's fine. So case user email or just string or nothing. If it was nothing, then maybe I will say anything. But otherwise, we will move the whole chunk into the block is ugly now, but we can reflect later. And then so there's more stuff that is here. This one is text nothing. And then if you have email that I'll show other. Okay, we can also do it here. So case user email. It is just a string. We will continue to do what we do. It is nothing. Then. They render nothing. This is now as because that this as is here. So I'm not sure about you, but as I'm doing this change, I actually didn't. I can, I can, I can pretend that I didn't know this code, but you don't have to know the code too well. And you just change based on what the compiler is telling you to achieve this. So as data changes, we usually just change the type and go with it. That's how we do it. So, while we were showing you the maybe and the nothing. So I'll just point out to you that things like nothing. And maybe, but these are not just like, sorry. So these are not special syntax of special things that the programming language gives you that you cannot, you cannot do. You can actually do your own thing like a user could be anonymous or registered with with a name with a string. And then from this point onward, you can say that, okay, registered. And you, and you do, you do have a value here already, or you can even say like, okay, let's say I have some, some user, which could be here. The difference is that I can't just, I can't just some user name it, or like, there's no way I can do anything with this value. Until I break it up with this. And then you do a pattern match and then you put a variable here, this can be anything. What happens is that this full bar is now a string, and you can say, I got. Another one is that the variance that it is like an item, but with information, the variance that you define, you will have to be completely exhaustive checking did you say everything. So we can say anonymous. So this is how you use the string and then now you can use the typical string, typical string functions to do anything you want, even though you are working with a type like that. This exhaustive check is super useful when business. When I guess you're at changes pivot, and then you have things like admin and give me a list of user, or even I feel registered. This string is very descriptive. I don't know why this I need it to be a name and email. And feel free to focus on this to get your domain correct. And then over here, the compiler will just type check everything tell you, like, hey, you know, so over here are now I have to like name it goes to Bob email it goes to Bob example. And now these cases are wrong because I cannot just string to lower the whole thing. I can only string to lower the name, for example. And now this is like a you're not doing that mean fine. So admin admin of other users. Then I guess I'll have to like, let me. This is the render user. And it is a render user, some user. Okay. And then over here will be render user. And now this one, I can say, let's map render user is a mapping over all the users are the users. And then I will join them together with a comma. And this is just now that I was just, I like to call refactoring in elm moving code because the most of the code is really just shifting around. This, this will be a characteristic that you just have to say but you have to experience it yourself, but it is it comes from the other red pill trade that I will talk about later, which is the pure part of it. So right now we are on the type type of it. But this kind of type is really different from my experience with Java go, whatever you make you call it right Ruby even we can explore more on what the type is that if anyone has other questions but this is the causes custom type or some some other place to call it. And you can start to define things really clearly, but otherwise, this is what we'll typically do a typical user in other language will look probably something like that you have a name, and then it is a string. And then you have your other users. Also, also something I can't do this one over here, but also also also other users for example. So you have is admin school is registered bull. And you would have a documentation somewhere and your wiki is actually what happens in my previous company right where we have a data type that that has multiple configuration, and then you will see that if is admin is true. It means it means will have other users. Otherwise, otherwise it's the right it's irrelevant right here. And various things that you're trying to talk about the combination of values that in one thing. And then for each function that you see work with it. And then you have your thing. This is my user. And then you'll be like, Oh, if that user is admin something then then there may be user dot other users work with otherwise. And you have to do this kind of decision in various places of the code. And it's just really tedious and error prone. Well, in comparison is the only thing that and somebody can forget to do. I mean, I forget to check this out. I'll just use this instead that that works compiler is happy. But whereas over here. There is no way I can get even the full buy information. We're going to use a detail detail. There's no way I can get the user detail when I want this out of the branch I cannot. I cannot do a right because there's no there's no no such variable. This variable is only inside this case statement. So you cannot, you don't get the chance to even make a mistake there's no other users when you're inside register the user detail when you're inside admin. So you have effectively broken out a force and force that everywhere else needs to handle some stuff. You cannot. Yeah, like I mentioned, you cannot do name. There's nothing you can do with this, except to break it out and then use the variables to that part is very powerful. Right. So this typing, typing and compiler giving an error, typing and compiler giving an error. So this, let's feel to me like tdd actually not not all of tdd so anyway so I've just talked that if you have not seen it you should watch it's pretty good. Other people say it's not just me right so this is good is the way that they understood tdd you know, but the gist of the top to give you a spoiler is that I got into it only when I understood it as a getting things done. Model of thinking, not like, oh, test will make it robust has to do this has to do that. No, no, it's this one we're like, hey, having test that's me get to the next step. And then, at every point in time, where the test fail and I just fix the smaller step and then just move forward, move forward, just super productive actually it sounds slow but actually faster. So tdd is what I have. And then this is why I need, and I make it work. So now then you have like put a goal post and they just fill in the middle right, which is a bit like that, but better. So you have your given you have to expect, and you put in your production code somewhere in the middle. The yellow portion is, I call it test harness, because you need to create this thing to plug in your code. When you have this then your tdd cycle is really good and you, what you know that the good thing is, you know when you are done, but you're done when expectation is met, and your code is good your blue part can use already. But wouldn't it be better, right. If the yellow part is just smaller I don't have to do so many, so many harness test harness. Yeah, so one one thing that I feel writing in a pure type functional language is that it is smaller. I actually write far fewer tests than normal. And I start to realize that actually there are different kinds of tests that I have been writing my whole life. Right. Some are super logic things like if you give me a number. So you're the 100 and I'm supposed to give you the grade, but it's a plus or B or F. So those. Yeah, sure. I do a test for that. But then there are also other test ways really just wiring things together. And this one suffices. In fact, just now the part where I'm showing you the anonymous user. How how when I specify this change, all the code has to add here to it and they cannot even use anything else wrongly. So this kind of test, the need for this kind of windows. I don't have to like make sure that somebody is checking that this person is admin before he uses other attributes. So it just disappears the whole class of errors disappear. The pure logic and things like great becomes a ABC or F is still exist. And people work with type languages. I don't know if people here will see go Java. What are you talking about? What does how can a type change that even replace that kind of path? Like for example, what does this even say? For those not familiar with go, this returns you to things and the idiomatic way of using it is that you get your user and you get your error. You check that there's an error and then you just go back. Otherwise, you are free to use user. Your code convention. But the thing is, what does this type signature tell me this? Did the code just go to the URL that some from Jason and instantiate a user thing for me. Are we connecting to a DB and doing a search by URL and that means the user that I return actually carry a database connection, a dirty flag, things like that. So what if user and error both nail that what do I do with the dramatic code, right? What if both are nailed and the last line when I'm using happily using users on a crash. And what if both are not near what does it mean, right? So these are all the questions that come up that makes type signatures or function signature, not really going to live up to this, this ideal. And this is this is a very standard function that we do as well. Signature the only thing is like, what does it mean? I don't know something is happening. It doesn't even return a value in my show not do it, but of course something is happening. So, I don't know. So this writing this function or this function. Signature doesn't buy me anything at all. That's what I'm talking about. When we talk about function signature as a removing a whole class of test. I'm talking about function signature for pure type functional programming function, you can write it in any language, you receive the argument you return the result. It's more like this reverse is more like string uppercase lowercase those those kinds of function you give it something and it does some memory algorithm if you want a calculation and it just returns you a value. So, it doesn't change anything anywhere else. So given this constraint then that makes the function signature actually mean something because if you don't give it you cannot use it. If you if it doesn't return it, it doesn't change anything else. So, so for to this function says signature for pure type language does give you this more meaningful replacement for some of the expectation and given. So what gives us that you can now use the custom type to narrow the problem surface area, like how I was changing the user and admin and things like registered username. When you when you change that then then your your function is up I'm dealing with this I have to do this. There's no escape. And also, because it, your function only deal with whatever is inside the function body. The code can be your code base can be like hundreds of thousands of lines. It doesn't matter because when you're working on the function body, only the argument and your return value. You don't need to worry about anything else and that's a huge relief. Instead of some other code where like, okay, I'm going to change something here but what what's kind of is the thing that I'm going to ask that somebody else doing something to it. Or, must I do something first before I call this function otherwise something won't work. I don't know a typical scenario even in gold. My previous company send us to a go training and then the, the trainer gave a really good example of, of course in the ghost index in a good context, but like you, you are like you have a user. I say every user. And then you say user send mail. The thing out is that this thing has very little. This thing is like very low info like I do not know what user send mail needs. Does it does it what attributes of it does it use alternatively, he would prefer even go. He would prefer if you say something like mail server subject body. This one is now slightly better because all the dependency of this function is right here. But this one still. This is like halfway there you can you can see the benefit between this and this, this thing is a bit easier to reuse than this. And you, you do not over here I do not know whether I need a secret setup email, that email server. It goes to, you know, this thing needs to be done I wouldn't know, because it's function doesn't say anything. Over here is, you know, you got to give me something here. Being more explicit with the, with the argument does help reduces the concern when you're writing this function body, because you just have to look at this, look at this, look at this. And then you just send off your merry way. And over here, then you may be like, um, mail server. It's mail server already set up. You don't know. I can talk about that later. Because this is in M you have a view function. And by looking at the function signature model is your state your entire application you can say current users who are you logged in or locked out. The page of search results you everything you put inside model model is a record. So, looking at this function, I'm missing that when you need to render, I will give you your model. And you are expected to return. HTML message is virtual dog. You're expected to return me a virtual dog, which will be like this tax H1P, all those things. So being in a, a, let's say this is a, let's say this is go or something else. This does not mean anything. You can, you can do anything you want. You can even retrieve data from database and then fill it in. But this being a function signature in a pure language. It means that I actually have no means of doing anything else other than pattern matching carrying a part like just now how I talk about the user. So, carrying apart the, the details of that I've stored inside model, and then making decision and then returning where maybe a P tag or bull tag, or this. That is all I can do. I don't even know whether that is a HTTP fetching going on. I don't even know that it is, it doesn't matter to me whether it's going on is ongoing is there's no such thing or I'm looking for a mouse click. This thing says, I have a model is all the information I'm supposed to represent it in HTML. And this is the top level view function that you have. So we cover the other stuff together. So when I finish this software engineering portion. So we, we talk about types, types being able to, it's one of the red pill that they have come to work with. And when I reach a language that does not have the custom type just now the enum the, the, the algebraic data type, and things become a bit awkward to do. I don't feel safe or even accurate. I'm trying my data. So then now comes the other portion of the repeal to software engineering. We, I feel like I need to be constantly vigilant. That's that's my sense of, I don't know, for the rest of you, if you are maybe senior in a team and then you have to jaguar the other people, but it just feels like a hill and then this ball you're trying to keep it there. It's not, it's not about whether the ball is high or low, but you're just trying to keep it in one place, but it keeps rolling off somewhere else. So these are sentiments that I have for software engineering. And we can have our best intentions, we can have our best will culture, I don't know, and say that yeah don't do this don't do that. And there's also this very mature thing that always come across about people saying that I am more interested in functional techniques. You see, you can do functional programming in JavaScript. You can do functional programming in Python, Scala and anything else. Then functional languages, I should, I should use, I should use all these things and then borrow some of these good things that we learn from them. It sounds very very good actually it's like wow this is like a matured CTO right. Then we forget this is just programming, but when you add time and other people right this quote again, finally from Go team. Then you realize that these are all just soft social contracts. You can say that you should do it this way you do a part you can do it at that first. And then you have your urgent fixes you have other people's code, you are being pulled to another project and you come back. You wish people do well but I mean, honestly in your own company. How many people are as good as yourself, or even better. And how many, what's the proportion of them needing a lot of guidance. Right. So these good things are just soft social contracts and the compiler is happy your interpreter is happy your test maybe doesn't catch it. And you feel that this is, I call it life with food gun where I work with, I work in a place that can allow things to happen is very happy to do that. And I just add paradigms. Let's do it functionally let some languages are even saying hey you can now also do static typing. I don't want to also do static typing. I don't want to have the option to have to put down to not do it. Life without food done would feel like this, where you don't offer the ball maybe the earth shake a bit the ball roll left and right but you can more easily reach an equilibrium. But how what you don't need to look too much at it. So what was this nice place to talk about. Right, so the warning or fair warning will be that you will not have freedom. In order to get this, you will not have freedom will be taken away from you. You cannot do this you cannot do that. Right, and that is there's even this runtime portion that's protected cannot see it. So basically, for anyone who has worked with go format, or m format probably not because none of you do and maybe go format, or any format that will appreciate like how go format, automatically format to go code, and then a whole category of full request just disappear. I don't even have to talk about it. I don't have to. This conversation goes somewhere else. And then we can focus on important things, I guess, like, not even having the conversation to say let's pick prettier let's fix energy is not even having this initial conversation is just so liberating. No freedom to do that, spend your energy and creative brainpower on doing other things. Which means you cannot anyhow right where you cannot anyhow then you will get your, your life without food done. And where am I. So, this is how a functional program looks like for this is not really like an Elm tutorial but first of all you need to get how this thing piece together these are things that escaped me when I was writing Elm I feel like I was just copy pasting things and then it worked and and I was very unsatisfied because I didn't know what's going on. So this is the explanation, and now I'm why I can appreciate what it does. So this is a pure functional program. And it will be surprising to you that your whole program, whatever you're writing your whole program actually just received argument. And it returns values. Okay. And who does the work if I'm just returning value and who does the work. Then the runtime does the runtime will be in charge of telling you that there's a mouse moving input has changed. We, our, our HTTP get has gotten the response back. So all these the runtime is you with it, actually sending the HTTP actually rendering the dawn calling other JavaScript is all done by the runtime, you're only receiving the arguments and then deciding returning a value. I'm familiar for most of us if we have done any even a little bit of JavaScript. So this is a scenario that form on submit expects a callback. In this callback function, you are given the event. And you're supposed to return true or false. If you say false, then the form does not commit. If you say true, then the form submit. Look at it, your callback function has no control. It doesn't actually make the form stop or do even anything. You just do return a value. And that's it. And do you even know when the event is coming in because it will call you. So this on form submit is actually the runtime the browser the browser will invoke your callback. You just, you just wait for a line and you decide and do the right thing. And that's it. So, with the idea of event callback right. So a functional program you can think of it as one big same callback function, hooked up to all events. You mouse moves. I call it. HTTP response come back. I call it event. What. So when I was doing enterprise Java, they have this phrase that they will say, what kind of Mickey mouse app. Can you do with this right on click hello on some a lower or lower lower this same how lower you're using everywhere. How does this scale. Then I asked you, how does your web app scale. This is a server side app. You have you have your routes, you have your callbacks. It's a very short demo, just three lines in your rails app you would have like probably a lot a lot of routes create user user and each of them have the callback right. And then you will like a this is not the same as this right because I have different callbacks for my route. This is how I scale my web application. Don't forget, because we don't write it, we do forget that there's only ever one entry point. Somebody has written some code to receive all the HTTP request that somebody looks at the request, and then looks at what you have defined calls the correct function. So this is still an entry point to deal with all kinds of HTTP. Right, so you can look at this. This is the same callback on the main, the main is the same callback function for all the events. And nobody ever, at least I know a question whether a web app can scale. So in a pure functional program. That's what happens, the events come in, and then you have this function entry point that decide. I think you are mouse move you go over that you are HD response you go over there. So you decide you route. And then in the end I don't care you just return me something and then the runtime will execute it. The structure is like battle test this is fine. You have been we've been doing this all the time actually your 20 rails controller works the same way. That's okay what one big callback I get, I get your concept. Okay. But why pure functions only right. One big callback filled with pure functions. That's a bit hard. All the options are like string to upper area map least reverse who can be an entire Mickey Mouse function right. This is not an interview what about test. You must do something real. So let's go back to your HTTP handler your callback again. So this one is Hitler's HTTP and you will receive a request. The logic is kind of stupid. But you know, the based on the request for your life. Give you for one. And then otherwise I'll read a file and send it back to you. Right. This is what we know is this HTTP handler. And inside this function, we're doing the response right for one we're doing the file read and then we have a callback. If the file read was successful, we will do a response right otherwise fall for. But instead of doing that, we just changed the way we think a little bit and say that instead of actually doing those three response right and found read, we just return a value to indicate. Okay, I want to write a written adjacent that says write for one. Otherwise I'll return this. So these are data structure as you can see these are data just data. And that this is your pure, pure version of this. Okay, okay, let's say you have that and then then what what happened, who actually put us over. So remember that there is this runtime that gets your return value. So this is also sample like an imaginative runtime. Okay, so the runtime has called your home and notice that you only get the request in the argument. The function arguments only request you have no response you even if you want to write you cannot write. So the runtime calls the request and it gets because the value back whatever value you have said maybe you said right for one of you said we saw. And then the runtime will now very mechanically very dumbly very simply look at the data type and thus the word. So this is very, there's a sheer layer, a very thin layer of logic here, but it's actually no no no logic it's all mechanicality. You return this kind of structure, the runtime will do this kind of work. That's it. So, this is how pure program works. It. And inside the runtime that it does it does the actual thing. So this is live without forget, you have your code is a one huge call back for all sorts of events. And then on the left you will see that message model message is like an event. So what a program is a functional, pure functional software. So when you have to do something, it will give you back the event that happened. And your code will look at something and then return that out something. And it's the runtime will keep the state for you, your funds, your code that you write in Elm remains stateless. If another event comes in to pick off where you left off, as you would want to think the runtime has to give you the model back. Okay, based on just now you were like that. And now there's a mouse click. What do you want to do. And then when you return you will keep the new model and then another event comes in and you say, just now, your state is like that you're, you're now already logged in and then you have a search result and result. Then something happened, what do you want to do. So this cycle goes around and around and around. And in your code, you cannot do many things you cannot do anything. But you can return command that the runtime can understand. And that you will do to fully do it. And then your coaches do for the big one big pure stateless callback function. So, so can this build things. Other people have built this thing I didn't, but the Elm boy is really impressive. He did a whole military in Elm. And then this elm physics where I think the chief was so you can build models and ask it to render it physics restriction, everything. So, these are projects that, well, somewhat able to show you that they can do enough complex things. Yes. I forgot what this hands on is about but this is like the end of the presentation already is maybe just so this is the part where I should this is how one big callback does the whole app right. So, I can move my mouse in those the clock is ticking it knows. And I think what else have I hooked up. You know, so it is the same. This whole program is the callback for all this event. And I think if I do like you will. No, he didn't. Okay, so nice. You went by really fast it fetch some data. And it disappeared again so it also handle click and fetching of the. You handle the click and trigger off sending the HTTP and then manage to pull it back. So, you see this custom type again. This is the same as just now how I was doing user admin user anonymous. So this is the same language feature that you use to do the routing. Remember that there was this. All the events come in. So this is, you use this language feature to do routing. And like early on over here. We usually have libraries, somebody wrote some code to do this routing. I really like that. I can just rely on a feature to do my case statement, break down the information and now here, over here. I have my x and y of the mouse move. I do not have the time ticking key, so it does it does not cross my concerns are separated. I can put this into a mouse move function. And then it will just be somewhere else right mouse move x y. I shouldn't say it's not file. So, yeah, so you just move it away and then now this is your if you look at it like you turn your eyes in one direction you can see that this is your route and is your handler route handler handler. And it's right here you can have all this information there, which is kind of nice to me. So, so this custom type pure functions that I don't have to deal with. Hard to understand code. Just use me with joint. I give you an example where may or may not be fair, but still, so this is really old code. So it doesn't matter. This is just a taste of like what what I mean, looking at normal code to me now. So when I see something like that. Okay, you get you do this. And I'm getting to the booty I instantiate a Shopify client and I list recurring and I loop. So, for example, I don't know what this Shopify app does because it's it called as no argument that's obviously a return value. And I see this now when I see this I will cringe a little bit because it's kind of presumptive that the claims has a shopping that is a string what if it goes strong so it'll be a runtime error. So I don't feel that my code base is in a good place. And when I get this I will have status is here, something will happen. You will you will actually delete this is executing a delete API call. Right. I think, and then over here you will instantiate some data and activate. So you have to trace down the code and sometimes even for things like that, for things like that for even things like this, you have to, there's no way to ascertain what let's say somebody else. Which is to you is true because you did not write this code and do to fully grow this code. It's not impossible but it will take a while. Alternatively, if I have, if I have expressed it, maybe this is roughly roughly the same code, but even if this is, if this code looks like that but it's not a pure language, I still cannot get away with many a great piece of data. And over here, I know that such data that's actually four kinds and I'm ignoring the cancer one because I cannot. I cannot do that. Not allow me to do that. That's a compiler fail me. So it's very clear over here versus over there where like, I did not feel mentioning this. And I know that I get the client from here. Okay, fine. These are all pure functions right so I know that apparently I need a conflict. And then I got claims shop and claims would have this attribute otherwise you wouldn't compile and you would see the type so these are like very easy on the mind, even if I look at someone else, someone else code. It's going to be okay if this status and you'll be a list of one thing. This is the list of one thing and then I see that I'm activating the recurring charge and then deleting it. Don't ask me why I'm just trying to translate the code. And then when it's canceled, it's empty it has nothing to do. So given a chart, I am doing a bunch of stuff. Okay, and then I just put them together. Okay, so, even a list. Recovering charges, recurring charges. And then I see that this is a task so many as this is actually doing something this this will actually make an API call. This is not pulling an attribute from client. And then when the task succeed, I will accumulate the task. So the, the layout of what this piece of code does is more contained and other than I have to look through this look to know whether. You are accumulating anything or is there any early return, you know, or I didn't know that when when this is happening. So it's just more easy to look at now that the functions are simple. You can get the same sentiment in some part of your own code. Sometimes you will be looking at a function and then that the function is really self contained and you feel really good. What happens in Elm is that all of it is like that. Or that good feeling you feel understanding the very narrow function is the feeling that you get for everything. And so these are some other projects and what the companies are doing. And there are a bunch of other. Writing, I guess. So the three attributes to recap is that the custom type is really powerful way of specifying constraint again, it serves as the router for me and the compiler checks it. And then the, the pure functional things. It makes code much much easier to look at. It is contained in a very small area, every every function that you write. You just have to input and output and nothing else changes nothing you don't need to care about anything, but there's something that should be done before this function is called. So that that kind of piece of mind is what I call the repeal. You cannot live without the truly experienced them. About that. So you, you can questions from anyone. Are you going to share the slides somewhere. Yes, I guess so. But yeah, I guess so. Good. Yeah, we will share that later after the talk. Yeah. Just make sure you join the telegram group or share there. Hmm, telegram. Okay. Like, how about what do I just think like a weird in Lee. Ivan, what was your background and what do you feel about life with food gun or no food gun. Michael, I like that Elm goes all the way down to the objects you're working with and can't figure out what is the object you're you working with doesn't have this attribute of that attribute. I think that's, as you say a compiler protects you from making silly mistakes. It's all right. Yeah, it's quite crazy right where like, actually, and to me, I was surprised that it look at his timeline on a bit sad, because it is, I've never I've not implemented this algorithm. I don't know how hard it is probably quite hard. But it's also said that it exists, but it's not done. It could be done. And then, you know, you can save a hell of trouble right. The speed of how Elm does this infer this one. Come very fast. We think it needs to be this, even though that this should be the first name should be a maybe because the inside the code you will see that there's a case office name just and nothing. So you know that it needs to be a maybe. So this part is really really good. That's why it's called a customized type, I guess. So it's not strongly type. However, it doesn't like have a type of restriction. There's two things going on here. So one is that you, you don't have to say the type, the type inference that this people come up with is able to look at this code. The left and the right, you can see that it's not, it's not like I'm saying I give you greeting user needs to be this is this is you didn't say anything you're just using user dot last name and then the type inference know that the user argument needs to be something name attribute. So the ability to infer that and create a type, even though you did not like it. It's really strong and it's now covers 100% of the language, even in little places, you will be able to tell you that over there you said this one and over here it's not like that. So this, these two code cannot work together. You have to fix it. Otherwise, you won't compile. So this inference at this speed really changes things up. Yeah. Very good points. Yeah. And then the custom type being able to be very unambiguous about. So let's say I have type inference. So what right, but I can still do. Let's say I have type inference, and then I do this this way like, okay, user send mail, and my, my code base is just filled with this. It looks really good. Can I use it somewhere. Maybe in my worker. Can I use it somewhere. Maybe in my worker. Oh, does your worker have db. No, so you don't know. You compile you run everything is okay, you know the code works as a composer. But if you write it even even the slight improvement on writing things in this way, you know that actually in order for this to even happen right. You know that I need something something something. So, just swapping it around and not doing so hence I'm not really not OP by not doing it this way or hiding the dependency. It already a little bit of stress from my code base then so that's why I got where I got really hungry and say, I said I want this for everything. I want a, a hybrid environment where I can do this but let's not do it because we have to be nice, you know, like don't do this. I want a language that tells me I cannot even do this. So from one point of view, there are two big features one is a function or the other way is like customers types. It made me feel it's more like a breed of OOP, like object oriented program and process oriented programming. It made me feel like that I'm not sure whether my. So, so one, one thing about object oriented programming is you, it's more like how you organize code right. If we look at how we organize code then we choose the object way to do it. And then you get you get things like that. So, what is going on here. I have hidden the need and the dependency from I still need it. It's not that I don't, it's magic. I just say use user send mail and it works. Right. So this is like, like, like how I mentioned hidden static type, you don't see the type in dynamic language, but your function has a type it has a requirement otherwise it wouldn't run. So this is same. So you, you have to dependency, but didn't say it. And then you're like, okay, is this kind of code organization helpful. Why are we organizing it this way that there's also a huge Alice. A few years ago, like, hey, when you're doing your rails code. Don't do it in your model don't do it here and then there's this whole wave of doing service class. And then that's considered good practice. We look at it and like what's the service club service guys is a registration. And then you probably have one function to give you all the argument. And that's it. So I'm doing OOP. I'm writing one function that resist all the arguments and doing something. So this is good practice. So like the, why am I giving myself a food gun of doing, doing other things here that is this service class anymore. Right. So if we scrutinize a little bit that hey we are picking up tools and then not use part of them. Because we have learned that actually not very useful. I mean, let me let me let me do that. Let me do service class, all the way to the 11 right, like, like that, this one. So mine. Now my code is like that. Everything inside is pure function. And if it's not good for me why why do we allow it. It's a good feel like from a different perspective I guess, like how you should see code can be organized and what is consistent like best practice. So it opens like a new point of view like from another perspective. Yeah. I'm very curious in what others think actually like other than the type inference, anything, take your book, Michael, like for example the service class comments. Did it. It's a good thing in real, right, it is right. Yeah, if you look at this and okay I'm using class, I'm supposed to do this. Right. This is good. Honestly, this is good. I'm not questioning this is bad or not. Then what what what what OOP is this. It's not would you agree it's more process oriented programming. Would you agree it's more tender to lie on the side of process or into the programming because apparently it's not object oriented programming right. So, I guess I call it functional because it's not OOP, but I guess you can be other things. But the, but it's true. But remember, it's true. It must be together. So it's not just like procedure or functional, but it must be pure. It must be pure like, like, like, no matter how much I say that this is good. This is better. This is this two ways are better than this one. But this is still a harder to operate you. I'm sure somewhere inside here, you have your mail server that connect. Right. Right. So this one thing about the pure languages is I don't have to be a good boy, you know, because the language makes me like I take away all your toys. You cannot do any of this. And then when I need to test my email sending function, there is no such thing as a mock. I do not need to even think like you do a code formatting, and then you have full request comments on that and then you think about inventing it this way or that and then you put go format, and then that decision just goes away. What liberated you don't have to think about that. The same thing go for this. I have to write my functions pure. Okay, I read all these things. And then when it comes to testing, the idea of mocking has never crossed my mind, which is very, very different from my 10 years in real. Okay, should we use the database for active record the data or stuff or something something something. You have something like that doing, doing something a side effect, not non pure. Then you have to deal with this before you can even do a registration call, you must mock, mock, mock, and then you make it happen. And then you tear down tear down tear down. The worst we have done is but it's just not preferable whenever you reach a function that maybe like you want to you need to test string to uppercase. Like nobody nobody is upset to test this function is really easy to test. And guess what, if all your code is easy to test like that. It's really liberating and that you don't know that there's no like slow test. You're building like a application that talks to an external service rank say API call, how would you, how would that be? Would you will write test for that or would you say more like you. Okay, yeah, so you will need to write, because it returns a value. So one thing is that is this one is the one that we are guessing some user. Let's look at this. Okay, when I click when I click I want to I want to text right. So this is just a command. If I don't do anything with the fact nothing happens. So this is just a value, CMD, and I say, let's see him, let's see him these equals this for example. But if I say command none, nothing has happened yet because I have created this value. Remember that diagram where I just return the value and then the runtime will do it. If I didn't use it and then nothing happens. So in order to test this, then I just have to come up with a data structure that I can test with. And then I can know that something you define. Correct. And then you can define it. You can define it in this way. So what people do is one, one, you can, there's two ways of doing it. One is you, you don't do that. Those things that are for side effect that you don't do it. Just don't test. Another one is that they don't, you don't return command. You specify my own, my, my, my perform you. Yeah, you call it, you call it perform. And then you'll be like, okay, I need to get, get user. I don't know. And then instead of this thing returning, this thing returning a command, you return perform. And over here you have to return your get user data. And then you test this. If this thing comes in, you give me the get user. And you can just now then wrap this data up into a, into a perform to command function. Right. Perform into a command. Then this one, you don't have to test, or rather you don't need to test it. P and then like case P of, oh, during the, when, when is this, then I better do just now whatever I did, which is that HTTB get something, something, something. Right. So it is pure, but it's just that we, we actually don't have the tools to inspect command. What command are you? So we have to use our own data type. Right. But this data type. So you wrap the API around your own data type. Correct. The one that I can now inspect. So when I check, then I can say, I, I expect it to be a get user. You know, to equal. Did it happen? Yeah, it happened. I see. So you, you don't really write this test because the compiler already tells all the assumes that you'll be getting a get returning a perform object. Oh, but there'll be many, right? There'll be many, because once you change this thing to a get user, all of them need to be this. I cannot do a command anymore. Right. Right. So it tells you the different places that you change to get this done. So, so what my function will do is I give you this message. I give you this model. Did you give me that I checked the model change according to what I expect. And is this perform among amongst the many kind of a form that we can do. Right. And then many others. Is it the exact one that I'm looking for? And then this test is, as you can see, is purely calculation. I give you this value. Did you give me this return value? Then you, I did not mark anything now. The, the, the, the boundary where my program is now limited to various places. Everything in my, in my application has been carved out into a very self-contained my value talk to my other value and this value things that is supposed to be like that and then return, return, return, return, return. So I cleaned the test. Right. So in a sense it's, it's like, it's really stateless in a way because they are pure functions, right? It is pure. You really cannot do anything. No joke. Yeah. And the part that I did not get by like, I'll go to Elm. I learned this thing. What's the syntax? What I did not get was this picture. Actually this picture and maybe later on this picture. Like that it comes in and then it goes everywhere. It returns something and it does. And I, I was also wondering why I picked up, I picked up react right for like maybe two, three years. It was like, yeah, actually funny. Why was I hand like routing is a thing. There's a red router version for version five routing is a thing. And state management is a thing. And then what, what's going on in Elm? Why did I not have to work? Think of that. So routing. Routing is nothing more than routing is nothing more than you have a function. You have a route. You first you will detect a type and you say page. Okay. And I said, okay, I have my homepage. And I have my user profile. For example, let's just do. Name string. For example. And what, what you need to do is you write a router function that receives a URL. And gives you a page. Or maybe page if you want, if you don't, you don't say that you better say I'm not found. Otherwise, if you. Now, let's say I just, I just buy a simple function or a, a URL, URL path. And I split it string split the path by all the flashes of, for example. Okay. Now I have, if it is flash. If it's nothing, right? Then you'll be home page. If it is user, I guess, and then some variable. Okay. Then this will be user profile. Name is. Which we have the language has the pattern matching. Right. And then everything else, everything else. So based on this, I have my rock. And I just have to get somewhere. Elm will be able to give me the URL like what's what's my current URL. So with this thing, I'll be like, okay, just now remember my, my, this file doesn't have a view. So remember that I have even here. Given the URL. Given URL is something, something, something to do. And now I just have to do case. What is my current page? Router of my given URL. And now I can do home page, if it's home page, then let me render the home page. User profile of, of who? Who? Then I render that page. If it's not found, I render the other page. So these are now all like home page profile of. Who.name was it? Not found. You won't do it here. You will be calling your own function. So this is your router. And not even because there is a, there is a library, but you don't have to use it. It's because. Oh, wow. Custom type is really powerful. And if you change your card username. Hey, things break. I love it. Yeah. Okay. Do you change the name to username? Yeah. Yeah. So I'll be focusing on this card a lot. It's not something that I really do in my past experience doing like this. Java, Rails, a goal. I don't focus so much as much as I should. I guess on my data type over here. I do. And because I can get so much mileage out of it. And I am not afraid to do it. You know what? This one, I see, you know, there'll be like other parts. And I may be, this is maybe, maybe not. Maybe it's a, maybe string. Maybe string, then this will be a list of user profiles, for example. Right. Let's say whatever. Then I'll just, I'll be happy to change this so that this is correct. This is like, yeah. Hell yeah. I feel that this is correctly defining what my application is trying to do. And then I don't worry. I'll just fix the errors. Just one by one. My test fail. But now is that I don't have the right test because the type inference is all catching for me. Right. It's catching all the different. Fielding areas. Yeah. And it's not sort of domain. It's not sort of domain first models and then everything else expands from there. Exactly. And then you, the investment you put into talking about this domain. Pays off in your code by holding them to a contract. That's pretty cool. Any other questions? Have you any? No question. Just clean super west. All right then. I think it's really a mind opening. Oh yeah. You have been born on the second flight. Yeah. Yeah. I found the good. Any questions? No other questions. Okay. So if there's still questions and ask me on Twitter. I'm. I'm true. Yeah. He's in teleport. Our telegram group as well. So if you've got any follow up questions. Yeah. More than welcome to throw any. Yeah. The slides to be shared as well. Yeah. Yeah. Yeah. Well, I prefer questions now. If you have any. I want to have. I want to ask you something. Yeah. Yeah. Yeah. No, but how imagine that you are working in a company, right? With with your teammates and whatever. And you try to explain all of these advantages. And you are struggling a bit, right? And eventually you convince them. And at some point you need to go to. Whoever pays your, your pay sleep. And you need to convince him that you want to go that drought. Right. And we know that that drought is not. What is trendy now. So yeah, which kind of arguments you can give to a non-technical person. Good to sell. This red pill. That, that discussion has. It's multifaceted. Right. Yeah. For one, one. Passed out of it. I don't even know where my slide. Passed out of it is to me is this one. They, first of all, first of all, I would want them to acknowledge that this is what they are trying to do. And that this is what they have to do to keep the ball somewhere. And if I don't have food gun. I'm not doing that. It's less. So maybe like trigger the cost mindset. Like, ah, you know, these are things that I do. And then I keep everybody in line. It's kind of, you know, easier to manage, right? Yeah. Then. So in this angle, I can, I think I can convince. But. Another part is this, this red pill I learned from Elm. It's not like monopoly on this. Other languages can. But I don't find many. Other languages. So the problem with picking Elm will be something that the manager has may not be comfortable with even if they're comfortable with this. Right. Even if you're comfortable with this, you'll be like, but the ecosystem is a bit weak. So you will have to weigh in on that. Okay. The ecosystem will be weak. Yes. But does it have what we need? And when it's missing, can we do something about it? Like MPM is like, I don't know whether he has a billion packages or not. How many are you using? How many dependencies? But you're struggling every day with those kind of problems and then you have to do this ball thing. Or you could have just, you know, return a good one. The ecosystem problem is harder for me. I feel because some people may or may not accept that it is viewed off as a risk. But this one is very straightforward. Maybe if you are talking about, hey, we are going to get some offshore developers ring a bell and then a bit like a, yeah, but if I give offshore developers the JavaScript code and then come back. And then you have to, you have to review it and be painful about it. Or you cannot do anything. It's easier to assess and keep it clean. So that cost cutting thing comes in, the ecosystem is a bit harder. I think the Rakuten post, which was somewhere here, no, no, no, no, no. Rakuten post does mention it. They use it for two years. They're happy with it. But then there are some downsides. They're talking about super long post, by the way. Yep. So the, so this will be things that just not as big. But this will be problems about Elm. I feel these are not problems about this tree red tail. Okay. Yeah. I want one, I know that, because I'm doing Elm in a, in a, even more unconventional way, because I'm using Elm on the server. And I'm also not the, the person who, who organized my code, like right off the bat, I can, I can organize my code in the perfect way. And then in the future, you'll be like, wow, I'm glad you thought of it doing this way. I really rely on this. This you cannot do anything thing, right. So what happened is my server time Elm had a, had a slow beat and I was like, big quiz like why, why is this so thing of it as your rails app. Or your goal and web app. And then he has a performance like on this call, something is going on. I couldn't figure out. I don't, I don't know why I wonder why. So what happened is that because it is, because it is like that only events in a return value. I don't know whether it hits you yet, Michael, that it means that your function can run by itself in any other environment. You just have to give this callback function some value. And then when it returns, you just look at the value. So what happened is that my, my server side Elm app, which is like, you can imagine your rails at your goal and server. When I pluck it out, I put it in Chrome browser to run. Given the scenario that made it slow, and I could use the Chrome debugger to like, oh, so this is going on. My entire app was pure. And I can put it in another place to check it out. And my code doesn't even know, doesn't even care. Nice. But it's not my, my foresight. It's not as if I'm so good that I can think of this. Hey, I'm being forced. It's just plain good architecture. And one thing to emphasize is also every language can do this. Your language, you can already do this. You have your callback function events in, you just do it like that. But what happens is this is that, you know, how to do in your, in your, in any other language. Because you can just do some other easier thing. I think that's it. Thank you. All right. Thank you. Thanks a lot. Thank you. Thank you. I will see you guys next time. Bye. Bye. Bye.