Mix in Elixir

By | October 30, 2017


Hello World in Elixer

before we move forward in code we need to learn about Mix. If you familiar with composer in PHP,  npm in NodeJS similer Mix is Bundler . It’s acrucial part of any Elixir project and in this lession we are explore its some best feature.

Content we learn here

  • New Porject
  • Interactive
  • Compilation
  • Managing Dependencies
  • Environment

New Project

when you are ready to create a new Project in Elixir . Mix makes it easy with the mix new projectName 

commands . Replace the project Name with your own project name

mix elixir Mix in Elixir Screenshot from 2017 10 31 01 04 34 300x178

in this example i created hello_world project . some rules in Project name that is project name must be every character small character . After create project then enter this project folder using command

cd hello_world

now open our project any of your favorite  editor inside lib folder you will see hello_world.ex file . Open the file you see the code as like as it


before understand everything i will change the file as like as below

now we start digging our code . Every file in Elixir start with a module.  we write our own function and variable inside module.  here we create a function which return hello world. def  keyword used to start any function or module and every def is started than it need to end .

After we complete our code we need to execute our code and run .its called Interactive.


It may be necessary to use iex within the context of our application . Mix makes it easy , We can start a news iex session


Starting iex this way will load your application and dependencies into your current runtime .

then we need to enter our own module by writing our module name

$ iex(1)> this part already written our command line editor we only need to write HelloWorld which is our module name.

then code enter this module then we need to write function name to execute .

both of line are same in Elixir no need to write bracket end of function name . after writing this line you see hello world in your screen .

If you not family about kotlin please see my previous tutorial

Leave a Reply