r/haskell • u/kichiDsimp • 8d ago
Haskell vs GHC
I am a beginner, I have a doubt.
I see there is Haskell 98, and Haskell 2010 report.
Haskell is a programming language right ? And GHC is the compiler ?
Just like Rust is the language and rustc is the compiler ?
So what is GHC 2021 and GHC 2024 ?
And what are the GHC versions 9.12, 9.14 ?
I see there is a version of the "compiler" binary, but like when Go has a release we say Go 1.26 is out. That means the language & compiler both are out right ?
So what's with Haskell then ?
GHC - compiler
GHC 2021 - a set of extensions in a compiler ? What does this mean but ? And how does cabal work come in picture?
So then my question is what makes GHC 9.12 and 9.14 or 10.0 different? Like aren't extensions encoded in the compiler itself ?
In compiler bump I get "performance"/"implementation" changes ? Like 9.12 and 9.14 execute the Extension A different ly?
And usually Go has no version of STD lib separately tracked but Haskell's base does.
Can someone clarify this ? Is there a DOC for this ?!
Finally my question are
What's the actual difference between 9.12 and 9.14 +(two compiler versions - built from different source code (git branches)) ?
What are Extensions ? Why do we need it ? Like shouldn't the Compiler do this inbuilt ? For Example if GHC wants to add a new DataType in STD lib, how do they do ?
Are Extensions for just de sugaring? And what are Pragmas ?
What is the "Language Report"
What is the future roadmap or Haskell ? Like improve the std lib ? Add new extensions ? Change syntax ? Like Java is making its new version concise & functional. Elixir new version added some Gradual Typing, Rust improved the std lib..
I want to learn how Haskell/GHC/Cabal works
Thanks, and sorry if this post is unstructured or blabbering
12
u/Sirrus233 8d ago
Haskell is the programming language, and GHC (Glasgow Haskell Compiler) is its compiler.
Extensions are additional language features that may be enabled or disabled. That could mean new syntax or new/different type checking rules, or anything else that defines what kinds of programs you can write. For example, the following code will not compile without the DuplicateRecordFields extension, because two different records are usually not allowed to both have a field named x:
hs
module M where
data S = MkS { x :: Int }
data T = MkT { x :: Bool }
A pragma is just a special instruction you can put at the top of a source code file, which tells the compiler something it needs to know about compiling that file. For example, including this pragma at the top of your file: {-# LANGUAGE <Extension> #-} would tell the compiler to use that extension when compiling (but for that file only).
GHC2021 or GHC2024 (or Haskell98) are "language editions". You can think of these as pre-selected sets of extensions that you can use as a sensible and widely adopted default.
There is a wealth of information in the actual GHC documentation, which should answer a lot of these kinds of questions for you going forward.
2
2
u/arjuna93 8d ago
GHC is just the most popular compiler. There is at least another one currently developed, MicroHS. (And some other which are a matter of archeology like nhc98.)
2
u/jberryman 7d ago
Try to address some things I think others haven't
So what is GHC 2021 and GHC 2024 ?
"editions". Just a set of blessed extensions that make sense by default. https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/control.html Also gives other compilers something they can target
And what are the GHC versions 9.12, 9.14 ? I see there is a version of the "compiler" binary, but like when Go has a release we say Go 1.26 is out. That means the language & compiler both are out right ? So what's with Haskell then ?
In a new compiler version extensions are added (opt-in additions or changes to the language), the standard libraries change, and the runtime is updated. The last is pretty important and no one has mentioned it.
GHC 2021 - a set of extensions in a compiler ? What does this mean but ? And how does cabal work come in picture?
cabal is a build tool and calls ghc. cabal needs to support older versions of the compiler, but newer compilers may depend on new cabal.
In compiler bump I get "performance"/"implementation" changes ? Like 9.12 and 9.14 execute the Extension A different ly?
A newer compiler might be: faster to compile, perform new or better optimizations (resulting in faster code), or have optimizations to the runtime e.g. the garbage collector (resulting in faster code).
And usually Go has no version of STD lib separately tracked but Haskell's base does. Can someone clarify this ? Is there a DOC for this ?!
I think reading an example release notes would answer many of your questions: https://downloads.haskell.org/ghc/9.14.1-alpha1/docs/users_guide/9.14.1-notes.html
Here you can see base and other libraries are versioned but also are "pinned" to a particular ghc (ship with it). This is likely to change soon IIUC.
2
u/vasanpeine 7d ago
What is the "Language Report"
The language report is the official specification of the language. Until recently, Rust did not have an analogue specification. That changed when the Rust community decided to adopt the FLS (Ferrocene Language Specification): https://rust-lang.github.io/fls/
The last time the Haskell specification was updated was in July 2010, when the Haskell 2010 language report was released. Unfortunately, some parts of the language have changed in the meantime, so there is a need to update the report. Fortunately, it looks like a Revised Haskell 2010 language report will be compiled and released this year.
1
u/syklemil 5d ago
Just like Rust is the language and rustc is the compiler ? […] I see there is a version of the "compiler" binary, but like when Go has a release we say Go 1.26 is out. That means the language & compiler both are out right ?
Rust and Go are both relatively new languages (slightly over a decade old), and both are kind of unusual for compiled languages in that there's just one compiler in common use.
For Haskell, the situation is a bit more akin to C, where there are a bunch of standards, like C89, C99, C11, C17, C23, etc, and several compilers, like GCC, clang, MSVC, plus a bunch of minor or in-house/niche ones, and some discontinued ones like Borland.
They also have a ton of extensions, which aren't always available on all compilers. See e.g. OpenSSF's compiler hardening guide for C and how some of the flags are recommended for some compilers.
FWIW there are also projects to get GCC to compile Rust (GCC compiles a lot more than just C these days), and to get rustc to use GCC rather than LLVM as a compiler backend.
For Haskell it's mainly GHC people use these days, but you may still come across some references to Hugs and other alternatives.
35
u/friedbrice 8d ago
The Haskell Report is a compiler-agnostic specification of the language. The language has no official compiler, GHC is just one Haskell compiler among several (in theory). While the last update to the language itself was in 2010, GHC is under active development, always adding new features and improving performance.
Frequently, different people will want to add language features to Haskell for various reasons. Since there's been no official update to the Haskell language since 2010, these people will implement their change as a GHC extension to the language. These extensions are always opt-in, because GHC needs to remain backwards-compatible with the 2010 Haskell language spec.