The best language with HTMX is Kotlin. It offers string templating, extension functions, and trailing lambdas. You can create your own domain specific language and build your own HTML components. It’s powerful and clean, and a preferred way of doing things. No weird dependencies or cross compiling needed. Just the language with no extra stuff.β¨
Table of Contents
ToggleIntroduction π
So, I’ve really been enjoying using HTMX and Tailwind to build websites. Mostly, because I’m mostly think as a backhand developer and HTMX allows me to build reactive UIs without needing to use React, and Tailwind allows me to build nice looking UIs without needing to think too hard, especially when I use Tailwind components.
Why Choose Kotlin with HTMX? π
This is a simple example of HTMX that I’ve built. My problem with using Golang with HTMX SSR stack is that people tend to prefer using Golang for it, for some reason, and I just really don’t enjoy the templating in Golang. So, I want to make the case as to why, maybe for your next project, you should consider using Kotlin paired with HTMX to get a really nice, reactive, clean UI.
The Great Features of Kotlin π
Before I get into the demo, I just want to share some things about Kotlin because it’s not a very common language. But there’s lots to like about it! I’ve got a basic "hello world" running. There are three features that I want to show off of Kotlin. The first one is that the string templating by default is very nice.
| Feature | Description |
| ------- | -------------------------------------------- |
| Strings | String templating by default is very nice |
The second feature is a little bit better. Usually when you define a class, you define functions inside it, which is fine and all but it’s kind of mixing data and functions which is not great. Kotlin has this nice feature called extension functions.
| Feature | Description |
| ---------------- | ----------------------------------------------------------------------------------------------------- |
| Class Functions | It's kind of mixing data and functions which is not great. Kotlin has this nice feature called extension functions. |
The third feature is trailing lambdas. Kotlin lets you create a function that takes a function, and you can do some really cool systems where you basically build your own domain-specific language.
| Feature | Description |
| ---------------- | ------------------------------------------------------- |
| Trailing Lambdas | Kotlin lets you create a function that takes a function, and you can do some really cool systems where you basically build your own domain-specific language. |
Building UIs with Kotlin for HTMX π»
Now, you don’t have to use XML to write HTML, you can use Kotlin with type checking, auto-complete, and all the variables.
Final Thoughts π
Kotlin is my preferred way of doing things like that. It’s just the language without any extra stuff, and that’s what makes this my preferred way of doing things.
Related posts:
- Title: Kotlin Coroutines – Task Management & Cancelling (Part 7)
- Dr. Pal responds to the controversy surrounding his comments on C-sections and red meat in the @BeerBiceps Podcast.
- PM Modi set to lead the inauguration of Ram Mandir. Will Congress attend? Dilemma for India. Ayodhya event raises questions.
- Ruby and Bonnie emphasize the significance of diligence in various professions and careers.
- It’s the end…
- Project – Dashboard in CodeIgniter 4 – Part 12