508

There is a lot of hype around Haskell, however, it is hard to get information on how it is used in the real world applications. What are the most popular projects / usages of Haskell and why it excels at solving these problems?

Wojciech Danilo
  • 10,776
  • 13
  • 60
  • 118
Sergio Tapia
  • 36,466
  • 70
  • 175
  • 253
  • 65
    No, I won't because it's a clear cut answer. No wiggle room for opinions and such. I just want to know what the language was created for. – Sergio Tapia Oct 22 '09 at 03:03
  • 6
    dupe? http://stackoverflow.com/questions/775726/whats-the-fuss-about-haskell – bdonlan Oct 22 '09 at 03:04
  • 12
    @Papuccino1, wait, do you want to know what it's _useful_ for, or what it was _created_ for? The former is what the question is asking, and there's a lot of room for opinion there... – bdonlan Oct 22 '09 at 03:04
  • 3
    @Papuccino1 - What benefit do the extra words in your title bring to the question? Also, I think you're misunderstanding the use of the term "functional" in this context, but it's hard to tell. – Chris Lutz Oct 22 '09 at 03:38
  • Agree on the dupe, though the titles of both questions make them look Subjective & Argumentative. I'm not sure it's a good idea to edit the title of a 6-month-old question though. – finnw Oct 22 '09 at 04:43
  • 2
    According to their own website many companies use it for different kinds of purposes... http://www.haskell.org/haskellwiki/Haskell_in_industry – Julian Jul 25 '14 at 07:18
  • Because it's turing complete, anything! Just because it's functional doesn't mean it can't do things! – AJF Dec 03 '14 at 16:42
  • 1
    [This document](https://github.com/Gabriel439/post-rfc/blob/master/sotu.md) gives a good overview of the strong and weak points of the Haskell ecosystem. – sjakobi Nov 26 '16 at 18:15
  • I've discovered one "quality of life" advantage of strong type system. You can search for functions by their type. That means I don't have to know what it's called, but I know what it does, and it's enough most of the time. – Dulguun Otgon Jan 28 '18 at 20:19

10 Answers10

321

What are some common uses for this language?

Rapid application development.

If you want to know "why Haskell?", then you need to consider advantages of functional programming languages (taken from https://c2.com/cgi/wiki?AdvantagesOfFunctionalProgramming):

  • Functional programs tend to be much more terse than their ImperativeLanguage counterparts. Often this leads to enhanced programmer productivity

  • FP encourages quick prototyping. As such, I think it is the best software design paradigm for ExtremeProgrammers... but what do I know?

  • FP is modular in the dimension of functionality, where ObjectOrientedProgramming is modular in the dimension of different components.

  • The ability to have your cake and eat it. Imagine you have a complex OO system processing messages - every component might make state changes depending on the message and then forward the message to some objects it has links to. Wouldn't it be just too cool to be able to easily roll back every change if some object deep in the call hierarchy decided the message is flawed? How about having a history of different states?

  • Many housekeeping tasks made for you: deconstructing data structures (PatternMatching), storing variable bindings (LexicalScope with closures), strong typing (TypeInference), GarbageCollection, storage allocation, whether to use boxed (pointer-to-value) or unboxed (value directly) representation...

  • Safe multithreading! Immutable data structures are not subject to data race conditions, and consequently don't have to be protected by locks. If you are always allocating new objects, rather than destructively manipulating existing ones, the locking can be hidden in the allocation and GarbageCollection system.

Apart from this Haskell has its own advantages such as:

  • Clear, intuitive syntax inspired by mathematical notation.
  • List comprehensions to create a list based on existing lists.
  • Lambda expressions: create functions without giving them explicit names. So it's easier to handle big formulas.
  • Haskell is completely referentially transparent. Any code that uses I/O must be marked as such. This way, it encourages you to separate code with side effects (e.g. putting text on the screen) from code without (calculations).
  • Lazy evaluation is a really nice feature:
    • Even if something would usually cause an error, it will still work as long as you don't use the result. For example, you could put 1 / 0 as the first item of a list and it will still work if you only used the second item.
    • It is easier to write search programs such as this sudoku solver because it doesn't load every combination at once—it just generates them as it goes along. You can do this in other languages, but only Haskell does this by default.

You can check out following links:

Callum Watkins
  • 2,444
  • 2
  • 27
  • 42
Xinus
  • 26,861
  • 26
  • 111
  • 160
  • 22
    The following thought often crosses my mind: in a pure language, a function always returns the same result when passed the same parameters. This is a guarantee. Imperative languages in contrast build everything on top of "statements". A statement does not come with any sort of guarantee (except its execution consumes time and produces heat). So the foundation is already shaky and everything bult on top of it will remain shaky. To me this was one of the reasons to learn haskell. – Martin Drautzburg Oct 27 '14 at 14:18
  • 1
    Haskell is very, very far from what I would traditionally consider to be "RAD" in the likes of Visual Basic or Delphi. RAD is less about the language and more about tools like GUI designers and the associated generation of boilerplate by the tools. – Barend Venter Sep 05 '15 at 22:44
  • @BarendVenter, RAD is not so much about how long in minutes it takes the developer to get something on the screen, but more about the ability to "turn on a dime" during prototyping. In a typical imperative codebase, major structural changes, as is frequent in prototyping, require significant amounts of cut&paste (order of statements) and re-writing classes from scratch, even changing interfaces. – sleblanc Oct 29 '15 at 15:14
  • That Microsoft calls VB a form of rapid development is just marketing, IMO. Having a graphical builder gives you the ability to easily add widgets to an application in an intuitive manner, but that's pretty much it. Anything else can be done as easily with just a text editor. – sleblanc Oct 29 '15 at 15:15
  • 13
    It's been 6 years since this question was asked and since the Go programming language debuted. Despite having a weaker type system and generally being "objectively inferior" (according to functional/ML fans), it's managed to ship more (and more important) software in those 6 years than Haskell has in its 26 years. I mean this as a case study; there are clearly things that are holding functional languages back, and they can't all be attributed to hype. – weberc2 Dec 15 '15 at 16:16
  • 5
    You forgot a point - coding in haskell is an absolute blast ;) I've had so much fun trying my hand at some problems in haskell. – J Atkin Feb 23 '16 at 22:15
  • 9
    @MartinDrautzburg Of course statements come with guarantees. What sort of useful language would have statements without guarantees? For example in C `x = 5;` guarantees that after it executes, `x` contains the value `5`. – user253751 Oct 05 '16 at 04:16
  • You probably meant: *For example, you could put 1 / 0 as the **second** item of a list and it will still work if you only used the **first** item.* – lovasoa Nov 12 '16 at 16:50
  • 3
    @immibis `x = 5` in _C++_ definitely does not guarantee that `x` contains the value `5` after it executes (operator overloading). @lovasoa Both statements are true, since it is possible to access and evaluate the second item in a list without evaluating the first item in a list. – E4z9 Dec 28 '16 at 14:11
  • 6
    @E4z9 Yeah but in C++ it guarantees that `operator =` is called. And it guarantees what happens if you don't define an `operator =` – user253751 Dec 29 '16 at 00:02
  • @immibis in C `x=5;` doesn't guarentee that x will equal 5 in a multithreaded program ;) – niceman Apr 25 '17 at 12:20
  • 2
    @niceman Sure it does. It doesn't guarantee that you won't set x to something else before the next statement executes, however. – user253751 Apr 25 '17 at 21:46
  • @immibis no it doesn't, you could have torn writes – Passer By Jun 01 '17 at 08:40
  • @PasserBy Well then you just need to update the guarantee. `x=5;` guarantees that `x` will equal 5 if there is no way that `x` could be simultaneously modified in another thread or if `x` is a type that can be atomically written or if you're on a weak consistency model. That doesn't invalidate the point that there are guarantees. (Alternatively, you could state that *you* are guaranteeing to the compiler that you won't modify `x` in multiple threads, and if you break your guarantee the compiler is free to break its). – user253751 Jun 01 '17 at 09:10
  • 2
    @immibis That's a great guarantee :) – Passer By Jun 01 '17 at 09:13
  • @PasserBy Better than Haskell's "this expression will always evaluate to an integer unless it's `undefined` or it uses `unsafe` functions or calls foreign code that breaks this or that rule"? – user253751 Jun 01 '17 at 10:29
  • 2
    @immibis I actually meant that not sarcastically. I don't actually know enough of Haskell to comment on how great Haskell's guarantees are, which is why I'm here – Passer By Jun 01 '17 at 16:34
  • Haskell cannot be a good general purpose language for rapid application development. Each of Python,JavaScript,Go, C#, Java,and Swift are useful primarily for more specific purposes in addition to general development. If Haskell is good for "rapid application development", that means it's good for nothing in particular. – Warlike Chimpanzee Mar 22 '18 at 13:08
  • @weberc2 and npm has more (and more not well perfected and not well maintained) JavaScript libraries than Go’s ecosystem. Quantity != quality. – Shelby Moore III Aug 23 '18 at 03:22
  • @ShelbyMooreIII Why are you comparing libraries with shipped software products? – weberc2 Aug 23 '18 at 21:45
  • @weberc2 I reiterate that quantity != quality. Go still sucks regardless because for example it uses reflection instead of supporting true polymorphism. And thus for example GopherJS can’t do proper dead-code elimination. I also think Haskell is [not the right way](https://github.com/keean/zenscript/issues/35#issuecomment-416021733) to go though. Yet Go has far too many warts and deficiencies to used as a counter example to Haskell. Just as we wouldn’t compare s/w shipped for the crap-language JS as a counter-example to Haskell’s relevance. – Shelby Moore III Aug 28 '18 at 06:37
  • @weberc2 I was just making the point that Go fanboys have a language more the league of crap languages like JavaScript and to not throw stones in their glass house. Goroutines and a C-like language with GC is not totally uninteresting but the lack of polymorphism really bites. – Shelby Moore III Aug 28 '18 at 06:42
  • @weberc2 You appear to not know much about what I prefer. Scala and Kotlin don’t solve real problems? Kotlin is now the officially endorsed by Google language for Android apps— not Go. And we’re [designing to improve on them](https://github.com/keean/zenscript/issues/32#issuecomment-417161479). Go has one main thing going for it (other than being a better C with GC), i.e. goroutines, but we’ll [put that in a modern language](https://github.com/keean/zenscript/issues/17#issuecomment-416825734). But much of (not all of) the rest of the language is archaic. Go fanboys are fun to toy with. – Shelby Moore III Aug 30 '18 at 01:51
  • @ShelbyMooreIII I guess I don't know your preferences, I'm trying to tease coherent points out of your posts, but I'll admit I'm not having much luck. Kotlin is endorsed because Android APIs are written in Java and Kotlin targets the Java virtual machine, not because functional programming languages are inherently better at shipping software rapidly, contra the original claim. :) – weberc2 Aug 30 '18 at 19:53
  • @weberc2 You have conflated FP and generics (aka type polymorphism). Go mostly lacks the latter, as it has some FP capability. Perhaps you were thinking _pure_ FP, but that wasn’t my complaint against Go. Go lacks even basic abstraction which requires generics. Perhaps [this discussion](https://github.com/keean/zenscript/issues/35#issuecomment-417672360) will help clarify. – Shelby Moore III Sep 02 '18 at 11:56
  • @ShelbyMooreIIII I don't believe I've mentioned either generics or pure FP, so I don't know why you think I've conflated them. Perhaps you read another comment and mistakenly attributed it to me? In any case, I'm quite familiar with generics and FP (pure and impure) so this seems like it's probably a misunderstanding. I do agree with you that Go does not have (user-defined) generics, however. Enjoy your long weekend! – weberc2 Sep 02 '18 at 14:56
  • "rapid" totally is not about Haskell. Modeling/prototyping in Haskell is usually slower than in Python/Go/Ruby about 10-20 times - experience of many Haskell/Go/Python dev groups working in parallel. Haskell is incredible complex and weird in places where everything must be clean and simple - it finds rocket science where everything is simple and direct: `myStruct.myField` in Haskell involves several extensions, concept of lenses and innovations in the language itself ;) – RandomB May 08 '20 at 11:32
245

I think people in this post are missing the most important point for anyone who has never used a functional programming language: expanding your mind. If you are new to functional programming then Haskell will make you think in ways you've never thought before. As a result your programming in other areas and other languages will improve. How much? Hard to quantify.

wheaties
  • 34,173
  • 12
  • 82
  • 126
  • 2
    I'm using an iPhone, Mac. Where is Haskell used? I mean for the apps I used they are written in Objective-C or Swift + something for database and servers. Swift can also be functional. So again I'm confused as to where it's used – Honey Dec 14 '16 at 16:25
  • 3
    Facebook does SPAM detection with it: https://code.facebook.com/posts/745068642270222/fighting-spam-with-haskell/ – Alex Dec 16 '16 at 16:28
  • 28
    This answer, written in a different tone, says that Haskell is a great exercise for a programmer, which IMO doesn't make a great general purpose language – Passer By Jun 01 '17 at 08:43
  • 6
    At Keera Studios we write iOS and Android games and apps using Haskell. – Ivan Perez Jun 20 '17 at 12:42
  • 1
    I totally agree with this. I've written a lot of code over decades in imperative languages. I've been exploring Haskell for a couple of months and it's opened my mind to things I hadn't thought about before. – Adahus May 03 '19 at 23:24
90

There is one good answer for what a general purpose language like Haskell is good for: writing programs in general.

For what it is used for in practice, I've three approaches to establishing that:

Indicates that it is good for graphics, networking, systems programming, data structures, databases, development, text processing ...

And finally, my opinion on what it is really strong at:

I hope that gives you a sense on how broad your question is, if it is to be answered with any specificity.

Tom
  • 806
  • 1
  • 7
  • 14
Don Stewart
  • 134,643
  • 35
  • 355
  • 461
31

One example of Haskell in action is xmonad, a "featureful window manager in less than 1200 lines of code".

unutbu
  • 711,858
  • 148
  • 1,594
  • 1,547
19

From the Haskell Wiki:

Haskell has a diverse range of use commercially, from aerospace and defense, to finance, to web startups, hardware design firms and lawnmower manufacturers. This page collects resources on the industrial use of Haskell.

According to Wikipedia, the Haskell language was created out of the need to consolidate existing functional languages into a common one which could be used for future research in functional-language design.

It is apparent based on the information available that it has outgrown it's original purpose and is used for much more than research. It is now considered a general purpose functional programming language.

If you're still asking yourself, "Why should I use it?", then read the Why use it? section of the Haskell Wiki Introduction.

Robert Groves
  • 7,114
  • 5
  • 34
  • 49
13

Haskell is a general purpose programming language. It can be used for anything you use any other language to do. You aren't limited by anything but your own imagination. As for what it's suited for? Well, pretty much everything. There are few tasks in which a functional language does not excel.

And yes, I'm the Rayne from Dreamincode. :)

I would also like to mention that, in case you haven't read the Wikipedia page, functional programming is a paradigm like Object Oriented programming is a paradigm. Just in case you didn't know. Haskell is also functional in the sense that it works; it works quite well at that.

Just because a language isn't an Object Oriented language doesn't mean the language is limited by anything. Haskell is a general-purpose programming language, and is just as general purpose as Java.

Rayne
  • 28,305
  • 16
  • 83
  • 100
9

I have a cool one, facebook created a automated tool for rewriting PHP code. They parse the source into an abstract syntax tree, do some transformations:

if ($f == false) -> if (false == $f)

I don't know why, but that seems to be their particular style and then they pretty print it.

https://github.com/facebook/lex-pass

We use haskell for making small domain specific languages. Huge amounts of data processing. Web development. Web spiders. Testing applications. Writing system administration scripts. Backend scripts, which communicate with other parties. Monitoring scripts (we have a DSL which works nicely together with munin, makes it much easier to write correct monitor code for your applications.)

All kind of stuff actually. It is just a everyday general purpose language with some very powerful and useful features, if you are somewhat mathematically inclined.

Edgar Klerks
  • 1,417
  • 11
  • 20
  • 7
    Re: the FB style, putting the false before the == means if you forget and only write a single = then the resulting behavior will be more obviously wrong instead of silently performing an unintended assignment operation and continuing normally – Magnus Sep 19 '14 at 20:31
  • A that's clever, your force that particularly error to be known compile time then. – Edgar Klerks Sep 19 '14 at 20:47
  • @EdgarKlerks, PHP has no compile time. This forces the exception to be raised where the mistake was, rather than leading to bizarre behavior or errors in distant code. – dfeuer Jan 04 '15 at 17:43
  • Although I see the benefit of writing `false` on the left, I don't see the point of using a tool to do it automatically: if you've already got a `==` operator then you already know you don't have the bug which that part of lex-pass is meant to catch, and if you've got a `=` instead there's no sure way to tell whether or not it's like that deliberately. – Jeremy List Apr 21 '15 at 10:07
  • 1
    @JeremyList Maybe they are really stringent on the coding style. I can see that neatly formatted code invites to write more neatly formatted code. Just a wild guess. – Edgar Klerks Apr 23 '15 at 18:33
  • @dfeuer But it has a phase where it builds up a symbol table? Maybe they catch it there then? Nevermind, this is off topic babble. I probably better check the source code myself. – Edgar Klerks Apr 23 '15 at 18:36
  • I am a newbie to Haskell but find it relatively simple to explore machine learning codes with Haskell (such as kNN classifier and perceptron) – stian Oct 02 '15 at 21:28
6

From Haskell:

Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry.

Basically Haskell can be used to create pretty much anything you would normally create using other general-purpose languages (e.g. C#, Java, C, C++, etc.).

Andrew Hare
  • 320,708
  • 66
  • 621
  • 623
5

For example, for developing interactive, realtime HTML5 web applications. See Elm, the compiler of which is implemented in Haskell and the syntax of which borrows a lot from Haskell's.

thSoft
  • 19,314
  • 5
  • 82
  • 97
3

This is a pretty good source for info about Haskell and its uses:

Open Source Haskell Releases and Growth

Janak Nirmal
  • 22,510
  • 18
  • 60
  • 95
Robert Harvey
  • 168,684
  • 43
  • 314
  • 475