axelson
Scenic Core Team
Here’s today’s talk:
ElixirConf 2017 - Don’t Write Macros But Do Learn How They Work - by @jessejanderson
You may have heard that “most of Elixir was written in Elixir” but what does that even mean, and how is that possible? Metaprogramming allows us to write code that writes code and, in addition to powering most of Elixir itself, has allowed for many great projects including Phoenix to exist. Even if you don’t have ambitions to create the next Phoenix, understanding metaprogramming basics and learning how the Elixir expressions work under the hood can lead to greater understanding of the code you write every day.
All talks are available in the Elixir Conf 2017 Talks List
Trending in Talks
LT: Skode: an ASCII shorthand for audio experimentation - Joseph Stewart | ElixirConf EU 2026
Comments welcome! View the ...
New
Lightning Talk: Kate Rezentes - Notion-land | ElixirConf US 2025
https://www.youtube.com/watch?v=nLWm8gIz8TI
Comments welcome! View th...
New
Lightning Talk: Ivy Markwell - Data migrations with Monarch | ElixirConf US 2025
https://www.youtube.com/watch?v=AF1z6Z3bJKY
Comments ...
New
Failing to Introduce Elixir - John Darrington
https://www.youtube.com/watch?v=KjAH68yVnh8
Comments welcome! View the <span class="hasht...
New
Testing Concurrency and Fault Tolerance in Elixir/Nerves - Marta Habdas | ElixirConf EU 2026
Comments welcome! View the <...
New
Practical Data Orchestration in Elixir - Silvia Zeamer | ElixirConf EU 2026
Comments welcome! View the <span class="hasht...
New
Lightning Talk: Joseph Koski - Functional Program with Elixir | ElixirConf US 2025
Comments welcome! View the <span class...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sillypog
I really enjoyed both this and Jesse’s previous talk at Erlang & Elixir Factory '17. He’s an entertaining speaker who gives really great breakdowns of these aspects of Elixir that newcomers to the language can get tripped up on.
JEG2
I agree that it was a solid introductory presentation. I found myself wishing it went a touch deeper, but I did enjoy it.
axelson
Having not delved into the AST form of Elixir I felt that this was a solid presentation on how to use macros. I especially liked the use of pattern matching with
defmacrosince I can see many ways that could be useful. It was definitely well presented and I liked the use of color/fading to highlight portions of code.However, I do have a question. Why was the two element tuple made a literal but an empty tuple (
{}), and a single-element tuple ({:example}) are not literals? It seems like it would be easier/more consistent for all tuples to be treated equally. If I had to take a stab at it, I would guess that it is somehow related to S-expressions and Lisp.kylethebaker
The reason that two-element tuples are special is so that keyword lists can be special. See the mailing list thread where José confirms it.
Zero and one item tuples could be special too, but I don’t think three item tuples could be. Since lists and atoms are literal I think there could be ambiguity between AST nodes and values. Something like
{:x, [], []}might be representingx()or it might be the literal value{:x, [], []}.So I think it could be either “all tuples are literals, except three item tuples”, or it could be “only two element tuples are literals”. I think having a single case where the rule doesn’t apply is more confusing than having a single case where the rule does apply. Though it could be that there is no ambiguity with three item tuples and I’m just overlooking something.
OvermindDL1
I actually really really really hate that things like 2-element tuples and literals are special cased, they lose their source positions and meta information. I wish everything, absolutely everything were 3-tuples.
Thankfully you can wrap literals in blocks to recover meta information, but you cannot do that to 2-tuples as things break I found out.
brightball
Thanks for taking over the posting responsibility for these videos. I’ve been really busy lately.
axelson
You’re welcome! I think the discussion is very valuable
jessejanderson
Thanks for the feedback everyone, I really appreciate it!
@sillypog
Great to see you again at the conf - thanks for the kind words! The trick I’ve found is to trip up a lot myself, and then just try to document everything that didn’t make any sense to me.
@JEG2
I personally don’t have a ton of programming history prior to Elixir, so how macros work and especially the AST in general were difficult concepts for me to learn. I’ve heard some excellent talks that started just a couple levels above where my own knowledge was, so at the time I didn’t learn much because I couldn’t follow along.
For sure, I’d love to have had another 30 minutes to talk so I could go deeper!
So my top goal for this talk was that someone with very little background would walk out of the talk understanding 90% of what was covered, and that they could then watch any other Macro talks and be able to easily follow along by recognizing the same concepts. I also went long every time I did a run-through of the talk so I ended up cutting a couple of examples at the end that would’ve introduced a few more of concepts of Macros (e.g. I really wanted to do an example of
__using__but just didn’t have the time).@axelson
As some others said, the reason for the 2-element tuple is to allow for the syntax of keyword lists, which I think might be important for the maintaining of
do/else/etcblocks inside of the AST. I was planning to cover this in my original talk but had to cut it for time at the last minute. I’ve got the slide to prove it! There’s some additional info (though not a ton) in the Official Docs: Syntax Reference.Also, could you add the
elixirconf2017tag to this post, thanks!axelson
Thanks for the additional info! Also I’ve tagged this with
elixirconf2017, didn’t realize that tag existed, will check the other posts as well.JEG2
Seems like a worthy goal to me and I would say that you nailed it.