I'm a Python programmer learning C# who is trying to stop worrying and just love C# for what it is, rather than constantly comparing it back to Python.
I'm caught up on one point: the lack of explicitness about where things are defined, as detailed in this Stack Overflow question. In short: in C#, using foo
doesn't tell you what names from foo
are being made available, which is analogous to from foo import *
in Python -- a form that is discouraged within Python coding culture for being implicit rather than the more explicit approach of from foo import bar
.
I was rather struck by the Stack Overflow answers to this point from C# programmers, which was that in practice this lack of explicitness doesn't really matter because in your IDE (presumably Visual Studio) you can just hover over a name and be told by the system where the name is coming from. E.g.:
Now, in theory I realise this means when you're looking with a text editor, you can't tell where the types come from in C#... but in practice, I don't find that to be a problem. How often are you actually looking at code and can't use Visual Studio?
This is revelatory to me. Many Python programmers prefer a text editor approach to coding, using something like Sublime Text 2 or vim, where it's all about the code, plus command line tools and direct access and manipulation of folders and files. The idea of being dependent on an IDE to understand code at such a basic level seems anathema. It seems C# culture is radically different on this point. And I wonder if I just need to accept and embrace that as part of my learning of C#.
Which leads me to my question here: is C# development effectively inseparable from the IDE you use?
using MyType = MyNamespace.MyType;
?global::
and work your way from there.using
doesn't make anything available that wasn't before; it only makes it easier to access (as in less typing needed to use a particular class).