In class the prof said one reason he likes C better than Java is that C has a preprocesor, and in particular macros. Is there any benefit to macros over declaring afinal/const variable with the desired value? I know Java doesn’t have global variables so would there ever be a situation where using a variable in substitution for macros would not work?
In class the prof said one reason he likes C better than Java is
Share
There’s no reason you can’t run your Java code through a macro preprocessor; it’s just not done as part of the language.
With that said, most of the reasons macros are valuable in C are matters of the C language, and most people’s use of them is extremely ugly and counterproductive, though they do have many good uses too.
Anyway, I would really question the expertise of someone who compares C and Java on the basis that one has macros and the other doesn’t. In the big scheme of things, that seems to be one of the most trivial differences between the languages. Highlighting it suggests to me that the person does not understand the real differences between the languages; perhaps he likes C but doesn’t know how to name any of the actual features C has over Java – things like storage duration and representation of types.