Zero-Overhead JSON Serialization in Crystal Using Compile-Time Macros
Crystal lacks runtime reflection, but compile-time macros can generate type-safe JSON serialization methods with zero runtime overhead.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Crystal lacks runtime reflection, but compile-time macros can generate type-safe JSON serialization methods with zero runtime overhead.
Haxe macros generate boilerplate at compile time, inlining target-specific code with zero runtime overhead. A worked example shows type-safe JSON serialization across JavaScript, C++, and Python targets, plus practical verification steps and the trade-offs to weigh before adopting macros broadly.
Guide to choosing a type‑generic abs implementation in C11 using _Generic macros and inline functions, with trade‑offs, sample code, and verification steps.
Use \newcommand to define repeatable LaTeX macros with optional arguments, defaults, and robust behavior in section headings.
Use a Nim macro with untyped parameters to build a compile-time static-if that drops unused branches from the AST.
A guide to designing and maintaining Haxe macros, focusing on AST transformation, trust boundaries, and avoiding compiler-side side effects.
C11's _Generic keyword lets you write a single macro that expands to the correct float, double or long double math function, eliminating duplicated code.
Haxe macros generate typed code at compile time, eliminating boilerplate with zero runtime cost. This guide walks through a working build-info macro, hygiene rules, compile-time costs, and how to verify expansions in the generated target output.
A step-by-step guide to writing, debugging, and safely using Crystal 1.8+ macros for zero-overhead code generation and DSLs — covering AST interpolation, hygiene, {% debug %}, and common pitfalls.