C# and .NET 4.0

All development related reviews. Engines, Tutorials, books, ect.
Post Reply
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

C# and .NET 4.0

Post by Jackolantern »

In my quest to create a workable, multithreaded websocket server for a browser-based HTML5 game, I invariably came to the decision of what language to work with. I had grown very rusty with Java, since I worked with it years ago now, and never made anything that large or complex with it anyway. So the re-learning process was hard and slow, and I kept being amazed at how different it was from C# and .NET, which I really got in to after leaving Java. So I made the decision to instead change to .NET, knowing this would basically mean my server would be locked to Microsoft operating systems, but could allow me to use my previous knowledge to become productive faster.

But in the past I had basically been using .NET based on 2.0 (Visual Studio 2005). Even though I had used 3.5 (VS 2008), I never really bothered to learn what seemed like the trivial enhancements the language had added. But now I made the decision to get fully caught up to all of the features of .NET 4.0 (and some I missed in 3.5), and I can say that they are not only useful, but actually groundbreaking.

C# has traditionally been seen as a clone of Java, but I really think it has become much more than that. LINQ is revolutionary, and I think the idea will spread into other languages after some time. Much of programming deals in obtaining and acting on various sources of data to get it into the final form you want so you can work with it. It was an absolutely brilliant idea to create a semi-SQL language that works within the language itself that can query arrays, collections, streams and more. What used to take 70+ lines of repetitive data fumbling can now be done in 2 or 3 lines of concise SQL-like querying. Unlike many of the past enhancements to .NET, this is a seriously major extension to the language that could be used several times a day by almost any .NET developer to make their life much better. At first I didn't understand why almost all of the new language features in .NET 3.5 were created to support LINQ (anonymous methods, lambda expressions, implicit typing, extension methods, etc.), but now I get it.

Multithreading also gets a huge enhancement in the form of the TPL in .NET 4 (an acronym for Task Parallel Library). Previously in .NET (and Java and a handful of other enlightened languages), the developer had to deal with threads themselves and much of their low-level intrinsic details (although the situation is much worse in some other languages, such as C++). TPL changes that, as now developers work with tasks, which are units of work that the developer wants to run concurrently. It delivers on the promise of a managed-code form of threads, since the developer works in terms of what they want to have done, instead of planning their whole application around how to handle all of the issues of multithreading. It is a breath of fresh air, and I know it is going to help me in my projects.

I truly believe that the last 2 versions of C# and .NET have moved C# into its own, and I would say that its connection to Java is now only historical and superficial. The world of .NET is huge, and there is more to know about it than probably any other language/platform that I know of, but it is well worth the time to learn it. It is turning previously repetitive, unworkable and difficult programming tasks into pleasures to work with, and...even making them fun!
The indelible lord of tl;dr
Post Reply

Return to “Development Related”