Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Metaprogramming Elixir : write less code, get more done (and have fun!)
McCord C., Pragmatic Bookshelf, Raleigh, NC, 2015. 120 pp. Type: Book (978-1-680500-41-7)
Date Reviewed: Jul 21 2016

Elixir is one of the programming languages built on top of BEAM, the Erlang virtual machine. That makes it inherently worthy of consideration since Erlang is well known as a platform for building highly reliable, massively parallel fault-tolerant systems. As a language, Elixir is made up almost entirely of macros that take as input expressions (called “quoted expressions”) and produce quoted expressions that are compiled by Elixir functions and the Elixir kernel into BEAM code. A quoted expression is a text representation of part of the program’s abstract syntax tree. It is not surprising, then, that Elixir also makes macros available to programmers and provides a suite of tools for macro development.

In Metaprogramming Elixir, McCord refers to quoted expressions as ASTs. This small book (106 pages of text, no index) contains six chapters. Chapter 1, “The Language of Macros,” introduces basic concepts and procedures. Chapters 2, “Extending Elixir with Metaprogramming,” and 3, “Advanced Compile-Time Code Generation,” continue with development of the material. Chapter 4, “How to Test Macros,” goes into considerable detail on how to test macros at different levels. Chapter 5, “Creating an HTML Domain-Specific Language,” shows how to generate Hypertext Markup Language (HTML) code from Elixir macros. Finally, chapter 6, “With Great Power Comes Great Responsibility (and Fun!),” contains a summary of McCord’s views and recommendations. For some reason, McCord, like nearly everyone who writes about Elixir macros, seems to feel compelled to express the opinion that you should do everything you can to avoid writing them.

The book is written in the effusive tone of the new convert; at times the level of enthusiasm exceeds the level of explanation, when less is needed of the former and more of the latter. The book must be read slowly and carefully, constantly verifying the work on a computer. Like me, many readers will need to read most sections more than once. The basic material needed is included, but additional effort to look up and internalize the relevant portions of the internals of Elixir is required--something McCord rarely mentions.

Learning Elixir macros to the level of fluid competency requires a serious commitment of time and effort. An absolute requirement is considerable fluency in Elixir. Since Elixir macros involve modifying the syntax of the language in ways large or small, practical programming experience and academic computer science knowledge are also essential--it’s doubtful the reader could make much progress without them. McCord mentions the need to know Elixir, but simply assumes further knowledge and experience without mention or apology.

Elixir macros can add an important element to the experienced programmer’s toolkit, so learning them is well worth the effort. This book can help you get started; at this time, it seems to be the only book dedicated to the subject. Recently, however, some excellent web resources have appeared, and they are very much worth pursuing. Among these, Saša Jurić’s six-part series [1] is noteworthy.

In addition to Elixir enthusiasts, to whom the book will certainly appeal, the book may also be of interest to those interested in developing domain-specific languages and other tools that take advantage of the Erlang virtual machine.

Although not strictly related to this book, I’d like to mention my dismay to see that the Rosetta Code page asking for demonstrations of language support for metaprogramming [2] contains entries for a number of programming languages, but not Elixir--at least not yet.

More reviews about this item: Amazon, Goodreads

Reviewer:  Edgar R. Chavez Review #: CR144618 (1610-0725)
1) Jurić, S. Understanding Elixir macros, part 1 - basics. http://www.theerlangelist.com/article/macros_1 (05/13/2016).
2) Metaprogramming. http://rosettacode.org/wiki/Metaprogramming (05/13/2016).
Bookmark and Share
  Reviewer Selected
Featured Reviewer
 
 
General (D.1.0 )
 
 
General (D.2.0 )
 
 
Reference (A.2 )
 
Would you recommend this review?
yes
no
Other reviews under "General": Date
Problems in programming
Vitek A., Tvrdy I., Reinhardt R., Mohar B. (ed), Martinec M., Dolenc T., Batagelj V. (ed), John Wiley & Sons, Inc., New York, NY, 1991. Type: Book (9780471930174)
Aug 1 1992
KNOs: KNowledge acquisition, dissemination, and manipulation Objects
Tsichritzis D., Fiume E., Gibbs S., Nierstrasz O. ACM Transactions on Information Systems 5(1): 96-112, 1987. Type: Article
Nov 1 1987
Programmer perceptions of productivity and programming tools
Hanson S. (ed), Rosinski R. Communications of the ACM 28(2): 180-189, 1985. Type: Article
Jul 1 1985
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy