The upshot is, I don't want to web application development in javascript; I just don't! I would argue against it even if I were doing work for a client, unless it was some extremely trivial amount of code. The lack of a good module system, strong typing, and a single consistent OO model are in my mind disqualifying. Of course there's no other option except javascript as an executable format for client-side application logic. Luckily we've progressed now to the point where we can write code in a better language and compile it to some sort of javascript which will run on the client side. This comes with many advantages:
- We avoid the badness of javascript, a good implementation language will simply give you strong typing, good OO, modules, etc.
- We get better unit testing and integration with existing mature IDE technology.
- We can, if we choose correctly, share code between the client-side and the server-side of our application.
Beyond wanting a JVM language, I would like one that is reasonably Java-like. Java may be criticized in various circles for this and that, and it has its faults, but its a very vanilla language, easy to understand, easy to write, very familiar. I also need something with good support for compilation to javascript. All of the above listed JVM languages have reasonable javascript target compilation support, so I did significant analysis of clojure, scala, and java itself. I also looked into the state of support for kotlin, ceylon, and dart.
Clojure is a little too functional for me. It lacks any real OO model at all. Clojurejs is a very mature ecosystem that provides all the functionality required to build a front end for a web application, compile to javascript, invoke existing javascript libraries, etc. However I just don't feel that the learning curve is worth climbing, and it is a steep one. If I was a LISP guy then I'd probably just go with this, but I'm going to pass.
I did a pretty extensive examination of Scalajs, including making a PoC of a front-end. Its a rather tempting idea. There's good support for React, which is an excellent front-end, and a good bit of support. Still, I find scala to be dense, obtuse, and hard to read. While I was able to master the language to a decent extent it would require a lot more time to fully master. I also found that the Eclipse support for scala/Scalajs is middling at best. Syntax highlighting, completion, and other features work intermittently and I spent many hours fiddling with things, and still never got Scalajs to consistently build my project every time. The resulting code is obtuse looking and I'm far from certain I've really achieved a good design. It would clearly require a lot of head scratching to get to a full web application this way. While scala is closer to a standard OO language than clojure, it still has a steep learning curve.
Of the three languages I checked out thoroughly that leaves java itself. Now, many years ago Google produced GWT, a large client-server app framework which relied on target compiling java to javascript. There were two issues with this, the framework was very heavy, mandating specific ways of accessing data, a specific application model and structure, etc. Secondly, javascript and browsers were much cruder in 2006 than they are now. As a result the target compilation was fairly unreliable and insuring cross-browser functionality was problematic at best. This earned GWT, and the notion of java as a front-end language, somewhat of a bad rep. Google eventually developed AngularJS as an alternative, and turned to Dart and then TypeScript in an attempt to make a lighter weight and more reliable construct.
However, as much as the entire mass of the GWT framework has no appeal for me and doesn't fit my idea of what I want to do, the GWT compiler itself is an excellent tool! Several different groups have continued to evolve the compiler and various light weight approaches to client-side java which simply use it as a nothing but a compiler. This is a very attractive concept. Currently I'm looking at VertxUI, which uses this strategy along with some simple libraries which provide something very similar to React, but written in java instead of JSX/javascript.
As for kotlin, ceylon, and dart... There doesn't appear to be a JVM incarnation of dart, though it seems like an obvious idea and dart has targetted other VMs, oh well! Ceylon has what appears to be a pretty solid javascript target compiler, some libraries, etc. Kotlin also targets javascript and has some active development. Neither of these two languages seems currently to have quite the level of maturity on the client side that java, scala, and clojure have. Ceylon seems to have limited traction in general, although it is a decent language. Kotlin appears to be gaining momentum, is a lot easier to use than scala as a java programmer, and has a decent amount of client-side activity. Still, neither of these seems to have anything quite like scalajs or java itself.
A final consideration is integration with my tool chain. I touched on Eclipse a bit earlier with respect to scalajs. I didn't get a chance to delve into kotlinjs, but kotlin is very heavily Intellij biased. I'm sure there's Eclipse support, but it is more of an afterthought. With scalajs there is a full suite of plugins for Eclipse and Gradle (my build tool of choice) although the community seems largely focused on the sbt command-line tool. I didn't evaluate ceylon deeply enough to discover exactly how well I could use it with Eclipse/Gradle.
VertxUI/GWT compiler seem to be rather winners here. Vertx itself has very solid Gradle support, and this seems to extend to VertxUI as well. Given that the implementation language is java, the Eclipse language support is sterling. I'm really looking forward to digging in and generating a PoC with this on a par with what I did for scalajs. It looks like the code itself will be MUCH more straightforward than the equivalent scala.
No comments:
Post a Comment