Elixir Interview Questions and Answers
Elixir is a functional and dynamic language that is designed for building scalable applications. It is based on Erlang language VM which is known for running fault-tolerant and low-latency systems. Erlang was written in 1986 by Ericsson to help address fault-tolerance and concurrency. Offering useful tooling and extensible design, Elixir is supported by meta-programming and polymorphism.
Development History
Elixir was created in 2012 by Jose Valim on top of the Erlang VM called BEAM.
Latest Version: he latest version is 1.7.3 which was released in August 2018.
Advantages
- Scalability and Extensibility
- Fault Tolerance
- Interactive and fast development
- Strong metaprogramming
- Simple syntax
Most Frequently Asked Elixir Interview Questions
Elixir is a functional and dynamic language that is designed for building scalable applications. It is based on Erlang language VM which is known for running fault-tolerant and low-latency systems. Offering useful tooling and extensible design, Elixir is supported by meta-programming and polymorphism.
- Scalability and Extensibility
- Fault Tolerance
- Interactive and fast development
- Strong metaprogramming
- Simple syntax
The latest version is 1.7.3 which was released in August 2018.
Erlang provides two types of data types:
- Constant data type: This data type cannot be split into primitive subtypes as it consists of Atoms and Numbers.
- Compound data type: This data type is used to put together other data types, and it consists mainly of lists and tuples.
An open source platform, OTP is a huge set of Erlang libraries to do all kinds of tasks, from assembling ASN.1 to providing a server.
Using Catch or Try can help prevent run-time errors from causing the process to terminate. Catch Expr throws value of the expression, except when an exception occurs during the evaluation phase. Try Exprs is nothing but the enhancement of catch with the added ability to identify and handle the desired exception class.
Erlang enables to put together code into modules, which consists of functions. A module introduces local scope of functions, both Public and Private. A module is stored in a file named “.erl.” Make sure the file basename and the name of the module are the same.
A process is created by calling spawn, which forms a process and returns the pid. Here’s how you can do it:
Spawn (Module, Name, Args ) -> pid ()
The function clauses can be protected using guards, but a clause can only be protected if the guard holds it. A guard sequence is separated by a comma (,) and semicolon (;). The guard sequence can only be true when at least one guard is true.
The valid guard expressions are Atom true, Other constants, Calls to the BIFs specified, Term Comparisons, Arithmetic Expressions, Boolean Expressions, and Short-circuit Expressions.