industry haskell in the software - tutbitti/functional-seminar/roleofhaskellinthesoftware... ·...

20
Haskell in the Software Industry

Upload: dangtram

Post on 25-Jul-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

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.

➞ 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.

Early history

➞ 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

The escape from the Ivory Tower

➞ 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.

Standard versus Implementation

What makes Haskell relevant for today’s software industry?

➞ Parsing and transforming data

➞ Creating custom DSL to express complicated business logic or rules

➞ Business domains where software reliability is a high priority

What is Haskell best suited for?

➞ Increased productivity

➞ Less bugs

➞ Less code

➞ Simpler software architecture

➞ Easier parallelism and concurrency

➞ Performance between “pretty good” and great*

Haskell’s selling points for the software 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, low-

level C-code

➞ https://www.haskell.org/haskellwiki/Haskell_in_industry

What is Haskell used for in the industry?

➞ 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 is Haskell used for at Leonidas?

What makes Haskell different?

➞ Lack of control structures

➞ No mutable variables

➞ Mostly immutable data structures

How does programming Haskell differ from imperative programming?

➞ Syntax

➞ Purity

➞ Immutability

➞ Non-nullability as a default

➞ Type-system

➞ Full type-inference

➞ Access to low-level operations and C FFI

How does Haskell differ from other functional languages?

What are the downsides of using Haskell?

➞ 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

Compiling to native binaries

➞ 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.

Difficulties in predicting memory and performance characteristics

➞ 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).

Issues with dependency management

➞ It takes significantly longer to become productive in Haskell

● Pair-programming with an expert Haskeller helps

➞ Haskell is very unique compared to commonly used programming languges

● 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

High learning curve

Questions?