Haskell ?

Discussion in 'Programming' started by blueraincap, Feb 26, 2013.

  1. Do any of you actually use Haskell? Below is a job description i find.

    Do you love Haskell? Do you like problem solving and finding elegant solutions? Are you not opposed to making money?
  2. nitro


    I wish I had time to dive into it.
  3. kut2k2


    Haskell is a programming language.
  4. whats good about it vis-a-vis other popular languages
  5. Haskell is another of the functional languages like F#, which are more dynamic than others.

    The idea is that you compose functions at run time when needed, which ends up being tremendously powerful rather than having everything statically typed and frozen at compile time.

    Functional programming languages (LISP was one of the first) have always been popular for "advanced research" and artificial intelligence type applications where you build up very elaborate structures at run time. Finance has always been a major user of functional languages.

    You can also build up data structures in object oriented languages like Java and C#, but you have to pre-declare all of the objects. This ends up being too restrictive for AI type programming.

    In functional languages, that restriction is lifted. List-based data structures, and functions, are defined whenever you want to so at run-time. It is very enabling.

    You can create very elaborate network structured representations of data that are intuitive and great for large projects.
  6. TraderDog


    Haskell is a great language. It is one of the only "true" functional languages in existence. It is not a dynamic language like Lisp. It is a static functional language in which everything must be declared. However, in Haskell, the compiler performs Howard-Milner type inference and based on existing declarations and the structure of your program and it infers variable types wherever possible. This means that for the most part you only declare top level functions as a way of documenting functions for the reader and providing your understanding of the function type to the compiler so that it can verify the correctness of your function declarations. This means that you get many of the advantages of static type checking without the verbosity and boilerplate of languages like C++ and Java. It also means that you avoid run time errors due to the lack of compile time checking in dynamic languages like Lisp and Python.

    Other advantages are that you can type expressions into a command line based incremental compiler, ghci, and have your Haskell statements dynamically compiled and executed in a manner similar to Lisp and Python but with compile-time type checking added in.

    Haskell can be difficult to learn because it is a "pure" functional language in the sense that it does not directly support side effects, such as assignment. In Haskell once a variable is bound to a value that value never changes. This has many advantages in developing Haskell programs because this avoids bugs due to unexpected changes in values. However, since assignment/side effects are necessary in real-world programs, you must learn a new approach, consistent with the pure functional nature of the language.

    Haskell supports assignments and side effects through the use of higher order function types and type classes. One approach is through the use of monads, a concept borrowed from category theory. You do not need to know category theory to use these types and Haskell code based on these types looks similar to standard code in languages that use assignment (almost every other language).

    Haskell also supports many different concurrency models and the compiler, GHC (Glasgow Haskell Compiler), is very good at producing efficient code. This is one of the reasons that Haskell can be used for real-world systems. Prior to GHC, compilers for "pure" functional languages (unlike impure, dynamic languages like Lisp) did not produce efficient, fast code. But GHC does and the compiler technology for this is one of the major contributions of Simon Peyton, the leader of the GHC project for the past few decades.

    I myself worked on compilers for several major languages (including languages like Lisp) and am very impressed with GHC. I also played around with some early pure functional language implementations and found that, at the time, while pure functional languages were very expressive and powerful that they did not seem practical because of the implementation overhead in these early implementations. That has all changed with Haskell and GHC. Some Haskell programs, when compiled, are competitive with hand-coded C counterparts. This is only possible because it is "pure" functional language without side effects. It permits the compiler to ruthlessly optimize your program.

    But the bottom line is that while Haskell is efficient and powerful, the learning curve for most is steep because it requires that you learn a very different way of designing and developing software out of pure functions. Many newbies find this too difficult and give up although once you move up the learning curve you find that the expressiveness of the language is incredible and that the code required for real problems may be 10% the size of what you needed to write before in other languages. This is due to (1) compact, simple syntax, (2) the lack of boilerplate, (3) type inference, (4) parametric polymorphism (similar to generics in Java and C++ but far easier to express and use), and (5) a powerful system for expressing complex data types and type classes (similar to Java interfaces).

    You also find that once you get your program to compile, it is far more likely to run correctly than programs in other languages, although complex applications still need to be tested.

    The learning curve for Haskell is steep and in the past the resources for learning for newbies were few. But now there are many good tutorials and books.

    For those that are interested here are two that I can recommend as a starting point: http://learnyouahaskell.com/ and http://book.realworldhaskell.org/. The main website for all things Haskell including the Glasgow Haskell Compiler project is http://www.haskell.org. The current Haskell Platform that includes the Glasgow Haskell compiler and an extensive library of of functions packaged with the compiler can be downloaded from http://www.haskell.org/platform/. The Haskell platform is intended to be a development platform that you simply download and install to get started on development. One of the obstacles in the past has been the complexity of setting up a consistent set of libraries and compilers for development. The Haskell platform solves much of that problem. It is open source (under various licenses) and runs on Windows, Mac OS X, and Linux.

    On the main website you will find many additional resources including links to user groups, conferences, tutorials, and related research projects. It is not commercial and is primarily academic although Microsoft has apparently provided some research funding and used some Haskell concepts for the definition and development of F#. On the website you will also find links to a few commercial organizations that use Haskell and other functional languages such as OCaml (functional, but not "pure"). You will also find links to user groups and online discussions such as the Haskell Cafe.
  7. hft_boy


    Also check out https://www.fpcomplete.com/.