views:

1804

answers:

21

I am into new desktop app development. I feel at home with .NET 2.0 and c#. I guess I don't need linq, nor care for WPF and other Vista-oid fancy keywords. I also like rather tight and slim 2.0 redistributable, even more for reason it's Vista and 7 included.

Why switch to 3.5?

+7  A: 

If you don't need LINQ, don't want WPF (or WCF), and don't like the extended use of generics, the simple answer is: don't do it!

However once you have used just one of the above features of 3.5 you will wonder how you ever did without. The real reason to move to 3.5 is to get the benefit of these features.

So if you are completely happy with 2.0, and have never said "I wish I could just... xyz", I suggest you stay where you are.

Kirk Broadhurst
Extended use of generics? I love generics. I love o pack methods into anonymous block, just for fun. But I don't want my user to toil twice the size of framework for my fun :)Also, maybe there is also memory footprint difference for the runtime? I guess everybody like their apps nice and sleek.
Daniel Mošmondor
.NET 2/3/3.5 all use the same .NET 2.0 runtime under the hood. The changes in 3.0 and 3.5 are a combination of new libraries and compiler tricks, nothing more. The runtime overhead is based on what your application does - assemblies are not loaded into memory until they're used.
Bevan
+1  A: 

The features I use the most are:

  • LINQ
  • Extension methods
  • Automatic properties

If you haven't used LINQ, and you try it, I think you will find that it (can be) a very powerful tool.

JTA
The only 3.5 feature here is LINQ, the other 2 are compiler enhancments which you can take advantage of by using VS208 to build apps targeted to the 2.0 framework in.
Jaimal Chohan
+2  A: 

If you don;t need to use any of the 3.5 features, then don't worry, it is just an addition of new Framework Libraries, the CLR and CLI havn't changed, thus everything you write, be it using framework libraries from version 2.0, 3.0 or 3.5 all ends up as the same IL code. Knowing this, if at some point in the future you decide you do want to add some 3.5 functionality to you application, you can do so with the knowledge that there will be no migration pains (ike the upgrade from 1.1 to 2.0) as all you're really doing is telling Visual Studio to "let you add the 3.0/3.5 dlls" to your project. Of course you will have to make sure your users have .net 3.0/3.5 installed.

Jaimal Chohan
+11  A: 

Assumption: You're working with Visual Studio 2005 and .NET 2.0.

Reason #1: Vista includes .NET 3.0 as a part of the OS Install; Windows 7 includes .NET 3.5

Reason #2: There are ways to target .NET 2.0 using Visual Studio 2008 (and VS 2010) so you can gain from the productivity "goodies" of those tools without abandoning .NET 2.0, then move to .NET 2+ when you're ready. (Visual Studio can help you avoid non .NET 2.0 assemblies while you code.)

Reason #3: Extension methods, particularly the static class Enumerable. Technically, a part of Linq, but a good way to write code cleanly, clearly, and in a more maintainable way.

Reason #4: Bug fixes to the .NET 2.0 framework. Remember that .NET 3.0 and .NET 3.5 still use the same .NET 2.0 runtime under the hood - they just add new frameworks/libraries and some compiler tricks. There have been a ton of bug fixes to the runtime which you're missing out on.

Bevan
Reasons 1 2 and 3 (excluding linq and IEnumerable) are compiler enhancements in VS2008 and have nothing todo with .net 3.5. Plus for reason 4, these are part of .net 2.0 SP1
Jaimal Chohan
Plus, just because you are running .NET 3.5 doesn't mean you have to use the new features.
Jeff Siver
@Jaimal Chohan - Only Reason #3 involves a compiler enhancement. .NET 2.0 SP 1 does't have a lot of fixes that have been released since then; you have to install .NET 3.5 to get those fixes.
Bevan
@Jeff S - that's what I was trying to indicate between Reasons #2 and #4. Thanks for supplying better words.
Bevan
+7  A: 

C# 3.0 has some really nice features, such as automatic properties and collection initialisers - both of which really clean your code. Linq is also great when dealing with collections, Lambda expressions are also cool.

.NET 3.5 is also included within Windows 7.

Question is - Why not?

Ben Hall
Automaic Properties and Initilaizers are actually compiler enhacements in VS2008, so you can build 2.0 apps in VS2008 and mke use of these features.
Jaimal Chohan
+1 for "Why not?"
Dennis Palmer
A lot of those language features are not related to the .Net version: the DLLs can be run on 2.0 or 3.5.
Yar
+7  A: 

One reason not to use 3.5 is Mono.

The Mono API today is somewhere in between .NET 2.0 and .NET 3.5 see our Roadmap for details about what is implemented.

Taken from here.

Another reason is that Winforms hasn't moved forward hardly at all, so you may want to wait until 4.whatever comes out before jumping.

My understanding is that some stuff, like LINQ, can be used just fine with .Net 2.0, since it's just a Library.

Yar
+1 for the Mono info. (tho Linq requires 3.5 libraries and thus won't work without 3.5 installed)
Jaimal Chohan
Thanks Jaimal. Not true regarding Linq, from what I've read (http://weblogs.asp.net/fmarguerie/archive/2007/09/05/linq-support-on-net-2-0.aspx)
Yar
But Mono's compiler does support C# 3.0 (the latest language version). It's only missing specific 3.5 framework classes, e.g., ASP.NET (but he's not doing web programming). Most of the reasons given on this page are C# 3.0 language features, for which Mono would do fine.
Ken
@Yar: Okay, not completly true, but not completly wrong. You still have to distrbute SystemCore, which is a 3.5 assembly as part of your application.
Jaimal Chohan
This is mostly about GUI development. Besides WPF, Mono's Winforms isn't that mature too, you can't use it for normal apps. for the rest of it, I, living in the mono irc, haven't heard too much of people missing features for 3.5. Linq and all this stuff is close to fully implemented. I myself have never seen any difference. Though for those 3.5 features not in Mono, they have a side project called Olive containing this stuff. sort of bleeding edge Mono.
Dykam
@Dykam, true regarding Mono Winforms. I'll have to check out Olive, thanks for that.
Yar
+45  A: 

One word:

Linq

Once you've done a single query on your objects using Linq you'll never go back. Linq isn't just databases, you can have any kind of collection, and if you can express yourself functionally, you can change

foreach (obj in myCollection)
{
   if (obj.property == match)
   {
      foundObj = obj;
      break;
   }
}

to

myCollection.Single(obj => obj.property == match);

EDIT: OR

var foundobj = 
(from obj in myCollection
where obj.property == match)
.Single()

Which one makes more sense? What about when you want to express much more complex queries like where this and that and that, from that select the ones that match some other property. You can do it in two function calls.

Sorry about the rant but I really do like Linq.

Spence
Spence, if you like that stuff, you should definitely check out Ruby. Exccuse the unrelated rant.
Yar
This does come at a cost tho: http://ox.no/posts/linq-vs-loop-a-performance-test
Jaimal Chohan
Depends what you are expressing. The big power I see for linq is the ability that will be provided by PLinq. It encourages you to write non side affect code, and could quite possibly be optimised in the future. And yes, ruby, haskell etc is very interesting. I still don't like the way that they use monads to do IO, I love the way C# has imperative code for imperative stuff, and functional code for functional stuff.
Spence
@Jaimal Chohan - I checked out that link, as I use Linq a whole lot in my code. I think the conclusions are flawed. While Linq is slower than Loop, the difference is much less than Håvard Stranden states, and not significant anyway. See http://www.nichesoftware.co.nz/blog/200909/linq-vs-loop-performance for my own test.
Bevan
Absolutely. LINQ-to-Objects and lambda expressions can make ugly code elegant. LINQ also works with XML, which is VERY handy. Old-fashioned delegates are seldom seen. Automatic properties are a joy, as are object and collection initializers. And the var keyword (if used judiciously) can make for more readable code. I never want to go back.
TrueWill
@Jaimal : why didn't he see that List<T> can have an optimized ToArray implementation that SelectIterator can't have?
David B
The first one makes more sense to me >_> easier to read.
Hintswen
@SWpence: "Which one makes more sense?", the first one, unless you've read up on Linq and know what Single() and => mean.
Ash
True. But this is the evolution of the language. Once you can express yourself functionally then you start to see patterns in your code. Making enumerables encourages you to do lazy evaluation, which is great because youc an end up saving yourself computation as linq does via Linq2sql etc. ___ As for the linq, I like it because you can read it in your head, for every object in mycollection find a single object where the objects property is equal to match. You can chain them together and still read them like so.
Spence
+1 LINQ is awesome. Everyday i find out new things i can do with it.
Botz3000
Good grief, 22 nanoseconds per *integer*?! I could concatenate four transform matrices in that time!
Crashworks
Well this is the really awesome thing about linq. It uses expression trees which say WHAT to do but not how. So in the future if PLinq is implemented properly there could be optimisations to use DX11 compute or CUDA etc for any math based stuff. The future could be fun :)
Spence
+1  A: 

How far behind are you willing to be? .NET 4 is coming soon. Cloud (via Azure or even Live Mesh) computing is the next wave, so you'll probably want to be ready for network connectivity by knowing WCF.

If you don't want to learn the new stuff, then you'll still be able to create some good desktop apps with 2.0. But part of being a developer is understanding what's coming next. Even if you don't choose to target a later version of the framework, you should at least spend some time to learn a bit of LINQ, WPF and WCF so that you know their power. Then when you need something that is only available in a later version of the framework, you'll know why you're using it and also should be able to justify the framework download to your clients.

Dennis Palmer
OK, I misread your question, so I've removed that first paragraph, but the rest of my answer stands.
Dennis Palmer
+2  A: 

I know various people who feel right at home with C, 8086 assembly, APL, punchcards, and front toggle switches (not kidding). They give the same reasons you do.

Would you advise an assembly programmer to try out C# 2.0? If so, perhaps you should try C# 3.5 for the same reasons. If not, keep enjoying C# 2.0, and know that people will, one day soon, see you the same way we see assembly programmers today. :-)

C# 3.5 is much better at letting you build higher-level abstractions than C# 2.0, just as C# 2.0 is better at this than C, and C than assembly. After all, isn't that why we program in HLLs in the first place?

Ken
Thanks for philosophical retort, it doesn't give out much tech info, but reminds me of my friend who won't give up C/C++ - and I sure don't want to go with him and the dino's.
Daniel Mošmondor
The problem is that just about anybody with 1/2 a brain cell can open up Visual Studio Express and learn C#, but it takes a real programmer to learn assembly, or even C++ (pointers and recursion yay!). I'm not saying that all .NET developers are bad, just that I meet a greater percenage of bad .NEt developers that C++ devs.
Jaimal Chohan
I find it funny you lump assembler and C++; 20 years ago we'd say "anybody with 1/2 a brain can do C++, but...". :-) I see nothing to suggest the percentage of bad developers changes with language or time. Most of the FORTRAN and ALGOL and C programmers I've known were terrible, too.
Ken
@Ken, you miss an important point. Assembly and C are still a much better choice for many tasks than .NET. Sure .NET 2.0 to 3.5 is not as big a jump, but if 2.0 does the job and 3.5 gives no compelling reason, it's actually a risk to change.
Ash
I disagree that assembly and C are (or have ever been) reasonable choices for just about anything other than bootstrapping, if your machine is more powerful than a 1984 Mac. You may consider this a controversial perspective of mine, if it makes you feel better. :-)
Ken
+2  A: 

It seems like every app needs to communicate with other apps now. So,

  • WCF

Having written a TCP communication library in the past, I would have been thrilled, overjoyed, ecstatic, and otherwise quite happy if I had been able to save those months by spending 1 day with WCF.

John Fisher
+3  A: 

I would upgrade just for lambdas!

SaveButton.Click += new EventHandler((sender, e) => this.Save());
ChaosPandion
SaveButton.Click += (sender, e) => this.Save(); SaveButton.Click += delegate { this.Save(); };
Lucas
I know but it looks really weird without the new EventHandler.
ChaosPandion
+1  A: 

I won't convince you to move to 3.5, if you are creating desktop apps for an audience that will find it burdensome to upgrade (e.g. pre-Vista users on slow bandwidth connections). After all the customer comes first.

As mentioned by several others, you can use many new features of the C# compiler even if you target 2.0 (e.g. object initializers, automatic properties), check this out for details. Also, you can use LINQ on 2.0 as well, using the LinqBridge library, which is very small and can be distributed with your app (this is Linq to Objects, not Linq to SQL)

DSO
A: 

If you often use repeater in Asp.Net like controls the ListView control is a much cleaner and easier to work with alternative available to asp.net 3.5.

I also use the routing module from MVC from time to time and find it much better for small sites than something like url rewriting.

Luke Lowrey
+6  A: 

Moving from .NET 2.0 to .NET 3.5 shouldn't even be a consideration. Here are some reasons why.

  • .NET 3.5 is fully backwards compatible with .NET 2.0 as it is built on the same core. 3.0 and 3.5 are merely extensions to 2.0.
  • LINQ - You can use Linq even without using databases. It changes every thing. This feature alone is well worth the move.
  • Lambda Expressions - Powerful search capabilities within collection. Related to LINQ.
  • Anonymous Methods - Created mthods without fully defining them.
  • Anonymous Types
  • Windows Workflow Foundation - Create workflows.
  • Windows Presentation Foundation - Replaces legacy Windows Forms - Can still be used with existing WinForms though.
  • Silverlight - Scaled back version of WPF for Web-Facing applications. Analagous to Flash.
  • Windows Communication Foundation - Replaces traditional Remoting and Web Services pieces with a much more robust infrastructure
  • For Web Development - ASP.NET MVC Framework - BEST!!!!

Without .NET 3.5, you're missing out on a lot. Seriously. Make the jump. You'll be glad you did.

Anthony Gatlin
+1  A: 

If you are creating or consuming web services, then you should be aware that Microsoft now considers ASMX web services to be "legacy technology". All new web service development should be done using WCF - which is not available until .NET 3.0, and gets quite mature and stable at .NET 3.5.

John Saunders
+1  A: 

Shouldn't the request really be "Convince my users/customers to move from .NET 2.0 to 3.5"

You didn't say whether you're writing code for a customer/user or just as a hobby. If it's the latter then yes, it's all about convincing you.

Otherwise, I can't see your customer being really excited about you being able to use Linq in your code, unless it will let you get things done substantially quicker and more reliably then before.

Of course if you're an experienced 2.0 developer you most likely are already very efficient even without lambdas, query syntax etc. Sure, they would provide some improvements but probably not great enough to excite your customer.

Now, if your customer comes to you and says, I want my new desktop application to have a GUI like one of those web pages with fancy animations etc, then it's obvious. You should seriously look at going to .NET 3.0/3.5 for Windows Presentation Foundation etc.

In summary, if there is a real and tangible reason to use newer technologies, go for it, otherwise it's often costly to get up to speed with a new platform/environment without direct benefit.

Ash
A: 

Read this blog http://weblogs.asp.net/scottgu/archive/2007/11/19/visual-studio-2008-and-net-3-5-released.aspx

From here you will get better idea on .Net 3.5 and VS 2008.

Why the higher version is coming is that,higher version is having easy for development and also having high performance :)

anishmarokey
+1 for the post!
A: 

I use 3.5 for my main project at the moment, and there are so many advantages. LINQ, Entity Framework, WPF (especially for databinding), LINQ, extension methods, automatic properties, LINQ, oh and Lambda Expressions (those are awesome)! And did i mention LINQ?

That being said, i still use .NET 2.0 for smaller projects where there isn't much code or anything fancy, such as file conversion utilities or some small tool sitting in the tray for just a few tasks.

I always use the lowest framework version that i can, as long as it fullfills all my requirements. So if it's just a small tool, i might go with 2.0, if i want a nice UI, i use 3.0, and if have a lot of database stuff to do, i use 3.5 SP1 with Entity Framework.

Botz3000
A: 

I've read a lot of the other answers and note the accepted answer with great development-time benefits of .NET Framework. Here's one more plus (among many) for .NET Framework 3.5 & LINQ.

Two words:

Deferred execution

Have a look at yield return and the clever compiler tricks that build state machines behind the scenes for you.

Neil Fenwick
+1  A: 

To be honest, reading most responses the reasons they give are mostly around language enhancements. But if you have no need for that, i'd be tempted to stick with 2.0 for the reason you state ie. broad accessibly, and avoid the platform compatibility nightmare we've had here....

Jonathan
A: 

Because of .NET 3.51 client profile, which has runtime size comparable to .net 2.0!

Daniel Mošmondor