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
2
u/Slypenslyde Feb 26 '21
I constantly go back and forth on dynamic vs. static.
I think it comes down to something snooty like "with good architecture, I don't need a compiler to help me understand the impact of a change." Any time I start a TypeScript project I enjoy having the freedom to sometimes go a little off the rails and be dynamic while still having a way to define some areas with static typing. But invariably as the project drags on, I start to feel two things:
It's hard to make concrete examples because I find to really get in that mess tends to take me a month or two. It doesn't make me hate dynamic languages, it just makes me feel like you spend the same amount of time on different problems.