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
0
u/Zardotab Feb 26 '21
The distinction can be blurry as one may make a domain or app-specific framework or version of a framework. The "shared-ness" of an API can vary on a wide continuum.
As far as the dynamic versus static/compile debate, generally I find that the bottom layers do better with stricter languages and the top layers do better with dynamic languages. Unfortunately we are generally forced to select one or the other in order to have infrastructure (bottom) and top layers work together. Maybe someday someone will invent a language that can do both fairly well. Until then, the ugly either/or choice continues. TypeScript may be an example of a language that gives the idea a first shot.