Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
7  
Python is a dynamic language, C# statically typed (like Java), so how you code in either is very different. –  Oded Oct 15 '12 at 11:00
4  
@Oded: using MyType = MyNamespace.MyType;? –  pdr Oct 15 '12 at 11:05
1  
@Oded: No, I think the same argument applies to using in C# as applies to import in Java. IntelliSense would be much more selective about the classes it offered me if I didn't open up entire namespaces to my code. However, I've worked in Java a bit and I think that argument is heavily offset by the massive collection of imports in every file. Intelligent namespacing is a much better solution to the same problem. –  pdr Oct 15 '12 at 11:21
3  
I don't know what it's like in Python, but in C# you can always start at 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). –  Michael Kjörling Oct 15 '12 at 12:27
4  
"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." - Which sounds horribly inefficent to me. An IDE is a tool which helps you be more productive. Sure you can build a house with a hammer and hand saw and cut down the trees yourself, but I think you'd have a much faster time of it with some power tools and buying some pre-cut lumber. –  Andy Oct 15 '12 at 13:57

13 Answers 13

up vote 22 down vote accepted

Visual Studio is so convenient that after working with it for a while it is difficult to use a different IDE. It has a lot of handy tools and a bunch of plugins available, so practically it has every feature you would need.

On the other hand, whatever language you learn, it is recommended to use command line at the beginning, so you can better understand how it works. C# isn't an exception.

is C# development effectively inseparable from the IDE you use?

Theoretically no, but practically yes. It is possible to write in C# using a text editor and command line, but if you have Visual Studio, you'd never do this. In fact very few programmers have ever executed C# code from command line.

BTW If you feel inconvenient with using foo, you can use the whole path when using a type.

share|improve this answer
9  
SharpDevelop and MonoDevelop are alternative IDEs to Visual Studio. –  Oded Oct 15 '12 at 11:11
    
@Oded, I've never used them but its interesting to take a look. Thanks )) –  superM Oct 15 '12 at 11:12
    
Thanks superM -- can you give a flavor of the kinds of features that make Visual Studio so indispensable? I know it has very good code completion, but what else? Is it more-or-less like Eclipse for C#, or is there something more specific about it that C# developers rely on? –  Ghopper21 Oct 15 '12 at 11:14
1  
@Ghopper21: I would suggest it's more comparable to IntelliJ than Eclipse (especially when you include Resharper), except that, in the .NET world, community plugins are generally written for Visual Studio. –  pdr Oct 15 '12 at 11:27
5  
+1: I agree, while you can write code at the command line with notepad, you'd be an idiot to ignore the tooling that VS or Sharp Develop brings to the table. –  Binary Worrier Oct 15 '12 at 11:55

The idea of being dependent on an IDE to understand code at such a basic level seems anathema.

It is not a question of understanding your code: given sufficient time, you can always locate the right variable with a basic text editor or even in a printout. As far as understanding the code goes, the IDE dependency absolutely does not exist.

Locating your references efficiently is an entirely different subject: I love the ability to find usages of Java variables in Eclipse as much as I love finding declaration points in Visual Studio, for both C# and C++. I prefer spending my time coding, rather than looking for declaration points manually. This is similar to doing math: I can multiply multidigit numbers on a piece of paper, but I prefer using calculator to save myself a minute or two.

Starting at a certain "critical size" of the code, a good IDE becomes very useful regardless of the programming language. The size may vary language to language, but once you cross several thousand lines, having an IDE helps regardless of your language. This has more to do with limitations of a human mind than with a particular programming language: at some point, your short-term memory is bound to "overflow".

There are tricks letting you increase that critical size where IDE becomes useful. For example, you could follow a naming convention (Hungarian names were big in the C++ world at some point, especially among the Windows practitioners). Another common trick is qualifying instance variables with this. even in contexts where such qualification is not required.

These tricks come with trade-offs: almost inevitably, they make your program less readable by obscuring names, or inserting the explicit references the encapsulation was intended to hide. Faced with the choice, I pick clean-looking code plus an IDE over a less-clean-looking code minus an IDE. I fully recognize, however, that other people's choices may differ from mine.

share|improve this answer
1  
I should probably have said "quickly read code"... It's quite a mental shift for me to not have all references right there in the same source file, and instead to use tools to locate those references. –  Ghopper21 Oct 15 '12 at 11:33
4  
Not that I couldn't choose to use this idiosyncratically -- but coding isn't an isolated art and I think it's best to follow (or at least start with) the norms of a coding culture -- i.e. be "Pythonic" with Python and whatever the equivalent "C# way" is with C#. And it's clear from the answers and comments here that using a good IDE like Visual Studio is central to the "C# way" (if that's the right way to put it). –  Ghopper21 Oct 15 '12 at 12:50
3  
@Ghopper21 Thing you'll run into with C# isn't that you can't write it without an IDE, but that the vast majority of C# code was written in an IDE and all the developers use that IDE. This fact combined with intellisense causes developers to fall into the google memory trap as studies have spoke about huffingtonpost.com/2011/07/15/… "According to the studies' findings, people with access to Google's massive web index are less likely to recall a fact when prompted; however, they remember where and how to locate that fact online" –  Jimmy Hoffa Oct 15 '12 at 13:51
1  
@Ghopper21 I'm not saying this memory trap is bad, it's a source of extremely increased productivity for most which is why only those with long memories of the days when they could memorize the entire API they worked with really complain about it. I am merely pointing this out because this fact directly affects the C# code you'll read and the style and culture of C# development. –  Jimmy Hoffa Oct 15 '12 at 13:52
1  
I never quite went down to bios/low level dos APIs; but my first language/environment was Borland TurboPascal; and I probably had ~90% of the language/standard library memorized at one point. The primary exceptions being related to completely failing to figure out what OO was supposed to be about. –  Dan Neely Oct 15 '12 at 15:56

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.

That's great, but it misses the point of the VS IDE. The point of an IDE like VS is rapid development support via strong code tools like refactoring and intellisense. VS is a very very good editor for C# code.

Now C# lets you code in a style that depends on its IDE to a greater extent (you can use lots of var keywords and the like). Some people prefer to be more explicit, for instance by using namespace aliases to be clear on which namespace a class belongs to (like import in Java or Python). That's more of a coding style choice than a feature of the language.

As C# is statically typed (although with some dynamic extensions, as of v4) it's always fairly easy to find out what types are being referred to - if they're wrong the code won't compile, and VS isn't the only IDE with support for C# intellisense. It's probably the best though.

Developing C# without a powerful IDE (like VS) is rather like hammering in nails by hand when you already have a top of the range nailgun - there might be the odd time you need to do it, but professionals use the right tool for the job.

I'd say the same is probably true of Java too. If there's a powerful IDE with intellisense and code refactor tools out there you should probably be using it.

However, look at it the other way round - if you don't want intellisense, compile time code checking and code-analysis/refactoring then a bloated IDE is not the way to go, and neither is a statically typed language. I think it's the other way round:

Many programmers that prefer a text editor approach to coding don't gain as much from statically typed languages (like C# and Java) and so could be better off if they stick to dynamic ones like Python and Javascript.

I think:

  • Dynamic languages suit lightweight tools (heavyweight IDEs confer less benefit here)
  • Static languages suit powerful IDEs (tools can help with the code at the cost of flexibility)
share|improve this answer
    
+1 for the reversed quote. –  fbmd May 24 '13 at 10:03

To answer your question: although it's slowly changing, the Microsoft development environment has largely been a monoculture.

This approach has many positives and negatives, which could be argued at length (e.g. consider the pros and cons of open and closed platforms, such as PCs vs an Xbox), but at the end of the day, the tooling from Microsoft is what most people use. The company has also shown that their decision making is often a kind of "give the most value to the majority of our users" process, always looking for practical compromises (most recently - consider Typescript). So basically, I wouldn't be surprised to find that the development of C# was / is done with the tooling (VS) in mind.

share|improve this answer
    
Thanks, that's helpful context. –  Ghopper21 Oct 15 '12 at 11:39
    
By the way, it could be argued that Python is also its own monoculture, given then strong adherence to what is considered "Pythonic" in coding style and approach, and the language's core design principle of having one obvious right way to do things. I tend to think programming monocultures in this sense can be very good, as it creates a coherent community and shareable code. It's just (too bad? and/or an opportunity to expand my mind?) that the Python and C# cultures are so... different! –  Ghopper21 Oct 15 '12 at 11:46
2  
@Ghopper21 That's a very good point about Python. I think MS's version of "there should be a single, obvious way to do it" extends to the choice of IDE :) –  Daniel B Oct 15 '12 at 11:56

For one, C# is not Python.. There are different design methodologies.

Now, to answer your question, it's completely possible to use your Python-esque using statements.

using FooBar=MyName.Foo.FooBar; 

It's just it is definitely not the norm because it's not nearly so easy. However, I think you should worry less about knowing exactly where exactly each class is coming from. I don't understand the entire point of doing it this way in Python though.

And also, C# is a language that lends itself very well to using IDEs to make it easier. Intellisense is amazingly simple to implement, especially compared to dynamic languages such as Ruby and Python. However, you don't have to be stuck to your IDE. I've heard of people using Eclipse. There also is of course MonoDevelop(which I use quite a lot), and you can even work from a command line. On my server sometimes, I'll be editing C# files with vi and then using xbuild to rebuild it... It's just that using an IDE makes things much easier compared to the command line for typical cases.

share|improve this answer

is C# development effectively inseparable from the IDE you use?

Of course not. Why would you not import the entire namespace? The choice of using an integrated IDE or a text editor has nothing to do with that. Importing the entire namespace doesn't make it harder to read the code or use it.

Remember, C# is a typed language. If you import several namespaces which has the same class you'll get a compilation error.

I personally don't use type declarations that much in either way. Instead I use the var keyword instead for the reasons that I describe here: http://blog.gauffin.org/2012/08/to-var-or-not-to-var-is-that-really-the-question/

share|improve this answer
1  
The issue is reading not writing code. (The Stack Overflow question I link to above gives an example.) When reading code, how do you know where something comes from? With Python, you can look for an explicit import (assuming the code follows the strong Python conventions for using such imports). With C#, it seems the consensus is that in practice you use an IDE like VS. –  Ghopper21 Oct 15 '12 at 12:04
    
If you don't know where the class comes from you'll likely have to look it up either way to know how it's working. Just google msdn <classname> and click on the first link. There you get the namespace too. –  jgauffin Oct 15 '12 at 12:06
    
That approach exemplifies the cultural difference. Not that Python programmers don't google stuff -- of course they do -- it's just the way of thinking about it is different. –  Ghopper21 Oct 15 '12 at 12:11
    
On a separate note, var in C# is nice syntatic sugar/compiler shortcut that I like for making code less verbose and repetitive. Just wish you could use it everywhere, not just inside methods. –  Ghopper21 Oct 15 '12 at 12:13
    
@Ghopper21: Yeah, I know. My point is that google indexes MSDN pretty well and you'll get the documentation directly by doing so. Hence you really don't need to document every class that you use by including the entire path to it. –  jgauffin Oct 15 '12 at 12:14

is C# development effectively inseparable from the IDE you use?

At my previous job I was mostly using vim to code in languages such as C#, JavaScript, Powershell, Perl, C++, and quite a few developers used to do something similar. The project was just too big for Visual Studio.

That said, most C# developers deal with much smaller projects and are quite happy to use VS.

share|improve this answer

My understanding was that in Python, "everything's public" or something to that effect. In C#, the module designer decides what is public and what isn't, so when you do an import you only get the public API anyway. That could be a reason for the difference you're describing.

share|improve this answer
    
That's definitely a big difference between Python and C#, but it doesn't really help me understand why there is such lack of explicitness in imports. As @pbr noted in his comment, Java (which also has the public/private distinction) is similar to Python in its cultural preference for explicit imports. –  Ghopper21 Oct 15 '12 at 11:36
5  
@Ghopper21 - The only reason to prefer explicit imports in Java (and C++ for example) is to prevent name collisions. C# made the design decision to deal with this problem via import/type aliases, since they better handle when you actually have a name collision along with the benefit of not having a bunch of boilerplate imports cluttering your source. –  Telastyn Oct 15 '12 at 13:25

Anyone bother to read way down here??

I summarize by saying the massively complex IDE functionality is indispensable and it will (should) evolve to the Zen of Sublime VimNess some day....

Our software is 129 projects of about 2M LOC. Add in the massiveness of the .NET framework and given this all I can say is the IDE is vital, transcending the motivations of this thread's question.

Insight into the Code Base

Period. You know the kinds of features we're talking about; except that its convenience becomes indispensable and essential with the kind of code base I deal with.

I write better code because of the IDE. I always add custom messages to my Nunit tests because it's easy, fast and accurate. I favor enumerations over strings due in large part to intellisense. I do not hesitate to use descriptive/long naming - a multi-line statement is composed fast and clean.

But even this smartness is too much at times. I often use good-old "find in files" text searching.

Coding help

Here is where I oft cry "enough!". Imagine a screen-full with a dozen colors of mostly obscureatta, some particular variable highlighted everywhere, brace highlighting obscuring what the brace actually is, squiggly underlining everywhere because "it" wants me to write literature not code, icons for Resharper context menus (you just gotta click it! then ignore it most of the time), a signature help popup spanning 2/3 of the screen horizontally, vertically displaying several overloads, a popup because of where you just happened to leave the mouse cursor.... I cant even seen the &^!% line*s* of code I'm working on!

Vis.Stud. needs to embrace minimalism so I can focus on coding and not go through hundreds (thousands if you count every color coding setting and all those plugins) of settings in a losing battle to reclaim sanity. A "Pareto" key would be great.

share|improve this answer
    
Really appreciated your thoughts here, as you seem to really "get it" in terms of both the IDE and "Sublime VimNess" approaches to things. I'm with you in all you say here. Here's hoping it comes to pass. –  Ghopper21 Dec 6 '12 at 13:20

This is an interesting view on C# development. What you are asking goes beyond C# though, if you're asking about the IDE.

Like you say, in Python, you can use various editors to write your code. You can do that with the .NET framework too. There are also other IDE tools you can use such as SharpDevelop. Visual Studio is very tightly co-developed with the .NET framework and is relatively expensive. Tools such as SharpDevelop and the "Express" versions of VS exist to entice more developers to use .NET. Essentially all an IDE does for you is provide an organised environment, usually with intellisense, add-ons for productivity and a "helper" to assemble what can end up being a very scary looking command-line to pass to your compiler. The same is true for Java, tools such as Eclipse just provide the organisation and productivity enhancements for us. Under the hood, nothing magical happens until you build or compile your project and that respect, all IDE's are just pretty faces to the unfriendly compiler.

When you talk about the "using" statement in C# and compare it to Python, it's not really the same thing going on under the hood. The using statements are used by the compiler to aid it's effort in transforming the C# code into MSIL. In MSIL, there is no "import all these classes from this namespace" directive. By the time code is at MSIL level, all the classes have been tagged with their fully qualified names. These "using" and "import" statements are to aid human readability. They are not compiler optimisation commands. After all this initial "tagging of fully qualified names" has gone on, there might be a kind of low-level "minify" to the FQNs but this is to aid the compiler/interpreter to execute faster. This is the optimisation - but there is no control of this offered to the developer, unless you are writing your own custom version of the compiler!

One final fundamental difference between all these languages mentioned on here are that some of them are interpreted by VMs, some are interpreted JIT style and some are fully compiled. How these using directives are implemented across those compilers and interpreters differs greatly.

HTH.

share|improve this answer
    
"These 'using' and 'import' statements are to aid human readability." -- yes, that's a key philosophical difference at work here. Readability at a textual level is a key first-order Python design principle. C# don't strictly need, but practically rely on a good IDE like VS to be "readable". Incidentally, "import" in Python is also more than about readability, unlike "using" in C#. –  Ghopper21 Dec 6 '12 at 13:17

As long as there's no conflict, it probably doesn't matter which namespace it comes from, if there is a conflict, it's the job of the compiler to complain about that, so it can be fixed at comple time.

I occasionally use ideone (online compiler) for testing and posting answers to SO, I've never had a problem with including the correct references and knowing what methods to call.

While I don't expect either classes or method names to be globablly unique, I do expect them to be unique within the area I am currently working on. Unless your looking directly at the source for the class you are using, I just don't see it making a difference -- and if you are looking at the source, it's still not going to be an issue most of the time (a quick search through all files should find it).

share|improve this answer

I think that historically the answer is pretty much, yes - getting C# development up and running effectively in anything outside of Visual Studio, Xamarin, or SharpDevelop was just too much an unpleasant experience.

But recently a lot of projects have emerged that makes it easier, e.g.:

OmniSharp, provides a foundation for intellisense and refactoring, along with vim, emacs, atom, and sublime plugins. I haven't actually used it, so I don't know how well it works, but it does look promising.

Yeoman ASP.NET MVC generators, helps bootstrap a new MVC project (maybe other generators exist).

paket, an alternative to NuGet where you can actually add NuGet packages to your project from the command line, and have your .csproj files updated (although there was a NuGet command line tool, actually updating projects to use the packages was part of the IDE integration, not command line tools).

Paket has the implication that you have to adapt your source code to using it - so if you sit as the single member in a team and wants to use a text editor for coding, and everybody else uses Visual Studio, you would have to convince everybody else to adapt the solution to your needs :(

So you should be able to get up and running, but there is comparably more work to do to get your toolchain up and running efficiently.

share|improve this answer

Not anymore:

http://www.omnisharp.net/

OmniSharp is a family of Open Source projects, each with one goal - To enable great .NET development in YOUR editor of choice.

It’s fun to say Cross Platform .NET. But is it reasonable for someone to develop .NET without Visual Studio and Windows?

Is it fun to do .NET on a Mac in Sublime? Ubuntu and Emacs? Windows and Atom? You can use your editor PLUS get to use great features like Intellisense (not just Autocomplete), Add Reference, Format Document, and lots more. Develop anywhere, deploy anywhere (and to Azure!)

I have tested this with subime3 and osx

More samples at

http://blog.jonathanchannon.com/2014/11/12/csharp-first-class-citizen-sublime-text/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.