Full Stack Web App Example With Kotlin 1.1

Not sure if Web Development is the right category for this thread. With the stable release of Kotlin 1.1 around the corner (the release might occur in a week or two?) have JetBrains thought of developing a sample full stack web app using Kotlin 1.1? See the old presentation on type safe web with Kotlin. The Kara framework would be a natural fit for the sample app however it needs an urgent update to support Kotlin 1.1, and the website requires a major overhaul (much of the content is out of date).

Just to clarify the entire sample web app would be developed using only Kotlin as the programming language. Doesn’t exclude using other languages (non programming ones, NO JavaScript!) in the development of the web app. Would make sense to have the sample full stack web app developed after Kotlin 1.1 is released, and published on GitHub under the Apache 2 license.

Kotlin Pet Store?

1 Like

Can’t download the Pet Store sample app. All the download links are broken.

I don’t checked the Oracle’s site.

Java Pet Store is famous example for standard Java platform, like “Tour of Heroes” for Angular application.

Do you would a simple Kotlin client/server web application?
May be a great idea for a popular project on Github, there are some volunteers?

Know about the Java Pet Store example. Big problem with Pet Store is that it is likely to use some custom JavaScript. Not opposed to Kotlin (on the JS/web platform) using JavaScript libraries provided Kotlin is used to completely handle the web front end. Kotlin 1.0 obviously doesn’t have stable JS support but 1.1 does.

Definitely after a simple Kotlin client/server web app with nothing too fancy. Web app should be simple.

Looked extensively at Kotlin based solutions for developing a web app. First one is Kara which has been mentioned before however it isn’t being regularly updated, no integration with Bootstrap & JQuery, doesn’t have Kotlin 1.1 support, and isn’t suitable if you only need something to cover the web front end. Another one to point out even though it only covers the web frontend is Yested (framework). While it does have some limited Bootstrap/JQuery support documentation is seriously lacking, doesn’t have Kotlin 1.1 support, framework has undergone a rewrite (is highly volatile/unstable), and the View Model approach is overly complex. Also I didn’t like the fact that Yested was doing DOM access at the low level which doesn’t ensure that a web app will work properly across all major web browsers.

What are JetBrains plans with Kotlin 1.1 on JS? Are full stack Kotlin web apps a part of this?

A little bit related to this is using the typesafe builder idiom. I built this out some, to support a static web site generator I wrote. After doing that, I must admit I have mixed feelings about doing things this way.

One pitfall is that you end up with an awful lot of “this” references in any given scope. This can lead to confusing behavior. I wrote up some of my observations in the code, particularly in corpsblog/Html.kt at master · zathras/corpsblog · GitHub . See especially lines 68-88, which I’ll reproduce here:

protected fun <T : Element> initTag(tag: T, init: (T.() -> Unit)?): T {
    assert(startInitAssert(0)) {
        "Depth error in ${tag.tagName()} tag -- incorrect nesting of tag types"
        // It's tempting to define tag types at a higher level of the inheritance
        // hierarchy.  That's a Bad Idea, because of the multiple nesting of receiver
        // types.  For example, consider:
        //  html {
        //    body {
        //      head { }  <--  Oops!  This calls html's head function
        //    }
        //  }
        // This assertion catches that error, because head's parent is html, but
        // head's init is called recursively during the call to body's.
    if (init != null) {
    return tag

Detecting the problem is possible, as shown above; indeed it’s IMHO a perfect place to use an assertion. But the fact that I needed to add this assertion feels wrong. The basic problem is that what the code looks like it’s doing, and what it’s actually doing is different.

I didn’t rip the code out or anything, but I don’t think I’d go this way if I were writing this again, or if I were doing something significantly more complex.

Anyway, just thought I’d throw this out there, since its somewhat related to this thread.

@billf - If you are using Kotlin 1.1 then there is a solution to the DSL scope problem via “@DslMarker”.

Thank you. That’s a nicer solution than the assertion.

I’m not on Kotlin 1.1 at present, but I made a note for future reference.

I kind of asked this in another thread just 2 minutes ago, but is this kind of development done anymore these days?

Serious question, not meaning to sound like I’m trolling. I guess reading these types of questions makes me wonder if people still write server-side rendered pages without javascript? Or maybe I’m misunderstanding and that’s not what is implied by the question?

The only reason I could think of anyone doing this was maybe they hadn’t picked up a modern frontend developing skillset? Or maybe an older enterprise company?

Reading the thread above again just to see if I missed anything obvious. Maybe you are writing both frontend and backend in the same codebase, but using Kotlin to compile to JS?

Most server-side development is done using a programming language other than JS. Implementing a web back-end using Kotlin isn’t a major issue (very easy to do with many options available). If anything the real issue is being able to easily implement a web front-end which isn’t straightforward, even if JS is being used. Also being able to easily integrate both the front-end and back-end together. JS doesn’t provide an easy/straightforward solution for this if it is used to develop a full stack web app.

Full stack web apps are in high demand (still growing), and are successfully holding their ground against single page web apps.

Hm interesting. I have been very curious about this. The only “thing” I was sort of aware of was SEO optimization stuff for search engine crawlers. I dont know if that has changed in the last 5+ years though with the growth of Single-Page Apps.

Heh, I guess I feel lucky to only be concerned with the data, and not a full-stack developer. Let the frontend guys worry about making the app look pretty :stuck_out_tongue:

Hopefully JetBrains have developed Kotlin JS to the point where it is well received (by the community and others), usable, and production ready when Kotlin 1.1 is released otherwise the Kotlin 1.1 release WILL be a disaster. Very important to remember that Kotlin JS and Co-routines are the main highlights of Kotlin 1.1.

brandonlamb My assumption is that the original post was not proposing an old-style “server-rendered-pages” app. I believe he was asking about a web app that was entirely in kotlin. Something like this:

Server-side: serves up json via a rest api. All server code is written kotlin that compiles to jvm byte code and runs on a jvm.

Client-side: written in kotlin that is compiled into JavaScript.

1 Like

One other thing, to brandonlamb’s point. server-rendered pages are becoming back in style. For example, with React, your pages can render client-side (as dom updates) or server-side (to a string). React allows you to mix and match server-rendering with client-rendering. By doing the initial render on the server you gain two advantages:

  1. super fast initial page load
  2. better seo results (as you mentioned)

But this is just a side point. I don’t think the original poster was implying server-rendered-pages as a requirement.

If you need to avoid JavaScript then use GWT or Vaadin - they were built with the purpose of avoiding JavaScript :wink: If you’d like to have a full stack solution on top of Vaadin with Kotlin, maybe this framework might be for you: GitHub - mvysny/vaadin-on-kotlin: Writing full-stack statically-typed web apps on JVM at its simplest
Disclaimer: I’m the author :slight_smile:

I have same question about full stack web application development using kotlin.

Vue.js/Node.js (Express.js) is current development environment. I hate JavaScript for sure, but GWT fails and Flex sold out for front end development options are limited to JavaScript frameworks (hate angular 4 & React.js)

If I am not wrong kotlin got no front end UI library, e.g. primeNG for angular 4 & element.io for vue.js.

Right now, you have to use other JavaScript frameworks for front end and kotlin serving at REST API. Please correct me if I am wrong and good front end solution is available.

I am sick of javascript frameworks & like to use kotlin as single language for full stack development.

I’m sure there are many of us who are still building big, monolithic web applications in SpringMVC or JSF2, running on JEE and Portals. Single-page web-apps and entirely Javascript-driven apps are a long, long way for us. Corporate and government bodies, mostly, for sure.

I’d love to see an entire web-app build in Kotlin (perhaps with a sprinkling of JQuery or the like). I’m trying to do it myself.

Kara is interesting, but us government/corporate types need HTML templates developed by designers, not coders; we need CSS delivered by the UI team; we need dependency injection and JPA/Hibernate. I guess only Spring Boot offers that right now.

One very important thing to note is that the position of Web Designer (people who develop web sites) has been made obsolete with the use of CMS (Content Management System). The Web Developer position is still around since there are no automated systems for developing web apps.

Although view templates are still the standard way to define views (web pages) for now, that will change in the near future in favour of DSL’s for building views in code, NOT markup. On the JS side they are partially there via React, except it still resembles a view template (is markup, not code).

I would still recommend you to try Vaadin-on-Kotlin. It was designed for server-side programmers who don’t want to touch JavaScript with a two-feet pole :slight_smile:

The purpose of Vaadin is to isolate and enclose JavaScript code into Components which you then orchestrate from server-side using a pure Kotlin code. You don’t have to write the JavaScript part: a rich set of components is pre-provided for you including layouts; unless you need to develop your own component you don’t have to touch JavaScript at all. All components fully use AJAX to communicate with server so that you can build rich single-page web app easily by using server-side Kotlin only.

Please see http://www.vaadinonkotlin.eu/ for more details; the main page links lots of example applications which are free, OSS and located on Github. Vaadin 8 uses GWT under the belt, Vaadin 10 uses JavaScript+WebComponents under the belt. AFAIK Vaadin is currently the only alternative to the REST+JavaScript approach.