The Haskell Legacy
Haskell Brooks Curry
Okay, so this guy was a big deal. Haskell Brooks Curry, born right at the turn of the century in Millis, Massachusetts, Curry spent his career working in cutting edge mathematics. Haskell was specifically interested in formal systems and processes, and because of this he would play a huge role in the early development of software languages (at least in the foundational logic behind them).
To date there are three programming languages named for Curry: Haskell, Brooks, and Curry. And the term currying, a logistical choice where a developer will take a function with multiple arguments and instead chain a link of functions together each with singular arguments, is also — not surprisingly — named in his honor.
What Makes it Haskell?
Wiki-Haskell, a fairly in-depth doc-resource for all things Haskell, describes the programming language as a “polymorphically statically typed, lazy, purely functional language”. We probably know these words and can parse out their definitions. Though all lined up in a row like that it can be slightly jarring. Let’s cover the basics.
Everything about the construction of Haskell as a language is geared toward efficiency, speed, and clarity. With Haskell, a programmer will need to make certain and pass the right value to each function, otherwise the compiler will not render the program. With Haskell expresses are determined at compile time, because of this the language needs to be statically typed. In general, Haskell allows for six specific datatypes: Booleans, strings, lists/ arrays, tuples, the the unit datatype.
Purely Functional & Lazy
In addition to being statically typed, Haskell is also purely functional. A pure function will take in a value, return a value, and offers no side effects to the values in question. This ensures that there remains a strict relationship between input and output throughout a Haskell program. The state of the value in question is left unaltered throughout the program.
This works in tandem with Haskell operating as a lazy language. Lazy programming languages do not execute or run functions until they are called to do so by the program. This allows for Haskell to operate quickly and efficiently throughout the program. After a function is computed, the result will be stored and indexed within a table on Haskell. Then each subsequent time the function is called Haskell will search the index and check whether that value is already available via the table. This allows for a cut down on the necessary number of functions.
Garbage Collection and GCH
Haskell produces a lot of trash. I believe those are their words. Because data are immutable in Haskell each iteration of a recursive function has the opportunity to store new data. You can imagine how massive this could become. Consequentially, Haskell can create up to 1gb of data per second (Wiki-Haskell). To solve for this Haskell uses GHC.
“Data immutability forces us to produce a lot of temporary data but it also helps to collect this garbage rapidly. The trick is that immutable data NEVER points to younger values. Indeed, younger values don’t yet exist at the time when an old value is created, so it cannot be pointed to from scratch. And since values are never modified, neither can it be pointed to later. This is the key property of immutable data.”
At the end of the function, it accesses only the last generation of pertinent data. The fewer values that survive — the less work to do. “If you have, for example, a recursive algorithm that quickly filled the nursery with generations of its induction variables — only the last generation of the variables will survive and be copied to main memory, the rest will be not even touched! So it has a counter-intuitive behavior: the larger percent of your values are garbage — the faster it works.” (haskell.org/documentation)
So who is it for?
Haskell has a relatively small user-base and in some ways is considered a niche language.
However, static type, lazy computation, and pure mathematical functions all help to assure an accuracy of code that makes Haskell an attractive language for many in fintech and academia. It is particularly adept when wielding large amounts of data.
Everything about Haskell was intended for sleek, efficient, and accurate computation. It is an ideal language for specific situations.