Introduction to Elixir - A Background and the Primitive Types - Part One

in #utopian-io5 years ago

elixir.jpg

Repository: https://github.com/elixir-lang/elixir

What Will I Learn?

  • You will learn about the BEAM and the Erlang Ecosystem and how that relates to Elixir
  • You will learn about Elixir primitive types such as Numbers, Strings, Characters, Lists, Maps, Tuples and more
  • You will learn how to use IEX (The Interactive Elixir Shell)
  • You will learn about the Elixir compilation Pipeline
  • You will learn about primitive operations and functions in Elixir

Requirements

System Requirements:
  • Elixir v1.8 requires Erlang 20.0 or later
OS Support for Elixir and Phoenix:
  • Mac OSx
  • Unix and Linux
  • Windows
  • Raspberry Pi
  • Docker
Required Knowledge
  • Some basic Programming Knowledge
  • An Elixir installation
  • VsCode or any other Text Editor
Resources for Elixir and Phoenix:
Sources:

Difficulty

  • Beginner

Description

In this Video Tutorial, we start a new series on the Elixir language. We talk about what the Elixir language is and how it came about. We discuss the technical aspects of the Elixir language and how it relates to the BEAM (Bogdan's Erlang Abstract Machine). We look at how Elixir is compiled into Erlang and we talk about the advantages that the BEAM gives us. We also look at the primitive types that exist in Elixir and how they work with simple operators.

The Basic Architecture of the BEAM and Elixir

In 1986, the Swedish telecom giant Ericsson developed the Erlang language and the BEAM. This system was devised at the core of the OTP or Open Telecom Platform and used primarily to automate Telephone switchboards. In 2011, an alternative syntax for the BEAM was released in the form of Elixir. Elixir was designed as a means to harness the power of the BEAM and the OTP system and make these systems more accessible to developers.


elixir-erlang.png

Above is an image of a few flow charts showing how Elixir compiles to the BEAM and how the BEAM works across multiple CPU cores. Elixir is an alternative syntax on the BEAM and so its able to completely harness the system. Elixir follows a few separate steps towards compilation than Erlang but these steps provide elixir with some nice features such as macros and full Erlang inter-opt. You could write a full Erlang program inside of an Elixir program and have it compile without issue.

On the Beam everything is a process and these processes are strongly isolated. The Processes communicate with one another through the use of message passing which gives rise to the Actor Model. Each process is run on top of a set of schedulers which decide how these processes are distributed across each of the CPU Cores. The Beam itself only runs on a single thread but the schedulers are able to distribute the CPU threads of operation to the processes allowing the application to fully use a Multicore CPU.

Elixir Primitive Types and Operations

Elixir supports all of the primitive types from the Erlang system and it adds to these types to make them more accessible. There are the number types, integers and floats which also use simple operations. Elixir also makes use of Atoms which are alphanumeric constants that refer to themselves. Elixir also has a large amount of collection types; this includes Tuples, Singly linked Lists, Maps, Strings, Binaries, Bitstrings and CharLists. All of these collection types have their own pros and cons and are useful in the ecosystem.


elixir_primitives.png

Above we have examples of these elixir primitives. Each of the primitives contains a set of functions and operations that can be applied to them to execute commands. All values in Elixir are Immutable and these primitives are very efficient as immutable data in memory. The collection types also are immutable and when you change a portion of a collection, the parts that are unchanged still refer to the old collection. This means that pieces of memory can be reused in response to demand. Some of the types such as Strings and Charlists are actually built on top of some of the other types like Binaries and Bitstrings. There are also multiple ways to define these primitives thanks to the macro system in Elixir.

Full Github Source Code can be found here: https://github.com/tensor-programming/intro-to-elixir

Video Tutorial

Curriculum

Related Phoenix Videos
GraphQL Series
Sort:  

I thank you for your contribution. Here are my thoughts. Note that, my thoughts are my personal ideas on your post and they are not directly related to the review and scoring unlike the answers I gave in the questionnaire;

I like how you care about your viewers. It might seem very trivial but what you did at 2:13 is very important, at least for me. I usually do not like following tutorials. I did follow two tutorials for Python and left one without finishing it. So the way of your explaining is some kind of charming but I do not know the reason. Do not get it as flattering.

Elixir is kinda alien to me as you would expect. I only worked with Java, JavaScript and Python-like high-level languages so far, so it feels different. Basic concepts are similar but it is just different kind of beast. Forcing data to be immutable is a nice concept, so you do not have to remember which function mutates and which returns the result. I found that maps are similar to NamedTuples in Python but without initialization. It would be better to say Tuple-like dictionaries as there is no immutable dictionary in Python.

I am very interested in the series and waiting for the next parts of it. Thanks for your efforts again!


Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Well done @yokunjon. Very good comments.
Cheers,
Bucky

Thank you for your review, @yokunjon! Keep up the good work!

Thanks @yokunjon. Its always good to hear feedback from a person who might not know the technology and is also sort of following along with the series. Your feedback is always invaluable.

Hi, @tensor!

You just got a 6.49% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

Hi @tensor!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server



This post has been voted on by the SteemSTEM curation team and voting trail. It is elligible for support from @curie.

If you appreciate the work we are doing, then consider supporting our witness stem.witness. Additional witness support to the curie witness would be appreciated as well.

For additional information please join us on the SteemSTEM discord and to get to know the rest of the community!

Please consider setting @steemstem as a beneficiary to your post to get a stronger support.

Please consider using the steemstem.io app to get a stronger support.

Hey, @tensor!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.028
BTC 65353.50
ETH 3202.07
USDT 1.00
SBD 2.61