- Overview
- Transcript
1.3 Installing Elixir and Using the REPL
To use Elixir, you have to first install it. I’ll show you how in this lesson, and we’ll explore the basic Elixir syntax in the interactive Elixir console.
Related Links
1.Introduction3 lessons, 11:49
1.1Introduction01:06
1.2What Is Functional Programming?07:42
1.3Installing Elixir and Using the REPL03:01
2.The Elixir Language5 lessons, 30:55
2.1Data Types06:19
2.2Modules and Functions06:52
2.3Control Flow and Recursion07:01
2.4Elixir Tools06:19
2.5Testing in Elixir04:24
3.Concurrency in Elixir6 lessons, 35:27
3.1Processes06:25
3.2OTP and GenServer05:08
3.3Supervisors08:16
3.4OTP Applications08:27
3.5Tasks and Agents03:16
3.6Distributed Processing With Nodes03:55
4.Conclusion1 lesson, 01:35
4.1Conclusion01:35
1.3 Installing Elixir and Using the REPL
Hi and welcome back to Get Started With Elixir. In this lesson we are going to install Elixir and use the interactive Elixir console IEX. Elixir is available for various distributions like macOS, Windows, Unix or even the Raspberry Pi. It requires at least Erlang 18, which will get installed automatically when using the recommended installation instructions. On macOS, the easiest way to install it is by using Home Brew and running brew install elixir. On Windows, you can download the provided installer. I use chocolatey with cinst alexa. I have a Mac, so I'm going this route. As you can see, erlang-19 will get installed, as well. Now that we have installed Elixir, we have access to the REPL or Read–Eval–Print Loop. It is better known as an interactive console or shell. In Elixir it is called IEX or Interactive Elixir. It works like you would expect it to. You can perform operations like 2 + 2 or assign variables like x = 3. You can also define functions like we did last lesson. The only thing to keep in mind, is that you have to surround it with a module. You will learn what that is in a later lesson. Now you can use the sum function, by referencing the main module. If you need help with something like the enum math function, just use the h keyword to get a nicely formatted documentation. If you have a type and want to know more about it, just use the i keyword. And if you wonder what other keyword functions there are, just use h without an argument. Now, when I execute a pwd helper, it gives me a warning, that I have to use parentheses. This has been added in Elixir 1.4. To enforce a clearer distinction between variables and argument list functions in your code. If you want to exit the shell just use Ctrl+C twice. This is because of the underlying Erlang virtual machine BEAM. This concludes the short introduction to the Elixir REPL. It is a very easy to use but powerful tool where you can experiment with your code. In the next lesson we're going to start with the Elixir language itself by looking at data types. See you there.