<CharlieDigital/> Programming, Politics, and uhh…pineapples

17Mar/09Off

Stupid Questions

Posted by Charles Chen

This one comes courtesy of Andrew Sorkin of the New York Times:



Do we really have to foot the bill for those bonuses at the American International Group?


Fittingly, he provides a stupid answer as well:



So here is a sobering thought: Maybe we have to swallow hard and pay up, partly for our own good.


Sorkin invokes "the sanctity of contracts":



...the “fundamental value” in question here is the sanctity of contracts


Welcome to the real world, Mr. Sorkin, where millions of Americans across a broad spectrum of socio-economic classes are employed with transient "contracts".  An NFL player can be cut at any time.  A grocery clerk's job can be eliminated without a second thought.  A consultant can be fired in an act of downsizing.  Long time employees can be terminated without severance.


Mr. Sorkin justifies his belief with another point that he pulled out of his ass:



Here is the second, perhaps more sobering thought: A.I.G. built this bomb, and it may be the only outfit that really knows how to defuse it.


More like they were trying to build a toy rocket and instead, built a bomb.  In this case, I would say they have no fucking idea how to defuse it because they never realized the dangers of what the created; they never really understood the risks to begin with and thus themselves lacked a fundamental understanding of how their own investment vehicles worked.  I'd say these people are the least qualified to handle this because clearly, they're the same idiots who thought that credit default swaps were a good idea in the first place. 


I'm sure many IT consulting companies would love to have contracts with Mr. Sorkin.  Even if their consultants write terrible, buggy, and unstable code, Mr. Sorkin would be convinced that because these guys wrote it, they would also be the most qualified to fix it.  Mr. Sorkin would be the the ideal IT consulting customer.  Send in your cheapest, least qualified labor and have a guaranteed income stream.  Not only that, Mr. Sorkin would be so ensconced with the sanctity of contracts, that he would feel compelled the keep employing the same guys who wrote the buggy code to the very end.


Sorkin then cites Pearl Meyer:



“The word on the street is that A.I.G. employees are being heavily recruited,” Ms. Meyer says.


Well good.  Isn't this how the free market and capitalism works?  If these guys, who were a part of the one of the greatest failures in free enterprise (dollar wise), can find people willing to pay them to ruin their businesses, then let them go.  I call B.S.; massive steaming piles of it.  The financial sector is shedding jobs at an astounding rate...let them swim and see how many want to jump off the boat.


In actuality, I think Meyer is full of shit.  AIG acquired 21st Century (an auto insurance company) in 2007 and promptly changed the name to aigdirect.  Interestingly, aigdirect.com now redirects you to 21st.com.  I guess that AIG moniker wasn't working out, huh?  You really have to dig around to find any association with AIG on the site.


At the end of the day, I'd like to see if Sorkin and his compadres would be defending the UAW's contracts or how about pension funds which are routinely raided or wiped out in restructuring?



In reality, there are lots of corporations that have figured out that there are loopholes in this bill. ... What those loopholes permit companies to do is make promises to a few sophisticated creditors to lock up all the assets of the business so that if the company ultimately fails, there won't be any sharing of the pain. The sophisticated guys will walk out with everything, and the employees and pensioners will be left with nothing.


The text of the law clearly gives a priority to the banks and the other creditors who protect themselves by contract. They come ahead of all of the employees and all the pensioners. It's been there since 1978; it is in the law today. If Congress wanted to change it, they could change it with the stroke of a pen, but that is what the statute says. ... What has changed over time is how much the banks are seizing in terms of the assets, ... so that by the end of the day, there is less and less and less left over for the employees and for the retirees.


How about you defend "the sanctity" of these contracts first and then we can talk about bonuses?


The comments are the only thing which redeem this otherwise steaming pile of excrement.



This argument would make more sense if the government wasn't forcing automakers to abrogate their contracts with their workers and pensioners. Would the columnist have us believe that those contracts that will be modified or cast away were any less legally binding than those at AIG? Balderdash...it's rewarding poor performance at the expense of the taxpayer.


— agincourt76, Seattle, WA


I don't remember seeing this argument when discussing the breaking of union contracts for the auto bailout. In fact breaking the union contracts was seen as a feature and not a bug.


— JStuddle, Los Ageles, CA


You have disgraced yourself. What have you said that hasn't been said? If anyone wants to hire these guys who ruined the world economy and collapsed their own firms, they are welcome to them. Yeah, they're real rainmakers. And do you think new people can't be hired to unwind the transactions with $165 million dollars?


— Sylvia Ellerson, New York, NY


Nothing in this piece says what it is that makes the bonus beneficiaries so indispensable. Their training? Their brains? They and only they know where the bodies are buried?

In every big company -- but especially in finance -- there are junior personnel just aching for a chance to take over from their superiors. Eventually they do. Why not now?


— donnolo, Monterey, CA


Its really very simple. Without government intervention, AIG would be bankrupt and none of those bonuses would have been paid.

The government breaks contracts in bankruptcy all the time. Of course it does set a precedent for people who loot their companies and the taxpayers. Even if the goovernment bails out the company, they may not get all the loot they expected. I don't know that is such a bad thing.

The truth is, the government ought to be going after many of these employees with criminal fraud charges. Its pretty obvious they sold more credit default swaps than their company could afford to pay off. Those were contracts too.


— Ross Williams, Minnesota


The thesis of this article is we must acquiesce in the millions of dollars of bonuses paid to AIG executives because (1) we must keep the “best and the brightest”and (2) the sanctity of contract must be protected.

The “best and the brightest” bankrupted the largest insurance company in the world. Keep them? They ought be carefully scrutinizer for criminal law violations: their conduct simply does not pass the smell test. Besides, in the financial crisis which AIG is a prime contributor, where are these so called “best and the brightest” going to go? The taxpayers inherited them, but we don’t have to keep them. Remember, AIG has been nationalized. We own it!

The plaintiff cry about honoring contracts rights hollow. Contracts ought to be enforced. That fundamental proposition is undebatable. Why isn’t the same application of the law urged in the case of the United Auto Workers?

These “bonus” given to the recipient of the taxpayers largess ought to be a “pink slip”


— David, Sherman, TX


Congratulations, Andrew Sorkin, you've just asked the Stupid Question of the Day!

Filed under: News, Rants No Comments
11Mar/09Off

Integrating NaturalDocs With SyntaxHighlighter (For The Win!)

Posted by Charles Chen

In working on some SDK-style developer documentation for FirstPoint, it occurred to me that we needed a way to create some all encompasing documentation which covered not only our code base, but also our markup, our JavaScript controls, CSS, and so on. We currently have most of this stuff in Trac wiki pages, which is a great place to put them, but our Trac deployment is going away and being replaced by Jira...or so I'm told.

In light of this, we needed a way to create portable, useful, developer documentation which included a mix of some auto-generated content and hand crafted documents as well (how-to's and stuff, which would be really terse if placed in code comment). There aren't really any do-it-all tools, but I stumbled across NaturalDocs which seemed to be the most well rounded tool of the ones I looked into (i.e. JSDocs, YUI Doc, a few others - it started off as a search for a tool for documenting UI conventions, markup, and script usage for our team) because of the fact that it allowed for the inclusion of loose .txt files which would essentially be treated like wiki pages.

You can see an example of the output at the MapQuest API documentation site.

One of the main reasons I liked NaturalDocs is because of the support for code blocks and how easy it is to write them in the loose text files. However, the downside is that the generated output is pretty...boring. Here's an example:

You can see that it has no intelligence with regards to the language. Doing a little digging around the 'Net, I found a ticket for a request for support for syntax highlighting. So I ended up rolling my sleeves up and solving this myself. I decided to integrate against the SyntaxHighlighter JavaScript library since I've used it previously and I like the output :-).

Here is the end result:

I hadn't touched Perl in quite some time (since college), so I had to dig around in there for a bit but I was able to integrate it after a few hours of flailing.

The steps required are as follows (these steps assume you use framed mode):

In the file FramedHTML.pm, you will need to add the following lines to the method BuildFile after the call to $self->ClosingBrowserStyles():

. '<script language="javascript" src="' . $self->MakeRelativeURL($outputFile, $self->HighlighterShCore(), 1) . '"></script>'
. '<script language="javascript" src="' . $self->MakeRelativeURL($outputFile, $self->HighlighterShBrushCSharp(), 1) . '"></script>'
. '<script language="javascript" src="' . $self->MakeRelativeURL($outputFile, $self->HighlighterShBrushXml(), 1) . '"></script>'
. '<script language="javascript" src="' . $self->MakeRelativeURL($outputFile, $self->HighlighterShBrushCss(), 1) . '"></script>'
. '<script language="javascript" src="' . $self->MakeRelativeURL($outputFile, $self->HighlighterShBrushJs(), 1) . '"></script>'
. '<script language="javascript" src="' . $self->MakeRelativeURL($outputFile, $self->HighlighterShBrushSql(), 1) . '"></script>'
. '<script language="javascript">'
. 'SyntaxHighlighter.config.clipboardSwf = "' . $self->MakeRelativeURL($outputFile, $self->HighlighterClipboard(), 1) . '";'
. 'SyntaxHighlighter.all();'
. '</script>'

Next, to support the new getters, you will need to modify HTMLBase.pm and add the following lines:

sub HighlighterShCore
	{
	my $self = shift;
	return NaturalDocs::File->JoinPaths($self->JavaScriptDirectory(), 'shCore.js' );
	};
 

sub HighlighterShBrushCSharp
	{
	my $self = shift;
	return NaturalDocs::File->JoinPaths($self->JavaScriptDirectory(), 'shBrushCSharp.js' );
	};

sub HighlighterShBrushXml
	{
	my $self = shift;
	return NaturalDocs::File->JoinPaths($self->JavaScriptDirectory(), 'shBrushXml.js' );
	};

sub HighlighterClipboard
	{
	my $self = shift;
	return NaturalDocs::File->JoinPaths($self->JavaScriptDirectory(), 'clipboard.swf' );
	};

sub HighlighterShBrushCss
	{
	my $self = shift;
	return NaturalDocs::File->JoinPaths($self->JavaScriptDirectory(), 'shBrushCss.js' );
	};

sub HighlighterShBrushJs
	{
	my $self = shift;
	return NaturalDocs::File->JoinPaths($self->JavaScriptDirectory(), 'shBrushJScript.js' );
	};

sub HighlighterShBrushSql
	{
	my $self = shift;
	return NaturalDocs::File->JoinPaths($self->JavaScriptDirectory(), 'shBrushSql.js' );};

You should add more to handle whatever syntaxes you need to handle.

By default, the code blocks are generated as <blockquote><pre></pre></blockquote>. To support SyntaxHighlighter, we'll need to change this to allow customizing the class name on the <pre> tag. I decided to use the suggested syntax for including this in the markup: (start code <language>). For example: (start code js). The first module that we have to modify to support this is Native.pm. In the method FormatBody, I made the following change to support the extra token:

# If the line looks like a code tag...
# [CHUCK] ORIGINAL: elsif ($commentLines->[$index] =~ /^\( *(?:(?:start|begin)? +)?(?:table|code|example|diagram) *\)$/i)
elsif ($commentLines->[$index] =~ /^\( *(?:(?:start|begin)? +)?(?:table|code|example|diagram) *((?:\w+)?) *\)$/i)
	{
	if (defined $textBlock)
		{
		$output .= $self->RichFormatTextBlock($textBlock);
		$textBlock = undef;
		};
	# [CHUCK] ORIGINAL: $output .= $tagEnders{$topLevelTag} . '<code>';
	$output .= $tagEnders{$topLevelTag} . "<code class=$1>";
	$topLevelTag = TAG_TAGCODE;
	}

You can see that I've introduced a capturing group to the regular expression to grab the language type (matching SyntaxHighlighter's language strings). The next step is to modify the generation of the intermediate <code> tag to include a class attribute.

If you stop here, the output generation doesn't work correctly since this only affects the intermediate output. We need to jump to HTMLBase.pm and modify the method NDMarkupToHTML so that we can generate the proper tag structure. Here are my modifications:

# [CHUCK] ORIGINAL: my @splitText = split(/(<\/?code>)/, $text);
my @splitText = split(/(<\/?code *(?:class=[^\>]+)?>)/, $text);
 

while (scalar @splitText)
	{
	$text = shift @splitText;

	if ($text =~ m/^(?:<code *(?:class=([^\>]*))?>)$/i)
		{
		$output .= "<blockquote><pre class=\"brush: $1\">";
		$inCode = 1;
		}

You can see that here, I changed the regular expression used to split the intermediate output into chunks to properly split on the new markup structure. In the if-statement, I changed the eq comparison to a regular expressoin match with a capturing group and inserted that into the output <pre> tag (for the win!).

Now be warned: this is not a complete fix. While this addresses the major issue, generation of the proper output, I did not make changes to copy the image files and JavaScript files required by SyntaxHighlighter (sorry, you're going to have to do that yourself :-P). The next set of steps are to:

  1. Copy the images associated with SyntaxHighlighter to the \output\styles directory (or whereever you like).
  2. Copy the scripts required for SyntaxHighlighter to the \output\javascript directory.
  3. Modify the paths in the CSS for the icons used with SyntaxHighlighter (in the shCore.css file).

Of course, the themes and CSS files are easy to include since you can specify those at the command line.

That's all there is to it! Happy documenting! I've attached sample files (including the modified source) for SyntaxHighlighter 1.5 and 2.0.

natural-doc-sh2.0.7z (315.01 KB)
natural-doc-sh1.5.7z (281.7 KB)

Filed under: Awesome, Dev, DevTools 2 Comments
10Mar/09Off

The Follies of C# 4.0

Posted by Charles Chen

Nikhil Kothari has been blogging furiously about Visual Studio 2010 and C# 4.0.  One of his posts covering the dynamic programming features in C# 4.0 raised some interesting discussion in the comments.

Some like Francois Ward:

I heavily dislike this. My philosophy has always been "right tool for the right job". There are dynamic languages that are vastly superior to C#, if you want dynamic. C# was meant to be a "pure" language, to do the stuff where you want as much strong typing as possible (also the reason behind Spec#), and as clean as possible.

This defeats that purpose in such a way that only an FxCop rule or code reviews could stop it from ruinning a codebase. If I wanted dynamic, I could do it in IronRuby (once thats fully out), and call the result from C#.

More so: this dynamic feature was mostly meant to help with COM interop, not as a convenience to save a few lines of code... and people are -already- thinking of ways to misuse it... Really, the .NET runtime was made so we could have all the languages we want on it, EXACTLY so we wouldn't need a "one language to rule them all" thing... The best codebases would use C# as the core, IronRuby (or something similar) for places where you need Dynamic, and F# for places where you need functional... there's no need to stick C# everywhere...and thus, there's no need to add this to C#. Its too late now, but at the very least we can make sure its not abused.

And some like poster "HB":

Why such resistance to this? Mandate to your team not to use it if you don't like it.

Every release of every programming language has the same problem. People resist the new features claiming that they will be abused and ruin everything and yet here we are in C# 4.0 and the use of 'var', anonymous <fill in the blank> and other C# 3.0 features haven't destroyed us.

For people that use a lot of Json (like in MVC), this will be especially handy

I tend to agree with Francois Ward.  While I appreciate the changes in C# 2.0 and 3.0 (moreso 2.0 than 3.0), this transition from "C# pure" to "C# bit-o-everything" is a bit disconcerting; it feels like change for the sake of change and it feels like change in the wrong direction.  As a disclaimer, JavaScript is perhaps my favorite programming language - I love how fluid the language is.  But on the other hand, I can also appreciate some of the structural rigidity of statically typed languages like C# in helping to coerce good OOP practices.

As many have made the argument "Well, you don't have to use it!", I'd like to respond from this angle. It's not a matter of whether I or any of us personally use it but rather how your stereotypical RAD developer (still the majority) uses it or rather abuses it.

I personally think that McConnell gets it right in Code Complete:

"The computer doesn't care whether your code is readable. It's better at reading binary machine instructions than it is at reading high-level-language statements. You write readable code because it helps other people to read your code."

"Making code readable is not an optional part of the development process, and favoring write-time convenience over read-time convenience is a false economy. You should go to the effort of writing good code, which you can do once, rather than the effort of reading bad code, which you'd have to do again and again"

In other words, programming in such a way as to reduce your LOC for a particular operation, while increasing the density (amount of logic in a given number of lines, words, or whatever other metric) or complexity of the statement has a negative effect on readability of the code (at least until the practices become standardized and fairly well understood). The problem I foresee with C# 4.0 is that it introduces features which will not be generally understood across the spectrum of developers. Remember: you are never writing code for yourself, you are writing code for your customers, you clients, the people who will maintain the code after your, your peers whom you work with, consultants who may not understand lambdas, and so on. You may have junior developers on your team (or even senior developers on your team) who may not be able to grasp your idea if you entwine your implementation with cool nifty tricks to reduce LOC.

From a practicality perspective -- as much as this sucks, it is always safer to program to the lowest common denominator; assume that you are writing your code for a novice to maintain and your code will be more legible, the structures will be easier to understand, and the comments will be less terse. Use patterns that are simple to understand. Use statements which are easy to read for a novice as a novice may one day be maintaining your code or extending it. For those reasons, I think that this is a mistake...a terrible mistake to satisfy a set of fringe developers who will actually "get" it and use these constructs in the proper manner.

The forward evolution of the C# language, while it does contain some awesome features and looks more and more like native JavaScript with each iteration, continues to confound me with the lack of concern for the general development community. Instead of focusing on constructs and framework extensions which promote design pattern usage, domain models, and good practices, we get extensions and constructs which undercut the effort to increase the development IQ of your average developer

It WILL be abused and then people like myself will have to go in there and try to untangle the intent of developers who misuse these facilities provided to them for all the wrong reasons just as I've seen people abuse System.Linq instead of writing good, performant code.

Microsoft's C# Future page is a good place to start with regards to some of the features coming out for C# 4.0.

Filed under: .Net, Dev, Rants No Comments
10Mar/09Off

Why We’re Nearly FUBAR’d

Posted by Charles Chen

The financial ignorance of the Average American is so widespread, that you -- yes you: sitting in your cubicle, making close to six figures at a stable white collar job -- you are probably sitting next to someone who's financially ignorant.


A story from the AP studying American's understanding of insurance yielded some astoundingly bad results:



Health: Fewer than half (49 percent) of those surveyed were informed about the cost of coverage if they leave their job and choose COBRA (Consolidated Budget Reconciliation Act) insurance to continue their health benefits. And just 58 percent were aware that health insurance will not cover their living expenses if they become disabled and cannot perform their job.


Home: Only 19 percent knew that the requirement for private mortgage insurance on a newly purchased home depends on the size of the down payment and lender; almost 30 percent think PMI is required by law.


The shortcomings in awareness conflict with what respondents thought they knew. Before taking the quiz, nearly 60 percent said they felt "very confident" when making insurance decisions overall, with only 15 percent voicing any insecurity about their decision-making abilities.


I'll admit, I'm probably one of those financially ignorant ones as well.  But I'm learning!  The problem is that there is a shocking lack of baseline financial education.  There is no standardized financial education test for high school students, as far as I know, and you know what?  Perhaps there should be and it should be a requirement for high school graduation or a G.E.D.  Perhaps two courses are in order: once in high school to cover basics for college students like credit cards, APRs, banking, paying bills, progressive tax brackets, credit scores, and so on.  Another, higher level course would cover things like renting (and your rights as a renter), mortgages, retirement savings, investing, more on progressive tax brackets, and so on as a national requirement for obtaining an associates degree or a baccalaureate.


(As an aside, one of the biggest peeves I had during the presidential campaign was the shocking lack of understanding of how a progressive tax bracket worked and the difference between a marginal tax rate and an effective tax rate.  I don't think that most people even understood the real effect of raising the taxes by 3% -- rolling back the Bush tax cuts -- on the highest bracket would be and who it would affect...)


Come to think of it, this would be an awesome two pronged approach!  Get kids educated on the basics of finance and put all those laid off Wall Street workers to good use.


But seriously, I think this is one of the biggest arguments against privatized health insurance options as a method of increasing insurance coverage and availability: people just don't know much about these things and people don't want to spend the time to dig into the details while they're healthy.  Most of the time, the materials are just too dense anyways.


There's a story in Time this week, "The Health-Care Crisis Hits Home", written by Karen Tulmuty, documenting her brother's experience with the twisted world of health insurance.  What's shocking are some of the numbers drawn from it:



When we talk about health-care reform, we usually start with the problem of the roughly 45 million (and rising) uninsured Americans who have no health coverage at all. But Pat represents the shadow problem facing an additional 25 million people who spend more than 10% of their income on out-of-pocket medical costs. They are the underinsured, who may be all the more vulnerable because, until a health catastrophe hits, they're often blind to the danger they're in. In a 2005 Harvard University study of more than 1,700 bankruptcies across the country, researchers found that medical problems were behind half of them — and three-quarters of those bankrupt people actually had health insurance. As Elizabeth Warren, a Harvard Law professor who helped conduct the study, wrote in the Washington Post, "Nobody's safe ... A comfortable middle-class lifestyle? Good education? Decent job? No safeguards there. Most of the medically bankrupt were middle-class homeowners who had been to college and had responsible jobs — until illness struck."


Scary numbers.

Filed under: News No Comments
9Mar/09Off

More Quotes From the Basketball World

Posted by Charles Chen

Steve Aschburner's article on Mike Miller's surprising drop in productivity contains a nice gem from Don Nelson:



"My first years with Nash, he wanted to be John Stockton,'' Nelson said. "He wanted to get 10 points and 15 assists. I wanted him to get 20 and 10. I felt he could score 20 points a game, but it took me a year to get him to. I ended up having to get angry at him. He was getting booed and he stopped looking for his shot and the team was going poorly, and finally we just had it out after a game.


"I basically told him he had to do what I asked him to do. He had abilities he hadn't even scratched the surface on, and he turned out to be an All-Star for me [in Dallas] and an MVP [in Phoenix]. I just didn't want him to only pass. He was my best outside shooter and he would never take an outside shot.''


Nash averaged 7.9 and 8.6 points in his first two seasons with the Mavericks, then bumped to 15.6 in 2000-01. He was at 15.5 (2004-05) and 18.8 (2005-06) in his two NBA MVP seasons for the Suns.


"You want them to max out on their abilities,'' Nelson said. "You want players to do what they do, if they're good at it. They can work on what they're not good at it. But each guy has his strength, and he's got to go to that.''


I think the same is true of any successful team environment: get people to max out their abilities and let them develop and work on what they're not good at; place people in position to succeed and you can drive the success of the individuals and also the team.

Filed under: QOTD No Comments
5Mar/09Off

Stonecutting And Product Development

Posted by Charles Chen

From an SI article on the success of the San Antonio Spurs, a quote from Jacob Riis which coach Greg Popovich uses to help his players gain perspective:



"When nothing seems to help, I go look at a stonecutter hammering away at his rock, perhaps a hundred times without as much as a crack showing in it. Yet at the hundred and first blow it will split in two, and I know it was not that blow that did it, but all that had gone before."

Filed under: QOTD No Comments