[Comparisons with other language families Bryan O'Sullivan **20080427053418] { hunk ./en/00book.xml 12 + hunk ./en/00book.xml 117 + &ch01a; hunk ./en/ch01-bis.xml 3 - + hunk ./en/ch01-bis.xml 161 - We started this project because a growing number + We started this project because a growing number hunk ./en/ch01-bis.xml 167 - With this book, we want to show you how to use + With this book, we want to show you how to use hunk ./en/ch01-bis.xml 211 - As a new Haskell programmer, you'll inevitably + As a new Haskell programmer, you'll inevitably hunk ./en/ch01-bis.xml 238 - not designed with a niche application in mind. Although it - takes a strong stand on how programs should be written, it - doesn't favour one kind of program over another. Here are just - a few examples of the variety of applications that have been - written with Haskell. + designed without any application niche in mind. Although it + takes a strong stand on how programs should be written, it does + not favour one problem domain over others. hunk ./en/ch01-bis.xml 242 - - - Innumerable compilers and compiler-related tools - - - Chip design software - - - A toolkit for music composition - - - Distributed revision control - - - Secure web middleware - - + While at its core, the language encourages a pure, lazy + style of functional programming, this is the + default, not the only option. Haskell also + supports the more traditional models of procedural code and + strict evaluation. Additionally, although the focus of the + language is squarely on writing strongly typed programs, it is + possible (though rarely seen) to write Haskell code in a + dynamically typed manner. hunk ./en/ch01-bis.xml 251 - For practical work, almost as important as a language itself - is the ecosystem of libraries and tools around it. Haskell has - a strong showing in this area. + + Compared to traditional static languages hunk ./en/ch01-bis.xml 254 - The most widely used compiler, &GHC;, has been actively - developed for over 15 years, and provides a mature and stable - set of features. + Statically typed languages have been the mainstay of the + programming world for decades. Although Haskell is a + statically typed language, its notion of what types are for, + and what we can do with them, is much more flexible and + powerful than traditional languages. hunk ./en/ch01-bis.xml 260 - - - Compilation to efficient native code - - - Easy deployment of compiled binaries, unencumbered by - licensing restrictions - - - Interactive interpreter and debugger - - - Code coverage analysis - - - Thorough documentation - - - Massively scalable support for concurrent and multicore - programming - - + In addition, Haskell's type system is often unobtrusive: a + Haskell compiler will automatically infer the type of an + expression or function if we don't provide it. Compared to + traditional static languages, to which we must spoon feed + large amounts of type information, the combination of power + and inference in Haskell's type system significantly reduces + the clutter and redundancy of our code. hunk ./en/ch01-bis.xml 268 - The Hackage package database is the Haskell community's - collection of open source libraries and applications. Most - libraries published on Hackage are licensed under terms that - allow both commercial and open source use. Some of the areas - covered by open source libraries include the following. + Several of Haskell's other features combine to further + increase the amount of work we can fit into a screenful of + text. As a result, it is not unusual for a Haskell program to + require one tenth the number of lines of code as an equivalent + written in a traditional language. With this come + improvements in development time and agility: we can create + reliable code quickly, and easily refactor it in response to + changing requirements. hunk ./en/ch01-bis.xml 277 - - - Interfaces to all major open source and commercial - databases - - - XML, HTML, and XQuery processing - - - Web client and server development - - - Desktop GUIs, including cross-platform toolkits - - - Support for Unicode and other text encodings - - - + These productivity improvements are sometimes accompanied + by a performance penalty when it comes to running code. It is + not unusual for a Haskell program to run at a half to a + quarter the speed of a comparable program written in a + traditional language. + + However, a substantial and increasing number of Haskell + programs perform as well as (sometimes better than) their + traditional counterparts. In part, this is due to advances in + Haskell compilers and libraries, where progress is rapid and + improvements benefit the entire community. Also, Haskell's + huge edge in developer productivity gives us more + opportunities to focus on algorithmic improvements. + + + + Compared to modern dynamic languages + + Over the past decade, dynamically typed and interpreted + languages have become increasingly popular. They offer + substantial benefits in developer productivity. Although this + typically comes at the cost of a huge performance hit, for + many programming tasks productivity trumps performance, or + performance isn't a significant factor in any case. + + Brevity is one area in which Haskell and dynamically typed + languages perform similarly: in each case, you write much less + code to solve a problem than in a traditional language. + Programs are often around the same size in dynamically typed + languages and Haskell. + + When we consider runtime performance, Haskell almost + always has a huge advantage. Code compiled by &GHC; is + typically between 20 and 60 times faster than code run through + a dynamic language's interpreter. &GHC; also provides an + interpreter, so you can run scripts without compiling + them. + + Another big differentiator between dynamically typed + languages and Haskell lies in the philosophy around types. A + major reason for the popularity of dynamically typed languages + is that only rarely do we need to explicitly mention types. + Through automatic type inference, Haskell offers the same + advantage. + + However, beyond this surface level the differences run + deep. In a dynamically typed language, we can create + constructs that are difficult or impossible to express in a + statically typed language. However, the same is true in + reverse: with a type system as powerful as Haskell's, we can + structure a program in a way that would be unmanageable or + infeasible in a dynamically typed language. + + It's important to recognise that each of these approaches + involves tradeoffs. Very briefly put, the Haskell perspective + emphasises safety, while the dynamically typed outlook favours + flexibility. If someone had already discovered one way of + thinking about types that was always best, we imagine that + everyone would know about it by now. + + Of course, we have our own opinions about which tradeoffs + are more beneficial. Two of us have years of experience + programming in dynamically typed languages. We love working + with them; we still use them every day; but usually, we prefer + Haskell. In our experience, Haskell starts to outshine a + dynamically typed language once a project grows to a handful + of thousands of lines of code. + + + + Haskell in industry and open source + + Here are just a few examples of large software systems + that have been created in Haskell. Some of these are open + source, while others are commercial products. + + + + Innumerable compilers and compiler-related + tools + + + Chip design software + + + A toolkit for music composition + + + Distributed revision control + + + Secure web middleware + + + + + + Compilation, debugging, and performance analysis + + For practical work, almost as important as a language + itself is the ecosystem of libraries and tools around it. + Haskell has a strong showing in this area. + + The most widely used compiler, &GHC;, has been actively + developed for over 15 years, and provides a mature and stable + set of features. + + + + It compiles to efficient native code on all major + modern operating systems and CPU architectures + + + Easy deployment of compiled binaries, unencumbered by + licensing restrictions + + + Interactive interpreter and debugger + + + Code coverage analysis + + + Detailed profiling of performance and memory + usage + + + Thorough documentation + + + Massively scalable support for concurrent and + multicore programming + + + + + + + Bundled and third party libraries + + The &GHC; compiler ships with a collection of useful + libraries. Here are a few of the common programming needs + that these libraries address. + + + + File I/O, and filesystem traversal and + manipulation + + + Network client and server programming + + + Regular expressions and parsing + + + Concurrent programming + + + Automated testing + + + Sound and graphics + + + + The Hackage package database is the Haskell community's + collection of open source libraries and applications. Most + libraries published on Hackage are licensed under liberal + terms that permit both commercial and open source use. Some + of the areas covered by open source libraries include the + following. + + + + Interfaces to all major open source and commercial + databases + + + XML, HTML, and XQuery processing + + + Network and web client and server development + + + Desktop GUIs, including cross-platform toolkits + + + Support for Unicode and other text encodings + + + hunk ./en/ch01-bis.xml 576 - + hunk ./en/ch01-bis.xml 578 - + hunk ./en/ch01-bis.xml 585 - + hunk ./en/ch01-bis.xml 589 - For questions about language syntax and + For questions about language syntax and hunk ./en/ch01-bis.xml 606 - Various extensions to the language have + Various extensions to the language have hunk ./en/ch01-bis.xml 616 - + hunk ./en/ch01-bis.xml 627 - + hunk ./en/ch01-bis.xml 634 - The Haskell community maintains a central + The Haskell community maintains a central hunk ./en/ch01-bis.xml 643 - - The The hunk ./en/ch01-bis.xml 651 - + hunk ./en/ch01-bis.xml 654 - There are a number of ways you can get in touch + There are a number of ways you can get in touch hunk ./en/ch01-bis.xml 661 - The first stop on your search for community + The first stop on your search for community hunk ./en/ch01-bis.xml 670 - Haskellers use a number of Haskellers use a number of For real-time chat, the For real-time chat, the hunk ./en/ch01-bis.xml 689 - There are many local user groups, meetups, + There are many local user groups, meetups, hunk ./en/ch01-bis.xml 693 - hunk ./en/ch01-bis.xml 696 - The The The The