Hacker News new | ask | show | jobs
by SomeOtherGuy 5257 days ago
>Is anyone here using haskell or a similar funtional language for any web app?

Yes.

>Would be interested in known your experiences and opinion compared to something like django or rails.

Rails is an abomination, so pretty much anything would be better than that. We rolled our own framework in scala. Despite initial resistance from some dynamic language proponents here, it is now the only thing anyone here will use for web development. Even the python fan won't touch django now.

>How difficult is it to build something with a complex domain model?

Easier than in dynamic languages. The problem with complex models is that humans can't hold all that information in their heads. Static typing lets us offload a bunch of important information to the compiler and have it error check for us as we go. Our biggest issue has been that scala isn't strong enough, I'd much prefer to be using haskell.

4 comments

>Our biggest issue has been that scala isn't strong enough, I'd much prefer to be using haskell.

I hear that. I learned Haskell because I thought it would help me understand Scala better (namely the type system), but Haskell spoiled me and I don't want to use Scala anymore. Only thing keeping me on Scala atm is Lift, a truly excellent rethinking of web frameworks. If I ever find the time I want to start porting Lift to Haskell.

I'm not a huge fan of lift, but the portion of it I am ok with (the templates/snippets side of things) is fairly similar to how you use snap. It may be worth it to work on helping to finish snap (or forking it if need be) rather than starting from scratch. Snap currently provides nothing for database access, so you have a blank slate there to copy mapper or record from lift (but those both suck horribly!).
Interesting, what aspects are you not a fan of (besides the persistence parts)?
The model side of things is certainly my biggest complaint. The other things are minor in comparison, but still annoying. I like the architecture of lift, just not some of the details of the implementation.

I don't like the way templates are forced to use snippets to load data, in particular as it results in snippets being dependent on the database, and thus not suitable for unit testing. The framework should be pulling the data into the view, which then passes it as an argument to the snippet to do whatever transformation on it. That way snippets are entirely self-contained and easy to unit-test. This is the sort of thing that I think would have ended up the way I want had it been written in haskell instead of scala just because writing small, self-contained functions is the typical haskell way of doing things.

I hate the very opinionated nature of the form handling, and the even more opinionated responses from the developers to questions like "how can I make a form that works normally and doesn't require a session". People are not bad for wanting forms to behave normally, and the "security" show the lift devs put on to justify the form handling in lift is insulting.

While I find templates acceptable, they are seriously missing out on type safety. I should get a compiler error if I create a template with invalid html. Ocsigen got this part very right (an ocaml framework/appserver). Not only do I not get this benefit for my markup, but lift itself generates invalid html on me when using virtually any of the included form generation methods. Very annoying.

Ideally what I want is a framework that gives me the type safety of yesod, but with the structure of lift. I hate faux-mvc web frameworks and find they make things more difficult rather than making things easier, and unfortunately yesod copies the typical rails clone structure. Lift doesn't make the mistake of trying to hide http from me, and gives me the simple and correct mapping of template to url, leaves the domain model in the model instead of cramming it into "controllers" that shouldn't be involved.

Thanks. Those haven't bothered me too much yet, but good to have on the radar. That's the first real critique of Lift I've seen, other than 'it's not MVC'.

As for Yesod, I was also thinking it would be nice to have the type safety and parallel/concurrent performance of Yesod with the templating and structure of Lift. Don't know Yesod well enough yet though. Too many side projects.

No interest in starting a flame-war, but as someone who's just getting going learning to code, I'm curious why you would call Rails an abomination. Can you explain in a way a complete beginner would understand?
I can try. Basically it is a PHP framework written in ruby. It has a really poor API that makes for very error prone coding. It completely fucked up the entire MVC architecture, creating a big fat controller layer that contains logic that belongs in the model. This makes it impossible to re-use code as much as it should, and makes unit testing much harder as there's too many inter-dependencies. And monkey-patching is the norm with rails, which causes all sorts of bugs. Monkey-patching is basically changing the API of existing classes, so then other libraries you might use break because the API they are expecting from the ruby library has changed on them.
Right , I get that static typing can be an advantage but how is the functional paradigm an advantage in this case?

Or is it more than you just want to use something statically typed that isn't Java?

Ah, yes we weren't looking for functional languages specifically, just languages with expressive type systems. As far as I know, the only languages with expressive type systems are also functional so we end up with a functional language as a consequence of that requirement, not due to actively seeking a functional language.

We use scala in a pretty functional way, but most of the gains there come in the processing/displaying side rather than the model. Just because that portion lends itself to a functional style of applying chains of functions on data to transform it.

What do you mean by "strong" enough? Are you just talking about strongly typed?
Yes. Scala lets you bypass the compile time type safety pretty easily, and as a result tons of libraries do precisely that. Take squeryl for example, it advertises itself as a type safe DSL for querying databases, but virtually anything you throw at it will compile, and then results in run-time exceptions.