Here’s a small example set for metaprogramming in crystal and ruby.
We’ll start by creating value objects in both crystal and ruby.
What about some class factory action? Again, crystal and ruby.
Fun right? Let’s see another comparison. This time it’s the visitor pattern. The crystal version doesn’t need any meta stuff, but the ruby one does.
Finally, a couple of slightly bigger examples, a state machine in crystal, and a validation engine in ruby.
If you want to dig deeper you can read about metaclasses in ruby, and check out the docs for crystal macros. You can also check the actual source for the examples in the github repo for this site.
Built by @dgsuarez.