12

Possible Duplicate:
What are some well known applications written in F#?

I see a lot of people talking about how cool functional programming is, how awesome Lisp and Haskell and F# are, etc, but what I don't see is them actually being used. Just about every program on my computer is written in either something in the C family, Delphi, or Python. I see tutorials talking about how easy it is to use functional languages to do complicated math problems, but no one talking about using them to do things most people actually care about using computers for, like business applications and games.

Does anyone have any examples of actual programs that people have heard of and are using, written in a functional language? The only one I can think of off the top of my head is Abuse, from almost 15 years ago. (Things like Emacs, where the core program is written in C with a functional language scripting layer on top, don't count.)

Mason Wheeler
  • 82,151
  • 24
  • 234
  • 309
  • 3
    I think you're confusing functional programming with functional languages. For instance, I've successfully applied a lot of functional programming concepts from [Real World Functional Programming](http://www.manning.com/petricek/) using C#. The language now has a lot of functional features. – Scott Whitlock Nov 28 '10 at 17:12
  • Some vital parts of the New York Stock Exchange run on Scheme. You may not have "heard of" it, but you probably "used" it! – Macneil Nov 28 '10 at 18:02
  • @Scott: I'm aware that some functional techniques are being recognized as useful, and language-level support for them is being added to a lot of mainstrean languages. That's not what I'm talking about. I'm thinking of the loud claims that FP advocates make about "pure" functional programming makng you ten times more productive. I figure if that was really true, pure FP would have taken over the world already on merit alone. Since it obviously hasn't, I'm looking for real examples of functional languages in use. – Mason Wheeler Nov 28 '10 at 18:06
  • 2
    `if that was really true, pure FP would have taken over the world already on merit alone.` The expressiveness of a language is only one part of the productivity equation. A language must also have good libraries and adequate support for I/O, both of which are common criticisms of Lisp specifically, and pure functional languages in general. This makes functional languages good for some problem domains, but not so good for others. By contrast, imperative languages are the "swiss army knife;" getting the job done may not be pretty, but it will get done. – Robert Harvey Nov 28 '10 at 18:34
  • If Emacs doesn't count, then neither does Abuse since most of the game was written in C (or C++) and lisp was used as a scripting engine. – Dean Harding Nov 28 '10 at 22:08
  • @Mason: I think the FP advocates really meant to say that "pure" functional programming makes *them* ten times more productive. – Larry Coleman Nov 28 '10 at 22:10
  • @Dean: Really? I had heard that the game was actually written in Lisp. But maybe I heard wrong. – Mason Wheeler Nov 28 '10 at 22:16
  • @Mason: I just did a cursory google and it seems to confirm that Lisp was only used as a scripting language... of course, you can't trust *everything* you read on the internet :-) – Dean Harding Nov 28 '10 at 23:06
  • Has any programming language "taken over the world?" – Barry Brown Nov 29 '10 at 00:18
  • 12
    When did *any* programming language *ever* "take over the world on merit alone"? In fact, when did *anything* take over the world on merit alone? Everything that ever took over the world did this either by accident, by marketing or by sheer luck. Java took over the world because CPU vendors wanted to screw Intel using the JVM, OS vendors wanted to screw Microsoft using the JVM, application vendors wanted to stay out of the OS and CPU fight using the JVM. Nobody *actually* cared about *Java*. It just happened to be bundled with the JVM. – Jörg W Mittag Nov 29 '10 at 03:27
  • @Jörg W Mittag: If it happens "by accident" then surely that is on merit alone. Your example shows that Java got picked on particular merits, and nothing else. They are merits of the language because otherwise it would have been a different language – Matt Ellen Nov 30 '10 at 13:10
  • @Matt Ellen: I'm not sure what you mean. My example shows that Java wasn't picked *at all*, it was the *JVM* that was picked. IBM, for example, had *far better* languages than Java. They picked the JVM *despite of* Java. I personally know lots of people who use the JVM, but I don't know anyone who uses Java. I don't think it's a coincidence that after just a few years, there were over 400 languages on the JVM *other than* Java. – Jörg W Mittag Dec 01 '10 at 01:34
  • @Mason: I edited your question to stop making it so local and to make it neutral in tone. Your own personal opinion of functional programming languages does not have to be known in order for you to get your answers. Also, by removing the arbitrary restriction, you will encourage more answers, some of which you may want to know. – Macneil Dec 01 '10 at 05:00
  • @Macneil: Your edits drastically alter not only the "tone" of my question but also the nature of it. They are not welcome, and I've rolled them back for a reason. If you want answers to a different question than the one I asked, feel free to ask your own question, but stop trying to put words in my mouth before I flag you. – Mason Wheeler Dec 01 '10 at 05:21
  • 5
    Closed as a duplicate? What duplicate? I see the F# question noted above, but believe it or not, F# isn't the only functional programming language. – mipadi Dec 01 '10 at 14:33
  • I don't understand why emacs doesn't count. The C portion is basically a lisp interpreter - whats wrong with that? I mean, thats like saying that portage isn't written in python because python's typical interpreter isn't written in python. – alternative Feb 21 '11 at 23:09

12 Answers12

20

I don't know of a lot of games or end-user applications written in functional languages, though I'm sure there are some. Games and end-user applications, though an important and visible part of the software market, are only a part of it. Remember, there is huge amounts of software out there that you never see because it is orchestrating processes that don't have end-user application or game interfaces.

For example, F# is popular at Credit Suisse for quantitative analysis:

http://blogs.msdn.com/b/dsyme/archive/2010/07/15/f-jobs-at-credit-suisse-london.aspx

Unless you work there, you're probably not going to ever see the user interface to that software.

Or, Erlang is popular for writing the software that controls mobile phone switches:

http://en.wikipedia.org/wiki/Erlang_(programming_language)

You probably don't think of making a phone call as an application, but someone had to write the software that controls the switch.

Eric Lippert
  • 45,799
  • 22
  • 87
  • 126
10

Ever used a modern website, lots of Javascript, tons of people using jQuery?

Well that's effectively a functional language, closures, functions as first-class objects, etc.

Everywhere, millions of users day by day.

Orbling
  • 5,696
  • 1
  • 32
  • 38
9

Erlang is in use at Facebook, Yahoo, and Amazon. It's also running embedded in Ericsson and Nortel ePBX (electronic Public Branch Exchange) telecom switches with ridiculous uptime. CouchDB is written in Erlang, as is ejabberd. There are more now, and more coming every day. Check out Totally Erlang for Erlang jobs to see who's working on what.

Alan
  • 301
  • 1
  • 4
6

Lisp dialects are used all over the place - but it's not really mainstream... yet

Jak and Daxter (YouTube demo) was written using GOAL (Game Oriented Assembly Lisp). From the Gamasutra review, I quote (emphasis added for clarity):

5. GOAL rules! Practically all of the run-time code (approximately half a million lines of source code) was written in GOAL (Game Object Assembly Lisp [acronym correct?]), Naughty Dog's own internally developed language, which was based on the Lisp programming language. Before you dismiss us as crazy, consider the many advantages of having a custom compiler.

Lisp has a very consistent, small set of syntactic rules involving the construction and evaluation of lists. Lists that represent code are executed by evaluating the items that are in the list; if the head of the list is a function (or some other action), you could think of the other items in the list as being the parameters to that function. This simplicity of the Lisp syntax makes it trivial to create powerful macros that would be difficult or impossible to implement using C++.

Other software written using Common Lisp includes:

the list goes on. It's fair to say that although Lisp is not exactly a fully mainstream language, it certainly solves a lot of difficult problems in a neat and elegant way.

Gary
  • 24,420
  • 9
  • 63
  • 108
  • 7
    A fascinating and scary comment comes from the last line of the Wikipedia article on GOAL: "GOAL's primary development and maintenance engineer is no longer available to Naughty Dog, and so they are transitioning to a C++ based pipeline for future projects." Which means that they bet their company on one programmer and when he quit they don't know how to deal with the language/framework he wrote. – Tangurena Nov 28 '10 at 18:02
  • Very interesting stuff. Apparently you can change out code while the application is running, a feature reminiscent of Erlang. – Robert Harvey Nov 28 '10 at 18:41
  • 1
    @Tangurena Good spot. It seems inconceivable that no-one would have thought to do an ongoing knowledge share/handover. – Gary Nov 28 '10 at 18:42
  • 1
    @Tangurena, nothing wrong in using a talented programmer - just see what John Carmack does - and it also appeared to have worked very well. The glitch here is that Naughty Dog forgot to have the knowledge shared across others. The socalled bus factor. –  Nov 28 '10 at 18:44
  • @Robert, sounds like a standard Lisp facility - being able to redefine defs on the fly. –  Nov 28 '10 at 18:45
  • @Robert Another example of "solving difficult problems in a neat and elegant way." – Gary Nov 28 '10 at 18:49
  • @Thorbjørn: Yes, that makes sense. – Robert Harvey Nov 28 '10 at 19:00
  • 1
    Interesting, but from the Wikipedia article it appears that the language is designed for imperative, object-oriented programming with little support for functional style or garbage collection. They basically re-implemented C++ in Lisp. (What would Greenspun say?!?) – Mason Wheeler Nov 28 '10 at 21:24
  • @Thorbjørn Ravn Andersen, @Tangurena From what I understand, the people at Naughty Dog that knew the GOAL compiler were (a) the writers of the GOAL compiler and (b) the founders of Naughty Dog. So, not so much betting the company on one programmer as the company not having existed if it wasn't for that programmer (they started out using GOOL, for the Crash Bandicoot series). – Vatine Nov 30 '10 at 10:10
  • @Mason, if you want C++ but with the ability to redefine code while running (optimized graphics pathways would be a certain candidate), it is actually a very nice solution. –  Nov 30 '10 at 10:39
  • @Vatine, so what they are saying is basically that the people who knew how, has left the company leaving just the name? Interesting. Do you know where they went? –  Nov 30 '10 at 10:40
  • @Thorbjørn Ravn Andersen Andy Gavin and Jason Rubin seem to now have a small independent games studio called "Monkey Gods" (at least if you take Wikipedia as gospel). – Vatine Nov 30 '10 at 10:48
  • Found this link telling a bit more about the Naughty Dog story: http://bc.tech.coop/blog/060118.html –  Nov 30 '10 at 10:49
  • @Thorbjørn I really like the last sentence in that link: "Lisp got them to where they needed to be to succeed - definitely a quality that entrepreneurs want in a programming language!" – Gary Nov 30 '10 at 15:43
3

Orbitz uses Lisp extensively for it's flight lookup engine.

Robert Harvey
  • 198,589
  • 55
  • 464
  • 673
  • I was aware of this example, but the actual letter (as opposed to Paul Graham's claims about it) make it apparent that this one falls squarely in the Emacs category. – Mason Wheeler Nov 28 '10 at 17:24
  • If you say so. I doubt Orbitz would consider their creation a "scripting engine." – Robert Harvey Nov 28 '10 at 17:28
  • Yeah, they probably wouldn't. But if it quacks like a duck... – Mason Wheeler Nov 28 '10 at 18:45
  • @Mason: This whole "Emacs doesn't count" exception is strange and makes the question less constructive. I think it could be improved. – Macneil Nov 29 '10 at 00:12
  • @Macneil: It's not meant to be strange. Anyone can put a scripting layer (for just about any language) on top of a basic application that already exists, making it easily extensible. I'm looking for examples about the core app itself. – Mason Wheeler Nov 29 '10 at 02:02
  • @Mason: I think that's where we differ. The core architecture of the application is the interpretor for the "scripting" language. – Macneil Nov 29 '10 at 02:03
  • 4
    @Mason Wheeler: the *only* part of GNU Emacs that is *not* written in ELisp is the ELisp VM. And that is only because of portability. The original versions of Emacs were written on Lisp Operating Systems which directly understand Lisp code, so they were 100% Lisp. – Jörg W Mittag Nov 29 '10 at 03:22
  • @Jörg W Mittag Actually, the first version of Emacs was written in TECO (a scriptable line editor). – Vatine Nov 30 '10 at 10:12
2

Functional Programming is not just limited to a particular language, its also a style of coding in my mind.

When I say style of course I'm ignoring the "pure" functional requirement of not including any states..

In that sense, I suspect its used a lot in daily situations.

Just to give you an example, in a recent project I used "functional" style of programming to transform URL's into dynamic Site-maps (tree structure) on the fly. This was done by breaking down the problem into smaller functions which was then composed together to create the final solution : Data In -> Function (F1+F2+Fn) -> Tree

Darknight
  • 12,209
  • 1
  • 38
  • 58
2

Xmonad, a windowing manager, is written in Haskell.

mipadi
  • 7,493
  • 36
  • 35
  • 1
    I respect their effort, but to me Xmonad is a niche (a X11 window manager) in a niche (used on operating systems minus Windows/Mac). I am not sure whether mentioning Xmonad is not amplifying the impression that functional programming is a niche. – LennyProgrammers Nov 30 '10 at 09:14
2

It's used in the industry by the minority that understand how and have the opportunity to use it. The majority of programmers won't understand recursion or things like first-class functions and that you can treat a function as a value and store it in a list. I'm not trying to sound elitist but the reality is the use of functional languages is limited because the vast majority of programmers can't get it. Sure lot's of people use Javascript but whether they use it in a functional way is another question.

Anyway here's a list of some organizations/people that use/used functional languages:

  • Paul Graham used Lisp to make a web store that got sold to Yahoo back in the day when Yahoo was king of the net.
  • Citrix use OCaml for the management tools for Xen.
  • The Halo team used F# internally
  • Fairly sure a lot of banks are using F# at the moment.
  • Ericsson use Erlang

But at the end of the day the language used makes little difference to the outcome of the project. The best programming language in the world won't save you from bad management implementing bad processes that have design and requirements proceeding for months and then expecting the 1000000 lines of documentation converted into working and tested code in 3 months.

sashang
  • 1,076
  • 1
  • 7
  • 18
1

Igor Engraver, a music notation program, is written in Lisp.

Joonas Pulakka
  • 23,534
  • 9
  • 64
  • 93
1

Lots of financial analysis used to be done in APL, from earlier responses it sounds like they've transitioned to F# today.

TMN
  • 11,313
  • 1
  • 21
  • 31
0
LennyProgrammers
  • 5,649
  • 24
  • 37
0

Perhaps not in a purely functional language, but I use functional paradigms all the time when I write python and javascript.

hasen
  • 1,389
  • 1
  • 13
  • 15