Elixir Interview Questions and Answers

Last updated on Feb 06, 2023
  • Share
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. 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

Here in this article, we will be listing frequently asked Elixir Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

Q11. How is a message sent and received in Erlang?
Answer

For sending a message, you can use an exclamation mark (!) as the operator. The syntax that you can use for sending a new message is Pid ! Message.

For receiving a message, you can use Pattern Matching from the message queue receive a statement.

Q12. Explain what are Spawn_link 1l3 and Spawn/ 1l3?
Answer

Spawn/ 1l3 creates a new process and return pid. In the system scheduler queue, the new process is created so that it runs later.

Spawn_link/1l3: provides the same functionality as spawn/1l3 but with an additional link that gets automatically created between the caller and the new spawn process.

Q13. What is the syntax to write Macros?
Answer

define ( Const, Replacement )

define ( Fun ( Var1 , Var2, …., Var ) , Replacement )

Q14. What are some of the pre-defined Macros in Erlang?
Answer

Here are the pre-defined Macros:

  • ? Module returns the name of the existing module.
  • ? Module_String returns the name of the existing module as a string.
  • ? File returns the existing file name.
  • ? Line returns the existing line number
  • ? Machine returns the existing machine name, ‘BEAM.’
Q15. What is a record?
Answer

The data structure that is used for storing a fixed number of elements is referred to as a record. Expressions are then translated into tuple expressions during the compilation record.

The Record is defined by the name of the record, which is followed by the field names. The record and field names should be atoms.

record (Name, { Field1 [= Value] , … FieldN [= ValueN] } )

Q16. What is the command for accessing record field?
Answer

Expr#Name.Field. This command returns the value of the mentioned field. To return the position of the specified field, you can use the command #Name.Field.

Q17. What is Erlang Port Mapper Daemon (epmd)?
Answer

It is a small server that is used for establishing distributed communications. This name server is responsible for mapping the node names to the machine addresses.

Q18. What are the main operators in Elixir?
Answer

Following are the main operators:

  • Arithmetic operators
  • Comparison operators
  • Boolean operators
  • Misc operators
Q19. What is String Interpolation?
Answer

It is a way to build a new string value where the code is wrapped in curly braces and ‘#’ function.

Example

x = "Apocalypse"
y = "X-men #{x}"
IO.puts(y)
x = "Apocalypse"
y = "X-men #{x}"
IO.puts(y)

Q20. What role does Crypto Module play?
Answer
The crypto module decrypts project applications by using digital signature and hashing function and.
Example

IO.puts(Base.encode16(:crypto.hash(:sha256, "Elixir")))

IO.puts(Base.encode16(:crypto.hash(:sha256, "Elixir")))

Reviewed and verified by Best Interview Question
Best Interview Question

With our 10+ experience in PHP, MySQL, React, Python & more our technical consulting firm has received the privilege of working with top projects, 100 and still counting. Our team of 25+ is skilled in...