Diff Is Great! Microsoft, Not So Much 15
Diff Is Part Of My Life (Now)
At work we use subversion for source control. While I know how to use the TextMate shortcut keys for accessing most of the Subversion commands, I still often prefer to alt-tab to my command prompt session and run svn commands manually.
One of the things I do before I commit changes is to run a quick svn diff, just to sanity-check myself that what I’m really committing is what I think I’m committing. Yes, yes, all my tests
pass, so it’s not like I’m afraid that I’ll break anything. But sometimes I’ve added some logging statements or something temporary that I don’t want to commit. Or maybe I’m just feeling
paranoid at that moment. Whatever. So today I ran svn diff, and the output was like this:
Index: app/views/admin/searches/_result_row.rhtml
===================================================================
--- app/views/admin/searches/_result_row.rhtml (revision 23633)
+++ app/views/admin/searches/_result_row.rhtml (working copy)
@@ -4,7 +4,7 @@
<td><nobr><%= order.company_name.humanize %></nobr></td>
<td><nobr><%= link_to order.customer_name, admin_dre_order_path(order) %></nobr></td>
<td><nobr><%= order.customer['email'] %></nobr></td>
- <td><nobr><%= order.customer['phone'] %></nobr></td>
+ <td><nobr><%= number_to_phone order.customer['phone'], :area_code => true %></nobr></td>
<td><nobr><%= order.customer['address'] %></nobr></td>
<td><nobr><%= order.customer['zip'] %></nobr></td>
</tr>
While I’m not motivated to describe the diff output in detail today, I want to share my thoughts about it, because I suddenly had a ephiphany while looking at this.
And then I got angry.
The First Step: Admit It
Hi, I’m Jeff, and I am a longtime Windows user. (group response: “Hi, Jeff!”).
My History With Diff
My first encounter with this “diff” stuff was in January of 2006. Brian and I had an idea for a tiny improvement to ActiveSupport. It was only a couple lines of code. Then we had to figure out how to actually submit the patch. The instructions said to create a diff file like this:
svn diff > mypatch.diff
We had barely used svn at that point, much less had I ever heard of the diff format, which I know now to be an industry standard – nay, worldwide standard – for describing differences in software code. Remember, I had been working as a professional Microsoft developer – actually getting paid – for 14 years at that point. Yet I had never heard of it before. Why?
Perhaps because I was a moron (definitely a possibility).
But let me also point out, that none of the Microsoft development tools I had ever, ever used, had ever, ever generated, interoperated with, or consumed anything in the worldwide standard diff format. As someone who only drunk, ate, and breathed Microsoft koolaid, I never had to use it before.
Or should I say, I had never had the privilege of using it before.
The Awesomeness Of The Diff Format
In the diff example above, I can see at a glance that I removed the line that simply emitted the customer’s phone number, and replaced it with a call to number_to_phone to get nicer-looking output.
Then, the epiphany struck.
This diff output isn’t just a human-readable summary of what I changed. It’s actually a script! If I wanted, I could save that diff script to a file:
svn diff > format_phone_number.diff
and then I could use any number of tools (like svn merge) to read that diff and apply all of my changes. The old line would be removed, and the new line would be inserted.
In other words, this diff thing isn’t just a way to view differences. It’s not the same as SourceSafe’s “View Differences”. It’s way more than that. It’s a standardized, portable script format that can be used to not only describe source code modifications, but is self-describing enough to allow a tool to programmatically read that diff output and modify code with it. In a predictable, reliable way.
How awesome is that!
Ok, to you this might all seem obvious. To me, it was no small happy thought. And it lasted about, oh, 9 seconds.
The Suckitude of Microsoft’s Development World
But now I’m angry. Why didn’t a realize this before? Why didn’t Microsoft adopt the diff format in its own development tools? Did they not know about it (like me)? Unlikely. Did they just want to preempt any chance of interoperability with the rest of the world? It makes me angry that Microsoft seems to have gone out of its way to provide alternate (and usually sucky) substitutes for simple approaches that everyone else was already using.
Since learning Ruby and Rails, I’ve learned so much more about computing. I can’t imagine how I ever thought I was progressing as a software engineer under the Microsoft ecosystem. Things like diff are second-nature to almost everyone else at a Ruby conference, but not for me. I’m still playing catch up, and it’s going to take me a while.
I guess I just have to take it one day at a time.
One day at a time.



think about why they unleashed to the world the massive suckitude that was Visual Basic & VBScript... It's to grow their market share by enabling a broader group of potential developers.. some who wouldn't be developers if the option was C++ or PERL.
Yeah, it stinks, but it was a business choice. It's also why there is a growing community called Alt.Net. .Net devs who are choosing to think outside the MS box; many of whom are fans of and inspired by Ruby and Rails. such as myself.
Nice example of using diff, but do you really use NOBR tags in your HTML?
If you've ever noticed, it's much easier to move from the Java/Unix camp to the .Net camp then vice-versa. Microsoft made the conscious decision to simplify and make the tools graphical. But it was a little like throwing the baby out with the bath water. It's only lately that they've attempted to pick up what they threw away with things like PowerShell.
Wow, Jeff, you sure love to rag on Microsoft.
You must have been in agony during those 14 years you spent earning a living on their platform.
@Matt: Maybe I wasn't clear. I wasn't in agony at all. I enjoyed it a lot. I still enjoy writing WinForms apps quite a bit. But as I look back, I feel like I've left out of a lot of good stuff that the non-Microsoft shops have been enjoying for a long time. Again, maybe it's because I was an idiot, but it sure would have been great if Microsoft had been a cooperative player with the rest of the industry, and didn't always feel the need to invent duplicates of everything. I'm using the diff format as an example, but hopefully you can think of your own examples, too.
Perhaps I should again mention how much I'm looking forward to using VS2008, and not just for the new WinForms/WPF stuff, but also to try out IronRuby and even the new MVC model for myself.
As Ted pointed out, Microsoft is starting to turn things around, and I'll be first in line to applaud them when they do. Honestly, I think the maturity of open source projects like Rails will, in the end, make Microsoft a better company.
Since you're on a Mac and using Textmate, I'll share my favorite diff-related command: svn diff | mate
Textmate should identify the input type as using diff format, but if it doesn't its easily selectable from the bottom of the window.. and from then on it should be automatically detected. I usually keep this window open when writing my SVN commit comments, so that I can describe preciselly what changes I'm committing.
I'm running somewhat behind you, but in the same direction. Plus I had more than a decade of mainframe COBOL before stumbling into VB1 (I'm very old).
I imagine that if SourceSafe was really being used within MS (and I have some suspicions that their normal dogfooding stance slipped a little) then much of the version control goodness happening in the *nix world would have simply gone straight past them.
It is a pain, though, because folk like us now have to work so hard to acquire good habits, bad ones being so hard to unlearn.
I completely agree with your statement "Since learning Ruby and Rails, I’ve learned so much more about computing". I've just moved jobs from a windows shop developing with asp.net to a mac shop developing with Rails and I feel like I'm finally learning the RIGHT way of doing something.
I thought I knew a thing or two about programming and computer science - how wrong I was!
I shudder to think about all the pain that VSS used to put me through - having to wait for people to check in files so I could get on coding.
Or how I would rarely use "Find in project" with Visual Studio because it took forever (now I use Grep and it takes seconds).
I can't imagine a life without the command prompt now, but on windows I would steer clear of it like the plague.
And the list goes on....
RE: Eifion's question ... you're certainly allowed to use <nobr /> tags, but since that is an HTML formatting tag (like <font>, etc), many UI developers prefer to cast that off into their CSS.
So, you can do this:
td {white-space: nowrap;}
Also, congrats regarding your diff epiphany. I, too, had many RoR epiphanies moving from Java-land to RoR-land.
I understand that anger when you feel you have been living under a Microsoft rock and can't believe you have been so blinkered.
You might enjoy the "Pragmatic Programmers Version Control: Using Subversion":http://www.pragprog.com/titles/svn2
Jeff,
Thanks for the response and clarification. I'm glad to see that you can still recognize many of the good things the Microsoft world has going for it.
I hate to say it but it's not Microsoft's fault that you didn't know about diff, it's yours. I've been a Windows developer for a bit longer than you and I've known about diff for quite some time, same as I knew about svn before the Rails camp made it big, same as I knew how to use cvs command-line while developing Windows applications.
A lot of developers get stuck in this "single framework" mindset and then they get lazy, expecting the framework developer to keep them educated about emerging trends and methodologies, like developers that waited until Microsoft had a testing framework before even learning about test-driven development. Devs just get comfy in their little niche and don't continue to educate themselves.
It's not up to your framework or vendor to educate you and in this day and age there really is no excuse for not knowing a bit more about the development world around us, whether it's some PHP, some Rails, a bit of LINQ, the new ASP.NET MVC toolkit, diff, svn, how to get around a UNIX system or even the basics of a batch file. Great magazines and excellent technical blogs abound and I firmly believe that a good developer should learn at least one new language or framework a year.
Also, I fail to see how Rails somehow educated you about diff when it was actually svn, a language and framework agnostic tool, that finally got your learning juices flowing. I fail to see any connection between Microsoft or Rails in you learning about diff.
Perhaps the reason his diff epiphany showed up in connection with developing in Rails is, that those tools are tied together so strongly. Rails and Ruby aren't just standing alone, but they bring a whole toolchain with them and a great deal of that is based on good old UNIX power tools, such as diff/patch, the shell and so on.
Also, the question in regards to Microsoft vs. diff wasn't that Jeff is a lazy developer that doesn't learn new things, but instead that Microsoft opted to not use something that's pretty much a standard in most other major developing environments. If there's a tool that does the job out there, use it, don't make a replacement.
Since some of the objects in space and time are analytic, it must not be supposed that the thing in itself is a body of demonstrated doctrine, and some of it must be known a priori; with the sole exception of the employment of the Antinomies, the Ideal of practical reason is just as necessary as our ideas.
Let us suppose that the noumena are what first give rise to our faculties, as is proven in the ontological manuals.