8

I'm learning Haskell for great good.

I'm pretty into OOP and the various type systems. I used Java to develop webapps (Java EE, spring, Hibernate, struts 1.x), now I'm using regularly Python (pylons, django, sqlalchemy, pymongo) and Javascript. I had a huge improvement in my personal productivity: the lightweight approach, duck typing, awesome iterators, functions as first class citizens, simple syntax and configuration, fast tools like pip and distribute (and much more) helped me a lot.

But the first reason of my productivity boost is the Python language itself.

What are the main benefits of using Haskell for web developing? For example, how its type inference can really improve my web app? So far, I noticed that when you decorate your function with its type-signature you are adding a lot of semantics to your program. I expect all this effort to come back in some way, to save many lines of code and to make them sound. I really like the sharp distinction between types and data, I'm starting to understand how they works, but I want something back :P

Don't get me wrong, I've just started studying Haskell so Maybe I'm missing some awesomness but I really want to understand its paradigm and when it's worth using it.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
vrde
  • 937
  • 1
  • 11
  • 25
  • 2
    You probably won't understand two thirds of how it works (I certainly don't), but the Yesod web framework uses types for great good. –  Apr 09 '12 at 13:26
  • @delnan Yesod (and [this fragment](http://yannesposito.com/Scratch/en/blog/Yesod-tutorial-for-newbies/#bulletproof)) looks like a good start, thank you. – vrde Apr 09 '12 at 13:42
  • May be this is not directly related to the *how* the benefits can be reaped, but this is an example of the advantages of using Haskell for web-app development - http://jekor.com/article/is-haskell-a-good-choice-for-web-applications – Gangadhar Apr 09 '12 at 13:53
  • I'm a little confused: Type inference means that often (90+% of the time) you don't need to write a type signature. But you say you "want something back" from having to append type signatures to everything (which you don't need to do). – amindfv Apr 09 '12 at 14:00
  • maybe I'm more confused than you @amindfv :) OK, type inference saves me from writing type signatures, but this is an *internal* (i.e. of the language itself) benefit. But what about *external* benefits? @delnan pointed out Yesod, that can protect our webapp from malocious strings (a string of type `URL` cannot have whitespaces or "<") using types. – vrde Apr 09 '12 at 14:15
  • Ok, it's terminology problem. I think the phrase you're looking for is "static typing" or "strong typing," which are what keep you from putting, say, a String where an Integer should be. Type inference itself is just the property that often you don't need to explicitly define the types. – amindfv Apr 09 '12 at 14:23

1 Answers1

3

Most web applications aim to be stateless and handle concurrency well. Its also rather important to scale (Google SEO reasons, and user experience).

Haskell handles these problems rather well (although IMHO in more academic and perhaps less "human" intuitive way).

That being said due to the sheer lack of people doing web app dev (compared to say node.js) and that traditional web app dev has been more focused in a OOP mind frame it might be rather difficult.

I had some issues trying to use it as you can see in my questions below:

How do I do automatic data serialization of data objects?

Handling incremental Data Modeling Changes in Functional Programming

Community
  • 1
  • 1
Adam Gent
  • 47,843
  • 23
  • 153
  • 203
  • By the way I don't mean to put down Haskell. I think its a rather powerful language. I just couldn't wrap my head around making it productive for web application development which is what I do for a living. – Adam Gent Apr 09 '12 at 13:43
  • 1
    I think you'll find it a much different experience in late 2015. Haskell now has some incredibly powerful web frameworks both for back end and front end (GHCJS compiles to JavaScript). If you're looking for web-dev with type safety, Haskell is gaining traction. – Elliot Cameron Oct 28 '15 at 04:50