...

/

Starting Your Project with Mix

Starting Your Project with Mix

Learn to build a project in Elixir using Mix.

Introduction to designing Elixir applications

Software that solves real-world problems has to maintain and organize various files. You must learn language features that will help you organize your code and design your application domain. A well-organized codebase makes it easier to fix bugs and add or change features.

In this chapter, we’ll build a game, and learn new techniques to develop and design our own application. We’ll learn how to:

  • Design the application entities with Elixir structs
  • Create polymorphic functions using Elixir protocols.
  • Create function contracts with Elixir behaviors.

The first step is to learn the basics of Mix, the essential tool to start any new Elixir project.

We’ll use a lot of the concepts that we’ve already explored. For example, we’ll see higher-order, recursive, and anonymous functions applied together to solve a problem.

We’ll move faster than in the previous chapters, focusing only on the new things.

Mix is a command-line interface (CLI) tool that provides the essentials for building any Elixir application. Mix helps us create and maintain Elixir projects, providing tasks to compile, debug, test, and manage dependencies and our environment. All Elixir libraries and applications were built with Mix. It comes by default with Elixir; we don’t need to install anything new.

We’ll use the Mix CLI tasks to create the initial setup of a small terminal-based game and the Mix module guidelines to ...