I’m new to programming, but I’ve been reading about tech for a while. I noticed that one language that gets mentioned quite often is Haskell. Could someone explain what’s the big deal with Haskell? Why do people push it so much? Trying to learn.

  • @uthredii
    link
    53 years ago

    What do you find more fun?

    • @qoheniac
      link
      7
      edit-2
      2 years ago

      deleted by creator

      • Ravn
        link
        6
        edit-2
        3 years ago

        It does force you to think more before you write code, but how much depends on the complexity and requirements of the project.

        In a pure functional and statically typed language like Haskell it is even more true because it will let you know about all the things that could go wrong or that don’t make sense. You’ll be made aware of possible failure which allows you to consider the possible divergences before they’ve occurred and handle them gracefully rather than just produce a runtime error and undefined behaviour.

        Consequently, things like reading and parsing a file will often be more involved because success can never be guaranteed when the programme depends on an external state like the file system, and so the compiler demands that you either work with the cases of failure or at the very least explicitly ignore the risks by producing an error (hopefully with a useful message).

        I for one am sick and tired of languages that force me to run my programmes and test for all possible edge cases just to find silly type inconsistencies, typos, bad assumptions or dangerous operations that are likely to fail sooner or later. So I’m quite partial to helpful type checkers and static safety guarantees.

        Note that imperative vs functional is orthogonal to both purity and type safety. Rust is about as safe as Haskell but is predominantly imperative. Schemes like Clojure, Racket and Guile are about as safe as Python, but are decidedly functional while the latter is not. There are also pure functional languages that are untyped, like Nix (which simply doesn’t do any IO at all, at least directly).

        Besides functional and imperative languages there are also logic programming languages like Prolog and Mercury. The former is an interpreted and rather unsafe language while the latter goes a long way to ensure that a programme is soundly typed and safe by introducing statically checked determinism, resource usage constraints (like only opening, using and closing a file once and in the right order - this is known as type linearity or uniqueness) and “modes” (which basically is: which function or predicate arguments can act as outputs from which inputs; allowing functions to act in reverse or predicate arguments can act as either inputs or outputs depending on which are known (“ground”) at that point, which is really cool).