AHGTH: Comments on Snap/Yesod

I spent some time last night looking at Snap, which is a web development framework for haskell. I have seen repeated comments that Snap is superior to Yesod so I finally poked around myself. We use Yesod at Alpha Heavy Industries for internal status pages and tools. I have found it to be a bit kludgy to use and Snap was advertising these Snaplets which I figured held some promise. My frame of reference for comparison is ASP.Net around version 3.5 and 4.0 which I also used to build a lot of tools.

First off I am not really interested in the technical merits of either platform. Both advertise very high request throughput and have made design choices to support it. I have no need of such a solution. Our webserver is lucky if it has two people making requests at the same time. I am mostly concerned with ease of development. In ASP.Net I could build a quick webapp to display data or do data entry (my most common tasks) in a couple of hours. In Yesod it often turns into a day long affair. I have realized how much ASP.Net had insulated me from the mechanics of HTML, building forms, etc… Yesod is a much lower level affair, and in some ways higher.

At the risk of inciting your wrath I will admit that I have repeatedly compared Yesod to many half baked Microsoft technologies like WCF and WWF. Both were very easy to get up and running with. Both demoed fantastically. Everything was great, until a scenario that was not considered comes up. I feel the same in Yesod. Its easy to get going, especially now, but then you need to do something a bit complicated and you have to dive into the details of the framework. Admittedly as my haskell wizardry has increased I have been able to devise simpler solutions to complex problems in Yesod.

Snap doesn’t seem to be much different. I will leave it to others to argue about what the right templating syntax is. It seems to have most of the same features although quite a bit less documentation. I was disappointed that most of the snaplets were built to interface with databases. I was really hoping for some powerful controls. I may be missing something and if I am I invite anyone to fill me in on what that is.

ASP.Nets controls are one thing I miss from the old world. It was super easy to build a datagrid or a series of charts bound to arbitrary data sources. Now many will say that to build highly scalable websites you can’t use these things and they are right. But most of the websites out there are not serving thousands of pages per second. What I really think either framework could benefit from would be a layer on top of what exists now. A set of full featured controls for charts, data grids, calendars and things I have never thought of.

In Yesod I am still not sure what this would look like. Is a chart a Widget? My chart control today is a Widget. In fact most of my widgets are controls and they are hacky and nasty since they are javascript powered. I have done more javascript code generation than I care to mention. Wait aren’t I supposed to be writing haskell?

All that being said both seem to have solid technical foundations. More work just needs to be spent on the higher levels. I look forward to seeing both evolve.

P.S. A reader may ask why use Yesod if I don’t like it? I don’t want to have to rewrite blocks of functionality in another language. It requires less time overall to just suck it up and make the best of it.

P. P. S. Is anyone knows how reusable controls in Yesod should be developed so they can just be linked in I will develop any future controls in such a manner and release them.

  1. I think you’re correct that Yesod is more “low-level.” I don’t have a lot of experience with ASP.NET, but from what I have seen, it has much more a philosophy of shielding you from what’s going on under the surface. In my experience, that’s a double-edged sword: it certainly can make some stuff easier, at the cost of complicating a lot of others.

    As for Javascript generation: that’s a valid complaint, one that we all have in the community. Solving client side development is an open question, and many of us are investigating solutions. For now, having to write JS manually is a necessity, but I hope for not much longer.

    I think some specific insights about what issues you’ve run into would be invaluable. Getting a comparison of what things are difficult and/or poorly documented in Yesod relative to ASP.NET would be a boon to our development. Could you send a few specific examples to the mailing list? For example, I *think* a Widget is the correct approach to the chart example, but I’m not certain without hearing more details. And maybe we can expose more high-level stuff as well.

  2. Slava Kravchenko

    Hello Steve,
    Did you try Elm (http://elm-lang.org/)? This might be what you’ve been looking for, if I understand your needs correctly. Not that I’m an active Elm user, but I’m considering it for my projects, in the nearest future.

    • I have not used Elm although it looks interesting. I tend to try to stick with more commonly used technologies and libraries.

      • The old Catch 22 of technology adoption… I agree: I, too, tend to only use commonly used technologies and libraries, especially for production use, so that I can decrease the amount of time I spend solving obscure issues unrelated to my problem domain. Still, working on the bleeding edge comes with its own set of rewards: the glory of the successful early adopter and pioneer.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>