I have long wished I could write React with Kotlin...
# compose-web
n
I have long wished I could write React with Kotlin using a "KSX" syntax, no builder stuff. I used ChatGPT Deep Research to create a spec for it, I want it to actually exist so bad! If you're curious about this too: • ChatGPT Deep Research spec for KSXReddit Poll to gauge interest
j
This syntax is basically the original design of Compose when it was targeting the Android view system (before Compose UI existed).
It was implemented in a fork of the Kotlin compiler. The Kotlin team at the time rejected both this syntax as well as adding a mechanism for a compiler plugin to escape/override the lexer/parser to add such a syntax out-of-band.
The syntax also had some intrinsic problems... but I honestly cannot remember what they were. I do remember that one of the problems with switching to functions was the combinatorial explosion of parameters, as you no longer could accept dp/px/sp/etc. with a single parameter but instead need an overload that varies the parameter type, and then you have to do that for every parameter which varies.
But that predated the modifier system existing, which I think obviated 99% of that problem
h
There is also Compose HTML using Kotlin/JS and targeting HTML DOM, with DOM/react/angular interop.
n
Thanks for the history links @jw, super interesting! Basically I have tinkered with Kotlin/JS and I am impressed. But then when you try to leverage the broader web ecosystem it just looks so clunky to the point that it's uncompetitive. Making Kotlin/JS work as smooth as it does seems like herculean accomplishment, but it appears to have very low adoption because it hasn't put any tooling effort into blending in to the ecosystem around it. It's not a clean poll obviously, but these are the results so far:
j
Yes I believe it is uncompetitive, but I also think attempting to compete is a waste of time.
You're much better served (no pun intended) with svelte or vue or, if you absolutely must, even react and TS for building websites.
The reason to use Kotlin/JS is that you already have Kotlin code, and then I'd rather then focus on TS export and interop, like they are with Swift
☝️ 2
🙌 1
No one who is objectively looking for a language to target the web would ever choose Kotlin
s
This. Kotlin/JS is great to share your business logic, but you'll have a much better experience writing the actual UI with something like Svelte (or even React + Tailwind if you want something that feels like Compose).
For small things, Compose HTML / kotlin-react / etc.. could do, but for anything serious a proper JS framework will be a smoother experience, even if you have little web experience. The entry bar to web-native tools is low and there's an abundance of resources to help you along the way. (though Kobweb seems to be making some great strides as a serious solution, but it's still far from it)
❤️ 2
r
I generally disagree with these bold statements. Developing web applications with Kotlin has been a really great experience for me, and I have built some serious applications over the last few years. Still I think such new KSX syntax is a bad idea, because it takes away the most important advantage - the Kotlin language itself.
👍 2
j
But that's because you knew Kotlin. Isn't your last statement sort of agreeing with that?
I'm not saying you can't make good web apps with Kotlin
I'm saying KSX is an appeal to people who don't really exist, because if they're in the position to choose between languages for the web without an existing reason to choose one then Kotlin isn't a good choice
👍 1
🤔 2
n
Just to follow-up, here is where the Reddit survey landed: