HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to ElixirVariablesData TypesOperatorsStringsListsConditions (if / else)Iteration (Enum)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables & Types
🔢 Numbers & Math
✍️ String
📚 List & Enum
🔀 Condition
🧩 Function
Elixir›Introduction to Elixir

Introduction to Elixir

First step into Elixir, a functional language running on the Erlang VM: printing with IO.puts.

Simple enough for a 5-year-old to understand

Print with IO.puts

IO.puts prints to the screen and moves to the next line.

Your first program
1
IO.puts("Hello!")
Prints to the screen and moves to the next line.
Output / InputPrints to the screen and moves to the next line.
Output / Input
💡 Hint: IO.inspect is used to see structures (items, map).

Comment line

Example code
1
# This is a comment — it does not work.
# for single-line comments.
Comment# for single-line comments.
2
IO.puts("Code here")
Only this line runs.
Output / InputOnly this line runs.
CommentOutput / Input

🎯 Exercise & Practice

Test what you've learned — answer, write code, check instantly. (1 left)

1.Print exactly Hello World to the screen.

🎯 Expected output: Hello World

Loading editor…

About this topic

Elixir is a modern functional programming language running on the Erlang virtual machine. It was developed in 2011 by José Valim to combine Erlang's resilience with a more familiar syntax.

Elixir's true strength comes from concurrency. The virtual machine can run millions of lightweight processes simultaneously, and if one process crashes, it doesn't affect the others. Designed to keep telephone exchanges running non-stop, this architecture is used today in chat systems and real-time web applications.

The language is purely functional: data is immutable, functions are side-effect free. But it's not as strict as Haskell; its syntax resembles Ruby and the learning curve is much smoother. This balance is the reason for Elixir's rapid spread.

What you will learn

  • how an Elixir script works
  • printing to the screen with IO.puts
  • inspecting values with IO.inspect
  • defining a module
  • Writing comment lines

Who is this for?

  • Those who want to write concurrent systems
  • Ruby developers looking to transition to functional programming
  • Those developing real-time web applications

When to use?

Elixir excels in systems holding a massive number of concurrent connections: chats, notifications, game servers, and live dashboards.

It is not suitable for heavy numerical computation or single-threaded heavy operations; the virtual machine is optimized for concurrency, not raw speed.

Common mistakes

Wrong

IO.puts [1, 2, 3]

IO.puts tries to print text and interprets the number list as character codes; meaningless characters are printed to the screen instead of the expected list. To inspect a data structure, the inspection function must be used.

Correct

IO.inspect [1, 2, 3]

Wrong

defmodule Selam do
  def merhaba do
    IO.puts "Hello"
end

Every block must be closed with its own end keyword; here the function's end is missing and the compiler gives a "missing terminator: end" error. Elixir doesn't care about indentation, keywords determine blocks; that's why a missing end shows the error at the end of the file.

Correct

defmodule Selam do
  def merhaba do
    IO.puts "Hello"
  end
end

Wrong

defmodule selam do
  def merhaba, do: IO.puts("Hello")
end

Module names must start with a capital letter; a lowercase name is interpreted as a variable and the compiler throws an error. In Elixir, names starting with capital letters are for modules and atoms, lowercase ones are for variables and functions.

Correct

defmodule Selam do
  def merhaba, do: IO.puts("Hello")
end

Frequently asked questions

What is the relationship between Elixir and Erlang?

Elixir runs on the same virtual machine and can directly call Erlang libraries. The difference lies in syntax and tooling: Elixir offers more readable syntax, macro support, and a much better package manager.

What is the difference between IO.puts and IO.inspect?

puts prints text and yields unexpected results for values that cannot be converted to text. inspect, on the other hand, shows any data structure in a readable format and returns the value; therefore, you can place it in the middle of a pipeline to inspect intermediate values.

What is the difference between a script file and a module file?

Files with the .exs extension are interpreted directly and run like a script; files with the .ex extension are compiled and used within a project. While learning, the script format is more practical.

Summary

Elixir runs on the Erlang virtual machine.

IO.puts shows text, IO.inspect shows a data structure.

Every block is closed with end.

Module names start with a capital letter.

Concurrency is the language's strongest feature.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code