Re:From TypeScript to ReScript
by smallerfish on Wednesday January 12, 2022 @09:23AM
(#29906625)
Have you had issues around the distribution size? I've been playing with building a kvision based app for the past year as a side project, and I can't get much lower than 2MB. I suppose I might try a "hello world" with compose web and see how that shakes out.
Re:From TypeScript to ReScript
by jillesvangurp on Wednesday January 12, 2022 @10:52AM
(#29908091)
It's a concern but it has been getting better. Dead code elimination (DCE) in kotlin.js has improved in the last year as they rolled out support for the new IR compiler with 1.5 and 1.6. It's still not perfect, but it's getting there.
For what it is worth, we are using the Fritz2 framework, which is quite nice. That was definitely a bit of a bet a year ago but we've stuck with it and they are getting close to a 1.0 now. We might switch to compose web at some point but it looks a bit early for that right now. One plus point with Fritz2 is that it comes with a nice component library, support for themes, etc. So you can get up and running pretty quickly without spending a lot of time on custom component design.
If you think of javascript as a compilation target rather than a language, typescript is just one of many languages that can target that. And I'd argue that even javascript these days is transpiled to what runs in the browser. It might be the same javascript dialect. But minified/obfuscated etc. But more commonly, it's more than just that. In short, modern javascript development involves transpilation/compilation. It just does. The whole scripted/interpreted vs. compiled distinction that people used to make is less relevant these days. It pretty much always involves some kind of compiler.
And if you are going to use a compiler, you might as well use a proper one that does some useful stuff like prevent bugs, check types, optimize, etc. Typesystems have come a long way in the last 20 years. In short, there is no technical reason to be using Javascript exclusively in 2022. Whether it's Clojure, Elm, Kotlin, or other languages; they each have in common that they have js transpilers that work quite nicely and type systems that are definitely a level up from the unholy mess that is Javascript's "it could be a string or some object or undefined, but who the hell knows". Some people actually prefer that. Other people want no part of that kind of sloppy typing. And the good news is that there is no technical need to have any of that.
I've been using Kotlin-js for the last year for a web application. The tool chain has some rough edges but the language is a joy to work with generally also for browser development. Definitely an upgrade over typescript, which I've also used in the past. And we have quite a bit of multi platform kotlin code that we also use server side. A lot of what we do is increasingly multiplatform and not explicitly dependent on the JVM. We could choose to use that code also on Android or IOS (via the native compiler). With compose web and other emerging Kotin web frameworks and the upcoming WASM compiler for Kotlin, I suspect it's going to become a lot more popular to use for web applications. With WASM, transpiling to Javascript will ultimately become a thing of the past. If you are compiling, you might as well produce WASM. Short term there are some open interoperability issues with browser APIs of course. However, nothing that can't be solved long term.