Retrospring is shutting down on 1st March, 2025 Read more
Opinions on macros in programming?
Hmm... I'm not really a macro kind of person - generally speaking I'll just shove everything into a function - but I have no issues with them.
With that said, Crystal has only a few basic functions, and most other "functions" in the language are macros of those basic functions, which makes understanding what those functions actually do a whole lot easier and somewhat self-documenting, and I think that's really cool.
Just like almost everything in life, this type of stuff can be nice when used properly and only when appropriate, and otherwise can quickly be a recipe for disaster. Macros are one of those 'implicit' programming concepts, the stuff that you just can't notice by simply reading code, and I've been bit enough times by all kinds of implicit programming that I started actively avoiding that.
If your macro has some way to let developers notice that it is a macro just by reading the code where it is used, like how you will always notice a Python decorator or a C# attribute, then that's fine as long as the name of macro gives away what it does.
Macros that could even redefine the entire language, like how I saw a project recently just defining a int32
macro with different bit sizes depending on the platform, or macros that have names that cannot be read by any sane human being (as is the norm with everything in C/C++ apparently), are absolute hell.
Retrospring uses Markdown for formatting
*italic text*
for italic text
**bold text**
for bold text
[link](https://example.com)
for link