Most websites consist of at least two tightly coupled components. One runs in the browser, the other on the server:
- Responsible for user interaction
- Untrusted execution environment
- Unreliable persistent local state
- Runs in a datacenter
- Responsible for business logic
- May be written in a wide variety of languages
- Trusted execution environment
- Reliable persistent global state
These two tightly coupled components are often written in different languages and must communicate with each other over a HTTP connection. This adds significant complexity to the overall system.
Kweb is designed to solve this problem by departing from the "fat client" architecture. We do this by moving as much of the logic to the server as possible, leaving a simple but powerful interface to the web browser where server-browser communications are handled automatically.
According to Github, Kotlin was the fastest growing programming language of 2018.
How does it work?
Kweb is a self-contained Kotlin library that can be added easily to new or existing projects. When Kweb receives a HTTP request it responds with a small HTML file including optimized instructions for building the page, and a client which connects back to the web server via a WebSocket. The client then waits and listens for instructions from the server.
To minimize latency, Kweb can preload instructions to the browser to modify the DOM instantly in response to browser events, perhaps to disable a button or temporarily display a "spinner". This allows Kweb to respond instantly to user behavior without a server round-trip.
Kweb is designed to be efficient. All operations are handled asynchronously, thread and memory usage are minimized. Kweb runs on the JVM, which is 5-10 times faster than Node.js.
Kweb also takes an end-to-end approach to state. You can bind the value of a DOM element to a field in your database, and have it update in realtime automatically.
- Free as in speech, licenced under LGPL v3.0
- A unified codebase for your webapp, from database to DOM
- End-to-end Kotlin (Why Kotlin?)
- Bind DOM values directly to a value in your database and have them update in realtime
- Statically typed HTML DSL - let your IDE catch bugs so you don't have to
- Efficient server-side rendering, DOM caching, and instruction preloading
- Very lightweight, Kweb is less than 5,000 lines of code