<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Codekana blog</title>
	<link>http://www.codekana.com/blog</link>
	<description>Stay informed about Codekana</description>
	<pubDate>Thu, 22 Apr 2010 18:44:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
	<language>en</language>
			<item>
		<title>New Codekana 1.5 pre-release: module definitions pop-up with quick-goto</title>
		<link>http://www.codekana.com/blog/2010/04/22/new-codekana-15-pre-release-module-definitions-pop-up-with-quick-goto/</link>
		<comments>http://www.codekana.com/blog/2010/04/22/new-codekana-15-pre-release-module-definitions-pop-up-with-quick-goto/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 18:39:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.codekana.com/blog/2010/04/22/new-codekana-15-pre-release-module-definitions-pop-up-with-quick-goto/</guid>
		<description><![CDATA[The new Codekana 1.5 for VS2002 to VS2008 is ready for download:
http://www.symnum.com/latest.html
(Symnum Systems is the new incorporated name of the old NGEDIT Software, be ready for a full phase-out of the old name everywhere.)
Before anything else: this version doesn&#8217;t support VS2010. We&#8217;re working on it, and we hope to have something in 2-3 months. See [...]]]></description>
			<content:encoded><![CDATA[<p>The new Codekana 1.5 for VS2002 to VS2008 is ready for download:</p>
<p><a href="http://www.symnum.com/latest.html">http://www.symnum.com/latest.html</a></p>
<p>(<strong>Symnum Systems</strong> is the new incorporated name of the old <strong>NGEDIT Software</strong>, be ready for a full phase-out of the old name everywhere.)</p>
<p>Before anything else: <strong>this version doesn&#8217;t support VS2010</strong>. We&#8217;re working on it, and we hope to have something in 2-3 months. See at the bottom for more info regarding this.</p>
<p>The main new feature in this version of Codekana is that it brings a new command with great functionality: <strong>Quick-Goto with a Module Definitions List</strong>. By default mapped to &lt;<strong>Alt-.</strong>&gt;, but you can map it to whatever you want, it will pop up a list with all the functions and definitions in the current module, with their full declaration and the symbol itself in bold. If you type in part of a name, or several parts of a name, it will filter the list down to those symbols that match the parts you&#8217;ve typed. After this, you can move up and down with cursors, and pressing &lt;Return&gt; will take you to that function in the module. Here it is for you to see:</p>
<p><img src="http://www.codekana.com/img/DocGotoFn.gif" alt="quick-goto" height="281" width="471" /></p>
<p>I hope you will find this a very useful feature.</p>
<p>I&#8217;m doing a pre-release before the official release, because this release incorporates the <strong>new license-key system</strong>, and I want to roll things out slowly to test everything. The link above has all the information on how to obtain the new-style license key. If there is any problem, just get in touch with me via email or using any of the support forms. The official release will happen over the next few days.</p>
<p>We are working in ViEmu/VS2010 first, but the main reason behind the wait is not that, but the fact that we have done a &#8220;<strong>product reboot</strong>&#8221; for <strong>Codekana/VS2010</strong>. The new version is a re-start from scratch, a redesign, with a new vision and direction. Moving from native C++ and COM to managed C++/CLI and .NET has been quite a challenge, but the great news is that the <strong>new editor model</strong> in VS2010 will allow us to do much, <strong>much more awesome things</strong> that the previous VS editor ever did. We are already doing some very innovative and incredibly useful things, and we just have to put in some more work to have it in a state that can be released. We are innovating in everything from parsing to visualization to functionality, and we think the new Codekana VS2010 will make quite a few people have a look at what we&#8217;re doing. Watch out here for news, or <a href="http://twitter.com/jonbho">follow me on Twitter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codekana.com/blog/2010/04/22/new-codekana-15-pre-release-module-definitions-pop-up-with-quick-goto/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New Redesign for the Codekana Web Site</title>
		<link>http://www.codekana.com/blog/2009/09/24/new-redesign-for-the-codekana-web-site/</link>
		<comments>http://www.codekana.com/blog/2009/09/24/new-redesign-for-the-codekana-web-site/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 16:17:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.codekana.com/blog/2009/09/24/new-redesign-for-the-codekana-web-site/</guid>
		<description><![CDATA[If you surf over to http://www.codekana.com, you will see that the whole page (including this blog) has been completely redesigned. It includes new information like customers testimonials, an animated GIF on the home page showing how Codekana works, and a clearer and more complete presentation of all the information. I hope it will help people [...]]]></description>
			<content:encoded><![CDATA[<p>If you surf over to <a href="http://www.codekana.com">http://www.codekana.com</a>, you will see that the whole page (including this blog) has been completely redesigned. It includes new information like customers testimonials, an animated GIF on the home page showing how Codekana works, and a clearer and more complete presentation of all the information. I hope it will help people understand the product faster and with less effort. Let me know what you think about it!</p>
<p>I also posted on the NGEDIT blog to announce this new design and detailing the reasoning behind it. There is also some interesting info on that post about the current state and next steps of my different projects, including Codekana, so you might find it interesting:</p>
<p><a href="http://blog.ngedit.com/2009/09/24/new-codekana-web-site-preview-of-the-j1ck-twitter-client-and-next-steps/">New Codekana web site, preview of the J1CK Twitter client, and next steps</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codekana.com/blog/2009/09/24/new-redesign-for-the-codekana-web-site/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Codekana customers around the world</title>
		<link>http://www.codekana.com/blog/2009/09/10/codekana-customers-around-the-world/</link>
		<comments>http://www.codekana.com/blog/2009/09/10/codekana-customers-around-the-world/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 11:06:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.codekana.com/blog/2009/09/10/codekana-customers-around-the-world/</guid>
		<description><![CDATA[I&#8217;ve been meaning to do this for some time now, and I&#8217;ve finally found the time to put it together. I&#8217;ve digged up the php code I used for the ViEmu around the world map over two years ago, entered the Codekana customers data, and got a nice map courtesy of Google maps.
An overview of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to do this for some time now, and I&#8217;ve finally found the time to put it together. I&#8217;ve digged up the php code I used for the <a href="http://blog.ngedit.com/2007/04/02/viemu-around-the-world/">ViEmu around the world</a> map over two years ago, entered the Codekana customers data, and got a nice map courtesy of Google maps.</p>
<p>An overview of Codekana customers around the world:</p>
<p align="center"><img src="http://www.codekana.com/img/ck-cust-sep09-world.png" alt="World" height="300" width="440" /></p>
<p>This time, unlike in the <a href="http://www.viemu.com">ViEmu</a> map, America is in the center. Just so that I won&#8217;t be accused of any favoritism!</p>
<p>See here the far east Asia and Oceania:</p>
<p align="center"> <img src="http://www.codekana.com/img/ck-cust-sep09-asia.png" alt="Asia and Oceania" height="358" width="250" /></p>
<p>Google&#8217;s geoloc is especially poor in this part of the world, so several sales often coalesce into a single point in the middle of the city (and I have to remove the street portion of the address manually, or the geoloc just doesn&#8217;t return anything!).</p>
<p>We also got Europe fairly covered:</p>
<p align="center"><img src="http://www.codekana.com/img/ck-cust-sep09-emea.png" alt="Europe &amp; Surroundings" height="340" width="440" /></p>
<p>Google&#8217;s geoloc for the UK is quite improved since the last time I did this - it just didn&#8217;t work back then.</p>
<p>And finally,  North and Central America. You can see the US is where Codekana is most popular - or maybe it&#8217;s just the higher concentration of developers?:</p>
<p align="center"><img src="http://www.codekana.com/img/ck-cust-sep09-america.png" alt="America" height="339" width="442" /></p>
<p>I find it curious that the tech hotspots in the West half of the US are so concentrated in California and Seattle,  while sales in the East half seem much more evenly distributed. There are probably more sales in California and the Seattle area than all the others together, but it&#8217;s not apparent on the map because they are so heavily concentrated.</p>
<p>These maps are neither complete nor totally precise: Googles geoloc isn&#8217;t always able to find the (lat,long) pair for an arbitrary address, and I haven&#8217;t used the data of all Codekana customers. If you are a customer and your town or country is not marked, please understand that is the cause! I just wanted to show that Codekana is widely used around this beautiful little planet.</p>
<p>I am currently working in a redesigned web site for Codekana, which will likely be ready in just a few days, and a new version of Codekana itself with several improvements is also on the way. The plans for late-2009 and early-2010 are to provide new versions with hugely improved functionality, both for Visual Studios &lt;= 2008 and for the new Visual Studio 2010.</p>
<p>To all Codekana customers: thank you so much for relying on and supporting Codekana. And I hope to give back to you by providing new functionality to make your daily coding easier and more enjoyable!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codekana.com/blog/2009/09/10/codekana-customers-around-the-world/feed/</wfw:commentRss>
		</item>
		<item>
		<title>On the Speed of Light, Innovation, and the Future of Parsing</title>
		<link>http://www.codekana.com/blog/2009/04/02/on-the-speed-of-light-innovation-and-the-future-of-parsing/</link>
		<comments>http://www.codekana.com/blog/2009/04/02/on-the-speed-of-light-innovation-and-the-future-of-parsing/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 15:09:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.codekana.com/blog/2009/04/02/on-the-speed-of-light-innovation-and-the-future-of-parsing/</guid>
		<description><![CDATA[(Or, how naïve early-twentieth-century physicists look today,
and how naïve we will look to twenty-second-century developers)
  I’ve always loved the popular story about how early 20th century physicists thought physics was basically “done”. There were just a couple of minor phenomena lacking an explanation, and it was widely believed that they would soon be fully [...]]]></description>
			<content:encoded><![CDATA[<p class="entree">(Or, how naïve early-twentieth-century physicists look today,<br />
and how naïve we will look to twenty-second-century developers)</p>
<p> <img src="/img/ckta-michelson.jpg" style="margin: 10px; float: right" alt="Michelson-Morley Experiment Notebook" /> I’ve always loved the popular story about how early 20th century physicists thought physics was basically “done”. There were just a couple of minor phenomena lacking an explanation, and it was widely believed that they would soon be fully understood. The whole building of physical law would be finished in a matter of years. These “minor phenomena” were the photoelectric effect and the apparently constant speed of light regardless of the observer, as shown by Michelson and Morley in their famous experiment.</p>
<p>Of course, we now know that explaining these phenomena would give rise to <i>relativity</i> and <i>quantum mechanics</i>. These theories questioned all previous physics, and made us start to actually see the enormous complexity of our universe: it’s not even clear that we&#8217;ll ever be able to fully understand it.</p>
<p>In some ways, I feel the computer and software industry is in a similar state. I <i>despair</i> when I see this short-sighted attitude in many developers and computer scientists, despite how primitive our current understanding is. Bill Gates is said to have lured David Cutler into leaving Digital and joining Microsoft to lead the Windows NT effort by asking “Don’t you want to write <i>the last major OS kernel</i>?” Purely as a hiring move, it was obviously a great success. But unfortunately, to many in the industry, current kernels <i>are</i> the last step of the road. <i>Ouch</i>.  It’s not only that it’s wrong, but also that this belief <i>impedes</i> original thought and progress.</p>
<p>What we now have are just the first babblings of software – clumsy languages, systems and architectures, poor tools, and primitive theories, which are guaranteed to have an expiry date in the not-very-distant future.  It’s <i>sure</i> we won’t be using the current theories and processes in a matter of a few decades.</p>
<p>I recently read an otherwise educated developer remark: “<i>parsing is basically a solved problem</i>”. He probably knew about parsing, maybe even in some depth: recursive descent, LR parsing, <i>lex</i> and <i>yacc</i> and their multiple descendants… But he must have been unable to see beyond that.  It’s the only explanation for his affirmation, because I think nothing is further from the truth.</p>
<p>These are the very early days of computing. We have just started exploring the shore of a new continent, and it’s shocking, because many are already proclaiming that it’s over. But the good news is that there is plenty of unconquered territory, most of the settlers have their eyes covered, and they’re not even attempting to grab any of it.</p>
<h3>An Itch to Scratch</h3>
<p class="entree">(Or, a vision, and the twisted path to its completion)</p>
<p>I am somewhat obsessed with visualization and user interfaces: anything that helps you better understand what you are working on, and which helps you <i>create</i>. And for better or worse, all my product ideas are born from an itch I need to scratch myself.</p>
<p>Back in early 2005, I thought it would be awesome to have the following visualization of code while I was editing it:</p>
<p><img src="/img/ckta-design.gif" style="margin: 10px" alt="Early Codekana Design" /></p>
<p>The goal was to understand <i>at a glance</i> the structure of the code and its control flow. I wanted to see the <b>name</b> of functions and classes <b>highlighted</b> in their definition (the syntax of C-derived languages is notoriously horrible in this regard, hiding the name among a lot of clutter). I also wanted <b>colored regions</b> marking code blocks, visually grouping the code. I wanted to be able to see where everything starts and ends, and see right away the <b>type</b> of each block: red for loops, green for if-blocks, and so on. Statements that break the normal flow of a loop (<i>break</i>, <i>continue</i>) should stand out. All this had to be done <i>in real-time</i>, inside the text editor or IDE, while the code was being edited.</p>
<p>You could call this <i>advanced syntax-highlighting</i>.  Actually, what <i>syntax-highlighting</i> usually refers to really isn’t such, because it doesn’t use any syntactic information to color the code. It usually just uses <i>lexical</i> information: the distinction between keywords, operators, numbers, constants, identifiers… Very few tools use any syntactic information for display purposes. And, sadly, this is not done because of a design choice, but because lexical analysis is so much simpler to do.</p>
<p>This feature is the kind of thing that once imagined, you can’t take your mind off. At the moment, I also thought it was completely innovative, as I hadn’t seen it anywhere else. This was one of the features I decided I would include in <a href="http://www.ngedit.com">NGEDIT</a>, the text-editor I was working on. There were many other foundational parts of the editor that still needed work, so I didn’t actually start implementing anything.</p>
<p><a href="http://www.viemu.com"><img src="/img/ckta-viemu-logo.gif" style="margin: 15px; float: left" alt="ViEmu Logo" /></a> Some time after that, my development effort deviated a bit, as I started working in <a href="http://www.viemu.com">ViEmu</a>, my vi/vim emulator for Visual Studio, Word, Outlook and SQL Server. For ViEmu, I actually adapted the vi/vim emulation core I had written for the editor, so that it could work inside these host apps, and released it as a stand-alone product. I focused exclusively on the ViEmu products for some time, turning them into solid, working products.</p>
<p>During this almost-exclusive stint in ViEmu, I stumbled into a few cases of features similar to the one I had envisioned: Jacob Thurman’s <a href="http://www.twodesk.com/castalia/">Castalia</a>, which implemented something similar for Delphi, DevExpress’ <a href="http://www.devexpress.com/Coderush">CodeRush</a>, with a similar version for Visual Studio, and also <a href="http://lemonodor.com/archives/001207.html">some scripts for lisp display in emacs</a>. They called it <i>structural highlighting</i>, a name I don’t like much, but which sidesteps the mix-up with syntax-highlighting. Still, none of them did the kind of control-flow-based color-coding I wanted, which is where it becomes really useful information.</p>
<p>Fast forward to early 2007. ViEmu sales were slow for the first few months of the year. I was living off of this, and savings were not huge, so I decided I’d implement another product to try and complement the lousy sales. I had now renamed the text editor to <a href="http://www.kodumi.com">kodumi</a> (a much nicer name if I can say so myself), and it was still work in progress. Actually, it had turned into a major research project that would (and will) still take a long time to complete.  If I was going to arrive somewhere shortly, I had to tackle something more manageable.</p>
<p>So I did some digging in the drawer of project and feature ideas. Among the many crazy, undoable concoctions, I came by the “control-flow outlines” idea. On one hand, I still thought it was a cool feature that would really improve the visualization of code. On the other hand, after ViEmu, I had become very familiar with extending the Visual Studio built-in editor (<i>short version: you’ll have to sweat blood to make it do what you want</i>). Together with a few other useful features, it could offer a nice addition to VS. It made sense, and it seemed to be within reach. That would be it.</p>
<p><a href="http://www.codekana.com"><img src="/img/ckta-ck-logo.gif" style="margin: 10px; float: right" alt="Codekana Logo" /></a> Inspired on <i>“kana”</i>, the Japanese name of reading and writing systems, I decided to call the product <a href="http://www.codekana.com"><b>Codekana</b></a>. And I set out to write it.</p>
<p>Such a project involves many tasks. There are core technology elements, interaction with the host application, and many more. At the beginning of any project, I like to evaluate the difficulty of each challenge. Adding extra elements to VS’s text editor window was clearly doable: other add-ins were already doing it, and a quick prototype helped me prove it.  Filled background regions turned out to be nigh-impossible, due to VS’s internal text-rendering system, but I could draw lines to represent the blocks.  This kind of hacking is never simple, or nice, but for an experienced Windows developer, it was a matter of putting in the hours. This was not the hard part.</p>
<p>Even if it is a <i>solved</i> problem to some, it was obvious to me from the first moment what <i>the really hard part</i> was.</p>
<p>It was, of course, the parsing.</p>
<h3>On a Whim</h3>
<p class="entree">(Or how perfectionist thinking can sometimes get you somewhere worthwhile)</p>
<p>I will gloss over the difficulties of parsing C/C++ and C#, which is not an easy job. I will also skip describing the task of implementing a responsive background parser using a multithreaded task-engine. I will even withhold from whining about the difficulties of getting Visual Studio to do what you want.</p>
<p>What made everything else seem simplistic in comparison is that, unlike existing tools, I was determined to <i>properly</i> support the free-form editing we do while coding. What do I mean by this? Have a look at the following typical editing session (the cursor is shown in red, and newly inserted text is marked in green):</p>
<p style="text-align: center;"><img src="/img/ckta-sample-editing-session.gif" alt="Sample Editing Session" /></p>
<p class="footnote" style="text-align: center;">Sample Editing Session</p>
<p>This session starts from a grammatically correct version of the code, and the source is gradually modified – in this case, just by typing.  The end result, on the right, is also grammatically correct. But the intermediate version, when you have typed the new code only partially, is <i>incorrect</i>.  In this incorrect version, braces don’t pair properly. There is a new opening brace, which still doesn’t have a matching closing brace. The question here is – what should the Codekana parser do with this version of the code?</p>
<p>Traditional parsing starts from the top and scans linearly.  Braces are paired according to a simple logic: a closing brace is understood to close the most recent opening brace that hasn’t been matched. This method works wonderfully in correct source code. But if applied to the intermediate version above, the result will be a surprising. See what pairings this scan will find (in green), and what brace it will leave unmatched (in red):</p>
<p style="text-align: center;"><img src="/img/ckta-sample-erroneous-code-wo-wrong.gif" alt="Erroneous Code Wrongly Parsed" /></p>
<p class="footnote" style="text-align: center;">Naïve linear rescan, starting from the top</p>
<p>Of course, this source code can’t be fully parsed properly, as it’s incorrect. But the parser has detected some pairs and these could be used for display or other purposes. The outline rendering could use the pairs, except that it’s a key problem that the pairs it has found are wrong, they are completely different from the ones found before the typing, and they will be wrong again after the closing brace is typed. A Codekana-like display will get very confused with this intermediate parse.</p>
<p>All traditional tools rescan in this naïve way. Regular compilers of course work this way: they work in “batch mode”, and have far less information than any dynamic parser. If you try to compile the above incorrect code, most compilers will just flag the function body’s opening brace as unmatched.  And if there is another function afterwards, the error can be as obscure as “nested function not allowed”, given the compiler will still think we’re inside foo’s body (and, technically, we are).</p>
<p>But even newer interactive-mode parsers, as the ones used by Visual Studio’s own Intellisense, or even <a href="http://www.jetbrains.com/resharper/">JetBrains Resharper</a>’s or <a href="http://www.devexpress.com/Coderush">DevExpress CodeRush</a>’s parser, will also fall into the same trap. The technique they use for dynamic parsing is “throw everything away and restart”. To avoid extra work, they probably start at the current function or near the editing point, but they don’t go much further than that. In the case above, some of them will even flag as incorrect <i>all code</i> below the editing point. Apart from the erroneous feedback provided, the extra work of re-parsing the rest of the module twice, first when entering the opening brace, and then again when typing the closing one, is nothing to laugh about either.</p>
<p>Of course, they are aware of the problem: an article on Resharper’s blog even complains about C-like languages’ syntax when compared to Visual Basic, where delimiters such as “End If”, “End Loop” and “End Function” allow better parsing with little effort: <a href="http://resharper.blogspot.com/2007/07/of-tools-and-languages.html">Of tools and languages</a>.</p>
<p>To alleviate the problem, some of these tools help address this by automatically inserting the matching closing brace, parenthesis or bracket when the user types the opening one. This ameliorates the issue, but it’s not a real fix. Other editing operation sequences can create similar situations, which cannot be fixed with simple hacks.</p>
<p>I knew this was what usual techniques afforded, and that this was what current tools were doing. But I had a clear idea of what I wanted to do instead: <b>I wanted Codekana to understand the situation</b>. When re-parsing the code in the case above, the new opening brace shouldn’t pair with the next pre-existing closing brace – it is much more likely that <i>the previous pairings persist</i>, and so the parser should keep them. Here is a screenshot of how I wanted Codekana to treat this case:</p>
<p style="text-align: center;"><img src="/img/ckta-err-code-ck.gif" alt="Erroneous Code Properly Understood by Codekana" /></p>
<p class="footnote" style="text-align: center;">Codekana correctly flagging the new, unpaired brace</p>
<p>It’s the new opening brace that is flagged as unpaired, and the previously existing pairings are assumed to remain valid. Codekana also knows that the source is incorrect, but it can apply this heuristic to flag the brace that is most likely the culprit, rather than the one that the naïve linear scan would pinpoint.</p>
<p>The heuristic is the following: assume that it’s <i>the new brace</i> that is unpaired. This is the case most of the time, and applying this logic is the only way to give the correct information to the user. It is also much better than what any other tool out there does.</p>
<p>In the general case, what I wanted was for the parser to use all the information from previous states to understand the editing better, and to better interpret any version of the code. The simplest case of this is what is shown above: flagging the new brace as unpaired, instead of the pre-existing one. But the lead was promising and I could envision more advanced use cases.  Code is often incorrect while it is being modified, and the developer still needs all the help he can get. And I’m not only talking about simple non matching-braces: when we ported Commandos 2 from the PC to the PlayStation 2, optimizing memory usage took months, and for extended periods of time, full branches of the one-million-lines-of-C++-code codebase didn’t even compile. Also during regular editing, the code probably spends more time in an incorrect state than in a correct one. Being able to apply refactorings and other complex operations while the code is partially wrong can be very useful.</p>
<p>It’s not only that <i>it works</i>, but that it’s <i>the right thing to do</i>. Enhancing the tools so they can better understand what is happening can only be a net win. </p>
<h3>Uncharted Territory</h3>
<p class="entree">(Or, once you know where you want to get, how you find the way there?)</p>
<p>As with any spec, there are different ways to implement it.  Codekana could just try to fully reparse the module and not <i>accept</i> the new text fragments until the whole module parses correctly, flagging these braces as unpaired. This would work, but it’s an ugly <i>hack</i>, it would require a lot of redundant parsing, and wouldn’t work in all cases. But mainly, it’s just not the <i>right</i> solution – it doesn’t scale to higher levels of usefulness.</p>
<p>I did have a look at standard research sources. I knew, because I’m familiar with them, that traditional books on parsing like <a href="http://www.amazon.com/Compilers-Principles-Techniques-Alfred-Aho/dp/0201100886">The Dragon Book</a> or other standard texts on compilers don’t even get close to covering this kind of scenario. What I was trying to do is a form of <i>incremental parsing</i>: reusing the previously existing parse to parse a newer version of the same source.</p>
<p>I had a look at what was available on incremental parsing, and found a few research initiatives, and even mentions of a few products. But it turns out none of them was focused on the kind of problem I was trying to solve. They were either trying to <i>improve the performance</i> of compile times, thus studying incremental analysis between correct versions of the code, or they were trying to <i>study the</i> <i>formal mathematics of incremental parsing</i>, which is a cool thing, but is not very practical. Their approaches would have analyzed the above incorrect source in the naïve and wrong way, the same as current tools do, only they would take much less time to do so. It’s not only important that the parser re-uses existing info, but <i>how</i> it re-uses it.</p>
<p>It was clear I had to design a completely different parsing engine. No existing techniques would be of help. It turned out that by pursuing a clear user-oriented goal, I had deviated from what is considered standard knowledge in parsing theory and practice. It had only taken this to get into <i>uncharted territory</i>. The bad news is that opening new paths can require a lot of effort. The good news is that this is much, much more exciting than being the thousandth implementer of an algorithm from the 70s, and potentially much more rewarding.</p>
<p>So, how could this thing be implemented? </p>
<p>The key to designing and implementing any code is to design <i>what data</i> needs to be stored and <i>how</i>, and the <i>operations</i> that act on it. None of the usual parsing techniques would work for the above case, because none were designed to understand erroneous code.</p>
<p>There is actually a technique called “<i>error productions</i>”, which includes common erroneous code patterns in the grammar of a parser so that the compiler can report errors properly. But this technique does not understand the “<i>ephemeral</i>” nature of code as seen by Codekana in an editing session.</p>
<p>Wait, this was the key! All current techniques deal with quite stable code, while I wanted Codekana to understand how code evolves.  Let’s see the parsing structures alongside each version of the code:</p>
<p style="text-align: center;"><img src="/img/ckta-sample-editing-session-parse.gif" alt="Sample Editing Session with Parse" /></p>
<p class="footnote" style="text-align: center;">Sample editing session with parse trees for the correct versions</p>
<p>With traditional tools, both the first and the last state of the code above have a representation as a <i>“parse tree”</i>, while the state in the middle doesn’t have a parse tree, because it’s incorrect.</p>
<p>The key realization was understanding that I had to extend the traditional parse tree to cover erroneous cases: a branch of the parse tree can contain an unmatched brace, that’s all. This never arises in traditional parsers, because they <i>“experience”</i> the code linearly. However, a dynamic parser experiences the non-linear timeline of editing operations, and thus a new, unpaired brace can appear, and should be inserted, anywhere in the tree. Until another brace comes later to match it, we’ll have to live with an unmatched brace:</p>
<p style="text-align: center;"><img src="/img/ckta-unmatched-parse.gif" alt="Sample Parse Including Unmatched Brace" /></p>
<p class="footnote" style="text-align: center;">Unpaired brace, happily living in the parse tree</p>
<p>If a closing brace is inserted below later, both are detected to match and converted into a proper block.</p>
<p>This treatment extend to other cases: if the closing brace of an existing block is deleted, the opening one will be “<i>downgraded</i>” to unpaired-status, and all the remaining nested or surrounding blocks will remain properly paired. All common cases are understood and properly shown to the user.</p>
<p>The principle also applies to more complex situations: the parsing could understand partially-written declarations, function calls, expressions, or any other structure of the grammar. These partially-complete instances can live happily in the parse tree until they are complete, and can thus be properly treated.</p>
<p>I call this incremental approach <i>“lead-based parsing”</i>, because many of the parsing actions start from actual keywords and operators found in the middle of the code, instead of linearly from any given point.  Actually, since incremental parsing has to be done wherever a change happens, the parser always starts <i>“in the middle of the code”</i> in the general case.</p>
<p>Once designed, there are many other intricacies in the implementation, but the actual <i>quantum leap</i> was realizing that a switch of perspective was needed in order to reach the design goal. And this switch took us to a completely new technique in parsing, one of the most studied areas of computing – all in the pursuit of creating a better development experience.</p>
<h3>Conclusion</h3>
<p class="entree">(Or, what does this all mean to you?)</p>
<p>At the end of July 2007, I was able to release Codekana 1.0. It included the incremental parsing system and many other features. It was a small and useful tool, and it will hopefully become much more powerful in the future.</p>
<p>Obviously, Codekana is not <i>“the future of parsing”</i>. It’s just a little tool that can make the life of Visual Studio developers easier. It has gone down a rarely-if-ever-visited path down the world of parsing, and it can offer a much better experience as a result. Actually, it <em>has had</em> to go down that path in order to offer that improved experience. </p>
<p>I do believe that it’s this kind of thinking which will get us to the next generation of computing as a whole. Especially in computers, most things are not even thought about yet, let alone solved and done. <i>In computers, it’s the early 1900s, baby.</i></p>
<p>Take-aways:</p>
<ul>
<li>Never assume that everything is done in any given field.</li>
<li>When you have a vision, stick to it even if you don’t know how to do it.</li>
<li>Know what the state-of-the-art is, so that you can use all available tools and you don’t duplicate work.</li>
<li>Decide the goals around your vision, not around what you can easily do, or you won’t be able to innovate.</li>
<li>To solve the part not covered by existing techniques, you need to understand <i>the essence</i> of what you are trying to do. But beware: it can take <i>a huge effort</i> to tell what the essence is, and what is just clutter surrounding it.</li>
</ul>
<p>Innovation is impossible unless you see what is beneath the surface. You can only copy other people’s creations. But as you learn to see the underlying principles, see what you want to achieve, and stick to your vision, innovating becomes unavoidable.</p>
<p>What do I think is the real, actual state-of-the-art in parsing? It’s this: there are <em>lifetimes</em> of research pending to be done in parsing.  Turing-award-winning algorithms and techniques to discover. Fortune-making products to be conceived and implemented. This is just in parsing – a small corner of computer science which has been studied to exhaustion. Don’t make me talk about less-explored corners.</p>
<p>Now, please, go, and innovate.</p>
<hr />
<p><script type="text/javascript">reddit_url="http://www.codekana.com/blog/2009/04/02/on-the-speed-of-light-innovation-and-the-future-of-parsing/"</script></p>
<p><script type="text/javascript" src="http://www.reddit.com/button.js?t=2"></script></p>
<p><a href="http://www.stumbleupon.com/submit?url=http://www.codekana.com/blog/2009/04/02/on-the-speed-of-light-innovation-and-the-future-of-parsing/%26title%3DThe%2BArticle%2BTitle"> <img border=0 src="http://cdn.stumble-upon.com/images/160x30_su_gray.gif" alt=""></a></p>
<p style="font-style: italic; ">PS: And if you want to check out Codekana, you can start exploring <a href="http://www.codekana.com">here</a>.</p>
<p style="font-style: italic; ">PPS: Thanks to Patrick McKenzie, Eric Sink, Ralf Huvendiek, OJ Reeves, Dennis Gurock, Tobias Gurock, Nick Hebb, Clay Nichols, Andy Brice, Doug Nebeker and Raul Ramos for their early feedback, which helped make it a much better article</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codekana.com/blog/2009/04/02/on-the-speed-of-light-innovation-and-the-future-of-parsing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Codekana 1.1.9</title>
		<link>http://www.codekana.com/blog/2009/01/29/codekana-119/</link>
		<comments>http://www.codekana.com/blog/2009/01/29/codekana-119/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 20:45:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.codekana.com/blog/2009/01/29/codekana-119/</guid>
		<description><![CDATA[I&#8217;ve just uploaded 1.1.9. This fixes proper constructor highlighting in the following C# syntax, which wasn&#8217;t properly recognized:
        public Command(Jobs Job, int Percentage)
            : this(Job)
        {
     [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just uploaded 1.1.9. This fixes proper constructor highlighting in the following C# syntax, which wasn&#8217;t properly recognized:</p>
<pre>        public Command(Jobs Job, int Percentage)
            : this(Job)
        {
            this.Percentage = Percentage;
        }</pre>
<p>Now &#8220;Command&#8221; gets properly marked. The &#8220;this&#8221; in &#8220;this(Job)&#8221; was confusing CK&#8217;s parser.</p>
<p>You can download it via this link:</p>
<p><a href="http://www.codekana.com/CodekanaVS-1.1.9.msi">http://www.codekana.com/CodekanaVS-1.1.9.msi</a></p>
<p>You needn&#8217;t uninstall the previous version before installing this one, it will auto-upgrade your installation. Also, the main download link now actually downloads this version, so no need to update if you downloaded 1.1 after today.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codekana.com/blog/2009/01/29/codekana-119/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Codekana 1.1.8</title>
		<link>http://www.codekana.com/blog/2008/08/04/codekana-118/</link>
		<comments>http://www.codekana.com/blog/2008/08/04/codekana-118/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 10:53:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.codekana.com/blog/2008/08/04/codekana-118/</guid>
		<description><![CDATA[I have just uploaded version 1.1.8 yesterday. This version fixes a freeze that could happen when doing a &#8220;Find in Files&#8221; operation with Codekana&#8217;s search highlighting active. VS would freeze and you&#8217;d need to kill it.
Here is the link to download it:
http://www.codekana.com/CodekanaVS-1.1.8.msi
You don’t need to uninstall the version you have installed, this will automatically upgrade [...]]]></description>
			<content:encoded><![CDATA[<p>I have just uploaded version 1.1.8 yesterday. This version fixes a freeze that could happen when doing a &#8220;Find in Files&#8221; operation with Codekana&#8217;s search highlighting active. VS would freeze and you&#8217;d need to kill it.</p>
<p>Here is the link to download it:</p>
<p><a href="http://www.codekana.com/CodekanaVS-1.1.8.msi">http://www.codekana.com/CodekanaVS-1.1.8.msi</a></p>
<p>You don’t need to uninstall the version you have installed, this will automatically upgrade the installation.</p>
<p>The bug happened very rarely, but funnily it would happen more easily when using a display with great height. I recently got myself a Dell 2408WFP 24&#8243; display which can be set up vertically, for a full glory of 125 lines of code in VS, and this helped me reproduce the problem as reported by a customer. Only afterwards I found out he was using a widescreen monitor in vertical position too! I&#8217;m considering writing a story on this, as it&#8217;s interesting on its own right.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codekana.com/blog/2008/08/04/codekana-118/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Codekana 1.1.7</title>
		<link>http://www.codekana.com/blog/2008/05/15/codekana-117/</link>
		<comments>http://www.codekana.com/blog/2008/05/15/codekana-117/#comments</comments>
		<pubDate>Thu, 15 May 2008 17:34:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.codekana.com/blog/2008/05/15/codekana-117/</guid>
		<description><![CDATA[I uploaded version 1.1.7 yesterday. This version fixes a freeze that would happen after searching for a regular expression that could result in a zero-width match, due to a bug in the search results highlighting feature. Visual Studio would completely stop responding after doing this, and the only option was killing it.
Here is the link [...]]]></description>
			<content:encoded><![CDATA[<p>I uploaded version 1.1.7 yesterday. This version fixes a freeze that would happen after searching for a regular expression that could result in a zero-width match, due to a bug in the search results highlighting feature. Visual Studio would completely stop responding after doing this, and the only option was killing it.</p>
<p>Here is the link to download it:</p>
<p><a href="http://www.codekana.com/CodekanaVS-1.1.7.msi">http://www.codekana.com/CodekanaVS-1.1.7.msi</a></p>
<p>This build will automatically update any previous installation, you don&#8217;t need to uninstall the previous version you have installed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codekana.com/blog/2008/05/15/codekana-117/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Web Site Revamp</title>
		<link>http://www.codekana.com/blog/2008/04/30/web-site-revamp/</link>
		<comments>http://www.codekana.com/blog/2008/04/30/web-site-revamp/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 17:19:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.codekana.com/blog/2008/04/30/web-site-revamp/</guid>
		<description><![CDATA[Unless you&#8217;re reading this with an RSS reader, you&#8217;ll notice that I&#8217;ve finally styled the blog to mostly match the rest of the codekana.com site. It still needs some work, but now that it is integrated with the rest I added a link to the blog on the top navigation bar. I also updated the [...]]]></description>
			<content:encoded><![CDATA[<p>Unless you&#8217;re reading this with an RSS reader, you&#8217;ll notice that I&#8217;ve finally styled the blog to mostly match the rest of the <a href="http://www.codekana.com">codekana.com site</a>. It still needs some work, but now that it is integrated with the rest I added a link to the blog on the top navigation bar. I also updated the copyright notice at the bottom to say &#8220;2008&#8243; (a bit late, I know).</p>
<p>Expect some more work on the web page over the next few weeks. Hopefully, I will be able to convey the usefulness of Codekana better with a better structuring of the pages.</p>
<p>Ah, the &#8220;really big plans&#8221; for Codekana are reserved for later this year, but I&#8217;m planning some new release with new features over the next couple of months!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codekana.com/blog/2008/04/30/web-site-revamp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Codekana 1.1.6</title>
		<link>http://www.codekana.com/blog/2008/01/06/codekana-116/</link>
		<comments>http://www.codekana.com/blog/2008/01/06/codekana-116/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 15:29:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.codekana.com/blog/2008/01/06/codekana-116/</guid>
		<description><![CDATA[I&#8217;ve just built and uploaded Codekana 1.1.6. Since I&#8217;ve made it into the &#8216;official&#8217; 1.1 version, you can just download the regular version:
http://www.codekana.com/CodekanaVS-1.1.msi
This installer will automatically upgrade any previous Codekana installation.
This version fixes a crash bug (!) that happened when using Codekana together with DevExpress&#8217; Coderush add-in and used its &#8217;safe rename&#8217; refactoring (or probably [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just built and uploaded Codekana 1.1.6. Since I&#8217;ve made it into the &#8216;official&#8217; 1.1 version, you can just download the regular version:</p>
<p><a href="http://www.codekana.com/CodekanaVS-1.1.msi">http://www.codekana.com/CodekanaVS-1.1.msi</a></p>
<p>This installer will automatically upgrade any previous Codekana installation.</p>
<p>This version fixes a crash bug (!) that happened when using Codekana together with DevExpress&#8217; Coderush add-in and used its &#8217;safe rename&#8217; refactoring (or probably any other Coderush refactoring that uses the &#8216;linked-identifier&#8217; user interface). The bug was in Codekana&#8217;s text-change processing engine, which would fail when submitted to the amount of overlapping text changes done by Coderush&#8217; refactoring engine.</p>
<p>Before this, 1.1.5 had fixed another crash bug that happened with VS2005 or VS2008 when Visual Studio didn&#8217;t have any items in the &#8216;most recently searched&#8217; list (the list that appears when you click in the QuickFind combo-box. The problem is that VS doesn&#8217;t signal any problen when Codekana tries to access the latest search for its search highlighting feature, and VS also crashes when you try to search for an empty string. I initially thought this was a VS2008 bug, but it also happens in VS2005 (not in VS.NET 2003) - I found it with VS2008 because it was a clean install and that was the trigger to give me an empty search-history list.</p>
<p>And before this, 1.1.4 had bumped up the priority of the function/class-name highlighting marker so that it wouldn&#8217;t be obscured by Resharper&#8217;s &#8216;color identifiers&#8217; feature. That way, if you use Codekana and Resharper together you won&#8217;t be losing the useful function/class-name highlights from Codekana.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codekana.com/blog/2008/01/06/codekana-116/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Welcome to the Codekana blog</title>
		<link>http://www.codekana.com/blog/2008/01/06/hello-world/</link>
		<comments>http://www.codekana.com/blog/2008/01/06/hello-world/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 14:27:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://www.codekana.com/blog/?p=1</guid>
		<description><![CDATA[Hi, this is a new blog which will let you stay up-to-date about Codekana: new release announcements, general news, requests for comments&#8230; If you are a user of Codekana, you will probably find useful subscribing to it in order to stay informed!
]]></description>
			<content:encoded><![CDATA[<p>Hi, this is a new blog which will let you stay up-to-date about <a href="http://www.codekana.com">Codekana</a>: new release announcements, general news, requests for comments&#8230; If you are a user of Codekana, you will probably find useful subscribing to it in order to stay informed!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codekana.com/blog/2008/01/06/hello-world/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
