Some courses start by explaining all the properties of Haskell. Others by dedicating entire lessons/chapters to the theory behind the language, Category theory (a branch of mathematics), lambda calculus (more maths), etc. Don't worry — I can hear you hyperventilate — we won't do that here. 🙃
Those approaches have nothing wrong, but they are designed to teach people with previous knowledge of mathematics and computer science — which most don't have.
This course is geared to people that do NOT code The lecture will be written as if the person already knows basic computing skills (like installing programs and searching over the internet — 🧓🏼 will have a hard time, but they are welcome! 😃) but nothing about programming. And further explanations will be provided by clicking on highlights like
Ok. Are you ready? Let's go! 🔥
A compiler is a program that translates computer code written in one programming language (the source language) into another language (the target language). The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g. assembly language, object code, or machine code) to create an executable program.
A computer program is a sequence of instructions in a programming language that a computer can execute or interpret.
A computer program in its human-readable form is called source code. Source code needs another computer program (compiler or interpreter) to execute because computers can only execute their native machine instructions.
A programming language is a formal language used by programmers (developers) to communicate instructions to computers. Usually, programming languages are written in plain text where each word, symbol, and number, has a pre-defined meaning for that specific language.
An interpreter is a computer program that directly executes instructions written in a programming or scripting language without requiring them previously to have been compiled into a machine language program.
The cool thing is that it doesn't matter if you have Windows, macOS, Linux, or whatever. Write Haskell, and the compiler will manage the rest. Cool right?
GHC (Glasgow Haskell Compiler) is a compiler and interactive environment for Haskell. Using GHC we can:
- Compile programs and execute them like any other app.
- Evaluate Haskell expressions on the fly using the interactive environment provided by the GHC (the GHCi).
For now, we'll use the GHCi. This interactive environment allows us to write code, hit enter, and get the result instantly! ⚡️⚡️ Allowing us to verify hypotheses faster than a 90' movie hacker.
We'll use the GHCi through our terminal. The terminal is a text-only window through which we can interact with our computer. You write text, hit enter, stuff happen, and you get text as response (most of the time).
Terminal, shell, and command-line are technically different things. But many use those terms interchangeably — especially in programming tutorials. 🙄 So, keep in mind that if someone says "go to the command-line" or "open the shell," they talk about the terminal app 😉.
Here's how it looks:
All operating systems have a Terminal app already installed.
We won't learn to use the terminal here because we'll only need a single
A command is a directive to a computer program to perform a specific task.
A command to change directory (cd) to the home directory:
A command to list (ls) all files (-a) in the current directory:
GHCi is usually installed with other tools (like Cabal, Stack, and a language server), but we don't need them for now, so we'll only install GHC. You can install the other tools later when you need them.
Each operating system has its own steps. I'll show you the most common ways. Select your OS (operating system) and follow the instructions:
Let's test if everything is OK. Open your terminal, type
ghci and hit Enter. You should see a line saying your GHCi version and another line with
Prelude> waiting for you to write something.
The first thing that we'll learn is how to quit using GHCi. On
:q and hit enter. It'll quit GHCi and return you to your terminal. To close your terminal, just close it like any other program.
Awesome! You already took your first steps to become a programmer! 🎉 We're ready to start our Haskell journey! 😃
I'll provide some homework and the solution to the previous lesson's homework in each lesson. In this case, though, there isn't much to ask. So I'll give you some tasks that will help you level up your programming knowledge in general:
- Search and learn the difference between source code and machine code. (Searching and finding information is a crucial skill for programmers. We can't — and don't — remember everything about every technology we use. So, if you want to be a great coder, you have to be an expert searcher.)
- Search and learn the difference between a compiler and an interpreter.
- Familiarize yourself with the terminal: Search how to use the
Don't worry if you don't understand everything. If you "kind of" understand, that's good enough. Each time you encounter the concept, you'll gain a little bit more insight 💪.
That's it! 😄 In the next lesson, we'll learn about Haskell Types! 🤩 See you there!!