Elixir Development Environment Setup: Guide
Get a sneak peek into the Elixir/Phoenix web development environment set up, the Prograils way.
Elixir/Phoenix programming has been a part of Prograils for a couple of years now. We do our best to keep the setup process simple and consistent for every developer, making it easy to onboard new members and keep the same configuration for everyone.
In this article, you will have a peek at how we set up the Elixir development environment and how to do it yourself with ease.
Elixir development environment setup guide
Programming languages are like hand tools. You can use a screwdriver to hit the nail, but it does not mean it is the brightest idea.
We understand that and that’s why we need a solution to support multiple languages on our computers. Even though we all do our best to keep all versions up to date (read the Prograils playbook for details), eventually you will always find a project that does not have the newest language versions.
That’s why we chose asdf as our go-to solution for installing languages on development machines.
- It comes with many cool features:
- support for multiple languages,
- support for most versions (asdf is a mature project)
- single configuration
.tool-versionsfile for every language you need in a project,
- simple interface for installation, configuration, updating languages,
- support for
KERL_CONFIGURE_OPTIONSfor Erlang compilation.
Elixir development setup: Database options
Relational databases are still the most popular storage solutions for applications. When choosing RDMS, the go-to option for us is Postgres.
PostgreSQL is a robust open-source database solution which has got some extra love in the last couple of years. From still common version 9.6, Postgres was extended with many new useful features like declarative partitioning, logical replication as well as enhancements to performance and scalability.
However, if you want to use a different database for your application, Ecto allows to use of plenty of different drivers, with more community drivers coming in the future.
Development setup - Postgres installation
If you are coding on Mac, there is an application called Postgres.app, self-advertised as “the easiest way to get started with PostgreSQL on Mac”.
It truly is. This mature project comes with regular updates as well as a really simple interface. For other options as well as other operating systems use guides on official Postgres website.
Editor choice for Elixir software development
There are many options to choose from: Vi, Atom, Sublime and many more.
For Elixir web development, I find Visual Studio Code to be the most appealing one. I am not a fan of Microsoft products, but VS Code deserves to be recognized as one of the best code editors created in our millennium.
With open-sourced code, this free editor has many useful features out of the box. In addition, it allows for customization and extensions. For web development with Elixir/Phoenix you can use packages like ElixirLS, GitLens to transform a simple text editor into a perfectly suited IDE - if you want that.
Development setup - Bootstrapping an App
When setting up any Elixir project (including a Phoenix web project), I recommend bootstrapping it as an Umbrella App.
This approach allows you for better separation of responsibilities between services, as well as speeds the compile-time in a development environment. The drawback is you have another learning step in your Elixir journey and more boilerplate to add to your codebase.
For keeping code organized you should use the mix format and possibly apply this task on file save.
Compiling the production version in Elixir is now easy. Version 1.9 of the language added Releases as part of the language core. For releasing to server, there are many different options - you can either do it yourself by copying release and starting it remotely, Docker, heroku buildpacks, or through a dedicated library like edeliver.
Learn more about libraries in Elixir.
Setting up an Elixir development environment - Wrapping up
The Elixir development process is fairly straightforward. Install the programming language and database, use your favorite editor, bootstrap your app and configure the production release.
In 2020 Elixir can be considered a fully production-ready language with a fair amount of libraries and an engaged community.
This makes it a lovely tool to start your next project. In case you have any questions or issues remember that you can always rely on help from the best language community you can get!
Have coding experience, but want to learn Elixir from scratch? Check out our free Elixir tutorial with lots of exercises!