goplexian.com | animation, modeling, scripting - 2010-01-04 11:12:00
Maybe I'm tired, but I had one of those moments today where something seemed to make a lot of sense and I just had to tell someone about it. So here you go.
As you may know I'm in the process of cutting my teeth on the Go language, but Go isn't the only language I'm looking at in my spare time although in honesty it is the one that's been getting the lions share of my available hours.
Another language I'm looking into is C++ and recently I've come across a a great introductory video series from Stanford University. The name of the video series is called "Programming Abstractions" if you'd like to google it.
Actually it was something said by the teacher in one of these videos which inspired the topic of this post. The instructor was going through a programming exercise and one of the students asked why she did not use a Do-While loop and her answer was that the "Do-While loop is so rarely seen in code that it often causes just about everyone who looks at it to slow down a little".
That really caught me off guard, I thought "Why would a structures rareness matter?"
So I paused the video and sat back in my recliner, tucked away snugly in its velvety embrace and had a good long think on the matter and, I think, I have become a better person for it.
Lets face it, all languages have dark corners where the ancient magic of esoteric functions gather dust. Most languages are absolutely huge when you consider the libraries as well, I'd wager that most programmers don't even know half the library's of their favorite langauges.
This fact presents an interesting question regarding writing code, is it better to design simple solutions using familiar methods or is it better to strive for beautiful and perfect solution even if that means employing unfamiliar methods.
As a side note I think this is one area where Go certainly leans to one side of the debate, its designers are trying hard to keep the language simple and small, similar to C in many ways, this may sound easy but if you've spent any time on the mailing list you'll know that it is a near constant barrage of feature requests. One example of Go's simplicity is that it doesn't have the Do-While structure or even While structure for that matter.
But getting back to the topic, I imagine that there are many who believe that it is always best practise to find that perfect library for the ultimate solution to any particular problem, and that they believe that the extra time taken for researching these solutions is well spent.
I certainly see the merits to that approach in certain situations.
However I think that the more pragmatic view also holds merit in certain cases, and that while a beautiful solution is certainly something to be proud of I think that most people ought to stop before embarking on that quest and simply ask themselves if it is justified given the problem at hand.
Without question the extra time spent doing research will certainly be of benefit, but if generating the solution requires a great deal of research on the writers part, then so also will understanding the solution require a great deal of research on the part of those who come later and try to read the code.
I do not want to give the impression that I am advocating one approach over another, I am only saying that it is good not to be dogmatic about methods. Some problems can be quickly and easily solved using basic tools and for those that can be solved in that way is may often be best to do just that and no more.
Yet here is the shocking and sad conclusion to this discussion, thinking back on my own behavior I can see that at times I have actually done the opposite, which is why I found this teachers classroom comment such a breath of fresh air and so enlightening.
Since simple problems are so easy to wrap ones mind around it is easy to waste a lot of time looking for an impressive solution even when a strait forward approach would work just as well, but on the other hand when confronted with something deeply involved it is so tempting to look for an easy way out using the tools which are most familiar instead of dedicating the time and effort which the problem likely deserves.
This is just basic human nature I guess, yet it is also human nature to analyze ourselves and to try to improve on our natures, so this is one area where I believe I have discovered an important lesson and I will strive to implement it in the days ahead.
As a side note I've joined Project52, if you'd like to know more click the button in the right column.
Goodnight!