Search code examples
haskellghc

Why some of the latest versions of ghc are not "recommended"?


Why so many "alive" versions of ghc at the same time? I believe that there is some technical reason but can't figure what exactly..

ghcup show 11 versions of ghc and one of those are marked as recommended. I couldn't find some explanation why that version is the recommended, thou...

I'm just trying to understand why the last version is not the recommended, and also why there is not just one version that is compatible with several versions of the language and the libs. I'm assuming that this is a hard problem to solve, but can't figure out why.

Just note: I'm using haskell for some time now but not an expert by any means.


Solution

  • Don't worry too much about it. It's not that the other versions are disrecommended, it's mostly just that with all those versions on offer GHCUP tries to make it easier for beginners to choose one that has low likelyhood of running into hiccups.

    Why not recommend the newest one? – Two reasons:

    • Sometimes new GHC versions do (deliberately) break existing code, it is after all a research compiler and not just an implementation of a fixed language standard. This usually concerns rather advanced corners of the language that a beginner would not likely touch on directly, but it may well lead to incompatibility with a library she's trying to use. Eventually the library would (hopefully) be patched to work with the newer compiler, but this can take some time.
    • Even a well-designed program in Haskell such as GHC isn't free of bugs, and obviously these are more typically encountered in a version with fresh new features. Older major versions will have their bugs largely ironed out via bugfixes introduced in a minor version, so it is typically safest to use the newest minor version of a major version 1 or 2 releases older than the newest.

    Of course, you still want the newer versions available in GHCUP too, both to allow access to the shiniest of new features and so library developers can future-proof their packages.

    Why not recommend an even older one? – This should be quite obvious:

    • The compiler does get better over time in terms of optimisations etc..
    • Old ways of doing things are sometimes just obsolete. For example, historically Monad did not have Functor as a superclass, which could lead to awkward morally-duplicate constraints and whatnot. Obviously, beginners shouldn't be confronted with that.

    Again, that does not mean that old versions should not be available. They're kept in GHCUP both so it's possible to compile legacy code that just doesn't work with newer compilers (and hopefully develop it to change that!), and also to allow library developers to check whether their package is still compatible with an old compiler.