26 ms·
Why Functional Programming Matters (1984) [pdf]
- joshuapassos 10y agoI love this paper
- deleted 10y ago[deleted]
- AimHere 10y agoFor those whose browsers don't speak bare postscript, a pdf also exists: http://www.cse.chalmers.se/~rjmh/Papers/whyfp.pdf http://www.cse.chalmers.se/~rjmh/Papers/whyfp.pdf
- executesorder66 10y agoOut of curiosity, which browsers do support native postscript rendering?
- lmm 10y agoKonqueror supports it in the sense that it will embed the appropriate KPart, just as it would for e.g. PDF. How "native" you consider that is an open question.
- executesorder66 10y agoThanks. By native I meant it renders without plugins or any configuration by the user, on a default install of the browser.
- lmm 10y agoThe line between plugin and not is pretty blurry for Konqueror - even its HTML renderer is a plugin in a sense.
- yoz-y 10y agoRenders fine in Safari. I assume it uses pdf.js or something in the same vein though, the page scrolling is very slow.
- proaralyst 10y agoMy Firefox does not.
- sctb 10y agoThanks, we've updated the link.
- skeptic2718 10y agoIs it that time of the year again?
- kutkloon7 10y agoA lot of pleas for functional programming give a long list of convincing examples that work well with functional programming. You can do this with almost any language, and this is also quite deceptional, as this is often done to convince beginners to learn another language; "look at how simple it is to program this contrived example in <language X>!". In order to be able to use a programming language or paradigm well, it is especially useful to know what its weaknesses are. Functional programming does not work well in programs which handle a lot of states. It does not work well in programs which have high requirements for performance or memory. It does not work well for programs which have to do low-level stuff. These are serious disadvantages, and I would like to see them highlighted more often in this introductory-style articles. Nevertheless, I think functional programming is a must to be able to write simpler programs, and I think programmers should write functions (i.e. methods that only depend on their arguments) whenever possible, for modularity and correctness reasons. I think the disadvantages can be solved by non-pure functional languages, and that there is a lot to gain for new programming languages in this area.
- amirmc 10y ago> I think the disadvantages can be solved by non-pure functional languages, and that there is a lot to gain for new programming languages in this area. We don't necessarily need new languages for this. There are already pragmatic languages out there, for example, OCaml [1] (and if the syntax is off-putting there's ReasonML [2] from Facebook). I'm sure there are other examples too. [1] http://ocaml.org http://ocaml.org [2] http://facebook.github.io/reason/ http://facebook.github.io/reason/
- shultays 10y agoHere is cat in brainfuck ,[.,] Why it is not year of the brainfuck programming is beyond me
- dualogy 10y ago> Functional programming does not work well in (cont..) You state earlier that programmers can and perhaps should write functional style (AFA feasible) in the languages that do excel at above problems. So you probably meant that "functional languages" ---rather than "functional programming"--- "does not work well" there. > (..cont) programs which handle a lot of states. It does not work well in programs which have high requirements for performance or memory. It does not work well for programs which have to do low-level stuff. The main problem with these issues is that there's no serious investment into optimizing the very few pure-and-lazy (for me the holy grail of FP) languages' (most-all of academic origin) compilers better for real-world loads such as you outlined. The described problem spaces themselves ("lots of states" -- huh?) are surprisingly simple to model in the type systems of the languages I'm into such as Haskell. Side effects are most elegantly solved and defining them yields succinct and non-ambiguous code. And really just like OOPs design classes to describe their problem spaces and stuff their logic into, so you start from your types in FP. That being said, so far I'm rather satisfied with GHC speeds and resulting binary performance. That is, of course, for non mission-critical-realtime-high-frequency-trades-while-raytracing-while-guiding-missiles use-cases only so far. A lot of automation I do, I really couldn't give a hoot about its performance as long as I'm not billed by the second (which you shouldn't be anyway). Because, hey it's automation! It means I can do other stuff! Likewise I don't care whether a dishwasher takes 1 or 3 hours. Adjust expectations and use the time freed: slower automation yields more time freed! Wait..
- cousin_it 10y agoThe top link on /r/haskell right now [1] is someone complaining that their program runs out of space due to a subtle interaction between laziness and IO. I think it's safe to say that we have tried laziness as the default and have learned that it's the wrong default, because it plays havoc with space and with IO. [1] https://www.reddit.com/r/haskell/comments/5h6emf/haskell_run_out_of_memory/ https://www.reddit.com/r/haskell/comments/5h6emf/haskell_run...
- tome 10y agoNo, that's not laziness per se, that's "lazy IO", something somewhat different. EDIT: It's not even a lazy IO problem since no lazy IO functions are used there.
- cousin_it 10y agoThe problem is laziness. Lazy IO just makes it happen with files, which is more noticeable. In regular lazy code it happens with memory instead (space leaks).
- fbreduc 10y agothese are not problems, only small details that you have to be careful of..not a large tradeoff to pay
- marcosdumay 10y agoThat's like saying that bounds overflow in C isn't a problem, just something you have to be careful of. To tell you the true, I can't understand why the code the OP talks about has a problem, and I can't even reproduce the problem (and never saw any of the problems of lazy IO in practice either). But I also can not say the code has no problem, and that is a big issue with the language.
- lomnakkus 10y ago> That's like saying that bounds overflow in C isn't a problem, just something you have to be careful of. I think there's a significant difference between undefined behavior (hello security flaws!) and the program crashing in a (reasonably) well-defined way.
- GrumpyNl 10y agoYou can program functional in almost any language. Its more a mindset. I can not emphasize this enough, keep it simple.
- chrisdone 10y agoI think what you mean by "functional" and what the author means by "functional" are distinct. Are you aware of the distinction?
- mpweiher 10y agoTo me, this is the most important part of the text (p2, bottom): "The ways in which one can divide up the original problem dep end directly on the ways in which one can glue solutions together Therefore to increase ones ability to mo dularise a problem conceptually one must provide new kinds of glue in the programming language." Functional programming is great because it provides two (new) kinds of glue: function composition and lazy evaluation. Even if you accept that (I certainly do for function composition, less enthusiastic about lazy evaluation), I would say that it only provides two new kinds of glue. We need lots of kinds of glue, in other words, lots of architectural connectors. And that means linguistic means of defining and varying architectural connectors. http://objective.st http://objective.st
- hota_mazi 10y ago> Functional programming is great because it provides two (new) kinds of glue: function composition and lazy evaluation. Certainly true for composition but laziness is more the exception than the rule in today's FP languages. And it's getting an increasingly bad reputation to the point that even Haskell is slowly (and reluctantly) being dragged in the strict direction (which it will never fully reach because so much of it would break).
- mpweiher 10y ago> laziness is more the exception than the rule in today's FP languages Exactly. I also wrote I am somewhat less enthusiastic about laziness. So that leaves just one kind of glue as FP's contribution, which goes back to my point to the contribution being good but not sufficient.
- bunderbunder 10y agoThere's one spot where I like laziness, and that's where it supports composition. I'm gonna hop over to C# because that's where my favorite example lives: LINQ is a functional library that lets you describe queries on data that are executed lazily. The reason why the laziness is great in this scenario is that it lets you separate the tasks of constructing a data processing pipeline, and executing it. The spot where it's tricky, though, is that it's a very leaky abstraction. It's easy to forget that these expressions might actually represent a lot of work, so if you get your lazy sequence object (IEnumerable<T> in C# terms) and then check if it has any values in one expression, and calculate its sum in another, then you might end up accidentally round-tripping a database twice. Because of those sorts of stumbling blocks, I think laziness is a power that needs to be handled with care. I'm pretty sure that means you most certainly should not make it the default behavior.
- inputcoffee 10y agoDoes someone have a better scanned version of this? The format is not great on this, but it looks really interesting.
- mgr86 10y agoI am not sure if this is better. But here is a scanned copy of the original journal article. I put it on google drive. Do you have a preferred PDF host? https://drive.google.com/file/d/0B8_iX4Icv1BmQkh3TWtqTXY5ajQ/view?usp=sharing https://drive.google.com/file/d/0B8_iX4Icv1BmQkh3TWtqTXY5ajQ...
- inputcoffee 10y agoThank you, this does read better (thicker font, better resolution) on my screen. I was fine with the post-script but for some reason it seemed thin and there was a slight blur. I just use my browser to read the PDF (usually chrome, sometimes Firefox or IE or even Opera).
- throwawayfp00 10y agoThis essay is as much an apology for Miranda and Haskell style lazy-by-default evaluation as it is for functional programming itself, and it's therefore absurd that in 2016 it's still being posted here, let alone enthusiastically upvoted. Lazy-by-default evaluation is a bad idea. It makes the design of the compiler orders of magnitude more complicated (see GHC) and in practice results in nasty performance-related bugs (space leaks) that can be catastrophic when encountered in production. Idris is gaining on Haskell in large part because of its strictness, and the GHC high priests not long ago relented and added a strictness pragma to their compiler in response (which does not actually give you a strict program). And of course they did this without any frank acknowledgement that the choice of default evaluation strategy for Haskell was a colossal mistake. Nor has the Haskell community apologized for its extremely disingenuous past advocacy that sold lazy-by-default evaluation as a powerful optimization, like this paper does, when in practice it's usually the exact opposite. The Haskell community is extremely cultish, even by the standards of FP.
- deleted 10y ago[deleted]
- antennas 10y agoFraming this essay as apologia for Haskell's laziness is a weird because Haskell was created exactly because there was a proliferation of non-strict functional languages and the Haskell committee recognized that having a common language would be beneficial. So it seems disingenous to separate Haskell and laziness: the latter partly defines the former. Haskell's evaluation strategy is not something you can just change and have the rest of the language stay the same. If Haskell were strict there would be a good chance that it wouldn't be pure (see: ML variants); if it wasn't pure then IO would not be a problem; if IO wasn't a problem then Phil Wadler wouldn't have needed to invent typeclasses, etc.
- dang 10y agoPlease don't do the programming language flamewar thing here. There are plenty of other ways to discuss them.
- m0th87 10y agoSee also Raganwald's Why Why Functional Programming Matters Matters: http://weblog.raganwald.com/2007/03/why-why-functional-programming-matters.html http://weblog.raganwald.com/2007/03/why-why-functional-progr...
- bunderbunder 10y agoIronically, his "rules of Monopoly" analogy helped me realize why I haven't completely given up on OOP, especially for non-hobby work. He holds up the idea that every piece of the game has the rules for what you can do with it tacked on as some sort of horrible mess, but, in the age of code completion, I'm finding that it's used to drive an amazing convenience from a practical perspective: Code completion. Take Python, which is a language that I'm still learning. If I have an object, but I'm not sure what I can do with it - or, more particularly, I'm not sure of the names for the things I can do with it - I can get a quick reference by hitting '.-tab' to bring up an autocompletion menu, just so long as I'm interacting with a more OO Python library. If I'm trying to work with a more procedural library such as matplotlib, though, I'm SOL and end up having to dive through the documentation. (I can't think of a really great functional library for Python that I use, but the same is true for the more functional-y bits of numpy and pandas.) And matplotlib is a big library, so there's a lot of documentation. Far from being a form of organization, that fabled central store of the rules that the author holds up as an ideal ends up being an awful quagmire to wade through. Granted, this is dependent on having an editor that does tab completion. And I'm sure it could be done with a functional library, too, but probably only if you're using a statically typed functional language, and I've no idea what a good UX would look like given how functional syntax works. But still, given the current situation, I think I've realized my main reason for thinking that object-oriented programming also matters: Because right now, when you're working with large and complicated systems, object-oriented programming still offers the more pragmatic, human-friendly user experience.
- Kenji 10y agoWhy Functional Programming ended up not mattering much at all, after all (2016) [pdf]