At work, we're moving away from C++ to C# with our next-generation software.
We're also using all the cutting-edge stuff when it becomes available, so we've already moved to .NET 4.0 and Visual Studio 2010.

Last week we had a course on all the new stuff in .NET 4.0, C# and VS2010, and I was pleasantly surprised. It's not just syntactic sugar, but Microsoft is also making things like multithreading easier to do, and more efficient. They've done quite a few optimizations to the VM itself, making the garbage collector work asynchronously, optimizing the threadpool to use lockfree algorithms where possible, so it will scale much better with more cores/threads... And they've also introduced a new parallel programming framework (sorta like OpenMP, only object-oriented).
They also supply you with an implementation of some lock-free container classes.

All in all, it seems like Microsoft is really putting an effort into making .NET perform well, making the best possible use of the underlying hardware. Giving you easy tools to work with... things that would be pretty hard to do in C++, let alone ASM.

So I'm getting more and more positive about C#. Perfectly optimized C++ or ASM code would be faster... but it takes a lot of effort to write. I mean, if you just use 'naive' C++ code, with coarse-grain locking on your container classes and such, with a naive threadpool, you may end up with slower code than using standard C# functionality.

As for VS2010, it can do some really cool things that I never knew of (but again, it only does most of them in C#, not in C++). Pretty powerful intellisense and refactoring, debugging with history, a good overview of threads and tasks (work-items in the threadpool), etc.

So, anyone else using C#/.NET? And what are your thoughts about it? It's a completely different world from C++/asm I suppose.
Posted on 2010-07-19 04:58:27 by Scali
Yes, .NET generates only minor overhead, while providing RAD times. It's true that you can code super-efficient C or ASM routines but reality is that 90% of the people make shitty code. I bet that when they switch to any .NET language then the compiler will make acutally faster/smaller/better code than what we generally have today. And if you have a function which needs to be extremely fast, nothing stops you from writing it in a native language and PInvoking it. But most of the time simple pre-compilation is sufficient (it further reduces the speed overhead of the CLR).

I've recently made a Quetannon clone (see the attached image). I was surprised by the ease and power provided by the .NET even in version 2.0. You get Sockects with full I/O completion port support with 1 function call ("BeginRead"). You can encrypt things with AES (something like 3 function calls, IIRC), you can utilize GDI+ for any imaging work you want (class contructor takes image's file name as its param and decompresses MFU image types). And with PInvoke / OpenTK / XNA you can write hardware-accelerated games if you want.

Yes, C# is great and .NET is actually the best platform I've ever seen ^^ Waaaaay lower number of classes than in JAVA and waaaay more powerful.
Attachments:
Posted on 2010-07-19 11:48:24 by ti_mo_n
Yea, I've used Java since day 1 pretty much...
It was a nice language to use, simpler than C++... but performance issues made it less appealing than C++ for the more hardcore work.
I checked out .NET in the early beta stages, and thought it was a nice improvement over Java, but still I never used it much. Mainly for quick tools and thingies,  not for more serious projects.

But at work, we started with a next-gen product a few years ago, starting from scratch in C#... and now it's been ported to .NET 4.0... and .NET has become a lot more powerful than in those early days. With modern multicore CPUs, the requirements for a language and its performance have changed aswell.

By the way, another way to use hardware acceleration (and arguably the best one), is to use SlimDX. A free managed wrapper around DX. Pretty much a replacement for the abandoned Managed DX project. SlimDX is up-to-date all the way to DX11. We use that at work, for DX9 (we still need XP compatibility).

OpenTK may be interesting... I wonder if I can make a multi-platform version of my BHM OpenGL sample in C#, which can run on Mono with linux/fbsd. If that works, it'd be almost as good as Java.
Posted on 2010-07-20 07:27:56 by Scali
By the way, another way to use hardware acceleration (and arguably the best one), is to use SlimDX. A free managed wrapper around DX. Pretty much a replacement for the abandoned Managed DX project. SlimDX is up-to-date all the way to DX11. We use that at work, for DX9 (we still need XP compatibility).

Thanks for the info! ^^

OpenTK may be interesting... I wonder if I can make a multi-platform version of my BHM OpenGL sample in C#, which can run on Mono with linux/fbsd. If that works, it'd be almost as good as Java.

That's precisely their goal. So even if the current version won't run smoothly both on windows and linux, future versions (hopefully) will :)
Posted on 2010-07-20 09:59:55 by ti_mo_n
VS 2010 is a bit slower than 2008, isn't it?
Probably because WPF is utilised in the IDE.

Hopefully it will be fixed by the SP1.
Posted on 2010-07-23 02:08:02 by anta40

VS 2010 is a bit slower than 2008, isn't it?
Probably because WPF is utilised in the IDE.

Hopefully it will be fixed by the SP1.


Depends on what you do, and what computer you do it on, I guess.
For large projects, VS2010 works much better for me than VS2008. VS2008 took ages to navigate through a large solution, and would often crash during compile or debug. With VS2010 the same large projects work as well as very small projects. Which is a great improvement.
I think the main problem with VS2010 is with the Intellisense. It tries to be more clever than VS2008 was, and takes longer to scan all your files. But once it's all cached, it runs pretty smoothly.
WPF doesn't really appear to be a problem, not even on my laptop with Intel IGP :)
But I run on Windows 7... WPF is supposed to be considerably better on Windows 7 than on XP.
Posted on 2010-07-23 02:24:07 by Scali
Whee, just installed Windows 7 Professional x64 on my PC at work, and now setting up Visual Studio 2010 Professional on it. Hopefully I can say farewell to XP permanently soon :)

We need the legacy codebase to be converted to VS2010 (currently VS2005), and for our release later this year, we want full Vista/Windows 7 compatibility, without having to run as administrator (currently everything runs, but it writes to places in the registry and filesystem where they have no business... you know the drill :)). So I need Windows 7 to test and debug stuff.
And since we need to support both x86 and x64, I get to run the x64 flavour :)
My machine actually came with 4 GB, it's about 2 years old now... but because it always had XP on it, today is the first time that 4 GB can (and will) actually be used :)
Posted on 2010-07-29 09:14:42 by Scali

sounds like somebody's having a good day at work!  :lol:
Posted on 2010-07-29 13:33:26 by p1ranha
I also installed Win7Pro x64 along with VS2010 on my home machine and I think it's so much faster. Granted, a lot of factors are probably weighing into the sudden speed burst (Old install was <4 years, was x32, also 4GB) but just loading VS seems instant to me. Splash Screen, second later it's there.

Now if only my work machine was that good. :-/ I desperately need a 24" screen for work...
Posted on 2010-07-29 13:50:40 by JimmyClif
Keep in mind that XP64 is based on the Win2003 server codebase rather than the XP codebase, so there's some more improvements than just 32->64.
Posted on 2010-07-29 14:07:11 by f0dder
True, but they've switched to win7 x64, not XP ^^'
Posted on 2010-07-29 17:18:38 by ti_mo_n

True, but they've switched to win7 x64, not XP ^^'
Dunno why I read it as XP64, heh :)
Posted on 2010-07-30 02:49:14 by f0dder


True, but they've switched to win7 x64, not XP ^^'
Dunno why I read it as XP64, heh :)


DANGER DANGER! Caffeine levels critically low! Insert coffee immediately!
Posted on 2010-07-30 03:10:06 by Scali