kids encyclopedia robot

Glasgow Haskell Compiler facts for kids

Kids Encyclopedia Facts
Quick facts for kids
The Glasgow Haskell Compiler
Original author(s) Kevin Hammond
Developer(s) Simon Marlow, Simon Peyton Jones, The Glasgow Haskell Team
Initial release December 1992; 32 years ago (1992-12)
Stable release
9.8.1 Edit this on Wikidata / Error: first parameter is missing. ()
Written in Haskell, C
Operating system Linux, OS X 10.7 Lion and later, Windows 2000 and later, FreeBSD
Platform x86, x86-64, ARM
Available in English
Type Compiler
License BSD New

The Glasgow Haskell Compiler (often called GHC) is a special computer program that turns code written in the Haskell programming language into instructions a computer can understand. Think of it like a translator! It helps you write and test Haskell programs on different types of computers.

GHC is the most popular tool for working with Haskell. It's also free and open-source software, which means anyone can use it and even help make it better. The main people who lead its development are Simon Peyton Jones and Simon Marlow.

History of GHC

GHC started way back in 1989 as a test project by Kevin Hammond at the University of Glasgow. Soon after, it was completely rewritten in Haskell itself. The first test version was released on April 1, 1991.

Over the years, GHC gained new features. These included tools to make programs run faster and ways to handle more complex tasks, like running parts of a program at the same time.

Later, the main developers, Simon Peyton Jones and Simon Marlow, moved to Microsoft Research. They continued to be in charge of GHC's development. Many other people have also helped create GHC, with contributions from over three hundred different programmers. Since 2009, companies have even helped fund new features for GHC.

What GHC is Called

The official website calls it The Glasgow Haskell Compiler. But if you use it on your computer, it might show up as The Glorious Glasgow Haskell Compilation System. It even had an early internal name: The Glamorous Glasgow Haskell Compiler!

How GHC Works

GHC is mostly written in Haskell itself. However, some parts that help programs run are written in C and C--.

A compiler like GHC works in a few steps:

  • Front End: This part reads your Haskell code. It checks for spelling mistakes and makes sure your code follows the rules of the Haskell language. It also checks the "types" of your data to catch errors early.
  • Middle End: After checking your code, GHC transforms it to make it more efficient. This is where most of the "optimizations" happen. It's like finding shortcuts to make your program run faster without changing what it does.
  • Back End: Finally, GHC turns the optimized code into instructions that your computer's processor can directly understand. These instructions are then linked with other necessary parts to create a program you can run. GHC can create code for different systems, like those using GCC or LLVM.

Haskell Language and GHC

GHC follows the official rules for the Haskell language, including Haskell 98 and Haskell 2010. It also adds many extra features, called "extensions," that are not part of the standard Haskell rules. These extensions give programmers more tools and ways to write code.

Cool Extensions in GHC

GHC supports many extensions that add new abilities to Haskell. Here are some examples:

  • Faster Data Types: These allow programs to use the computer's basic data types more directly, which can make number-heavy code run much faster.
  • Strict Evaluation: This lets you tell the computer to calculate a value immediately, rather than waiting until it's absolutely needed.
  • Easier Syntax: GHC offers more convenient ways to write code for common tasks, like working with lists or different parts of a program.
  • Template Haskell: This is a powerful feature that lets you write programs that can create other Haskell code. It's like having a program that can write parts of your program for you!
  • Quasi-quotation: This allows you to define new ways to write code within your Haskell program. It's useful when you're working with code from other programming languages.
  • Generic Programming: This helps you write code that works for many different types of data without having to write separate versions for each.
  • Parallel Computing: GHC can make your programs use multiple parts of your computer's processor at the same time. This helps programs run much faster, especially for big tasks.
  • Compiler Hints: You can give GHC special hints (called "pragmas") to help it optimize your code even better.
  • Rewrite Rules: These are like special instructions that tell GHC how to replace one piece of code with another that does the same thing but more efficiently.
  • Record Dot Syntax: This makes it easier to get information from structured data, similar to how it's done in many other programming languages.

Where GHC Can Run

GHC works on many different computer systems. You can use it on Windows computers, and most types of Unix systems like Linux, FreeBSD, OpenBSD, and macOS. It also works on different kinds of computer processors.

See also

  • Hugs (interpreter)
  • Yhc
  • Haskell Platform

Images for kids

kids search engine
Glasgow Haskell Compiler Facts for Kids. Kiddle Encyclopedia.