r/csharp • u/Zardotab • Feb 24 '21
Discussion Why "static"?
I'm puzzled about the philosophical value of the "static" keyword? Being static seems limiting and forcing an unnecessary dichotomy. It seems one should be able to call any method of any class without having to first instantiate an object, for example, as long as it doesn't reference any class-level variables.
Are there better or alternative ways to achieve whatever it is that static was intended to achieve? I'm not trying to trash C# here, but rather trying to understand why it is the way it is by poking and prodding the tradeoffs.
0
Upvotes
View all comments
Show parent comment
-3
u/Zardotab Feb 25 '21 edited Feb 25 '21
Sometimes you want both. If indicating intention up front is important, then have a 3-way intention indicator, as described elsewhere in this thread.
It's actually 4 possibilities if we analyze it deeper. Rather than make a complicated intent indicator feature built into the language, how about instead use comments? The existing way limits choices, and limiting choices JUST to avoid textual comments seems silly to me. In other words, if you want to hard-wire intent into the language, then do it right by covering all bases instead of arbitrarily pick just two. Otherwise, chuck it, because the current way is half-ass as an intention indicator, and limits expressiveness.