Prompts for “Why Functional Programming Matters”
Due on Monday, October 29 by 10pm
Read “Why Functional Programming Matters” by John Hughes, pp. 1-11 (the end of 4.1). You may read on if you are curious, but it is not required.
Commit your response as a PDF to your short responses repository. You are encouraged (but not required) to use LaTeX to typeset your response.
- What do you think? Do you accept Hughes’ argument that functional programming “offers important advantages for software development?” If no, what features is it missing or what disadvantages does it introduce? If yes, how do you explain the fact that it has been nearly thirty years since the publication of this paper, and yet the most popular functional programming language, Scala, is used by roughly 1% of professional programmers?
-
Hughes says:
Functional programming is so called because its fundamental operation is the application of functions to arguments. A
main
program itself is written as a function that receives the program’s input as its argument and delivers the program’s output as its result. Typically themain
function is defined in terms of other function, which in turn are defined in terms of still more functions, until at the bottom level the functions are language primitives.There is nothing in the above description that sounds unique to me. C, as we know, also has a
main
function which can be composed of other functions applied to arguments. So why do I need an entirely new language? From my perspective, it sounds like a C programmer can write functional code and more. - F# does not use lazy evaluation by default (it is optional, using the
lazy
keyword). This was a conscious design choice by F#’s designers, and they were well aware of the fact that this would make it harder to “glue” programs together in the manner advocated by Hughes. Give one reason why they might have decided that this powerful “glue” was not worth it. If you’re having trouble thinking of a reason, consider the way that you often write code: write a little, try it; when things go wrong, stick inprintf
statements to figure out what’s happening.