IDG held their reoccurring experience sharing event, Code Night. This time on the theme “Framework” and speakers were introducing frameworks to develop full-stack-applications. The products in presentation ranged from platforms for independent developers, to solid enterprise solutions – offering smooth gluing between layers, optimal stack and stellar performance. As one of the companies who had the honor of holding a workshop, Starcounter was providing a hands-on workshop with developers under the encouraging topic “Thick VS Thin Client”. Our Lead Developer, Marcin Warpechowski broke down the full-stack approach to SW development. The purpose of the workshop was to analyse and identify the pains of having a Single-Page Applications thick clients and to suggest a lightweight thin client solution.
Let’s go deep
Usually, with thick client approach, the user interface is streamed from server to client app through multiple tiers of REST interface and client, coupled with JSON – all under the resource-oriented architecture paradigm. Main problems that are triggered by this approach frustrate user all over the world and include page freezing, latency and delayed consistency. If we remember physical characteristics of fat clients such as heavy code interconnected by ‘glue’ layers, duplicate logic and therefore overall complexity increase with double-end validation it is easy to understand SPA’s limitations those introduce. They bound much desired but hardly reachable quick transactions between page updates, no data redundancy and state consistency on web-applications.
A solution for streaming user interface using a combination of WebSocket, JSON and JSON-Patch that allows to build SPA-s without any need to write arbitrary APIs, such as REST, GraphQL or Falcor. Stateful connection of Server Application with a view-model to ultra-thin client with zero logic is realized by means of immediate JSON-Patches over HTTP. This two-way binding is provided by a novel protocol “PuppetJS” allowing fully interactive web front-end. Synchronization of JSON-Patches between concurrent server and client operations is maintained without delays or server denials by applying a new algorithm, called “Operational Transformation” that safely transfers the functional state of both parties and keeps consistent view of client-server “conversation”.
During the session Marcin described benefits to productivity, performance, UX and integrity for thin client, using suggested solution, but also mentioned existing limitations, such as necessity to have connection always on. In the current realities it can be tolerated by having cold-standby server for data replication. The session was highly hands-on and participating developers were very interested in the PuppetJS structure. A question that came up during the evening was if there is PuppetJS implementation for both client and server side. Current solution is available as a part of Starcounter, but development isn’t laid back, therefore the separate Puppet C# package will be on NuGet very soon. Other questions were centered around the Starcounter architecture itself and the server specifications that are applicable for our solution. To answer that question, basically any server is able to support Starcounter architecture as long as it supports long-lived JSON documents, modified by JSON-Patch over HTTP and WebSocket. Furthermore data consistency solution was raising a lot of questions, such as data security or MVVM updates events. All data transactions are secured on disk in a LOG-file. As READ operation is called only on startup, the WRITE operation is the only one being issued during actual work, therefore Starcounter is able to sustain performance of millions operations per second. JSON-Patch in our template engine is highly responsive and can proactively react on a each key press or focus/unfocus event – it straightly goes to the server. In case you have server on premise, you can enjoy stellar productivity with out-of-the-box real-time data sharing with ultra-thin client architecture by Starcounter.