O'Reilly logo

Learning Elixir by Kenny Ballou

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Domain-specific languages

Macros have the ability to create small, embedded languages for solving specific problems. Occasionally, certain problems are not well expressed in the current language, however, they would be very easily expressible in a new, smaller, and more precise language.

Usually, creating a new language requires steps through lexers, parsers, and evaluators to even get the language off the ground. However, macros can extend the current language facilities to accomplish creating an embedded DSL.

A notable DSL example using Elixir and macros is the Ecto project. The Ecto project attempts to provide a similar language to SQL in Elixir for querying data stores. Instead of writing the SQL yourself and passing it to the database connector ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required