Chapter 0 - Design of Web Applications
By John Lenz. 2016.
The central question is "Where does the transformation between domain data and the DOM live?" Consider Reddit: the domain data stored by Reddit is the subreddits, the stories, the comments, the votes, the user preferences, the currently logged in user (if any), and so on. We can view the task of a web developer as writing a function which maps this data to the eventual DOM that will be displayed in the user's browser. The different designs of web applications focus on the different possibilities for this mapping of domain data to the DOM.
In this second design, the transformation from the domain data to the DOM happens both on the server and the client.
In this third design, the transformation from the domain data to the DOM happens only on the client.
My recommendation for Haskell is to use either Design 1 or Design 3 (or both for different parts of the website). I have built several successful projects using Design 2 in Haskell, but I now believe that keeping the transformation from domain data to DOM in one place (either the server or browser) has large advantages in coding and maintenance (at least in Haskell).
Design 1 supports the most browsers, from ancient browsers to limited browsers running on tiny hardware to the latest and greatest browsers running on modern hardware. For example, Wikipedia's goal is to be accessible to anyone with an internet connection so firmly stays in Design 1. Design 1 also has a large amount of tooling, libraries, and development resources available. As a disadvantage, Design 1 cannot implement highly dynamic websites where parts of the DOM change as the domain data changes. The main danger is feature creep, where aspects of Design 2 enter into the website over time. Design 2 can work, but only if the domain data and architecture is designed from the start.
Design 3 requires modern browsers, is more complicated to integrate with search engines, and is still somewhat new so tools and libraries are growing quickly. Design 3 requires most of the new browser features added as part of HTML5 in the past few years; the main problem is Internet Explorer. Generally IE 9 and below do not have enough features and IE 10 is possible to support but quite difficult. So typically Design 3 websites will only support IE 11 and up. The good news is that IE 11 and up are the only browsers receiving security updates and IE 11 is available for Windows 7 and all later versions, so IE 11+ captures the majority of users who have a modern, up-to-date Windows OS.
Yesod is an excellent library for building websites in Design 1 and 2 which I have used successfully in the past. While I haven't personally used them, Snap and happstack are also great libraries for Design 1 and 2, and many other smaller libraries.
For Design 3, there is not currently a framework or all encompassing library in Haskell. Instead, there are several great pieces that can be combined and this will be the focus of the remainder of this book.