andrewoma/reakt

re-write for Kotlin 1.1.3? :)

Closed this issue · 6 comments

#11 says "incremental compilation" needed. I wonder if the latest 1.1.3 has this?

I found this from https://stackoverflow.com/questions/44837218/what-is-correct-version-match-between-kotlin-gradle-plugin-and-kotlin-js-library?noredirect=1#comment76655251_44837218

Thinking about re-writing this for 1.1.3 unless someone else is?

from https://blog.jetbrains.com/kotlin/2017/03/kotlin-1-1-1-is-out/ "Gradle incremental compilation is now enabled by default. You can still turn it off as described in the documentation if you need to."

Hi, as far as I'm aware, incremental compilation is for the JVM only at the moment (not the JavaScript backend).

In the mean time, have a look at https://github.com/Kotlin/kotlin-fullstack-sample

It includes React wrappers

thanks, looking at it now. What I liked about reakt though was:

  1. no npm
  2. react js files are in resources dir just like css files are
  3. you can run the todo example from file://index.html no web server required
  4. gradle handles building everything including the javascript files the browser will load

over in kotlin-fullstack-sample world I now have:

  1. npm requirements
  2. webpack required to build all the js via http://localhost:8080/frontend/frontend.bundle.js i.e. this url isn't a file but a route, and the web server running on 8080 has to assemble it all
  3. there is no index.html file in front end. You have this port 9090 and port 8080 proxy system.

So I'm going to try and switch my app over to kotlin-fullstack-sample style, OR better yet, I'd love to bring the example in kotlin-fullstack-sample back over to your gradle build system.

(I had an app working using your reakt system but when I got to this part: https://blog.frankel.ch/kotlin-front-end-developers/ implementing google maps, I realized the kotlin was out of date.)

Hey, I am the guy that added the gradle script. When I did it, I strictly tried to stay as close as possible to the kotlin gradle guides. I dont know, if its the suggested way now. Especially the integration into IntelliJ.

However, you should consider this project (as said in #11) as a proof of concept. I played around with it some time ago and I see two main problems:

  1. The code generator based on a Typesafe binding, that is not up to date (at least, I found no uptodate definitions).
  2. The builder pattern used to create the vdom did not make use of all the features, that Kotlin makes possible. So you can still write kotlin vdom builder code that outputs invalid html, which should be impossible (compiler error).

Both things are non trivial to fix and result in a more or less complete rewrite. I for myself, failed multiple times - mostly because of the second problem.

Also consider, there are some other frameworks, that do much of the stuff, react does - but with a WAY smaller js footprint (and simpler apis).

thanks @synopia this good info. So I'm starting a green field Kotlin JS project and the requirements are, no full page screen refreshes except the 1st load. And then something like:

https://github.com/turbolinks/turbolinks

but with more intelligent vdom incremental changes than just swapping out the entire body tag like turbolinks does. Also, I want to avoid ruby language if I can.

I looked at https://preactjs.com and https://vuejs.org but didn't find good Kotlin support yet. Can you recommend the best option for Kotlin and a single page javascript app that makes AJAX calls to some api backend?

I certainly would NOT use this as a foundation going forward - I built it as a proof of concept to see how viable KotlinJS was at the time (years ago).

Unfortunately, I found it wasn't viable and didn't take it any further:

  • KotlinJS didn't support modules (now fixed)
  • KotlinJS didn't support gradle (now fixed)
  • Compilation times with nested builders were slow (now fixed)
  • No incremental compilation (still not fixed)
  • No way to build for mulitplatform (sharing code on JVM/JS) (still not really fixed although underway)
  • No natural way to run unit tests within the IDE (still no way apart from invoking things like Karma runners).

Also React at the time wasn't pleasant to work with, in particular you couldn't use standard classes and had to call React.createComponent and messed with this references.

I'm still not convinced KotlinJS tool chain is good enough yet, so won't be investing time into it (although I'd love to use Kotlin for front-end development). Unfortunately, it doesn't seem to have much of priority within the Kotlin team.