{"id":4641,"date":"2014-03-30T14:14:31","date_gmt":"2014-03-30T14:14:31","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/linux-c-programmer-to-c-windows-programmer-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:14:31","modified_gmt":"2014-03-30T14:14:31","slug":"linux-c-programmer-to-c-windows-programmer-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/linux-c-programmer-to-c-windows-programmer-collection-of-common-programming-errors\/","title":{"rendered":"Linux\/C++ programmer to C#\/Windows programmer-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f0be2e75b92f1dc3b88764420b435f7e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nheisen<\/p>\n<p>I have been coding exclusively for a while now on Linux with C++. In my current job, it&#8217;s a Windows shop with C# as main language. I&#8217;ve retrained myself to use Visual Studio instead of emacs ( main reason is the integrated debugger in VC, emacs mode in VC helps ), setup Cygwin ( since I cannot live without a shell ) and pickup the ropes of managed language. What tools, books, website ( besides MSDN ) or pitfalls do you think I should check to make myself a more efficient Windows\/C# coder?<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6905efdf12e66dd9a3b94e6aa4d01cac?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPop Catalin<\/p>\n<p>The first things to consider when switching from C++ to C# the fact that mostly share some of the surface syntax, but the difference of programming paradigms gets bigger and bigger as you dig in more into .Net.<\/p>\n<p>Get to know the C# core programming paradigms before starting to program else you might fall in the trap of writing C++ programs in C#, which isn&#8217;t the best idea by long stretch. The most important things to get accustomed to are:<\/p>\n<ul>\n<li>Automatic memory management and garbage collection including the dispose pattern. Learn the basics and pitfalls.<\/li>\n<li>What are classes, interfaces, structs and primitives in .Net, and how they behave compared to C++.<\/li>\n<li>Events, delegates, properties, lambda expressions all of which are somewhat new concepts when coming from C++.<\/li>\n<li>.Net generics and differences between templates.<\/li>\n<li>strings, arrays, custom attributes, reflection, exceptions and threading basics in .Net, all of these are heavily used everywhere in .Net, and you must learn their intricacies to use them effectively.<\/li>\n<li>GUI programming in Winforms and ASP.Net (and maybe after there WPF), components, controtrols, databinding. The .Net GUI model.<\/li>\n<\/ul>\n<p>First start with a generic .Net book that introduces you to all of these concepts. I recommend a book over reading tutorials and articles first of all so you can have a <strong>big complete picture of .Net<\/strong> at the end. Articles on the internet might not achieve this. Best generic .Net book I&#8217;ve read:<\/p>\n<p><strong>Professional C#, 3rd edition.<\/strong> by Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/media.wiley.com\/product_data\/coverImage\/99\/07645575\/0764557599.jpg\" \/><\/p>\n<p>And second, since you&#8217;re from a C++ background, and you are used to working close to the metal and thinking in way that is close to how hardware works (raw memory management (pointers, mem allocations, etc) I can only recommend <strong>one book<\/strong> that will really <strong>demystify<\/strong> what .Net is and what it does :<\/p>\n<p><strong>CLR Via C#<\/strong> by Jeffrey Richter<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.microsoft.com\/MSPress\/books\/imgt\/6522.gif\" \/><\/p>\n<p>I can&#8217;t stress enough how <strong>good<\/strong> this book is for every .Net developer, especially when coming from C++ and at the same time being one of the best .Net books I&#8217;ve read. The book is a pure pleasure to read and covers topics from :<\/p>\n<ul>\n<li>.Net execution model (from MSIL to native code)<\/li>\n<li>Memory management (how the .net runtime and garbage collector manages memory, heap layout, memory generations, finalization, large object heap)<\/li>\n<li>Designing types<\/li>\n<li>Assembly loading, reflection, application domains<\/li>\n<li>and many more &#8230;<\/li>\n<\/ul>\n<p>This is <strong>my best advice<\/strong> I could give to anyone on their way to become an expert C# developer in the shortest time possible.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/af287b8eb5936f6f42c3620a8e05bc06?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ns d<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0c614e0777f5475e1f2e08ca784ddd66?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNash<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d57e9a80a93c88338120d2f4568e6a5f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFranci Penov<\/p>\n<p>Read about garbage collection in .Net (http:\/\/msdn.microsoft.com\/en-us\/library\/0xy59wtx.aspx). People coming from C++ land are used to the explicit memory allocation and management. In C# explicit memory management is virtually non-existing.<\/p>\n<p>Another topic you should check out is the difference between C# generics and C++ templates. I don&#8217;t have a good link for that one, though.<\/p>\n<p>Depending on the product you are working on, you might have to resort to calling Win32 API functions from C#. This is done through P\/Invoke, so you might want to read a bit about it as well. And if you have to actually use it, http:\/\/pinvoke.net is very useful collection of C# declarations for most of the Win32 APIs.<\/p>\n<p>You might also want to learn at least the basics of COM, as very often C#\/.Net applications choose\/need to reuse components from third party vendors, which are often implemented as COM components. COM is a complex topic though. My favorite books on COM and Essential COM by Don Box and Proffesional DCOM by Roger rimes. I would borrow these from a library, as all you need to read are the first few chapters (unless you want to go in depth).<\/p>\n<p>A basic understanding of windows, messages and message queues is necessary, if you are going to write client applications. You will be using Winforms of WPF\/XAML for these, and both technologies do a good job of isolating the details from you; however to be able to write good code you need to know what is going behind the scenes. I am not sure what a good book would be for that, but MSDN has lot of information.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/107f2fafb2d29fedc3783b141139a878?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nConcernedOfTunbridgeWells<\/p>\n<p>My background was predominantly C\/Unix and Python with some java and dusty 2000-vintage VB6 when I first used C#. I was familiar with managed runtimes from the work I had done with Java and the .Net API&#8217;s have a somewhat similar look-and-feel to earlier MS API&#8217;s.<\/p>\n<p>I found Troelsen&#8217;s Pro C# and the .Net 2.0 Platform to be a really good C#\/.Net resource. There are more recent editions out now.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0c74142595db4aec458ea57561e70eb6?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMike Post<\/p>\n<p>Get yourself a copy of Resharper. It&#8217;s probably the single best productivity tool out there for straight up coding.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a83ba904028c9527cbd162553776c793?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFriedrich<\/p>\n<p>Shouldn&#8217;t be the base the CLR? And shouldn&#8217;t it be unimportant which .NET language is used? If I look through the .NET docs I can decide if I&#8217;d like to see the stuff in VB.Net, C# or C++. So if you know C++ why shouldn&#8217;t you use &#8220;managed C++&#8221;?<\/p>\n<p>Regards Friedrich<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>heisen I have been coding exclusively for a while now on Linux with C++. In my current job, it&#8217;s a Windows shop with C# as main language. I&#8217;ve retrained myself to use Visual Studio instead of emacs ( main reason is the integrated debugger in VC, emacs mode in VC helps ), setup Cygwin ( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4641","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4641"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4641\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}