I got a book named "Pro C# 2005 and the .NET 2.0 Platform, Third Edition by Andrew Troelsen".
I am wondering whether I should buy the "Pro C# 2010 and the .NET 4 Platform, Fifth Edition" instead. Since, the latest version of .NET is 4.0. If I learn C# based on this old book, do I miss some critical parts of the C# language? Or, I can start with this book and learn new .NET 4.0 features with other resources.
Thank you
You can start with that book and learn C# 4.0 from elsewhere. This is what's been added after C# 2.0:
C# 3.0:
LINQ
lambdas
extension methods
expression trees
anonymous types
local type inferencing
automatic properties
object initializers
collection initializers
partial methods
C# 4.0
dynamic member lookup
covariant and contravariant generic type parameters
optional parameters and named arguments
parallelization framework (actually part of .NET 4, not C# 4.0 per se)
You will miss a lot. Most notably in my opinion, Linq. Linq changes the whole face of idiomatic C# so much that I could not reccommend starting with the old book.
I think you will be missing out on LINQ, which is quite a notable addition. If you are open to other reccomendations, I would say try Jon Skeet's C# In Depth. It gives a very good coverage of the various changes in the language from versions 2.0 to 4.0 (I purchased the early access edition).
Lambdas / LINQ are pretty huge.
C# 2 has generics, and it's good, but C# 3 and 4 have LINQ and dynamic typing, respectively, both of which are very powerful in their respective milieus.
And that's just to name two. There's a crap-ton more in there that you're missing out on.
If you can, always develop against the latest version.
You can certainly start with C# 2.0 and learn the basics. There are many great new features in C# 4.0, but many of them are advanced or what are called 'syntactic sugar' meaning it's a more terse way of writing something you could already do with C# 2.0.
There are many different posts about the new features you can reference, without buying a complete book on it:
http://www.15seconds.com/issue/080228.htm
http://code.msdn.microsoft.com/cs2010samples
I'd reccommend not spending the money up front, and checking out what the interweb has to offer.
Personally, I think 2.0 is the right version of C# to start with. If you're going to learn the language for the first time, then starting with 2.0 is totally fine. 2.0 is the major release of the core language.
From 3.0 some features have been added which are nothing but "syntactic sugars" and "time/typing savers", and which confuse beginners, and you're gonna have to post questions here like "whether I should use constructors or object initializers".
Of course, you'll not find the new features added in 3.0 and 4.0 in a book for 2.0. But just as you said, you can always be introduced with those from other resources.
I wouldn't recommend you start learning C# with such an old version.
If you have the money to buy the new edition you should go for it. There were a lot of changes since .net 2.0.
If buying a new book it's not possible for you at this moment you could start learning the basic stuff from that book and learn new features from online resources.
You would miss most of the new technologies.
3.0 introduced WPF, WCF and WF
3.5 gave us LINQ, and other related techniques like lambda expressions, extension methods...
4.0 brought the DLR, for dynamic typing.
A full summary of new features can be found on wikipedia.
LINQ isn't all you'll miss. A lot of technologies that were added to 3.0 with LINQ (and largely because of it) stand on their own merits and make it very worthwhile to adopt the latest version.
Lambdas
Anonymous Methods (might have been 2.0, can't remember at the moment)
Type Inference
Dynamic types in 4.0
Lots of new classes and improvements
I think you might be doing yourself a disservice if you cripple yourself with 2.0 if you don't really have to. The Framework is, after all, free, and so is the online documentation. Further, online tutorials abound, and you hve a plentiful resource for programming advice right here on StackOverflow.
MSDN has a helpful set of pages (start here) that tell you exactly what you will be missing out on when you target older versions of C# and the .Net Framework.
Remember when you target a C# version you are not just tying yourself to the language but to the matching .Net Framework - there is a whole bunch of new stuff in 2008 and then again in 2010 that you will miss out on by going .Net 2.0.
The major things you will want to know about that have come along since 2.0 include:
Linq (a powerful compiler-checked query language used for list/set processing and as an interface to ORM frameworks).
Anonymous types and delegates (lambda expressions). Need to store a list of some data fields you've gotten from a Linq expression, but don't need/want to define a whole new type just to store them? You don't have to anymore. Similarly, if you need to do something to each element of a list, or specify some operation to return a result, but don't want to define a named method, you don't have to. C# allows you to specify "anonymous" types and delegates, which are defined where they are used and are accessible only through the variable containing the delegate or data reference.
WPF (The next generation of UI development, it is an XML-based presentation layout definition that will EVENTUALLY replace WinForms and ASP.NET)
WCF - the next generation of web service classes, supporting built-in security features like encryption.
Microsoft Entity Framework - Microsoft's take on ORM frameworks like NHibernate
Dynamic typing - C# 4.0 allows for relaxed type restrictions by defining types or parameters as dynamic. This allows .NET to interface more seamlessly with assemblies or native APIs written in "duck-typed" languages (where the type is always dynamic, inferred from what you're trying to do with the instance)
Better covariance/contravariance support - .NET 4.0 allows you to specify that collections of a type can be treated as if they were a collection of a derived type, or an ancestor type.
The versions of .Net are all primarily similar, but the only thing you may glean by starting with 2.0 would be to get a history of where certain changes in the languages came from. That's more of an experience thing though. If you're not already trained in C#, it would be best to start at the very latest. The fundamentals of the language will still be the same. You'll also learn the latest techniques for accomplishing common tasks rather than learning an outdated method and then having to relearn it later and try to understand the differences and why it exists in the first place.
Start with the latest stuff. Don't learn from antiquated sources and then try to fill in the gaps with extraneous information.
Programming technologies change so fast as it is, why would you invest time reading such an old book? I'd get the newest one.
As well as the aforementioned Linq/lambdas etc, the later books will also cover technologies such as WPF which has pretty much replaced winforms for desktop development, and WCF which is the common communications method now, so I'd try and get a later book.
Related
Reading the Bruce Eckel book "Thinking in C#", to relearn C#, since I haven'y used it for many years but am likely to be needing it again soon.
I was surprised by this statement:
"In C++, the keyword that implements
parameterized types is “template.”
.NET currently has no parameterized
types since it is possible for it to
get by—however awkwardly—using the
singly rooted hierarchy. However,
there is no doubt that parameterized
types will be implemented in a future
version of the .NET Framework."
I think I remember reading somewhere that C# has generics - which are similar to C++ templates?
Am I wrong, or is the Eckel book simply too outdated (if so, is it worth still reading or is there a more up to date book online?)
[Edit]
Eeek, I'm glad I checked in here first. Looks like I'll have to throw that book away (written in 2002 I believe). Can anyone recommend any downloadable book that has the same depth of Eckels 'Thinking in ...' series?
There are a lot of C# books out there, but most of them are far too basic, or do not cover enough material. I was happy to find Eckel's book, since he covers C# in usual thorough style (from an introduction to OOP [which I don't need], through WinForm and Threading) - Unfortunately, it looks like its too old (Damn you MS for changing C# specs more times than I've had hot dinners!)
Can anyone recommend a good downloadable C# book that has a similar width/depth coverage?
[Edit 2]
Just seen this book:
http://www.free-ebooks-download.org/free-ebook/dotnet/CSharp/beginning-visual-csharp-2010.php
I'd like the opinion of this book from any professional C# developers out there ...
It's probably describing C# 1.0, which didn't have generics.
I would recommend finding a newer book that covers LINQ (introduced in C# 3) and dynamic (C# 4).
I would definitely get the most recent book that's relevant to the version of the .NET framework you're programming for. I started with an old book which didn't even cover automatic properties. Now one year later, I'm changing all of the previous code because it's so bloated and verbose.
Anyhow, C# does have generics, which as far as I can tell are the equivalent of C++ templates.
Generics are in C# since .NET 2.0, which came with Visual Studio 2005. The book is older than 5 years, you definetly need to get rid of it! :)
As others have noted, your book is out of date, or rather describes an out-of-date version of the framework.
It's interesting to note that the first language specification for C# published to ECMA for standardization included generics as a part of the language. C# 1.0 and 1.1, in not including generics, were not full implementations of the C# language. 1.0 and 1.1 should have been numbered 0.1 and 0.2 or some such, but Microsoft doesn't number things like that, as risk adverse people avoid doing real work with beta products.
Thus far, I've worked with C# 3.0 for all my applications and I've never worked with C# 2.0. But now I have to work with C# 2.0 for my next project.
What are the factors to be considered when migrating to an earlier version of C#?
Is it tough to adapt/live with am earlier version?
What are the classes/libraries that I'll miss when moving from C# 3.0 to C# 2.0?
Is it that you have to target .NET 2.0, but can compile using 2008 / 2010?
If so, you'll still have all of the features of C# 3.0, including extension methods, lambdas, query comprehensions and implicit typing.
If you download LinqBridge, you'll have that, too.
I'm using this setup for .NET 2.0-targeted shareware app right now. All I really miss for this particular project is WPF. :-)
I would recommend Jon Skeet's C# in Depth, as he starts out with 2.0 then moves onto 3.0 (as I understand it, a new edition is coming that will also cover 4.0). His book divides the different versions of the language nicely and goes into good detail, giving you exactly what you are looking for. I guess in your case just read the book backwards :)
Linq. If you don't use that, it's probably a breeze.
Don't know if you mean 3.0 or 3.5...but it's all going to depend on what language/framework features you're used to using. If you're using anonymous types, WCF, WPF, WF, or LINQ, you're going to have to find alternatives. If you're using lambda expressions, object/collection initializers, implicit variable declaration, and extension methods, then you're going to have to write things slightly differently, but it shouldn't be a huge deal. Aside from that, you should be pretty safe.
I mean library and syntax of C#.
For the class library, ask the Mono Class Library status page
C# 3.0 is supported fully.
C# 4.0 version works but considered 'preview' until MS compiler is finalized. There're even some language extensions, although I doubt if they will be ever backported to MS compiler.
You can view Mono's status updates (Like a Timeline, really), from their wiki.
Mono Status Report
There's a pretty in-depth analysis here from January of this year.
The Wikipedia article's "Current status and roadmap" looks helpful too.
There's no equivalent of VT fixup or anything related to unmanaged exports for that matter.
That's not surprising, though. Considering that you would have a hard time using something looking like a Windows DLL as .so or .dylib. ;-)
I am not sure, but mixed-mode hasn't been supported a few years ago when I wanted to use it.
Maybe they added it, but I don't think so. Might be the big fat mother of all worm cans to open for an X platform CLI implementation.
There are three aspects you need to consider.
Language
Framework
Runtime
Language:
Mono fully implements C# 2.0, and has almost complete support for 3.0. This means it supports all of the syntactical language features like generics, properties, anonymous methods/types, etc.
Mono supports Visual basic 8, but not 9.
Framework:
Mono fully implements ASP.NET and ADO.NET. Windows.Forms is mostly done.
WCF and WF are in progress.
WPF is not done, and is many years away from being done (if ever). I believe this is now a side project.
Linq-to-SQL is not yet finished.
Runtime:
The CLR has been almost fully implemented, including support for the DLR.
Your best two sources of information are probably the Mono home page (specifically the FAQ and the Status report), and the Wikipedia page on Mono.
Please have a look at the Mono Project Site or at the Wikipedia-Article.
But the last thing I heard is thet C# 3.0 is complete (except some LINQ-Features).
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
C# has a good momentum at the moment. What are the features that you would need to have in order to switch (or return) to Java?
It would also be quite useful if people posted workarounds for these for the current Java versions, e.g. Nullables being wrapped around custom classes, to make this a much more interesting wiki.
As a .NET/C# developer here are the missing features that annoy me. This list in no particular order - just as thoughts come to mind:
The Java library is too small. For common things I have to choose between 5 competing open source products because the base library is lacking in so many ways.
This is an Object Oriented programming language right? Why in the heck do primitive types not inherit from "object"?
Pointers
Lambdas
Closures
Partial Classes and to a lesser extent partial Methods
Real support for Generics
Using statements and Dispose - this was a real WTF for me. You really have to explicitly close connections in try/catch blocks. Poor Java guys!
Yield return would be nice
Unsigned integers - again WTF? I have to use number types larger than I need for what purpose again?
In Java you can return from final blocks of try/catch. A co-worker confused the hell out of me for hours by introducing a bug this way. This behavior should be prohibited as in C#.
I rarely have to use Java and when I do, I have all sorts of WTF moments.
Edit: I Removed for-each comment based on the fact it is no longer a missing Java feature since 1.5.
In my experience, Java vs. .Net is more of a business decision than a technical one. Shops with MS experience trend towards .Net and shops with Java experience trend towards Java & OSS. I've seen little evidence of people switching based upon language features. On the other hand, I've seen shops heavily tilt towards one platform b/c of one or two key employees they wanted to hire being knowledgeable in that area.
in no particular order:
function pointers (delegates); the whole passing interfaces around thing is stupid
real generics; what's the point of having type safe generics if the compiler can't even hold the meta data through a unit's compilation?
ui speed; all the self-drawing ui libraries are very slow compared to native controls wrapped in "managed" libraries, not to mention that microsoft's self-drawn ui is hardware accelerated through direct3d
an yield return construct; c# is so user friendly in this it's crazy
operator overloading
linq; just cuz its so addicting
properties; more synctatic sugar you get addicted to
better interop with native code; c#'s p/invoke and native com support makes interop so easy compared to jni -.-
first class value types; this goes hand in hand with real generics, having generic lists that never box/unbox in c# is part of why c# is faster than java.
and i'd say this is the most important one:
a responsive, informative debugger; nothing can even come close to visual studio right now
Just going off the cuff, I think the biggest thing Java 7 needs that everyone is lamenting the lack of is closures.
I'm a C# programmer and about one year ago I had to participate in the development of an application in Java. What I missed the most was:
Visual Studio (Eclipse is nice, but
VS is VS, especially Team Edition)
Comparing strings with ==
Properties
Basic types as first-class objects
(e.g. not "int" type vs "Integer"
class)
Anonymous methods (a workaround can
be made by using anonymous classes
but it is not the same)
LINQ
And there was one single Java feature that I missed when I went back to C#: explicit exception declaration in method signatures.
DISCLAIMER: I am speaking about a somewhat old project, I don't know if some of these features are present in current versions of Java.
Less heinous XML parsing and manipulation tools. Doing anything with XML in Java sucks.
I'll also give one answer the other way around. C# needs an enumeration implementation like Java has. Java's enumerations rock!
Let me add anonymous overrides to this list also. Sorry to go off topic, but C# needs the ability to anonymously override methods. I have been switching back and forth between Java and C#, and I have to say for unit testing legacy code, there is nothing better than anonymous class overriding.
I would need function pointers of some sort. The ability to use delegates in C# is so useful. There are so many times in Java where I want to create a map of delegates or function pointers as the solution, but I can't. I know you can simulate a similar thing in Java, but having the abstraction as part of the language is a huge plus!
Momentum. I have done a lot of development on both platforms. I'm enjoying the .NET side more because of the way the C# language is evolving. Java's evolution seems to be more a reaction to C# than an actual vision. So I think the best thing for Java to do is ignore .NET and create something new of its own.
Another one I would like is some equivalent to LINQ. I noticed how much I actually depend on the ability to use LINQ when I tried to do a top coder competition and realized they only support .NET 2.0. Once you get used to using LINQ to solve problem and make it part of your regular programming vocabulary it is very difficult to not see problems in that light. It is akin to using generics and then not being able to use generic.
I think, choice between Java and C# is not a question of language features, but a question of platform and ecosystem choice.
So, I doubt that any new syntactic sugar in Java or C# can lead to a significant amount of switchers between the platforms.
After all, JVM world has Scala and many language-sensitive developers are using it in some way.
I think, you should consider swithcing this holywar from "Java vs C#" to "JVM vs CLR", because JVM is (in the last years — mostly) not only Java, but also Scala, Groovy, Clojure, JRuby, Jython, and dozen of JVM-languages.
Properties!
Anonymous objects are nice too
Continuations, like Scala (on top of the rest) would be good too, for agents development.
Support to run over CLR (and vice versa perhaps for JVM) without IKVM and other such layers.
Let's be clear that we need to distinguish between Java and the JVM. I actually switched from C# to Java, but I admit it was not because of Java's amazing language features! In my very humble opinion, C# is the better language, and CLR is the perhaps a more elegant VM. However, even with Mono, you're not writing applications that run everywhere!
I think the greatest argument for Java is the amazing community it has. This is where the cutting edge technology is being developed, not at Sun (now Oracle). The Java community has consistently been the leader in developing Enterprise technologies. For instance, how long did it take Microsoft to provide a DI Framework? Where's AOP in .NET? When I start a .NET project, my foundation is Spring.NET, a Java port. When I need ORM, it's NHibernate. Need a testing framework? NUnit. I realize there are other OSS projects for the .NET platform, but their numbers and support from Microsoft are laughable compared to the Java community.
on the other side, has .net got enterprise open projects like Terracotta (semi commerical), Infinispan, Compass ? no. ncache (commerical), lucene.net are far behind them. Especially Terracotta is unique, it can improve some of your app x100, it's simply perfect and free (partitioning is commerical). If we implement a high load app in both .net with anything and java with terracotta + hibernate + terracotta-hibernate-integration, java app will probably far more performant than .net one. Ther're some ports to .net like nhibernate, log4net, lucene.net, but all of them are trying to catch java versions. And entity framework is a disaster, they have to start with nhibernate as the base or get some lessons from them.
.net is only working on windows (mono is far from enterprise, there isn't any enterprises using it), how much money does myspace.com spent for their 4000 windows web server licences ? 1 million ?
You can't install a simple plugin to VS (and can't do some other things) if don't buy professional edition,
Some windows instance types in amazon web services are nearly x2 price of the linux ones.
if you look at ohloh.net open source java project counts (with language comparison tools), you'll see that java has x5 more volume than c#.
also Java has %20 share on worldwide while c# has %4.x (source:tiobe.com)
Look at the top web sites; only microsoft and myspace are using .net. google, amazon, ebay, linkedin, alibaba, twitter (switched to scala from rails)... many of them are using java and many others are using php, ruby (facebook, yahoo,..)
As a language Java is far behind c#, but Scala (runs on jvm) is as good as c# and it's performance is nearly same as java and also it can use all jdk and other java code as his library.
I'm not saying java is better, but I'm saying java is as valuable as .net, too.
A native 'decimal' type for Java replacing the BigDecimal class would be nice. But Java thread-safe collections are nice.
Perhaps the question is not so much what Java 7 needs to persuade developers to use it, but more a case of what makes developers want to move from Enterprise/server-side java language to a different C# desktop Windows-only oriented world?
For most developers, the language isn't difficult to pick up be it Java or C#. I develop in Java, but Linq didn't take long to understand and use.
I think the choice of Java or C# depends on what motivates you personally -perhaps money? in which case either language will do whether they have certain features or not.
Ste
They should start by fixing the Calendar/Date related classes, even that seems too much to ask.
A simple way to map values in your model to the UI (like bind in Java/FX)
I think it depends on bussiness decisions, not the languages themselves.
But I really really really love C# lambdas and curry :D :D
http://mikeomatic.net/?p=82
a map({codeblock}) which runs over anything iterable would be nice. And filter too. And being able to return multiple values easily from a method.
(a,b,c) = getThreeValues();
(would assign the individual variables a, b and c).
Actually I just think they should have Haskell as a supported scripting language on the JVM :D
linq, lambda, anonymous types
I don't see any point in "luring" anyone anywhere. They solve different problems and you should use whichever one suits you.
Java has less "Language" and less structures to trip up new people, it's platform independent and it doesn't change too fast allowing old code to stick around for a LONG time (Good for some large companies).
C# has tight desktop integration and a slew of nice features that make it more fun to program. It has .net integration. It has pointers, closures, etc which make it harder for n00bs (a valid language target, hence Basic) but more fun for experienced programmers--I haven't convinced myself that these features make you more productive, but in some situations they can make your code a lot nicer! Also if you need pointers, you need pointers.
I don't see a whole lot of overlap in target audiences. Why change a language to attract programmers when it's healthier for the entire industry to have two healthy languages each targeted at solving different problems attracting different developers?
For example, in Java there is Functional Java and Higher-Order Java. Both essentially give a small API for manipulating higher-order, curried functions, and perhaps a few new data types (tuples, immutable lists).
LanguageExt looks very promising for making functional style programming in C# easier.
https://github.com/louthy/language-ext
have you looked into F#?
Also a neat blog post would be here that talks about how to use the new generic / lambda expressions built into c# 3.0.
If you just add using System.Linq to the top of your source file there are a LOT of nice new functions added to working with collections such as folding / filtering / etc.
Assuming you can't use F# for whatever reason, and just want to use functional paradigms and idioms in your C# code to improve quality & reliability:
Functional style pattern matching for C#
Monad library for C#/.Net
There is also 'elevate' which has some functional things like option types (maybes) etc.
I think you want F#
Also, the more recent versions of C# have a lot of functional concepts included in the base langauge.
There may be such a library for C#, but you should probably consider just using F# http://research.microsoft.com/fsharp/fsharp.aspx and http://msdn.microsoft.com/en-us/fsharp/default.aspx.
Microsoft plans to make F# a first-class language in Visual Studio so there should be little risk in using one of the CTPs to build your initial stuff.
If you're looking for something that extends C# then no, but there is F# which is a .NET based functional language. From the "About F#" page:
F# is a typed functional programming language for the .NET Framework. It combines the succinctness, expressivity, and compositionality of typed functional programming with the runtime support, libraries, interoperability, tools and object model of .NET. F# stems from the ML family of languages and has a core language compatible with that of OCaml, though also draws from C# and Haskell. F# was designed from the ground up to be a first-class citizen on .NET, giving smooth interoperability with other .NET languages. For example, C# and F# can call each other directly. This means that F# has immediate access to all the .NET Framework APIs, including, for example, Windows Presentation Foundation and DirectX. Similarly, libraries developed in F# may be used from other .NET languages.
Since F# and OCaml share a similar core language, some OCaml libraries and applications can cross-compile either directly or with minor conditionally-compiled changes. This provides a path to cross-compile and/or port existing OCaml code to .NET, and also allows programmers to transfer skills between these languages. A major focus of the project has been to extend the reach of OCaml-like languages into arenas where they have not traditionally been used. Throughout the project the designers of F# are grateful for the support and encouragement of Xavier Leroy and others in the OCaml community.
Not a shrink-wrapped library per se, but Luca Bolognese of Microsoft has a series of blog posts where he builds a C# library for functional programming with types like tuples, records, type unions and so on:
Also Linq is basically a library for functional programming with syntactial support in C#.
Check out http://code.msdn.microsoft.com/FunctionalCSharp for some samples.
F#, there's a CTP release available from microsoft.
One more option to consider is FuncSharp. It's not so heavy as LanguageExt and it does cover the most important patterns/aspects.