Monday, March 15, 2010

Simple stuff missing in .NET and Visual Studio

I'm a Java programmer, but today I had to deal with C#.NET to create a simple Windows Forms application which had some mathematical and algorithmic stuff.

I've heard a lot of positive comments about Visual Studio, but what I experienced today was not up to the level of usual praises it gets from a lot of developers. Compared to IntelliJ IDEA, which is my favorite IDE, there are several stuff missing in Visual Studio (2008 edition). First thing was auto-complete. Of course it does have a reasonable auto-complete facility, but it's partial (at least with the default settings - I don't know whether there's a way to change it). Whenever a method name is completed, we have to manually code '(' and ')' parts of the method call, which I found a bit inconvenient. The same seems to be the case with strings, once I open a double-quote, the IDE doesn't automatically close it - it's inconvenient when there's a lot of such coding to be done.

Second noticeable thing was that most often it doesn't automatically point out the coding errors unless we build it manually, this is troublesome when there's a lot of coding to be done. Then there was no way of altering editor's background color - it's set to bright white by default and can be really troublesome for the eyes in the long run.

Finally, the most weird part, I wanted to use a Hashtable to have access to some values using keys. I defined one and then wrote code to add a lot of stuff. Then when I was looking for a method to retrieve them based on keys......there was no such simple method retrieve elements like in Java's Hashtables. (there was a method to check whether an item exists, but can't fetch it directly - how terrible is it?) After a Google search, I found a lot of articles teaching how to fetch an item in C# Hashtable - iterate through all elements....! This is really useless and a terrible hashtable implementation I've ever seen. Of course they might have written efficient methods to put stuff (I assume at least those Add methods are efficient), but there was no efficient or an easy way of retrieving them back. For algorithms which have a lot of get calls rather than inserting elements, this will cause unnecessary overhead.

Although I have no idea of moving to .NET, hope these will be fixed in upcoming Visual Studio 2010 edition.


  1. I also noticed these problems when I started using VS recently.

    I thought of moving to C# or C++ from Java because sometimes it's difficult to use Java for algorithmic stuff.
    Because Java lacks operator overloading, more codes have to be written to get the same thing done.
    eg: increasing an element inside an ArrayList, you have to call 'get' and 'add' methods which can be done in a single line in C++ and C#.
    I haven't used Hash Tables in C#, it suggests me to move to C++

  2. Somehow I didn't notice the comment until now.

    Later I got a clue from a .NET geek to solve some of the issues associated with Visual Studio - that is to install the 'Visual Assist' plugin. Visual Assist will provide better auto-complete + many other facilities to make development more productive.

    But still I'm disappointed with C# standard library. I had to write some algorithms for number base conversions since the standard library didn't provide a way to convert between arbitrary bases (eg: converting from base 6 to base 11 etc...) and also there was no way of dealing with fractions in different bases. These little missing stuff can waste time.

    C++ provides a method for permutations. i.e next_permutation(). This will be very handy for writing brute-force algorithms quickly. Again, you can write such a method in less than an hour in Java or C#.

    In the worst case, in C++, one can write a program with a bug which will cause a windows memory leak (i.e. when trying to modify array elements which are not inside the array - it will modify random locations in memory instead of throwing something like Java's ArrayIndexOutOfBoundsException... and windows might not recover if those memory locations have critical stuff....) - it can then throw in a blue-screen-of-death. :O There's no option other than restarting the machine. :)

    Btw, the top 3 coders at TopCoder use C#, C++ and Java respectively. Perhaps they might just be using the language they are most comfortable with, without considering the most suitable language. ;)