Nim Metaprogramming in the Real World
Andre and Ryan Program
0:00 / 0:00
Nim Metaprogramming in the Real World
6 249 просмотров · 4 г. назад
Andre and Ryan Program
307 подписчиков
6 249 просмотров · 4 г. назад
Originally presented at FOSDEM 2022
Metaprogramming in Nim is very powerful. But why would you use it? How is it used in the real world? We will explore the "power levels": starting from generics, continuing to templates and finally arriving at macros. We will first look at generics usage in VMath (Vector Math Library) and Jsony (JSON Parsing Library). Then we will continue on to templates and how they are used in VMath and Windy. Finally, we will look macros, the top of the "power levels", and how they are used in Shady (a Nim to GLSL compiler) and Genny (Generates bindings for Nim libraries).
0:00 Intro
0:30 Metaprogramming power levels
1:28 Generics
2:23 Using generics in VMath
4:40 Using generics in Jsony
8:20 Templates
10:26 Using templates in VMath
11:43 Using templates in Windy
15:10 Macros
15:22 Using macros in Shady
19:40 Using macros in Genny
20:51 Using Genny to generate bindings
30:18 Closing
Links to libraries in this talk:
vmath - https://github.com/treeform/vmath
jsony - https://github.com/treeform/jsony
windy - https://github.com/treeform/windy
shady - https://github.com/treeform/shady
genny - https://github.com/treeform/genny