Haskell in the Software Industry What is Haskell? Haskell in a nutshell Haskell is a pure, non-strict, statically typed, garbage collected, general purpose, functional programming language. Early history ➞ Growing interest towards lazy languages in the late 70s and early 80s led to the creation of several academic languages. ➞ Haskell was designed by a committee of researchers to combine the best features from the existing lazy languages. The escape from the Ivory Tower ➞ Haskell stayed relatively unknown outside research circles until at least early 2000s. ➞ Uncertain what caused the sudden growth of interest, but can be partly attributed to the combination of 1 The Haskell standard reaching maturity with the revised edition of The Haskell Language Report ‘98 2 The Haskell library ecosystem having a critical mass of high quality libraries for real applications 3 The global resurgence of interest towards the functional paradigm in general Standard versus Implementation ➞ Standard Haskell is defined in The Haskell Language Report ➞ Some library authors like to ensure that their can be compiled with any compliant compiler. ➞ However, almost all real-world development of Haskell is done using GHC. ➞ It is common in application development to target GHC exclusively and take advantage of all it’s non-standard extensions. ➞ Some companies even maintain their custom, in-house Haskell compiler optimized for their specific use-case. What makes Haskell relevant for today’s software industry? What is Haskell best suited for? ➞ Parsing and transforming data ➞ Creating custom DSL to express complicated business logic or rules ➞ Business domains where software reliability is a high priority Haskell’s selling points for the software industry ➞ Increased productivity ➞ Less bugs ➞ Less code ➞ Simpler software architecture ➞ Easier parallelism and concurrency ➞ Performance between “pretty good” and great* What is Haskell used for in the industry? ➞ Facebook uses Haskell as part of their infrastructure ● HAXL: a parallel, data-query DSL ➞ Banks and other financial institutions commonly use Haskell, OCaml or Erlang ➞ Used for embedded, hard real-time systems as a DSL to generate statically checked, lowlevel C-code ➞ https://www.haskell.org/haskellwiki/Haskell_in_industry What is Haskell used for at Leonidas? ➞ The use of Haskell in real projects is still pretty limited: so far we’ve done two small production projects and one medium sized project in addition to one-off “scripting” tasks ➞ Even outside production use, Haskell is useful for exploring ideas around functional programming and teaching functional concepts ➞ We’ve organized a semi-regular event called “The Lambda Saturday” where people can discuss and learn about Haskell and functional programming What makes Haskell different? How does programming Haskell differ from imperative programming? ➞ Lack of control structures ➞ No mutable variables ➞ Mostly immutable data structures How does Haskell differ from other functional languages? ➞ Syntax ➞ Purity ➞ Immutability ➞ Non-nullability as a default ➞ Type-system ➞ Full type-inference ➞ Access to low-level operations and C FFI What are the downsides of using Haskell? Compiling to native binaries ➞ Deploying native binaries somewhat problematic compared to VM languages ➞ Need to use a cross-compiler or a build server whose operating system matches the target machine ➞ In practice, this can be automated but needs to be taken into account Difficulties in predicting memory and performance characteristics ➞ Haskell code can achieve extremely good performance, but only in the hands of a very experienced Haskell programmer. ➞ With less experience, it’s easy to write code that has quadratic or exponential complexity or which quickly leaks memory due to incorrect use of laziness. ➞ The Haskell ecosystem does provide tools to tackle these issues, but it’s a genuine problem when starting out. Issues with dependency management ➞ I.e. the “cabal hell” ➞ When two libraries B and C both depend on library A and you are developing application D, it’s possible to have a situation where B and C are linked against two different versions of A. ➞ Can be mitigated with sandboxes but there’s no perfect solution (as of yet). High learning curve ➞ It takes significantly longer to become productive in Haskell ● ➞ Haskell is very unique compared to commonly used programming languges ● ➞ Pair-programming with an expert Haskeller helps Requires unlearning old habits The academic roots of Haskell still show through ● Many abstractions, libraries and terminology based on category theory and other branches of abstract mathematics ● Lot of valuable learning material is in the form of research papers Questions?
© Copyright 2024