If you have never checked out Rosetta Code, you should. It says it’s a programming chrestomathy (a word I had to look up): a collection of code snippets that show, for a given task, how it is achieved in a variety of different programming languages. You can use it as a proxy for a nerd meter, I expect: the degree to which you find it interesting is how big of nerd you are.
Or how big of a professional programmer. Or maybe how big of an interested intellectual. Checking out how to do the same task in 66 languages to me is fascinating, and many of the tasks there a progamming pearls that developers have been kicking around for years, and thus serves a something of a definitive reference.
The Walk A Directory task, for example, shows pretty plainly that for all the hoopla about Java, it isn’t all that compact, but still a lot more compact than C. Python showed as pretty compact; Ruby more compact still. Perl: still terse but effective after all these years.
I thought I might use a little programming task like this to get a little more familiar with a comparatively recent scripting language, so I tried Ruby. Now mind you, I didn’t try very hard, but I did get put off pretty quickly about hit-and-miss the documentation was. I retreated to python, which I’ve used a bit before, but I’m still a long way from expressing myself effortlessly with it.
Which got me to thinking about how we get ourselves going in a programming environment these days: we learn by Google. You don’t get out a manual and wade through the basics; you just start, and Google up potential answers anytime you get stuck. I’m not sure if this approach is better or worse; but in my experience it isn’t any quicker. Like with Ruby, I found that the explanations I found for a particular issue might have solved that the issue with that particular command, but didn’t get me any closer to understanding the Ruby paradigm, if there is one. After the retreat to python, for all its intended purpose of being object-perl, I was dramatically surprised that the method to cast something to a string is the same as it was in BASIC (no, I don’t mean Visual Basic).
So why don’t we toddle down to Borders and peruse the technical books to get a feel for the paradigm? Because it isn’t there anymore (but not by any fault of mine), and Barnes and Noble is a poor substitute.
The Rosetta Code site is a little light on how it came to be, and why, and who is behind it (probably because it is a product of developers and not marketing people). There are a number of projects being pursued open-source/contribute style. I hope the initiative endures and prospers.
I did complete my python script to traverse a directory structure and crank out the results to a CSV file. The purpose is to give the results to my networking guys so they can generate more space on our drives by archiving the big-old stuff first.
rootPath = 'c:\Lexmark'
pattern = '*.*'
f = open("out.csv", 'w')
for root, dirs, files in os.walk(rootPath):
for filename in fnmatch.filter(files, pattern):
f.write( '"' + os.path.join(root, filename) + '",' + str(os.path.getsize(os.path.join(root, filename))) +
',"' + time.asctime(time.localtime(os.path.getctime(os.path.join(root, filename)))) +
'",' + str(os.path.getctime(os.path.join(root, filename))) + '\n')