比较Haskell的Snap和Yesod web框架 [英] Comparing Haskell's Snap and Yesod web frameworks

查看:81
本文介绍了比较Haskell的Snap和Yesod web框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近新闻中的两个Haskell Web框架是 Yesod (0.8)和 Snap (0.4)。



很显然,Yesod目前支持更多功能比Snap。但是,我受不了Yesod使用HTML,CSS和Javascript的语法。



所以,我想了解如果我使用Snap而不是使用Snap,那我会错过什么。例如,看起来不像数据库支持那里。会话如何?其他功能?

解决方案

完全披露:我是Snap的主要开发人员之一。



首先,我们来谈谈Snap是什么。现在,Snap团队在hackage上维护了五个不同的项目:snap-core,snap-server,heist,snap和xmlhtml。 snap-server是一个web服务器,公开由snap-core定义的API。 heist是一个模板系统。 xmlhtml是由heist使用的XML / HTML解析和渲染库。 snap是一个综合性项目,它提供了强大的snaplets API,使Web应用程序可组合和模块化。



Yesod拥有大量的hackage项目。大多数(全部?)都列在 Yesod类别中。一些值得注意的是yesod-core,warp,persistent和hamlet。

Haskell网站开发的实际情况是,它比专有或选择要少得多似乎被察觉。一般而言,这些项目非常松散地耦合在一起,并且可以相互交换。您可以使用warp(Yesod团队的Web服务器),heist(Snap团队的模板系统)和acid-state(Happstack项目的持久性系统)来构建网站。你也可以使用snap-server与hamlet或persistent。

也就是说,这两个项目肯定有一些差异。我可以客观地指出的最大区别是Yesod项目通常大量使用Template Haskell和quasiquoting来创建简洁的DSL,而Snap项目坚持构建支持可组合性的组合器库。几乎任何我能想到的其他差异都会主观地偏向Snap。两个项目命名的伞包显然会为上述组件做出特定选择,这些选择将反映在项目依赖关系中。但是,这并不意味着你不能拉出不同的东西并使用它。



Snap确实有会话身份验证,与几个数据库的接口以及漂亮的表单处理(这里这里)使用消费者管理员,其中包括对任意嵌套的动态大小列表的预先打包支持。这些只是一些不断增长的可插拔的生态系统。会话和认证snaplets是以后端不可知的方式编写的。因此,使用少量胶水代码,您应该可以将其用于任何可以想到的持久性系统。在未来,Snap将会尽可能地坚持这一政策。



在大多数情况下,我认为Snap vs Yesod vs Happstack的选择不是特性问题更多的是个人品味。每当有人说其中一个框架没有另一个框架时,大多数情况下,通过导入必要的软件包来从其他框架中引入缺​​失的功能是非常容易的。



编辑:为了更详细地比较三大Haskell网络框架,请查看我最近的博客文章。对于使用一些更广泛的泛化的粗略(但可能更有用)比较,请参阅我的 Haskell Web Framework比较矩阵


The two Haskell web frameworks in the news recently are Yesod (at 0.8) and Snap (at 0.4).

It's quite obvious that Yesod currently supports a lot more features than Snap. However, I can't stand the syntax Yesod uses for its HTML, CSS and Javascript.

So, I'd like to understand what I'd be missing if I went with Snap instead. For example, doesn't look like database support is there. How about sessions? Other features?

解决方案

Full disclosure: I'm one of the lead developers of Snap.

First of all, let's talk about what Snap is. Right now the Snap team maintains five different projects on hackage: snap-core, snap-server, heist, snap, and xmlhtml. snap-server is a web server that exposes the API defined by snap-core. heist is a templating system. xmlhtml is an XML/HTML parsing and rendering library used by heist. snap is an umbrella project that glues them all together and provides the powerful snaplets API that makes web apps composable and modular.

Yesod has a host of projects on hackage. Most (all?) of them are listed in the Yesod category. Some of the notable ones are yesod-core, warp, persistent, and hamlet.

The reality of Haskell web development is that it's much less of an exclusive-or choice than seems to be perceived. In general the projects are very loosely coupled and fairly interchangeable. You could build a website using warp (the Yesod team's web server), heist (the Snap team's template system), and acid-state (the Happstack project's persistence system). You could also use snap-server with hamlet or persistent.

That said, the two projects definitely have some differences. The biggest difference I can point out objectively is that Yesod projects typically make heavy use of Template Haskell and quasiquoting to create concise DSLs, while Snap projects stick to building combinator libraries that favor composability. Just about any other differences I can think of will be subjectively biased towards Snap. The umbrella packages named after both projects are obviously going to make specific choices for the above mentioned components, and these choices will be reflected in the project dependencies. But that still doesn't mean that you can't pull in something different and use it as well.

Snap does have sessions and authentication, interfaces to several databases, and nice form handling (here and here) using digestive-functors that includes prepackaged support for arbitrarily nested dynamically sizable lists. These are just some of the growing ecosystem of pluggable snaplets. The sessions and authentication snaplets are written in a way that is back-end agnostic. So with a small amount of glue code you should be able to use it with just about any persistence system you can think of. In the future, Snap will stick with this policy as often as possible.

For the most part I think the choice of Snap vs Yesod vs Happstack is less an issue of features and more one of personal taste. Whenever someone says that one of the frameworks doesn't have something that another one has, most of the time it will be pretty easy to pull in the missing functionality from the other framework by importing the necessary package.

EDIT: For a more detailed comparison of the big three Haskell web frameworks check out my recent blog post. For a rougher (but possibly more useful) comparison using some broader generalizations, see my Haskell Web Framework Comparison Matrix

这篇关于比较Haskell的Snap和Yesod web框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆