{"id":25903,"date":"2007-07-23T10:00:00","date_gmt":"2007-07-23T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2007\/07\/23\/the-real-cost-of-compatibility-is-not-in-the-hacks-the-hacks-are-small-potatoes\/"},"modified":"2007-07-23T10:00:00","modified_gmt":"2007-07-23T10:00:00","slug":"the-real-cost-of-compatibility-is-not-in-the-hacks-the-hacks-are-small-potatoes","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20070723-00\/?p=25903","title":{"rendered":"The real cost of compatibility is not in the hacks; the hacks are small potatoes"},"content":{"rendered":"<p>\nCommenter\n<a HREF=\"http:\/\/www.semack.net\">\nMyron A. Semack<\/a>\nasks\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2006\/11\/20\/1109012.aspx#1115421\">\nhow much faster Windows would be if you took out the backward compatibility\nstuff<\/a>.\nMyron is so anxious about this that he\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/pages\/407234.aspx#1117157\">\nasked the question a second time<\/a>.\nAsking a question twice typically counts as a reason\n<i>not<\/i> to answer it, but since I had already written up the answer,\nI figured I&#8217;d post it anyway.\nOh great,\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2006\/11\/20\/1109012.aspx#1122951\">\nand now he asked it a third time<\/a>.\nMyron is so lucky I already wrote up the answer,\nbecause if I hadn&#8217;t I would&#8217;ve just skipped the topic altogether.\nI don&#8217;t respond well to nagging.\n<\/p>\n<p>\nThe answer is, &#8220;Not much, really.&#8221;\n<\/p>\n<p>\nBecause the real cost of compatibility is not in the hacks.\nThe hacks are small potatoes.\nMost hacks are just a few lines of code\n(sometimes as few as zero),\nso the impact on performance is fairly low.\nConsider\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2004\/03\/26\/96777.aspx\">\na compatibility hack for programs that mess up\n<code>IUnknown::QueryInterface<\/code><\/a>:\n<\/p>\n<pre>\n...\nITargetInterface *pti <font COLOR=\"blue\">= NULL<\/font>;\nHRESULT hr = pobj-&gt;QueryInterface(\n                 IID_ITargetInterface, (void**)&amp;pti);\n<font COLOR=\"blue\">if (SUCCEEDED(hr) &amp;&amp; !pti) hr = E_FAIL;<\/font>\n<\/pre>\n<p>\nThe compatibility hack here was just two lines of code.\nOne to set the <code>pti<\/code> variable to <code>NULL<\/code>\nand another to check for a common application error and work around it.\nThe incremental cost of this is negligible.\n<\/p>\n<p>\nHere&#8217;s an example of a hack that takes zero lines of code:\n<\/p>\n<pre>\nHINSTANCE ShellExecute(...)\n{\n ...\n return <a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2006\/11\/08\/1035971.aspx\">(HINSTANCE)42<\/a>;\n}\n<\/pre>\n<p>\nI count this as zero lines of code because the function has to return\n<i>something<\/i>.\nYou may as well return a carefully-crafted value chosen for compatibility.\nThe incremental cost of this is zero.\n<\/p>\n<p>\nNo, the real cost of compatibility is in the design.\n<\/p>\n<p>\nIf you&#8217;re going to design a feature that enhances the window manager\nin some way,\nyou have to think about how existing\nprograms are going to react to your feature.\nThese are programs that predate your feature and naturally know nothing\nabout it.\nDoes your feature alter the message order?\nDoes it introduce a new point of re-entrancy?\nDoes it cause a function to begin dispatching messages\nthat previously did not?\nYou may be forced to design your feature differently in order to\naccommodate these concerns.\nThese issues aren&#8217;t things you can &#8220;take out&#8221;;\nthey are inherently part of the feature design.\n<\/p>\n<p>\nConsider for example color NTSC.\n(Videophiles like to say that NTSC stands for &#8220;never twice the same color.&#8221;)\n<\/p>\n<p>\nThe NTSC color model is backward compatible with the existing system\nfor black-and-white television.\nHow much cheaper would your color television be if you could take out\nthe backward compatibility circuitry?\nThat question misses the point.\nThe backward compatibility is in the design of the NTSC color signal.\nIt&#8217;s not a circuit board\n(or, to be more historically accurate, a set of vacuum tubes)\nthat you can pull out.\nYou can&#8217;t &#8220;take out&#8221; the compatibility stuff from your television set.\nThe compatibility is fundamentally part of the way the NTSC color\nsignal works.\n<\/p>\n<p>\n","protected":false},"excerpt":{"rendered":"<p>Commenter Myron A. Semack asks how much faster Windows would be if you took out the backward compatibility stuff. Myron is so anxious about this that he asked the question a second time. Asking a question twice typically counts as a reason not to answer it, but since I had already written up the answer, [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-25903","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>Commenter Myron A. Semack asks how much faster Windows would be if you took out the backward compatibility stuff. Myron is so anxious about this that he asked the question a second time. Asking a question twice typically counts as a reason not to answer it, but since I had already written up the answer, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/25903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=25903"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/25903\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=25903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=25903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=25903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}