# When is metaprogramming the best solution?

**URL:** <https://discourse.julialang.org/t/when-is-metaprogramming-the-best-solution/87197>\
**Category:** New to Julia\
**Created:** [September 13, 2022, 10:02am UTC](https://discourse.julialang.org/t/when-is-metaprogramming-the-best-solution/87197 "2022-09-13T10:02:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AwesomeQuest](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/awesomequest/32/38910_2.png) [@AwesomeQuest](https://discourse.julialang.org/u/AwesomeQuest)\
**Post date:** [September 13, 2022, 10:02am UTC](https://discourse.julialang.org/t/when-is-metaprogramming-the-best-solution/87197/1 "2022-09-13T10:02:03Z")

</div>

Julia has all these fancy metaprogramming features but when is it actually most optimal or comfortable to use them?  
Follow up question: Is it ever worth it use metaprogramming in a complicated way?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [September 13, 2022, 10:31am UTC](https://discourse.julialang.org/t/when-is-metaprogramming-the-best-solution/87197/2 "2022-09-13T10:31:24Z")

</div>

Mandatory link:

[![](https://global.discourse-cdn.com/julialang/original/3X/7/5/759062729d830f12cdfa7374e0be51cc40e42a54.jpeg "JuliaCon 2019 | Keynote: Professor Steven G. Johnson") ](https://www.youtube.com/watch?v=mSgXWpvQEHE&t=585)

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [September 13, 2022, 1:08pm UTC](https://discourse.julialang.org/t/when-is-metaprogramming-the-best-solution/87197/3 "2022-09-13T13:08:28Z")

</div>

I am a _user_ of macros, but have never written any. `@chain` and `@benchmark` are my most common encounters with metaprogramming. `@turbo` and `@tullio` are other good examples.
