145 points · by dons · 14y ago · 109 comments
Of course, support for type-safe URLs will vary by templating languages, so you may have to manually render URLs yourself, but that's doable via getUrlRender.
Many users come with different pre-conceptions about what a good template language should be, but once they actually start using Hamlet, they love it. So honestly I am not 100% sure how much effort using a different template language is because not a single user has wanted to switch to an alternative.
That said, give us your use case on the mail list (after giving hamlet a shot) and we will figure out how to make it easy for you. Also, we have users using mustache client side after first generating their mustache templates with hamlet.
If that is robust, then I'm not sure what definition you are using.
In your opinion.
>but once they actually start using Hamlet, they love it ... not a single user has wanted to switch to an alternative.
Hamlet is one of the major reasons we're using snap instead of yesod. Of the 5 devs here who worked on a test app in yesod, the most favourable reaction to hamlet was "well, I guess I could live with it if I had to". Just because we didn't come ask "how hard is it to use a decent template system with yesod" doesn't mean we love hamlet. We just tried out snap and happstack instead, where using whatever template engine you want is obvious and trivial.
On the other hand, it seems you are very adamant that you must type your own closing tags rather than have the template language ensure they are correct through indentation.
Our goal is not to make every single developer happy. If you don't appreciate DRY & reduced errors (improper closing tags in this case), Yesod is certainly not for you, no matter what template language you used.
> Note the awesome Shakespearean inspired name convention. Another good reason to use yesod.
Lol.
> Until here I believe it goes in the right direction. Even if I believe the real future is by generating HTML pages from the client (using javascript) and server limited to serve JSON (or XML, or any object representation system).
This is a little unclear. Do you mean, prior to Yesod you thought web development was heading in the right direction, but Yesod made you realize there was a much better way, even if the future is HTML5 rich web apps with the app server as a JSON/XML API endpoint?
1. http://yannesposito.com/Scratch/en/blog/Yesod-excellent-idea...
- Security by default, directly imported from the Haskell type system.
- Fast, also, because Haskell is quite fast compared to most languages used for the web.
- Able to manage a lot of concurrent connexions,
- Incredible foundation language, Haskell is simply awesome (look at my latest blog post for details[^1]).
On the other hand, IMHO, the future of the web might be:
- an API server as good as possible (fast/distributed/clever)
- many good quality dynamic (and generally native) clients
Therefore, I find most of the effort put in the HTML/CSS/JS generation while impressive not so essential for what I look. On the other hand, the notion of Yesod's widget is a very clever first step in the direction of web component abstraction. So in conclusion, yes, Yesod went a step further from what I expected from server side web technologies when I discovered it.
[^1]: http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-Way...
* Generating migrations automatically when saved may cause some troubles while making large changes. It's a default setting?
* Hamlet seems good but not so obvious for real-world designers. Would be great if you provide an easy way of switching to another template language.
* Keep the good work :)
There is of course some performance overhead to encrypting, but Felipe's skein package has been highly optimized, and Yesod is still able to achieve ~50,000 req/sec on modest hardware. (Apologies for not having more accurate numbers, I haven't run our benchmark suite on EC2 in over a year.)
What are the major differences between them? Is one of them a clear winner, the way Django/Rails are in Python/Ruby respectively?
Snap is relatively simple and as such easy to fully understand. But since it is a relatively simple framework, you have to mix and match other packages to get the functionality that you want.
Yesod on the other hand is very elaborate - it contains a lot of functionality and relies fairly heavily on the use of Template Haskell and Quasi-Quoting.
As with Ruby and Sinatra, it is mostly a matter of taste. Some people prefer lightweight frameworks and add the components they need, while others like to do things within one well-integrated framework.
I've used both and this is pretty from my experience.
If I can make comparisons I think:
* Yesod is like Rails w/ haml+sass (but type-safety throughout)
* Snap is like Servlets+JSP (especially wrt templating, besides that it is quite similar to Yesod)
* Happstack is like Zope w/o the frontend (mainly because it is the oldest (has a pre-Rails feel to it) and has its own in-haskell ACID db (Zope has ZoDB))
> Snap is relatively simple and as such easy to fully understand. But since it is a relatively simple framework, you have to mix and match other packages to get the functionality that you want.
I found it as hard a Yesod to get it up and running. Both suffer from old docs/tutorials/examples, both needed me to climb the daunting haskell learning curve.
> Yesod on the other hand is very elaborate - it contains a lot of functionality and relies fairly heavily on the use of Template Haskell and Quasi-Quoting.
How is that a problem? I say: "Template Haskell and Quasi-Quoting FTW!" DSLs or little interpreters are great in reducing code-size. Reducing code size is great, arguably nr.1, in reducing bugs.
> As with Ruby and Sinatra, it is mostly a matter of taste.
I suspect you mean "Rails and Sinatra".
It is not a matter of taste: Rails and Sinatra both build on the Rack interface and have several options for http servers (mongrel/webrick/thin/etc).
With Yesod and Snap you find they both have their own "Rack". Yesod has "WAI" and an http server "Warp" -- these blow every other option out of the water in terms of speed and seem to have a more clever design.
But it could be just my opinion. (I did remember reading somewhere that the Snap devs envy Yesod's speed and try to make their solution faster which is a good thing)
> Some people prefer lightweight frameworks and add the components they need, while others like to do things within one well-integrated framework.
This is mostly a matter of how you build your app: "from scratch" or "scaffolded". Both Yesod and Snap allow both ways. Scaffolding with Yesod brings you much further along the axis of "well-integratedness" then scaffolding with Snap which is obviously a win those preferring the scaffolding approach.
Snap offers heist as a default template engine. It is nothing like JSP at all, it is a pure html template engine like lift or zope's templates. There is no embedding any sort of logic or code in the template at all.
>How is that a problem? I say: "Template Haskell and Quasi-Quoting FTW!"
Using is fine, it is intended to reduce boilerplate and works well for that purpose. Yesod over-uses it where it is entirely unnecessary. You lose composability and have to learn another language.
Or from the horse's mouth:
Snap: "Snap is a simple web development framework for unix systems, written in the Haskell programming language."
Source: http://snapframework.com/
The Yesod book: "The Haskell community is constantly pushing the boundaries finding the cleanest, most efficient solutions for each challenge.
The downside of such a powerful ecosystem is the complexity of choice. By using Yesod, you will already have most of the tools chosen for you, and you can be guaranteed they work together."
Source: http://www.yesodweb.com/
I'm using Yesod now simply because it seemed to have the most active community and I don't mind a lot of choices being made for me, since I'm also learning Haskell at the same time. Maybe I'll feel differently later.
Happstack on the other hand ... invented type-safe routing, which I haven't seen anywhere else before it. Dynamic languages tend to have something vaguely similar you might call "named routes" but they don't provide the same static guarantees.
Happstack likes to use templates mixed in with code, which sounds insane but note that this is rather different from code mixed in with templates. This templating is type-safe and syntactically checked at compile time, and allows reusing all of Haskell rather than a limited subset, so using modules and functions these templates easily end up more modular and composable than any template language you've ever seen before. Admittedly, it's not the most designer-friendly solution (but should designers really mess with the HTML to begin with?).
Happstack likes to use a persistence system for native Haskell values. I suppose you could say this is similar to ZODB with Pyramid, although it's "on steroids" (due to Haskell).
I'm biased towards Happstack as you might notice from this post, but the point I'm trying to make is more that Happstack is non-traditional (in the tradition of Haskell!) and not quite like anything else. This is often seen as a weakness because it means it is less familiar to new users; I might wonder why they're using Haskell to begin with, then. :-)
(You could even argue that Happstack should be more familiar, to Haskell programmers, because it favors reuse of existing Haskell idioms like combinators, algebraic data types, monad transformer stacks...)
That said, if you do want a more traditional framework, Snap and Yesod are both great options.
Yesod gives you templating and persistence out of the box, but the template engine is a love it or hate it deal, and persistent isn't mature enough to use with an RDBMS backend.
Snap gives you templating, but no persistence out of the box. The template engine doesn't give you compile time type safety, but it also contains no logic, it is an html template system like lift. If you want to talk to a database, you use whatever haskell module you want, there's nothing snap-specific about it.
Happstack is basically the same deal as snap, but early on was pretty heavily focused on their own acid-state storage system. It has since become much more storage agnostic, and the acid-state storage system is used outside of happstack now.
Between happstack and snap, happstack has better docs, including tutorials on how to integrate with a ton of different web related modules (different template systems, digestive-functors, etc). Snap has a better web server underlying it, and subjectively appears to have more developers actively working on it. Because both allow you to use whatever modules you like quite easily, migrating an app from one framework to the other is pretty easy. Migrating from snap or happstack to yesod or the other way is quite a lot more effort.
How is this the case? Compare http://yesodweb.com and http://snapframework.com/ and tell me you really believe that the yesod guys are marketers?
> persistent isn't mature enough to use with an RDBMS backend.
How so? Also, Persistent is still at 0.9, so the version number would agree. Any persistence layer you use with Snap or Happstack is just as easy to use in Yesod too.
> Snap has a better web server underlying it
Again, how so?
I didn't say yesod had the best website, I said they put the most effort into marketing. Michael and Greg do a lot of talking about yesod, and are the only haskell framework attempting to draw in people from outside of haskell. You seem to have interpreted this as an insult, it was not. Usage increases with awareness.
>How so?
Unless you are using your RDBMS like a dumb storage system, then persistent doesn't provide the tools to access it. We're not talking advanced stuff here, the most basic fundamentals were done incorrectly: it requires int primary keys on all tables for crying out loud. Obviously multi-column foreign keys just went out the window then too. Of all our apps here, not even the most trivial could be ported to yesod using persistent.
>Any persistence layer you use with Snap or Happstack is just as easy to use in Yesod too.
Certainly. But the major difference between yesod and snap initially appears to be "yesod provides high level DB access and snap doesn't". This may be true of mongo DB (I have no use for it), but for an RDBMS it actually ends up being that neither provides high level DB access, and you have to use something from hackage.
>Again, how so?
Happstack's webserver has several issues, space usage being a major one. This isn't a controversial statement, Jeremy will tell you the same thing, it is why he's focusing on replacing happstack-server.
It just looks awful.
* http://happstack.com/ * http://snapframework.com/
Design time!
There is someone under the name "papsosouid" [1] on this thread with an account that's "coincidentally" as old as the thread itself, and has only commented on this thread so far [2].
He seems pretty acquainted to this community (he was quick to show me the HN posting guidelines) therefor I suspect he must have another account at HN. I also suspect he has created this new account especially for posting in this thread: why would one do that? I cano only think of; (a) to conceal whom he really is, or (b) because he expects karma-negative results of his actions -- one not excluding the other.