What Yesod got Right
November 19, 2011
Web development in Haskell is still virgin territory. Haskell is always capable of trying to copy what other languages do, but Yesod has blazed many new trails in the pursuit of finding the right way for Haskell. Yesod is a web framework plus 3 other projects: WAI, Shakespeare/Hamlet, and Persistent. When we go over this list, we start to realize that the strenght of Yesod lies in these 3 other projects and how they are easily integrated into Yesod.
- backend independence (cgi, Warp, whatever comes next).
- Share huge amounts of code between applications and frameworks at the middleware and backend layers
- Overall this is a no-brainer to anyone experienced with using a similar concept in other programming language, and almost every programming language is converging on a similar standard concept.
- Enumerators have the right performance characteristics
- Maybe a better version of enumerators will appear in the future.
- compile-time safety
- no extra variable mapping steps required
- automatic variable conversion based on type
- Hamlet's DRY HTML, specifically indentation to signify closing tags
- currently no dependency tracking, but I patched GHC for that, and our development server handles it
- How to put code into a template? Hamlet supports a minimal set of Haskell (we could call it logic-less), but others want the full power of Haskell in their templates.
Persistent Database interface
- easy data serialization
- easy basic query language
- Haskell records have namespace collisions
- Query language is not truly universal and cannot satisfy many use cases
- routing - Discussed in the last blog post
- declarative, succinct, and easy to use
- easy type-safe URLs
The funny thing is we really have no idea if we actually got the web framework right. Routing is only a small part of a web framework. In Yesod using templates is safe and DRY, WAI gives you flexibility, and data serializes easily to the database. There is really only one (very broadly speaking) style we can think of for compile-time templates or a WAI. But there are a lot of ways to change how a web framework operates. Widgets are definitely great, but I wouldn't be suprised if there is even a more powerful way to achieve the same result. The nice thing is that anyone else can try to build a better web framework by re-using what Yesod got right. And we have already seen new frameworks appear that leverage WAI and re-use yesod packages.
We are always thinking about how to make things better, and we appreciate all the constructive feedback we get, and those that start extending Yesod. Thinking about what Persistent got right, and watching some developments in the community is going to lead to some changes to Persistent that should be announced soon. Hopefully we will then have all 3 ancillary projects right and can then focus more on the web framework itself.