Skip to content

re: Are C macros awesome? VIEW POST

re: I've definitely seen macros used to create unreadable code. But don't they provide a lot of power when used well? For example, I don't think there'...

For example, I don't think there's any way to do what I did in Go.

Well, it is hard to judge without specific example :)

But both C and Go are intentionally limited in some ways. So of course for them macros feel useful. However Go designers preferred to go limited but not use macros (of course one can add some macros preprocessor before Go compiler anyway).

Languages which compile to bytecode like Java and C# take middle place between scripting and compiling to native code. So usually there is no sense in macros.

I remember Scala (Java-based language) was going to introduce macros. Many people were alarmed. Probably this idea have died in peace - I don't know.

Man, I always miss so much in these discussions from not knowing C++ :P But everyone seems to think it's horrible, so I'm averse to learning it.

I won't say it's horrible, but it become so overcomplicated over years, so many (like me) prefer Java, Go or something like this.

Nevertheless it makes sense to get acquainted with C++ at "non-professional" level to know better what magics are implemented in it nowadays :)

Concluding it's good to have macros in C. But it is also good we don't have them in many other languages :) just my humble opinion, of course.

code of conduct - report abuse