

Make to perform a sort - with most code dealing with the low-levelĭetails of data manipulation - the Haskell program encodes the sortingĪlgorithm at a much higher level, with improved brevity and clarity asĪ result (at the cost of efficiency unless compiled by a very smart compiler): Whereas the C program describes the particular steps the machine must Theįirst program is written in Haskell and the second in C. Into ascending order using a standard method called "quicksort".

Program is like, and the expressiveness of functional languages, look at Programming languages take the same ideas and move them into the realm Spreadsheets and SQL are both fairly specialized languages.

What's good about functional programming? (among other things) figures out the best order in which to evaluate Implementations often perform extensive query optimization which

Indeed, the query can be evaluated in any convenient order. Relation should be computed, without saying how it should be computed. Projections, selections, joins and so forth. Low-level "how" is a distinguishing characteristic ofĪnother well-known nearly-functional language is the standard database This focus on the high-level "what" rather than the In which the ordering of method calls is crucial to the meaning of a With programs in conventional languages like C, which consistĮssentially of a carefully-specified sequence of assignments, or Java, Happen, you can't make much use of it! This contrasts strongly Of re-calculation is that the notion of assignment is not very useful.Īfter all, if you don't know exactly when an assignment will for the most part, we specify the value of a cell by an expression (whose parts can be evaluated in any order), rather than by a sequence of commands which computes its value.Īn interesting consequence of the spreadsheet's unspecified order.
#Haskell functions how to#
we do not tell the spreadsheet how to allocate its memory - rather, we expect it to present us with an apparently infinite plane of cells, and to allocate memory only to those cells which are actually in use.we do not specify the order in which the cells should be calculated - instead we take it for granted that the spreadsheet will compute cells in an order which respects their dependencies.To be computed, not how it should be computed. In a spreadsheet, one specifies the value of each cell Aįunctional program is a single expression, which is executed byĪnyone who has used a spreadsheet has experience of functional They are "imperative" in the sense that theyĬonsist of a sequence of commands, which are executed strictly oneĪfter the other. Specification then is the first prototype of the finalįunctional programs are also relatively easy to maintain, because theĬode is shorter, clearer, and the rigorous control of side effectsĮliminates a huge class of unforeseen interactions.Ĭ, Java, Pascal, Ada, and so on, are all imperative
#Haskell functions software#
Much of a software product's life is spent in specification,ĭesign and maintenance, and not in programming.įunctional languages are superb for writing specifications which canĪctually be executed (and hence tested and debugged). It is particularly suitable for programs which need to Haskell is a wide-spectrum language, suitable for a variety ofĪpplications.
