Wednesday 16 November 2016

HASKELL – Functional Programming Language

Need of Functional Programming Languages
Writing large software systems is really complex, difficult and expensive. Maintaining such complex systems is often time consuming and costly. So it is significant to structure it well. Well-structured and less complex software is easy to write, easy to debug, and provides a set of modules which provides reusability to cut down future programming costs. Functional programming languages, such as Haskell, can make it easier as compared to the conventional languages. Conventional languages lay theoretical restrictions on the way problems can be decomposed. Functional languages push those constraints to back. Haskell is the highest level functional programming language with shorter programs and less bugs.

Functional Language and its advantages
A functional language is one where the exclusive or effective form of expressing algorithms is the interpretation of mathematical functions which involves avoiding state changes and fickle data. This is as against the languages that are declarative, imperative, and procedural which gives priority to state change. Further, Higher level programming languages can write the same program using less lines of code. The number of bugs in a program is proportionate to the number of lines of code, so a shorter program has fewer bugs.

Some of the advantages are:
Brevity: Programs written in functional languages tend to be much shorter than their essential equivalents.
Ease of Understanding: Programs written in functional language are generally not difficult to understand. It would be easier to understand those programs even with very less knowledge of logic.
No Core Dumps: Most functional languages especially Haskell, is a strongly typed language, excluding a huge class of easy-to-make compile time errors. Moreover, strong typing means no core dumps! which simply means that there is no possibility of treating an integer as a pointer, or a null pointer.
Code Reuse: Haskell's is a strongly typed language but is much less restrictive than, say, Pascal's, because it uses polymorphism.
Recursion: Recursion is one of the important features in functional programming, as it is the lawful and often the only way to iterate.
Lazy Evaluation: Authentic computations are referentially clear and they can be implemented at any time and still yield the same result. This property of functional language makes it possible to suspend the arithmetic computations of values until they are needed, that is to compute them lazily.

Haskell as Language
Haskell was designed in 1988 by a committee of academics named after the logician Haskell B. Curry whose work in mathematical logic serves as a foundation for functional languages. The language Haskell is based on the lambda calculus, hence the lambda we use as a logo. The committee’s primary goal was to design a language that satisfied the following constraints:

1. The language should be good enough for research, teaching, and applications for building large systems.
2. The language should have its own syntax and semantics.
3. It should be freely available, which means that anyone should be allowed to implement and distribute it.
4. It should be based on unanimity.
5. It should diminish futile variety in functional programming languages.

The outcome of the committees’ meeting was HASKELL 98 which was one of the standardized versions of Haskell language. HUGS was an interpreter used for Haskell. It was simple for people who were learning the basics of Haskell. It offers speedy compilation and more execution speed. For a beginner, it is an excellent language to step in to programming world, since it doesn't have any complex syntax This is how it works

main = print"Hello, world"
 
To run the program
hugs hello.hs
 
Some of the Tools available for Haskell
The Glasgow Haskell Compiler
The Glasgow Haskell Compiler (GHC) is a state-of-the-art, open source, compiler which gives interactive environment for the functional language Haskell. In addition to the Haskell 98 native code generation across much architecture, GHC implements many cutting-edge features including Software Transactional Memory providing much easy implementation of highly concurrent programs.


Haskell Mode for Emacs
It is a basic Haskell mode for Emacs which provides color coded environment and automatic indentation. In addition, this package comes with Haskell interactive modes for both Hugs and GHCi.
 
Mr. Varun Sapra
Assistant Professor
Dept. of Information Technology

No comments:

Post a Comment