eph baum dot dev

← Back to blog

WTF is Idiomatic

Published on 10/27/2023 09:50 PM by Eph Baum

Featured Image

In a recent post I used the word “idiomatic” more than once and had to make sure I was using right. Then, someone asked me what the hell it meant so I figured others might also wonder what it means and figured I’d write another post about it because content, right?

In the context of programming, “idiomatic” refers to code that follows the practices, patterns, and conventions of a particular language. Writing idiomatic code usually results in more readable, efficient, and maintainable code. It aligns with the language’s philosophy and leverages its unique features.

On the other hand, “non-idiomatic” code can often resemble “writing Language A in the style of Language B.” For example, using throw and catch for control flow in Elixir could be considered non-idiomatic because Elixir, being a functional programming language, prefers other constructs like pattern matching, guard clauses, case, and cond for handling various conditions and branching logic.

Idiomatic Elixir Examples:

Pattern Matching:

def calculate_area({:circle, radius}) do
  :math.pi() * radius * radius
end

Guard Clauses:

def is_even?(n) when rem(n, 2) == 0, do: true
def is_even?(_), do: false

Non-Idiomatic Elixir Examples:

Throw/Catch for Control Flow:

try do
  if some_condition do
    throw(:abort)
  end
catch
  :throw, :abort -> :error
end

Imperative Style Loops:

# Using recursion to mimic a 'for' loop, instead of using Enum.map/2, Enum.reduce/2, etc.

By adhering to idiomatic practices, you embrace the strengths and paradigms of the language, making it easier for others who are familiar with the language to understand and contribute to your code.

I hope this helps clarify the terms “idiomatic” and “non-idiomatic” in the context of Elixir or any programming language.

Written by Eph Baum

  • Making Brutalist Design Accessible: A Journey in WCAG AA Compliance

    Making Brutalist Design Accessible: A Journey in WCAG AA Compliance

    How I transformed my brutalist blog theme to meet WCAG AA accessibility standards while preserving its vibrant, random aesthetic. Talking about contrast ratios, color theory, and inclusive design.

  • Building Horror Movie Season: A Journey in AI-Augmented Development

    Building Horror Movie Season: A Journey in AI-Augmented Development

    How I built a production web app primarily through 'vibe coding' with Claude, and what it taught me about the future of software development. A deep dive into AI-augmented development, the Horror Movie Season app, and reflections on the evolving role of engineers in the age of LLMs.

  • Chaos Engineering: Building Resiliency in Ourselves and Our Systems

    Chaos Engineering: Building Resiliency in Ourselves and Our Systems

    Chaos Engineering isn't just about breaking systems — it's about building resilient teams, processes, and cultures. Learn how deliberate practice strengthens both technical and human architecture, and discover "Eph's Law": If a single engineer can bring down production, the failure isn't theirs — it's the process.

  • Using LLMs to Audit and Clean Up Your Codebase: A Real-World Example

    Using LLMs to Audit and Clean Up Your Codebase: A Real-World Example

    How I used an LLM to systematically audit and remove 228 unused image files from my legacy dev blog repository, saving hours of manual work and demonstrating the practical value of AI-assisted development.

  • Migrating from Ghost CMS to Astro: A Complete Journey

    Migrating from Ghost CMS to Astro: A Complete Journey

    The complete 2-year journey of migrating from Ghost CMS to Astro—from initial script development in October 2023 to final completion in October 2025. Documents the blog's 11-year evolution, custom backup conversion script, image restoration process, and the intensive 4-day development sprint. Includes honest insights about how a few days of actual work got spread across two years due to life priorities.

  • 50 Stars - Puzzle Solver (of Little Renown)

    50 Stars - Puzzle Solver (of Little Renown)

    From coding puzzle dropout to 50-star champion—discover how AI became the ultimate coding partner for completing Advent of Code 2023. A celebration of persistence, imposter syndrome, and the surprising ways generative AI can help you level up your problem-solving game.