Skip to Content

Posts by Narendra Patwardhan

Iterating the Elixir Way: From Recursion to Streams

When you first pick up a language that embraces functional ideas, loops can feel odd. In Elixir there are no while or for statements that mutate a counter. Instead, iteration is expressed through recursion and a set of powerful higher‑order functions. This article walks you through the core concepts, shows how they’re applied in everyday code, and equips you with fresh examples you can adapt to your own projects.

Why Understanding Elixir’s Iteration Model Matters

  • Predictable data flow: Since values never change in place, reasoning about code becomes easier.
  • Composability: Functions that accept other functions can be
Iterating the Elixir Way: From Recursion to Streams Read More

Control Flow in Elixir: From Pattern Matching to Tail‑Recursive Loops

Elixir gives you several tools to make decisions and repeat work. In this article we’ll explore:

  • Choosing between case and multi‑clause functions
  • Using the with special form to chain operations that can fail
  • Expressing loops with recursion
  • Turning ordinary recursion into tail‑recursive form for unlimited iteration

Each section introduces the idea, explains why it matters, and shows fresh, real‑world examples that differ from the classic “TODO list” or “user registration” snippets you may have seen elsewhere.

Why Control Flow Matters in a Functional Language

In imperative languages, if, while, and for are the building blocks of

Control Flow in Elixir: From Pattern Matching to Tail‑Recursive Loops Read More

Understanding Pattern Matching in Elixir

Before we can talk about if, case, or any kind of looping, we need to get comfortable with the most fundamental building block of Elixir’s control flow: pattern matching. In a language that treats data as immutable values, the only way to “look inside” a value is by matching its shape against a pattern. The = operator is not an assignment; it is a match operator that attempts to bind variables on the left‑hand side to the corresponding parts of the right‑hand side.

Basic Match: Variables and Literals

A lone variable matches anything:


value = 42          # binds value to
Understanding Pattern Matching in Elixir Read More

Essential Elixir Building Blocks: Keyword Lists, Sets, Dates, and Runtime Mechanics

In this article we explore a collection of everyday Elixir building blocks that make the language both expressive and efficient. We’ll look at how to handle optional arguments, work with unique collections, manipulate dates and times, craft performant output streams, understand the most common operators, dip our toes into macros, and peek under the hood of the BEAM runtime. Along the way you’ll see fresh, self‑contained examples that illustrate each idea from a practical perspective.

Every non‑trivial Elixir program relies on a few core abstractions:

  • Keyword lists vs. maps – the idiomatic way to pass optional parameters.
Essential Elixir Building Blocks: Keyword Lists, Sets, Dates, and Runtime Mechanics Read More

Working with Elixir's Core Data Types: Atoms, Booleans, and More

Elixir’s core data types are the building blocks of every program you’ll write. In this article we will walk through each primitive type, explore how they behave, and see how they combine to form more expressive structures. All examples are original, using domains such as a video‑streaming service, a game leaderboard, and a simple IoT sensor hub.

Even though Elixir runs on the Erlang VM and provides a dynamic type system, knowing the characteristics of each type helps you write faster, more predictable code:

  • Performance‑critical paths: atoms are stored once in a global table, making them
Working with Elixir's Core Data Types: Atoms, Booleans, and More Read More

Getting Started with the Core Building Blocks of Elixir

Before you can build a robust Elixir application you need to be comfortable with the language’s most fundamental pieces: the interactive shell, variables, modules, functions, and the way the runtime understands types. This article rewrites those basics with fresh, real‑world examples, so you can experiment right away and see how each concept fits together.

Why These Basics Matter

  • Interactive exploration lets you prototype ideas in seconds, without creating a full project.
  • Variables and immutability shape how data flows through your functions.
  • Modules and functions provide the namespace and composability that keep code readable.
  • Operator shortcuts such as the
Getting Started with the Core Building Blocks of Elixir Read More