Why Kotlin Is The Best Language (to use with htmx)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
start start I've really been enjoying uh using HTM X and Tailwind to build websites um pretty much all my side projects I use HDMX Andel wind uh mostly because I'm mostly think as a backend developer and HDMX allows me to build reactive uis without needing to use react and Tailwind allows me to build nice looking U eyes without needing to think too hard especially when I use [Applause] okay I'm already loving this that was fantastic that was absolutely the guy nailed it the guy nailed it so good right there just came in hot came in ready came he just was just Juiced the man was Juiced here's the deal I want to build reactive UI and I don't want to use react got them I don't I'm not good at styling I use Tailwind got them right like that's great this is great we'll go 1.25 to win components and in this example of hmx I've built this dummy project where obviously this isn't a full render every time so we're just using HDMX to reender this bit and then the UI is done using to and UI so this is pretty much as simple as it can get but my problem with to and HDMX SSR stack is that people tend to prefer using goang for it for some reason and I just really don't enjoy the templating in goang I've been called out I've literally the shots have Temple the temple the this okay hey first off I love that you have an opinion okay can we just be real for a second can we actually have a can we can we finally like can we finally have some Dev that has an actual just [ __ ] opinion for once is this not just so annoying that every dev has to preface everything they say with 900 if statements just to make sure that everyone's feels feel good this guy just comes out right away and be like you know a lot of people been likeing go I think it's a bad idea love it love it I love it he is using a Mac instantly judged probably uses vs code but you know what we're going to we're going to forgive him for that last miles dude attacking the Church of go I know and now the Church of go will nicely send their zealots after him and perhaps he will find himself waking up to some friends in his house that love go okay so I want to make the case as to why maybe for your next project you should consider using Colin paid with hmx and tell to get a really nice reactive clean UI but before I here hold on I'll try to turn it up a little bit it's kind of hard cuz now cuz now I'm going to start getting into that weird peing you know because I'm already at 100% I'm already at 100% I can't really go any higher I'm sorry this is uh this is as this is as fast as we're going to go I'm not going to go any higher I get into the demo I just want to share some things about C because I know it's not a very common language um but there's lots to like about it so I've got a basic hello world running there's three features that I want to show off of col the first one is that the string templating by default is very nice so if say that I can do that and that works just as this I guess it's kind of like JavaScript but I don't have to use weird brackets I don't have to do F Sprint F or anything like that I can even put things there and just make it a bit more complicated say this for example I can make it go to uppercase so that's feature one okay one okay basic string interpolation I mean python has that right okay go does go I don't think go has any version of this other than uh what is it what is it format format format Sprint yeah I mean I get it the these are more convenient Sprint f is you know is not is not as convenient as this I can totally get it you can you can have raw strings though okay calm down buddy come in here we're not raw dogging strings right now okay using a little bit better usually when you define a class um you define functions inside it like this yeah um which is fine and all but it's kind of mixing data and functions which is not great so we call I like mixing data and functions okay so you're already you're you're emotionally trying to bruise me okay I like that data I like methods I like methods I like methods I think they're Superior for the LSP uh development lifestyle has this nice feature where you can uh declare functions on existing objects like this to say I want to add a function to square which returns an integer and then I can use f uh to access whatever is here and these are called extensions functions so I can add it to my custom classes or I can add it to existing classes um so what I can do here is I could do two do square and this will print four no I understand Russ can do this you just have to you just you just literally have to do a lot more to make it happen okay you have to do a lot more to make this happen he's just giving okay so how's this related to hmax he's giving you some some he's giving you a little dude this is the foreplay to the actual problem so he's given you some things that are going on honestly [ __ ] uh extension methods I I love I love traits I love the ability to uh to to extend things that already exist it's really really really good okay so what is this times this well this is the thing that it points to this would be an integer it's a it's a function on an integer um the second feature I want to show are trailing lambdas so usually you can create a function trailing lambdas and this is super common in many languages I'll just Add a prefix to make them obvious and then I want to make it take a function um which Returns the string and okay okay and what I'll do is I'll print the prefix and then the result of the function okay okay that's all fine but what colon lets you do is when you have this at the end it lets you do this cool syntax where instead instead of doing it how you normally would and doing it in here say you do that in here which is a function that returns um one whatever what I can do is move it out so now this is out here and I can also just emit the return this is valuable because when you mix both the extension functions and the trailing lambdas you can do some really cool system where you basically build your own domain specific language so I have an example here which is VOR which is the standard web server for I'm not super into domain specific languages but this route thing does look really cool okay I'm lost so this route is a function that has a path prefix then it has that trailing Lambda the last argument is a Lambda and so therefore they're having they're literally just route components and then this is like a function usually DSL suck I I've never programmed I've literally never programmed cotlin and come on come on catch catch up boys okay catch up all right um I don't know how I feel about this I think it's kind of cool trailing land is love I I think I kind of like it I think I kind of like it okay ketchup pretty much does this so you have an application. module which is an extension function that you use and then inside this you have some a that you define the routes just like this okay so routing must be a a a function that is just a trailing Lambda is that what's Happening Here is routing just that see this is the one thing I didn't get because I saw that right away and I saw that routing does not have parenthesis and so I couldn't tell if it's being called as a function and then that okay yes it is okay so if it does not have any arguments then you can just call it as is and it does this whole routing genus stuff useful and super clean but it's not magic either like I know how these works I can write these and at work we often do we write um for testing we write our custom little dsls so that we can set up the scenarios exactly how we want in unit test um in a declarative way and that's basically what this does it lets you create declarative code inside an imperative language which is super useful and for this for example where this isn't very imperative I'm just trying to Define rout each of these but where this gets taken one step further is that now I do feel like this is pretty cool so so far I really do like this okay we're about to get wild aren't we we're about we're about to get wild aren't we we're about to get a little bit we're about to this this is where it's going we let we let we let Tim Cook and I think an iPhone might have just come out we're not sure what's about to happen here I think we got something good this is looking sweet don't have to use XML to write HTML you can use this thing with types checking and auto complete and all the variables like I'm here this is my HTML but I just Define a variable or everything and my classes are just set it makes HTML not XML which is so nice um because even react jsx is still XML I don't want to be writing XML I don't want to be touching magic I I want to use just the core mechanics of the language in order to create something that uh renders how I want D I don't know okay first off okay this first off hold on this right here stop with this okay nobody uses react without jsx okay I've never seen somebody literally react. create element and then properly call that function whatever the arguments are with it okay nobody does that we got that that just cannot be an argument we cannot have that as an argument because it's not a real argument okay it's not a real argument but that's what he wants no well well I mean it's but yes but this is way more con like I totally see what's going on here like this is actually very easy to read it's this is very compelling soan did it well yeah soan also wrote a a server in in what this is not easy to read okay whoa whoa whoa whoa whoa whoa whoa whoa whoa whoa no it's not what is not easy okay pam pam pam you got to hit me with this what's not easy to read pam pam Pam what's not easy to read about that wait hold on you're worried about a couple of those Pam okay Pam okay Pam what's the alternative what is the alternative Pam because this is what you get this is the alternative pam pam pam because what I see right here that I think is really nice Pam did Pam leave pam pam pam lost it Pam was like here Pam uh Pam I'm going to put you I'm going to put you right here so I I don't I don't miss you okay I I got you right here so you know when you when you when you're ready to respond I I will catch it okay I'm going to catch it don't you worry we're going to catch it for whatever reason this apparently is the world's worst interface um okay that not a let's see not a couple a couple 100 XML or HTML HML is better is it how is it better though okay so I guess your argument would be this okay so I let me try to like reason about your argument before I get all before I before I lose it but right now what I what I think I hear you saying is that when you look at this right here you cannot immediately tell what is it closing is that correct so due to the fact that it's a parenthesis as opposed to a slash closy header slash that is where the confusion comes in okay okay I can understand that argument the downside of intelligent dsls is that you lose any of the other HTM HTML tooling like LSPs and coloring Fair sort of sort of fair fair sort of maybe I don't know if that's true with this right like I don't know how cotlin works cotlin is obviously it could have a great API for returning stuff so I don't know if that's true uh this right here I don't know for some odd reason I could like again we're looking at a pretty small amount of stuff right here okay we're looking at a pretty small amount of stuff right here and what I see is very readable I would say that this is no less or no more readable than jsx by any any stretch of the imagination this is very sus you think it's very sus I don't know I really like it I'd have to use it I guess my small time and O camel slightly changed me a little bit and this feels easier to read if that makes sense jsx is not readable yes if you've ever done anything with larger jsx it gets really unreasonable really really quickly it gets just as it gets it gets super super diff difficult so it's harder to visually parse because years of web dev condition uh conditioned me for parsing okay fair but that that can be broken right you never want to optimize just because that's the way things have been done like genuinely the best thing you can do for your career and for your life is to never let what feels good and comfortable continue just to be the thing you do because it feels good and comfortable you should always be willing to try other things um I don't know to me this is super cool and I would love to like honestly I'd love to play around with it the thing I don't like about it is that I don't want to have to derive all these things right I wouldn't want to write all of this and so if there's like a sweet ass library that can just do it and has all the H1s and divs and headers and everything for me that could be cool how do you define can I do custom elements very curious right if I can if I can do custom elements yeah maybe that'd be pretty pretty exciting uh there probably is I I I would hope there is because I assume they just have to fulfill a contract that they just have to return some sort of interface whatever they call column in cotlin like it just has to fulfill some sort of data shape and we're good to go you can 100% do custom elements the div is just an interface with extensions yeah okay I don't this actually looks pretty cool so he's an example I don't know I I actually kind of love this I kind of love this I think I I think I could get into it I think I could get into it pretty deeply of the dashboard as you can see I'm just creating these um and then adding text it's looks a bit daunting at first but it's so much easier to abstract because I can take it one step further and here I've created my own extension function which means I can basically create my own HTML components inside of this system and I can pass parameters in here if I want to oh yeah he has all these little like events calendar all this kind of stuff and then here for the index I pass in here and then I use the dashboard here and just pass it in like a normal HTML component because I created just like these were um and I can copy this if I want to I can do the exact same thing which is super powerful and then here this one's a bit more complicated so the Navar I pass it the tabs that I want and then I I could just do a for by the way this just looks like standard HTML by the way I mean there's you're not getting I mean this is this is this is I mean this is just div soup boys boys boys we got div soup do you like Temple more Temple is really good yeah Temple is really really good and so it's hard to say like the pro okay so I always come to the same thing and I've said this kind of a few times now which is the complexity of expression in a language allows you to build really incredible abstractions which allow you to spend a lot of time building incredible extraction or uh abstractions which can be super convenient and look like this and super clean and nice and seems really really nice but at the end of the day the one thing I worry about is that sometimes you spend all this time building the abstractions themselves for this really clean version of programming but you end up not even using most the abstractions you create because that is like product development you end up spending all this time in the in the Act of building something not in actually making something functional and good and so I always have this problem right here which is it's it's the same problem with rust rust I spend all this time creating the thing to create the thing whereas go just says you know what we're not going to allow that you can't spend your time creating the thing to create the thing it's just not it's just not there it's just not an option and so it just feels very very very easy to not fall into this trap of ever trying to create a nicer way to create things it's like this derivative development that happens and that would be my worry about using something like Colin is that I do a lot of derivative development but I like creating things yeah I know that's the problem is I would I would I would I would do a lot of that I thought the goal was type masturbation pick we are this is I mean this is a long session this guy is this guy's been edging For What appears to be months and my Fe to this man has this man needs to call the doctor immediately render what I want and this is a super powerful way to use HDMX and tawin um because is really nice and the templating is just the language I don't have to add any weird dependencies I don't have to cross compile I don't have to do some string templating thing I can I can Mo to a file if I want I do like that too like I think all the arguments he's making are actually really sophisticated and really well done and I think that if you're if you're missing any of the arguments he's making you're just a damn fool you're you've been using JavaScript for long that you think that that is the only way to do things there is something that's really nice about like a dependency free development experience is incredible it really truly is like the less dependencies you can have the less steps you need to get to the end point is like it's it's it's absolutely such a joy to work with and so it's like when you can just have I'm using a language and just the language itself I have built to make the thing it go it just feels so good but npm dependencies are free they may be free but they do have so much interaction with how you do your building right typescript the compiler is free TSC is free on YouTube but guess what you still have to go through all of the things that allow you to even use typescript and so that's kind of what my like that's what I'm seeing right now is that you can have a dependency free really nicely abstract like if someone were to make a really concrete uh really well thought through library with all of this kind of here in a way to specify it but then you never need to cross compile you just do this that could be that could be pretty cool a Vite starter template though yeah you know what the problem about V starter template is that uh you stop being a starter project dog you start being a real project that needs to get real things done and you start realizing that you need to trade things out due to constraints or changes within your environment you go from one person programming to 100 people programming well guess what happens your little Vite preconfig thing becomes a team it becomes the build team there's a team that literally goes and makes sure that your JavaScript an interpreted language gets compiled into a more interpretable version of JavaScript and there is multiple people working on this one singular thing okay you have to admit that there's some level of crazy to that entire experience know I can leave them in this one uh I can override these I can create my own ones I can say I want to use create enums for Tailwind classes or create abstractions and basically create a normal CSS file using Tailwind classes I can do all that because it's just the language without any extra stuff and that's what makes this my preferred way of doing things like that absolutely thought that was amazing I'm giving that the thumbs up this was actually a really really this was this was really good this was really good Levi that was really great people go give Levi a follow that was really really really really awesome Levi freaking awesome I just want to let you know oh my goodness I am Levi's first subscriber I am Levi's first subscriber let's go gosh I'm number one the man's number one that feels pretty cool that was great honestly this was great I thought this was really really well done hey get get get the guy up to like a 100 sub Subs if we can okay if you like what he was doing I hope that he builds more because this was actually a really good video this was actually one of the best honestly this was one of the best tech videos I've seen in an incredibly long time it was so to the point and he gave a really great foreplay and then it just became the thing it was so good it was so good and he showed you all the stuff beforehand so you could really follow along because I didn't know anything about cotlin I'm not a great ciner and so it was very very good I loved it I loved it it was great I love it I love the foreplay
Info
Channel: ThePrimeTime
Views: 109,957
Rating: undefined out of 5
Keywords: programming, software engineer, software engineering, developer, web design, web development, programmer humor
Id: zJNkIJCQohU
Channel Id: undefined
Length: 20min 54sec (1254 seconds)
Published: Mon Feb 19 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.