Introduction - HaskellWiki
Jump to content
HaskellWiki
Search
Search
Log in
Personal tools
Log in
Introduction
From HaskellWiki
Haskell is a computer programming language. In particular, it is a<br>polymorphic statically-typed functional programming language with non-strict semantics,<br>quite different from most other programming languages.<br>The language is named for Haskell Brooks Curry, whose work in mathematical logic serves as a foundation for<br>functional languages.<br>Haskell is based on the lambda calculus, hence the lambda we use as a logo.
Why use Haskell?
Writing large software systems that<br>work is difficult and expensive. Maintaining those systems is even<br>more difficult and expensive. Functional programming languages, such<br>as Haskell, can make it easier and cheaper. For example, a new user who<br>wrote a small relational DBMS in Haskell had this to say:
WOW! I basically wrote this without testing just thinking about my<br>program in terms of transformations between types. I wrote the<br>test/example code and had almost no implementation errors in the code! The<br>compiler/type-system is really really good at preventing you from<br>making coding mistakes! I've never in my life had a block of code<br>this big work on the first try. I am WAY impressed.
Even if you are not in a position to use Haskell in your programming projects, learning Haskell can make you a better programmer in any language.
I learned Haskell a couple of years ago, having previously programmed in<br>Python and (many) other languages. Recently, I've been using Python for a<br>project (the choice being determined by both technical and non-technical<br>issues), and find my Python programming style is now heavily influenced (for the better, I hope ;-) by my Haskell programming experience.
Graham Klyne
Haskell offers you:
Substantially increased programmer productivity (Ericsson measured an improvement factor of between 9 and 25 using Erlang, a functional programming language similar to Haskell, in one set of experiments on telephony software).
Shorter, clearer, and more maintainable code.
Fewer errors, higher reliability.
A smaller "semantic gap" between the programmer and the language.
Shorter lead times.
Haskell is a wide-spectrum language, suitable for a variety of<br>applications. It is particularly suitable for programs which need to<br>be highly modifiable and maintainable.
Much of a software product's life is spent in specification,<br>design and maintenance, and not in programming.<br>Functional languages are superb for writing specifications which can<br>actually be executed (and hence tested and debugged). Such a<br>specification then is the first prototype of the final<br>program.
Functional programs are also relatively easy to maintain, because the<br>code is shorter, clearer, and the rigorous control of side effects<br>eliminates a huge class of unforeseen interactions.
What is functional programming?
C, Java, Pascal, Ada, and so on, are all imperative<br>languages. They are "imperative" in the sense that they<br>consist of a sequence of commands, which are executed strictly one<br>after the other. Haskell is a functional language. A<br>functional program is a single expression, which is executed by<br>evaluating the expression.
Anyone who has used a spreadsheet has experience of functional<br>programming. In a spreadsheet, one specifies the value of each cell<br>in terms of the values of other cells. The focus is on what is<br>to be computed, not how it should be computed. For<br>example:
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.
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.
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.
An interesting consequence of the spreadsheet's unspecified order<br>of re-calculation is that the notion of assignment is not very useful.<br>After all, if you don't know exactly when an assignment will<br>happen, you can't make much use of it! This contrasts strongly<br>with programs in conventional languages like C, which consist<br>essentially of a carefully-specified sequence of assignments, or Java,<br>in which the ordering of method calls is crucial to the meaning of a<br>program.
This focus on the high-level "what" rather than the<br>low-level "how" is a distinguishing characteristic of<br>functional programming languages.
Another well-known nearly-functional language is the standard database<br>query language SQL. An SQL query is an expression involving<br>projections, selections, joins and so forth. The query says what<br>relation should be computed, without saying how it should be computed.<br>Indeed, the query can be evaluated in any convenient order....