8000 GitHub - sylhare/Elixir: Experiment with Elixir
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sylhare/Elixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hex pm Build Status codecov

Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang virtual machine (BEAM).

Elixir also provides a productive tooling (Mix build tool, interactive shell)and an extensible design (scalability, fault-tolerance).

Instead of thinking of object, you think of little easy to test process that you spawn and kill when needed.

Getting started

Go to elixir-lang.org and install elixir following the instruction, on MacOS with brew:

brew install elixir

Elixir has an interactive prompt called iex that you can try on the commad line. To quit the iex use [command] + [c] then [a].

To run a script try with:

elixir hello.exs

To compile your module you should use elixirc such as

elixirc hello.exs

Using Mix

Mix is a development tool for Elixir that help kick start an Elixir project:

mix new demo

Before running a project you might want to update all dependency using:

mix deps.get

And a project will be generated. To test your mix project try using:

mix test

However is you want to use your project functions in the iex, go in your root folder and run:

# The -S is for source
iex -S mix

Mix project organisation

It is adviced to follow the Mix structure in order to organise your files, ie:

  • The package script should be in lib
  • The test files of the scripts in test
  • Configuration settings in config

For the other folder, usually they are populated dynamically:

  • deps is for installed dependencies
  • _build is the compiled sources of your project
  • doc is for documentation that can be generated with ExDoc
mix docs

Mix project integration

The package can be installed by adding the package name to your list of dependencies in mix.exs:

def deps do
  [
    {:demo, "~> 0.1.0"}
  ]
end

Package can be either download from repository or directly fron Hex

Publishing a Mix project

Mix projects are hosted on Hex. To get started, you will need to install hex using:

mix local.hex

Then you will need an account:

mix hex.user register

Then follow the procedure to add the correct metadata to your mix.exs so that you can finally publish it:

mix hex.publish

Tips

There are no multiple comments line. A comments starts like in python with #

# Will print Hello world
IO.puts "Hello world"

What is the difference between .ex and .exs:

  • The ex is compiled to the erlang .beam code
  • The .exs is more of a script that is compiled just-in-time.

Sources

About

Experiment with Elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0