Your first Elixir Project (Part 0)

by Adam Davis

Table of contents:

Have you heard of Elixir, the incredibly scalable functional programming language that developers love, but haven’t gotten around to trying it out?

If this is the first you’ve heard of the language, check out my previous post where I give an overview of elixir.

I’m writing this tutorial series as a way to introduce other developers to the language and get them up-and-running with a simple project.

Overview

In this post, you will…

After following all parts of this tutorial, you will have created a project that can convert between different units of measurement.

Installation

The first thing we need to do is install elixir. If you use a package manager, the process is as simple as running a command.

If your package manager isn’t listed here or you run into trouble, click here for the official installation instructions.

Creating the project template

When writing code in elixir you’ll make frequent use of the build automation tool mix, which you should have access to after installing elixir.

  1. Open your terminal and navigate to the directory you’d like to work in.
  2. Run mix new unit_converter (You can think of this like npm init or create-react-app or ng new. This command creates the basic scaffolding for you to build a project in elixir)
  3. Run ls. You should now see the unit_converter directory.
  4. Open the unit_converter directory in your favorite code editor. If you use vscode, you can do this by running code unit_converter

The structure of your project should look something like this:

├── .formatter.exs
├── .gitignore
├── README.md
├── lib
|  └── unit_converter.ex
├── mix.exs
└── test
   ├── test_helper.exs
   └── unit_converter_test.exs

Now let’s take a tour of the files that were generated…

If you want to jump straight into writing code, you can skip to the next part of this tutorial for now and come back here if you have questions later on

Onward!

Now that you have your project template and understand it’s structure, it’s time to move on to part 1 of this tutorial and start writing some code.

Adam Davis

Share this post: