Ropes I Know

August 10, 2008

C# (or .NET) Really Helps

Filed under: .NET, Computer, Programming Languages — Tags: , , , — Yeti @ 7:25

Some time ago, I realized why I really like C# (or .NET, for that matter), now I decided to try and put it into words.

I program a lot. I mean, an awful lot, really. Just as a brick-layer layers an awful lot bricks, because that’s what he does all day. Modularity has always been one of my concerns, but it never really worked up to the point of really reusing code. I mean reuse as in: just use it again. Full-stop. And not, “oh, I did something similar some time ago, I’ll just copy ‘n paste this stuff into this project and adapt it to my current needs”.

Curiously enough, since I started to rely heavily on managed code and, more specifically, on C# instead of good-ole C++, ever more pieces have started to fall into ever more places where they seem to fit …

Some reasons why this might be so:

  1. I have incidentally gained enough experience or even expertise to do “The Right Things” now. Just at the time I learned to use C# and managed code (I started to use managed C++ quite some time later, because at the time of my learning C#, .NET versioned at 1.x – and programming managed code in “C++ w/ managed extensions” just felt like eating barbed wire, only worse).
  2. C# is a language that fits me like a glove, it’s easy to learn (if you know some other languages – I started with UCSD-Pascal on the Apple II in 1983 or so, later used Turbo-Pascal under CP/M, then C on the Atari ST, later C++ and so on, along the way I have programmed the 6502 and the Z80 and their derivatives, the PDP-11 and the µVax in assembler and machine language and I tried some more exotic ones, like LISP and Prolog, I even wrote a LISP system for the Apple-II …)
    [Edit: I lied, the first computer I used was a Sinclair ZX-81 and therefore I started with BASIC, I hope you’ll excuse …]
    Contrary to my former fears, C# is astonishingly fast. I really did not expect that.
  3. The .NET framework is well thought-out and easy to understand and use. In contrast to the dreaded C++ std::Library … well, that might be well thought-out, too, but easy to use or even understand?
    You decide … Don’t get me wrong, I think C++ and the std::lib are very well crafted, in the sense that a mechanical watch is. But it’s just too easy to stick the wrong pin into the wrong place. If you’re lucky, it does not explode right into your face, instead it just stops working without telling you why. If you have really bad luck it’ll start doing weird things you’ll only discover months or years later.It’s not only made by geniuses, it’s made for geniuses, apparently I’m none of that kind.
    I just want to shoot with that gun, I don’t want to invent one …
  4. Microsoft’s IDE (Visual Studio 2003 and up) is designed in a way that it really helps promoting the widespread use of C# instead of C++, just because it assists the programmer so much better than the C++ counterpart of it. But then, this might be just because C# is much easier to handle (not only by programmers, but by tools and the IDE, too).

In reality it’s not a single one of those reasons on the list, it’s a combination of all of them, with #1 being the one having least impact (concerning me, I mean).

#4 really helps an awful lot, the refactoring tools (although limited) animate one to really do refactoring, code-completion just rocks (in general, I only type about less than half of what I finally consider to be my code) and the compiler is fast as lightning, just because it doesn’t have to compile. 🙂

#2 also scores quite high. Especially in combination with #4. When using C++, I more than sometimes end up doing some kind of cargo-cult-programming, just to get the damned thing through the compiler. And if it compiles, who said that it should behave like I meant it to? An infamous quote about programming goes something like this:

A computer does exactly what you tell it, but not what you want it to do.

Using C#, things have started to behave differently. What I type almost every time compiles at first try, and, more importantly, it even does what I intended it to do. This fact might be partly owed to #1, alright. I still use C++ a lot – even managed -, it has its applications (e.g. it’s a lot easier to just import and use a function from the “normal” Win32-API).

#3 also has it’s share, although in the meantime I have found some rough edges and quirks that could have been done better (e.g. you have to dispose some classes after use and some not), but generally speaking, I think the .NET framework is one of the better things from Microsoft that ever hit humanity.

Last but not least, the combination of #2, #3 and #4 makes it incredibly easy to reuse classes and components I have written while working on some other project. Just include the project in the solution, or add a reference and that’s it.

DLL-hell has frozen over, finally!

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: