We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
ElixirConf 2023 - Andrew Selder - Speeding up dynamic templates Using Meta-programming
ElixirConf 2023 talk on speeding up dynamic templates using meta-programming, exploring macros, unquote, and ETS to generate templates at compile time for fast rendering.
- Elixir templates can be slow when they are compiled at runtime.
-
Using
EEX function from string
to define a function can lead to performance issues, as it is essentially a quoted expression that is evaluated at compile time. - Macros in Elixir can be used to generate templates at compile time, which can significantly improve performance.
- Macros are functions that are evaluated at compile time and return a chunk of abstract syntax tree (AST).
- Unquote can be used to manipulate AST generated by macros.
-
The
quote
function is used to generate a chunk of AST that can be used to generate a module at compile time. - Unquote can be used to insert variables into a quoted expression.
-
The
EEX function from string
can be used to generate a template at compile time, which can be orders of magnitude faster than the standardEEX compile string
. -
The
code compile quoted
function can be used to compile a quoted expression and generate a module at compile time. - Macros can be used to generate templates at compile time for fast rendering.
-
The
defmodule
macro can be used to define a module at compile time. - Unquote can be used to dereference variables in a quoted expression.
-
The
ETS
(Erlang Term Storage) function can be used to store and retrieve data at compile time. - Macros can be used to generate templates at compile time for fast rendering, which can be especially useful for complex templates.
-
The
Phoenix
framework uses macros to generate templates at compile time for fast rendering. - Macros can be used to generate templates at compile time for fast rendering, which can be especially useful for complex templates.
-
The
Elixir
language has a strong separation between compile time and runtime. -
The
quote
function can be used to generate a chunk of AST that can be used to generate a module at compile time. - Macros can be used to generate templates at compile time for fast rendering.
-
The
defmodule
macro can be used to define a module at compile time. - Macros can be used to generate templates at compile time for fast rendering, which can be especially useful for complex templates.
-
The
ETS
(Erlang Term Storage) function can be used to store and retrieve data at compile time.