Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Elixir

You're reading from   Learning Elixir Unveil many hidden gems of programming functionally by taking the foundational steps with Elixir

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher
ISBN-13 9781785881749
Length 286 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Kenneth Ballou Kenneth Ballou
Author Profile Icon Kenneth Ballou
Kenneth Ballou
Kenny Ballou Kenny Ballou
Author Profile Icon Kenny Ballou
Kenny Ballou
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Introducing Elixir – Thinking Functionally FREE CHAPTER 2. Elixir Basics – Foundational Steps toward Functional Programming 3. Modules and Functions – Creating Functional Building Blocks 4. Collections and Stream Processing 5. Control Flow – Occasionally You Need to Branch 6. Concurrent Programming – Using Processes to Conquer Concurrency 7. OTP – A Poor Name for a Rich Framework 8. Distributed Elixir – Taking Concurrency to the Next Node 9. Metaprogramming – Doing More with Less Index

Installing Elixir

Before we can truly begin our journey into the depths of Elixir, we need to install it and make sure our environment is sane. I will cover some basic installations for most OSes. As far as hardware requirements are concerned, there really are none. However, if you happen to not have a multi-core CPU, you may miss out on the inherent speed benefits of the runtime.

GNU/Linux

Most distributions, today, will have Elixir in their repositories and this is the preferred way to install Elixir. Installing Elixir from your distribution's repositories will also take care of installing Erlang.

If you are using a Red Hat-based distribution of GNU/Linux, you can use the yum package manager tool to install Elixir:

# yum install elixir
...

Transaction Summary
===========================================================================
Install  1 Package (+14 Dependent packages)

Total download size: 16 M
Installed size: 31 M
Is this ok [y/d/N]: y
...
Complete!

If, on the other hand, you use a Debian-based distribution, you will need to add the Erlang Solutions repository and install Elixir using dpkg and apt-get:

$ wget {.deb for your distribution}
$ sudo dpkg -i {downloaded version of erlang}.deb
$ sudo apt-get update
$ sudo apt-get install elixir
...
The following extra packages will be installed:
  erlang-asn1 erlang-base erlang-crypto erlang-inets erlang-mnesia
  erlang-public-key erlang-runtime-tools erlang-ssl erlang-syntax-tools
Suggested packages:
  erlang erlang-manpages erlang-doc erlang-tools
The following NEW packages will be installed:
  elixir erlang-asn1 erlang-base erlang-crypto erlang-inets erlang-mnesia
  erlang-public-key erlang-runtime-tools erlang-ssl erlang-syntax-tools
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 12.9 MB of archives.
After this operation, 23.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
...
Setting up erlang-crypto (1:17.5) ...
Setting up erlang-mnesia (1:17.5) ...
Setting up erlang-runtime-tools (1:17.5) ...
Setting up erlang-syntax-tools (1:17.5) ...
Setting up erlang-asn1 (1:17.5) ...
Setting up erlang-public-key (1:17.5) ...
Setting up erlang-ssl (1:17.5) ...
Setting up erlang-inets (1:17.5) ...
Setting up elixir (1.0.4-1) ...

Note

The .deb file you download will be specific to your distribution. The Erlang Solutions download page has as many to choose from.

Or, if you're like me and you're running Arch Linux, you can install Elixir with pacman:

$ sudo pacman -S elixir erlang-nox
resolving dependencies...
looking for conflicting packages...

Packages (2) elixir-1.0.4-1  erlang-nox-17.5-1

Total Installed Size:  107.70 MiB

:: Proceed with installation? [Y/n] y
(2/2) checking keys in keyring                     [#################] 100%
(2/2) checking package integrity                   [#################] 100%
(2/2) loading package files                        [#################] 100%
(2/2) checking for file conflicts                  [#################] 100%
(2/2) checking available disk space                [#################] 100%
(1/2) installing erlang-nox                        [#################] 100%
Optional dependencies for erlang-nox
    erlang-unixodbc: database support
    java-environment: for Java support
    lksctp-tools: for SCTP support
(2/2) installing elixir                            [#################] 100%

I'm suggesting the non-X (erlang-nox) version as Arch separates the Erlang releases based on whether it has GUI libraries included or not, and we will not need them for this book. If you later decide that you want or need them, you can simply install the regular Erlang package and tell pacman to remove the non-X version.

Apple Mac OS X

For Apple Mac OS X, you are hopefully using Homebrew or MacPorts.

Use the following command to install Elixir via Homebrew:

$ brew update; brew install elixir

Use the following command to install Elixir via MacPorts:

$ sudo port install elixir

Windows

If you're using Microsoft Windows, you can download a precompiled binary from the Elixir INSTALL (http://elixir-lang.org/install.html) page. Go through the installation wizard to complete the installation.

Manual installation – binary

Manual installation should really be avoided if at all possible, but I'll include it in case your system isn't listed here or on the installation page, or for some other unforeseeable reason.

First, you will need to download and install an Erlang binary provided by Erlang Solution (https://www.erlang-solutions.com/downloads/download-erlang-otp). Next, you will need to download a precompiled ZIP file from Elixir's releases page. Unpack the ZIP folder to the location of your choice. Once unpacked, you should update your PATH variable to include the bin directory of the Elixir release.

Manual installation – source

Another option with respect to manually installing Elixir is to build Elixir from source and, by extension, build and install Erlang from source.

The latest source of Erlang can be found on its GitHub page (https://github.com/erlang/otp). After building and installing a satisfactory version of Erlang, download and build the source for Elixir, also available on GitHub (https://github.com/elixir-lang/elixir-lang.github.com).

You have been reading a chapter from
Learning Elixir
Published in: Jan 2016
Publisher:
ISBN-13: 9781785881749
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image