Elixir Installation and Setup
Note: this page has been created with the use of AI. Please take caution, and note that the content of this page does not necessarily reflect the opinion of Cratecode.
Elixir, a functional, concurrent, and scalable language, has been gaining popularity for its capabilities in building fault-tolerant systems. Built on top of the battle-tested Erlang virtual machine (BEAM), Elixir is an excellent choice for developers looking to dive into the world of functional programming. Let's get started by installing and configuring Elixir on your system!
Installation
Elixir is supported on various platforms, including macOS, Windows, and Linux. We'll cover the installation process for each of these platforms.
macOS
For macOS users, the recommended way to install Elixir is through Homebrew. If you don't have Homebrew installed on your system, follow the instructions on the Homebrew website to get it up and running. Once you have Homebrew installed, run the following command to install Elixir:
brew install elixir
That's it! Elixir should now be installed on your system.
Windows
For Windows users, the easiest way to install Elixir is by using the official installer. Download the latest release and follow the installation wizard. Once the process is complete, Elixir should be installed on your system.
Linux
Elixir installation on Linux varies depending on the distribution you're using. Visit the official Elixir installation guide for detailed instructions on installing Elixir on your specific Linux distribution.
Configuration
Now that Elixir is installed on your system, it's time to configure your development environment.
Interactive Elixir (IEx)
Interactive Elixir, or IEx, is a REPL (Read-Eval-Print Loop) that allows you to execute Elixir code interactively. To start IEx, open your terminal (or command prompt on Windows) and run the following command:
iex
You should see a prompt similar to this:
Erlang/OTP 24 [erts-12.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] Interactive Elixir (1.12.2) - press Ctrl+C to exit (type h() ENTER for help) iex(1)>
Now, you can start experimenting with Elixir code! For example, type the following command into the IEx prompt and press ENTER:
IO.puts "Hello, Elixir!"
Text Editor or IDE
Choose a text editor or IDE that supports Elixir syntax highlighting and code completion. Some popular options include Visual Studio Code with the ElixirLS extension, Atom with the autocomplete-elixir package, and Sublime Text with the ElixirSublime package.
Creating Your First Elixir Project
To create a new Elixir project, you'll need to use the mix
command. mix
is Elixir's build tool and task runner, and it's essential for managing dependencies, compiling your code, and more. Run the following command to create a new project:
mix new my_first_project
Replace my_first_project
with the desired name for your project. This command will generate a new directory with the necessary files to start building your Elixir application.
That's it! You're now ready to embark on your Elixir programming journey. As you explore the language, make sure to check out the official Elixir documentation and the Elixir School for in-depth learning resources. Happy coding!
Hey there! Want to learn more? Cratecode is an online learning platform that lets you forge your own path. Click here to check out a lesson: Drawing Basic Shapes (psst, it's free!).