{"id":1198,"date":"2011-10-08T01:23:22","date_gmt":"2011-10-08T06:23:22","guid":{"rendered":"http:\/\/neosmart.net\/blog\/?p=1198"},"modified":"2011-10-08T01:23:22","modified_gmt":"2011-10-08T06:23:22","slug":"my-thoughts-on-sutters-c-and-beyond-2011","status":"publish","type":"post","link":"https:\/\/neosmart.net\/blog\/my-thoughts-on-sutters-c-and-beyond-2011\/","title":{"rendered":"My Thoughts on Sutter&#8217;s &#8220;C++ and Beyond 2011&#8221;"},"content":{"rendered":"<p>Around a month ago, <a href=\"http:\/\/www.gotw.ca\/\" rel=\"follow\">Herb Sutter<\/a> gave a talk on why C++ is once more gaining relevance in the world of programming, and how after a decade of neglect and abandonment, it is set to pave the way into the future. I downloaded it a while ago and finally had a chance to watch it last night; the talk itself is most-excellent and is around 40 minutes long, you can stream it online or download it in a higher-resolution format <a href=\"http:\/\/channel9.msdn.com\/posts\/C-and-Beyond-2011-Herb-Sutter-Why-C\" rel=\"follow\">on Channel 9<\/a>. Or click below to watch:<\/p>\n<p><center><video poster=\"http:\/\/media.ch9.ms\/ch9\/b021\/c55c43d3-9867-4140-a69b-9f420181b021\/CB2011HerbSutterWhyCppFinal_512_ch9.jpg\" controls><source src=\"http:\/\/media.ch9.ms\/ch9\/b021\/c55c43d3-9867-4140-a69b-9f420181b021\/CB2011HerbSutterWhyCppFinal_low_ch9.mp4\" \/><object type=\"application\/x-silverlight-2\" data=\"data:application\/x-silverlight-2,\" width=\"512\" height=\"288\"><param name=\"minRuntimeVersion\" value=\"4.0.50401.0\"\/><param name=\"source\" value=\"https:\/\/channel9.msdn.com\/scripts\/Channel9.xap?v=1.8\"\/><param name=\"initParams\" value=\"mediaurl=https:\/\/smooth.ch9.ms\/ch9\/b021\/c55c43d3-9867-4140-a69b-9f420181b021\/CB2011HerbSutterWhyCppFinal.ism\/manifest,thumbnail=http:\/\/media.ch9.ms\/ch9\/b021\/c55c43d3-9867-4140-a69b-9f420181b021\/CB2011HerbSutterWhyCppFinal_512_ch9.jpg,deliverymethod=adaptivestreaming,autoplay=false,entryid=c55c43d398674140a69b9f420181b021\"\/><\/object><\/video><\/center><\/p>\n<p>As someone that&#8217;s been using both C\/C++ and .NET extensively over the past years, I found there was one very important point that Sutter glanced on, danced around, and did everything short of actually naming in his talk and it&#8217;s that if you&#8217;re doing anything remotely intricate or complicated, <strong>leaky abstractions in managed languages will bite you in the ass, and end up <em>lowering<\/em> your productivity<\/strong>, some times (and if what you&#8217;re working on is truly complicated, often times) to a point where you&#8217;d have been <em>more<\/em> productive using C or C++ in the first place.<\/p>\n<p>The concept of leaky abstractions isn&#8217;t anything new and I&#8217;m hardly the first to point out how it can turn a knight in shining armor into a harbinger of doom and destruction. It&#8217;s the number one problem fundamentally present in almost any framework, but even more so in managed languages where the framework is all you have, and you&#8217;re not allowed to side-step it and build your own foundations to work with (p\/invoke and interop aside). But lately it&#8217;s becoming more and more of a problem as the &#8220;push&#8221; for innovation that Sutter speaks of has become a fundamental requirement in just about all corners of the industry. <\/p>\n<p><!--more--><\/p>\n<p>5 years ago, few in the .NET community could tell you what p\/invoke was and how you&#8217;d use it. Now, it&#8217;s considered fairly basic knowledge and a working familiarity with the underlying C WIN32 API is a must for any desktop software developer looking to make a memorable, high-performing product in the world of .NET. Pretty much each and every WIN32 API documentation page on MSDN has a comment from someone on how to import that particular function into .NET with an interop definition, and people are running into the limitations of the managed framework far more often than they used to.<\/p>\n<p>I&#8217;m still a big fan of .NET in general as it makes it really easy to quickly jump from idea to prototype to finished product for quick, one-off applications or basic tools and utilities. Even for huge products and projects, .NET&#8217;s GUI tools far exceed any C++ offerings in terms of ease-of-use and even functionality when it comes to having standard controls and features a single click away. But the leaky abstractions in .NET are proving to be a real pain in the back, and sometimes even interop just doesn&#8217;t cut it for the most trivial and basic of things.<\/p>\n<p>Recently, <a href=\"http:\/\/stackoverflow.com\/questions\/7520706\/force-standardoutputencoding-to-utf8\" rel=\"follow\">I hit a wall<\/a> with .NET in attempting to make EasyBCD support the parsing of internationalized BCD output in the form of bcdedit&#8217;s stdout. bcdedit, like many other Microsoft tools and utilities, is only UTF8 or Unicode aware if the console codepage is explicitly set in the application&#8217;s console window. I spent an entire day trying to shoehorn this functionality via various .NET hacks and failed interop attempts, a week off-and-on testing and debugging my various incomplete solutions, and in the end my solution was to create a C++ &#8220;proxy&#8221; application that would create a console, set the codepage to UTF8, run the command line utility, and pipe the output back to the host (source code here, MIT license: <a href=\"https:\/\/github.com\/NeoSmart\/UtfRedirect\" rel=\"nofollow\">UtfRedirect<\/a>). It was a guaranteed fix, took all of half an hour including testing it on 4 different platforms and experimenting with various internationalized stdout texts.<\/p>\n<p>I personally believe the &#8220;best&#8221; compromise for medium-sized projects is to use C#\/.NET to create the GUI and small helper scripts\/utilities, but to build the core in C++ with an exposed C API or commandline interface. The short and long of the matter is, making a language truly and properly productive is a lot more work than just providing a sandbox with prettied-up API calls. You have to <em>organically<\/em> add improved productivity into a language from the bottom-up, making sure that the productivity goes hand-in-hand with power and flexibility, that it always second fiddle to being able to get the job done; after all, what use is a one-liner code if no mater how you twist and turn you can&#8217;t get it to do what you want?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Around a month ago, Herb Sutter gave a talk on why C++ is once more gaining relevance in the world of programming, and how after a decade of neglect and abandonment, it is set to pave the way into the &hellip; <a href=\"https:\/\/neosmart.net\/blog\/my-thoughts-on-sutters-c-and-beyond-2011\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":505,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[91,325,810,360,212,812,11,811],"class_list":["post-1198","post","type-post","status-publish","format-standard","hentry","category-software","tag-net","tag-c","tag-c0x","tag-coding","tag-development","tag-leaky-abstractions","tag-programming","tag-utfredirect"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4xDa-jk","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/1198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/users\/505"}],"replies":[{"embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/comments?post=1198"}],"version-history":[{"count":3,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/1198\/revisions"}],"predecessor-version":[{"id":1201,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/posts\/1198\/revisions\/1201"}],"wp:attachment":[{"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/media?parent=1198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/categories?post=1198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/neosmart.net\/blog\/wp-json\/wp\/v2\/tags?post=1198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}