Saturday, May 31, 2008

Knowing C

{

I've been having a good time listening to the StackOverflow podcasts. Joel's a great curmudgeon and Atwood is as opinionated as ever.  An ongoing disagreement between the two has been the usefulness of knowing C.  Joel's adamant about its importance and Atwood thinks there is much else a developer can spend their time in understanding. 

Eric Sink has since chimed in with a post called C and Morse Code wherein he reveals his cards: like Joel, he thinks it's of vital importance if you want to reach past mediocrity:

I'm not going to take a black-and-white stance on this.  I won't go so far as to say that every developer must learn C.  I've met lots of developers without C experience who are successful and making positive contributions to important software projects.

Furthermore, I'll admit that knowing C is not a magic solution to poor skills.  A lousy developer who happens to know C is simply better equipped to hurt himself or somebody nearby.

However, I can say these two things:

  1. All of the truly extraordinary developers I know are people who really understand the kind of low-level details that C forces you to know.
  2. Every programmer without C experience has a clear path of personal development:  Learn C.  Get some real experience using C to write a serious piece of software.  Even if you never use it again, you'll be a better programmer when you're done.

My relationship with C is tenuous at best. I spent a few months some years ago delving into it (and C++) seriously - I'm curious to go back and find some of that code but it was a few machines ago*.  I remember during that time I'd work on little toy programs (mostly an implementation of some algorithm) in C and then have the need for a utility and write it in something else.  It would be interesting to take Eric up on his second point of writing a "serious piece of software" using the language.  One interesting angle on this is how one would keep said "serious piece of software" strictly in the realm of C, without venturing too much into the world of C++ and object orientation done poorly.

So brainstorm question: what's something nice and useful that could be implemented strictly within C? (That one might not yawn and think *gosh* that would take 1 minute to do in Python).

}


*Great memories of Me, Markus, and bcc32 in a coffee house somewhere in southern California.  Too far gone are those days...

Thursday, May 29, 2008

Splitting Files with Python

{

I've been recently needing to generate sql scripts from large Excel spreadsheets. But once the script is finished I've had issues getting SQL Management Studio to execute as large a script in a single run. The solution? Split up the file with a little Python that takes it's arguments like this:

ipy Splitter.py  LargeFile.sql 3

#import clr
#pass arguments like so:
# THISSCRIPT.PY FILE NUM_PARTS
# ipy Ringil.py LargeFile.sql 4

import sys

if(len(sys.argv) == 3):
splits = int(sys.argv[2])
f = open(sys.argv[1])
data = f.readlines()
lc = len(data)/splits
print "number of lines", len(data)
for c in range(0,splits):
outstream = open("data" + str(c + 1) + ".sql", 'w')
for line in data[:lc]:
outstream.write(line)
outstream.close()
del data[:lc]
f.close()
else:
print "Expected arguments: file and number of splits\n example: ipy Splitter.py LargeFile.sql 4"


 



}

Tuesday, May 20, 2008

It's speed that counts

{

I usually don't talk about hardware because I don't pay too much attention to it unless something is bothering me.  However I've discovered something interesting about myself in the last week.  I've done a lot of my development over the last few years on an enormous HP zd8000.  I jokingly called it "the 747" because of its size and girth - 10 lbs and a 17" screen.  For a guy like me who's usually also carrying a few books in his bag it's quite a load as evidenced by my going through at least one laptop bag (my current one is also in poor shape). 

So because of some changes at work I got to try out a machine I'd liked the thought of - another HP but this one with a small 13" screen and weighing perhaps 4 lbs.  It's a great little machine and has a cool look but after about a week I'm back to the 747.

Why go back to the back pains and encumbrance of this massive machine?  One simple reason: speed.  It's got twice the RAM (2GB) and a much faster processor.  I didn't think about this much but for a person like me who is usually running an instance of SQL Server, an IDE of some sort, a text editor, web browsing with 10 tabs open, listening to music, chatting up friends (Messenger is no joke when it comes to resources), etc, etc - you get the picture - it's frustrating to be on a beautiful, compact machine that you have to wait around for. I'd rather exchange power with encumbrance for convenience with time penalties.

Or, as I like to joke with my South Dakota friends, I'm like a guy who exchanged his Chevy Silverado for a crossover vehicle... until he realized that he made his living hauling lumber.

Footnote: I ordered a Thinkpad T61 which should be a foot in both worlds. I guess my bit of the economic stimulus went to China.

}

Monday, May 19, 2008

Nregex mention

{

Steven mentions Nregex in a list of regular expression testers online. Nregex is still up and still useful especially if you need to work with .NET's implementation of regular expressions. A coworker of mine just used it to build a parser for Sql Reporting Services RDL files.  Steven's own RegexPal is a fairly intense implementation of regular expressions in javascript, complete with syntax highlighting.

}

Monday, May 12, 2008

Workaholism

{

Matt from 37Signals blogs about workaholics with the following assertions: they don't get as much done (most of the time) and they focus on inconsequential details.

Many leapt to the defense of workaholics - people who, it seems, are workaholics themselves. Because I'm often labeled a workaholic I'm trying to see past my emotions and yet it still doesn't smell like the truth to me.

And even more so because this weekend I watched Triumph of the Nerds, Cringley's chronicling of the personal computer industry from it's humble roots in what would become Silicon Valley.  As he interviewed people, I couldn't help but think that software development is experiencing a culture change.  The people who got the boat off the ground were almost entirely obsessed with their work, even down to the details.  I have a hard time imagining an Andy Hertzfeld, Woz, or young Bill Gates as a 501 developer.

Even if you go forward a few years, guys like John Carmack don't fit the mould of "balanced life/time to go pick up my kids and watch TV!"

These days though, I think what used to be hobbyism is now simply work and fair game for any person who wants a way to earn their keep and "clock out" for life afterwards.  This is not to say that it wasn't that way before, it just seems like much more commitment was involved.  Or maybe the moral is that no one with a 501 development attitude did anything noteworthy.

But even as I write that and play my hand as a kid who grew up on the folklore of the early computer industry I have to do a gut check because me staying at work late building yet another website for someone is not the same as writing the first GUI.  Not even close...

I take away the notion that there isn't necessarily a direct relationship between time spent at work and productivity but I also know that if I had the 9-5 attitude with no tendency to "get into" my profession, I might as well be an accountant. And as grandiose as it may seem, I'd love to have one idea that really matters versus a lifetime of mediocrity so I could rush home to have a "life."

}

Saturday, May 10, 2008

Old Computer Books

 

{

I was recently feeling ashamed of myself after reading Atwood's Programmers Don't Read Books...  post for what he called Programming book pornography: "The idea that having a pile of thick, important-looking programming books sitting on your shelf, largely unread, will somehow make you a better programmer."  To clarify, I actually do read the books I have bought but I'm guilty of keeping a full shelf for the sake of showing off my long and continuing struggle to be a good programmer. 

One way I can soften this sort of conceit is by thinking of how I'm really proud and boastful of my friends in real life who do things that amaze me. I'm not shy to boast on their behalf.  In the same way a lot of these old books are like old friends that have seen me through some pretty turbulent times.  I carried Francesco Balena's Programming Visual Basic 6.0 around for years when I was training people on VB6, COM, and ASP.  Another set of heavy books I spent many a quality night in a hotel room with were Gary Cornell's Core Java and Core Java Advanced Features. I don't have a formal computer science education but I consider a large part of my education the 7 or so years I spent on the road, in various hotel rooms, reading and practicing what I needed to know.

If truth be told there are a few there that I didn't get much out of.  I never did run Slashcode and I never did more than tinker with Bryce.  But I'm not ashamed to say that I had hopes of doing so that time supplanted with other things.

I packed them away and made room for some of the books I have piled on top of the shelves.  Since I don't travel much and remain in project mode I'm not as efficient about reading what I have but a smaller shelf is more tidy and palatable.  I won't wait so long before my next big cleanup.

So the big question: what to do with these books?

}

Thursday, May 08, 2008

Processing.js

{

John Resig of jQuery fame has released a library called Processing.js for javascript graphics. Yes, you read that right: Javascript graphics.

Earlier this week I was in some training and the instructor asked what future we saw for Silverlight.  My response was that I can't drink the koolaid just yet; while there are certainly applications in streaming media in which Silverlight will compete to the death with Flash, for web applications I see people taking Javascript to the level where its maturity with the browser makes most applications feasible. I also like the competitive environment around the Javascript libraries - the Dojo, jQuery, YUI, Scriptaculous, and other people trying to outdo one another just means better ideas, faster turn arounds, and a better experience. 

}

Monday, May 05, 2008

C# Extension Method for Generic Collections

{

Tinkering a bit with extension methods tonight, inspired in part by Scott Hanselman to write something I've frequently needed with generic collections: to spit them out in some delimited format.  Here are the extension class and method:

    static class EnumerableExtensions
{
public static string AsDelimited<T>(this List<T> obj, string delimiter)
{
List<string> items = new List<string>();
foreach (T data in obj) {
items.Add(data.ToString());
}
return String.Join(delimiter, items.ToArray());
}
}





You can spit out your delimited instances of any List<T> now:

            List<string> test = new List<string>(new string[] { "David", "Morgan", "Philip" });
Console.WriteLine(test.AsDelimited(" => "));

List<int> primes = new List<int>(new int[] { 2, 3, 5, 7, 11, 13, 17 });
Console.WriteLine(primes.AsDelimited(" , "));





}