My team has recently made the jump from using type...
# react
s
My team has recently made the jump from using typescript for our node.js servers to instead using Kotlin, and it's been a hit so far, so now we're investigating the tradeoffs of using Kotlin also for our web UI layer. Can anyone speak to the trade-offs of using Kotlin + React for Web UI vs just using typescript?
t
1. Which additional libraries do you use for frontend part? 2. Which bundler do you use? 3. Do you use lazy loading for separate pages?
s
1. I don't know right now. Engineers pull in what they need as they need it. If a UI component exists that they can use, they will typically pull it in. SweetAlert comes to mind. 2. Currently we use NX or react-scripts depending on the project. It all uses webpack under the hood I think. I understand a move to Kotlin will be abandoning these other approaches (and this is also one of the appeals of moving over as well.) 3. No... We probably should though. Is this something Kotlin would allow?
b
Kotlin.js comes with substantial initial size bloat, so I would not recommend it for small SPAs
s
The initial size bloat is because of the stdlib though, right? KotlinJS doesn't generate JS that's substantially larger than js code though, does it?
I mean - I assume there are the obvious exceptions, like enum classes...
b
Yes, it's much less noticeable in medium/large apps
Just create a hello world kjs app and look at your bundle size. It's gotten better with ir backend, but it's still substantial.
Plus kjs doesn't support es6, so no treeshaking after dce
s
@Big Chungus
no treeshaking after dce
Isn't dce treeshaking? Those two things are synonymous in my mind.
Are there plans to support es6 in KJS?
b
Dce is "kinda" like treeshaking, but not as powerful and doesn't integrate with npm lib treeshaking
We're all waiting for es6 support now that ir backend is stable
a
As a both expert typescript web and expert kotlin developer , I can say I wouldn’t recommend using kotlin for react if you can build in typescript. The simple fact is that there is so much direct tooling knowledge and resources devoted to typescript and react.
Solving issues, sharing knowledge, etc is easier. Unless you can translate between typescript js and kotlin and understand how kotlin uses yarn
That said, it’s team dependent and knowledge dependent.