Scott Hanselman

The Programmer Phases of Grief: or Language Translation is Harder Than It Looks

February 23, 2007 Comment on this post [25] Posted in Musings | Programming
Sponsored By

One's mind should be pretty clear when programming. I'm a decent enough programmer, but I'm not a bad-ass programmer. At least not anymore.

Back in the day, before marriage, before diabetes, before babies, when I was sleeping a full 8 hours, I could code some nice stuff. Now it's just a miracle it compiles. When it does.

I also tend to, um, not think. At all.

I have been looking into OpenID lately, and had the privilege of meeting the CEO of JanRain, Scott Kveton (pronounced 'k'-vee-ton', but real fast, like the first two syllables are one) and mentioned that I was pleased they had made a .NET compatible OpenID library available (Andrew Arnott has wrapped it in a nice ASP.NET 2.0 Web Control).

I was thinking I'd add OpenID support to Corillian's Voyager eFinance Server as a Proof of Concept, as our authentication system is pluggable. It'll be a nice demo, as our CardSpace one already works great.

I went and download the .NET OpenID Library preparing for a few hours of tedious work.

Tangent

The .NET OpenID library is written in Boo - I blogged about Boo in 2005 (I wonder if Ayende will update his Boo Reflector support for Reflector 5.0?) - which is a language that is damn-near Python. You can convert your code to Boo with this online tool if you want to play. Here's some Boo examples versus C# 2.0.

Right now the best and easiest way to write Boo is to use SharpDevelop, the Open Source IDE. Boo is a first-class language within SharpDevelop, along side VB and C#, and includes all the usual good stuff like debugging and what-not.

The OpenID .NET Library, as I said, is written in Boo, very likely because the original library was written in Python and Boo offered not only a clear porting direction, but also made the developer comfortable. More on this later.

I figured this evening I'd "port" the Boo source for this library over to a "proper C# library" so the masses wouldn't have to sweat Boo. This experience let me through the...

Phases of Programmer Grief*.

Shock

I was of course, like any religious zealot C# programmer, shocked and offended and looked on with disbelief that anyone would use any language that wasn't the One True Way® to produce perfectly viable and runnable IL. Microsoft's whole multi-language, single-runtime was just to prove a point to the Java guys right? I looked at the code with disdain

Shock is often accompanied by numbness...

No curly braces? Duck typing? Is this how these people live and code? Freaks. Toy Languages, man, toy languages.

Denial

At this point, I don't think it'll be hard to port this. The library includes NUnit Tests, but as the library is structured with a lot of things marked internal to the assembly, there's two libraries. The main one, and the test one - but the code is also compiled into the test assembly. I started marking things public, and separated the two.

I've already missed the forest for the trees here, and I'm happily stepping on butterflies in my quest for the big game.

My goal was to use the Test library, as is, to test my glorious new C# library - the one I hadn't started yet. If the same tests passed on my C# version, shiny. I started poking around the code, trying to get an idea on where to start. The library includes a Server and an Consumer, and since I just needed the Consumer in the short term, I figured I start there.

Bargaining

There's not THAT much code in the consumer, but there's not only a number of utility classes, but there's also a bunch of Boo language-specific collections and such. Also, as .NET 2.0 doesn't include Diffie-Hellman support (Orcas does, BTW), the OpenID library referenced Mono.Security to get there BigInteger class and Diffie-Hellman support.

ASIDE: Be aware that Mono is GPL'ed Mono Libraries are MIT X11. Mono produces IL, and Mono libraries are CLS compliant, you can reference them in your Windows .NET applications happily, and they'll work fine 99.9% of the time. Adding a Mono library to my Windows .NET CLR program doesn't make it run under Mono, it's just referencing a library. Some people, like myself (yesterday) look down on this like we look down on C# programs referencing Microsoft.VisualBasic.dll, but hey, it's tested code I didn't have to write...you'll no doubt see my own personal epiphany coming later in this post...

I thought I might write my own Diffie-Hellman...

Note that I'm getting totally off the main task-at-hand already here...but I've not noticed it...yet...

...or find one that was already done. If I could just remove that Mono.Security reference...

Guilt

I started to feel bad, who am I to remove this library? Someone's worked hard on it, it shipped, let's leave it be, and get to the real work. Maybe I can find a better way to port this...ah, yes, Reflector!

I'm completely delusional...lack of sleep?  Analysis paralysis or just complete lack of thought? Ah, too much soda, perhaps? High blood sugar?

I'll just reflector the assembly and decompile it into C#. Heh, maybe I'll use Denis Bauer's FileDisassembler. There's probably some Boo specific stuff, but I'll yank that, no problem. It might be sinful, but no one is looking.

Of course, Boo assemblies include dozens of anonymous generated types and adapters to make Boo's closures work (it was designed before Anonymous Delegates could be used for closures) as well as for type inference.

Gosh...this decompiled C# code isn't even close...this may express the intent to the computer, but it doesn't reflect the Programmer's Intent at all.

Anger

Stupid piece of crap Reflector! Man, Lutz can't even decompile to something I can freaking read!

Remember that IL is the applesauce on its way to becoming apple juice. Note that Stupid Scott is pissed here because Lutz's Reflector can't turn applesauce back into an apple. Darn Reflector and the Laws of Abstraction.

Shoot...this is going to take longer than I thought. Now I've got to just freaking write thing whole thing from scratch by actually thinking and understanding what the code is intending to do! Man, I wasn't planning to think tonight, I just wanted to get OpenID on my blog.

Depression

I'm not a good programmer! I've been coasting on charm for at least the last three years. I remember what closures were in college, but I've been using .NET 1.1 for the last five years and it dulls the senses...I might as well just give up and become a nurse.

Acceptance and Hope

Wait a second. I've already got a library that works. It's got unit tests. It depends on a tested and released Mono library and a 3 year old non-mainstream language, but it works. It's been used and implemented live before and someone has already wrapped it into an even better and more useful abstraction. Maybe it'll work after all. 

The moral of this story is that my time would have been better spent learning Boo, reading the source, and using the Library. The source came with a NAnt Task, but I just created a Boo Project in SharpDevelop - THAT wasn't wasted time.

After I'd learned enough Boo, if I really wanted a C# version, for whatever reason, I should have just written it from scratch using the public interface as a template and the Programmer Intent, written in Boo, as my algorithmic scaffolding. Hindsight is 20/20.

Now, how do I get my evening back?

* With Tongue Placed Firmly in Cheek.
** Image
stolen from here.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Hanselminutes Podcast 52 - End to End Tracing

February 22, 2007 Comment on this post [4] Posted in Podcast | Programming
Sponsored By

My fifty-second podcast is up - that's a full year of podcasts. Oy! This one talks about End to End Tracing, and how there's magic in the XmlTextListener. You don't need WCF to do E2ETracing, but it helps.

ACTION: Please vote for us on Podcast Alley! Digg us at Digg Podcasts!

Links from the Show

SVC Trace Viewer (WCF) (m45)
CorrelationManager Class (m48)
Live Service Trace Viewer (m4b)
Using the Trace Viewer (m46)
Traces in User Code (m49)
Who's On (m4e)
End to End Tracing (m47)
End to End Tracing is Essential - PDF (m4a)

Subscribe: Feed-icon-16x16 Subscribe to my Podcast in iTunes

Do also remember the archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

Our sponsors are /n software and Telerik.

 Telerik is a new sponsor. Check out their UI Suite of controls for ASP.NET. It's very hardcore stuff. One of the things I appreciate about Telerik is their commitment to completeness. For example, they have a page about their Right-to-Left support while some vendors have zero support, or don't bother testing. They also are committed to XHTML compliance and publish their roadmap. It's nice when your controls vendor is very transparent.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

  • The basic MP3 feed is here, and the iPod friendly one is here. There's a number of other ways you can get it (streaming, straight download, etc) that are all up on the site just below the fold. I use iTunes, myself, to listen to most podcasts, but I also use FeedDemon and it's built in support.
  • Note that for now, because of bandwidth constraints, the feeds always have just the current show. If you want to get an old show (and because many Podcasting Clients aren't smart enough to not download the file more than once) you can always find them at http://www.hanselminutes.com.
  • I have, and will, also include the enclosures to this feed you're reading, so if you're already subscribed to ComputerZen and you're not interested in cluttering your life with another feed, you have the choice to get the 'cast as well.
  • If there's a topic you'd like to hear, perhaps one that is better spoken than presented on a blog, or a great tool you can't live without, contact me and I'll get it in the queue!

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Binary Fortress Software's ASP.NET ViewState Helper - A Treasure Trove of Tools

February 22, 2007 Comment on this post [2] Posted in ASP.NET | Reviews | Tools | ViewState
Sponsored By

I was working on some demos here at Corillian and I needed to check the size of the ViewState on a page. There's lots of ways and lots of tools that can help you do this. Certainly FireFox's Web Developer Toolbar, while not specific to ViewState, can help you analyze a page.

Nikhil Kothari's Web Development Helper is also very good at this, but requires a little more setup and ASP.NET 2.0. An awesome tool, though.

I stumbled on Binary Fortress Software's ASP.NET ViewState Helper (their support forum is brand new, but if you have trouble go there).

What a slick tool! A 300k download, and works on ASP.NET from the outside - by futzing with IE's object model. It watches you surf and collects statistics. You can then double click on any of the pages and view the decoded ViewState.

I like a tool that does its job, doesn't run inside of IE (I've had it with Browser Helper Objects), and gets out of the way when I'm done. Recommended. This tool is a very useful addition to your c:\utils.

(BTW, their Web Performance Monitor has promise too, but I haven't looked at it yet).

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

OpenDNS

February 22, 2007 Comment on this post [20] Posted in Tools
Sponsored By

Use OpenDNSDNS is one of these things that we just take for granted. You type www.cnn.com and it resolves to an IP Address.

Who've have thought you could take a stodgie old protocol like DNS and hack a business model around it?

UPDATE: One of the founders of OpenDNS, David Ulevitch, has responded with some helpful info in the comments area.

OpenDNS has. Just set you DNS settings to 208.67.222.222 and 208.67.220.220 or click the button in the upper right corner of this post.

Interestingly, that button is a SMART button. If YOU are already using OpenDNS, you'll see one image, while everyone else sees the other.

They not only offer faster DNS lookups, but they'll

They make their money when you completely booger up a domain name, or DNS doesn't resolve, and you'll get a search page with their advertisers on it.

Now, to be clear, the protocol purists will hate this, declaring things like in the comments here:

I also don't like that "spelling correction" or "anti-phishing" feature. That doesn't belong in the cache; it belongs at the resolver. I would agree [snip] — OpenDNS is unsuitable for use as an enterprise DNS cache. It might be a good solution for people who want to run their own personal cache on a local node.

Personally, I'm loving it. I loves me a clever hack and this be one. Take a look at their FAQ. Since there's no software to install, and you can undo it anytime, it seems harmless to me.

If you want to try it with nslookup on Windows, remember to include the trailing . after the domain name.

C:\Users\Scott>nslookup www.craigslist.org.
Server: resolver1.opendns.com
Address: 208.67.222.222:53

Non-authoritative answer:
Name: www.craigslist.org
Address: 66.150.253.241

C:\Users\Scott>nslookup www.craigslist.orr.
Server: resolver1.opendns.com
Address: 208.67.222.222:53

Non-authoritative answer:
Name: www.craigslist.orr
Address: 208.67.219.41

Notice how the misspelled domain points to a 208.67.x.x address? That's OpenDNS. They'll redirect requests to craigslist.orr to the real site, that's how they handle misspellings - they're actually misspelled in the cache.

Take a look at their http://system.opendns.com Status page. They are pretty hard core. I'll be hooking the parents and relatives up with this one, ASAP. If you're a parent or relative of me, go here to the Getting Started Page if you like, and follow the instructions, and call me if you have trouble. When you're done, visit http://welcome.opendns.com and you'll know if it worked or not.

Comcast's (my ISP) DNS tends to suck, and I have been compensating by running DNS Masq here at the house on my Linksys Router.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

LifeHack: Carry Fewer Club Cards with BarCodes and lose the Costanza Wallet

February 22, 2007 Comment on this post [7] Posted in Musings
Sponsored By

I've been meaning to scan the six stupid "club cards" that The Man uses to track me as I do my shopping around town into one single card like this guy.

This has been more on my mind since I started using the Umbra Bungee Wallet exclusively. I freaking love this wallet. No more Costanza Wallet for me.

Now I've created a custom single uber-club-card (Yes, I know they are tracking me, and No, these aren't my real numbers) using JustOneClubCard.

It's just a little web app with a list of stores (mapped in the background to that stores barcode-style) that generates little double-sided cards for your wallet.

Elegant, clean, simple, very Web 1.5. Now I have six fewer key-chain dealies to carry around.

Thanks to JustOneClubCard, the Mark of the Beast is now that much more convenient to carry.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.