Language for the ages
julesrichardsonuk at yahoo.co.uk
Thu Oct 20 12:52:56 CDT 2005
a.carlini at ntlworld.com wrote:
> Jules Richardson wrote:
>>That was such a scary thought I had to share it, although I suppose it
>>does point out that comments are only useful if you speak the language
>>they're written in, and there's no real substitute for decent code
>>which goes a long way toward explaining itself... :-)
> I presume that you realise that "decent code which goes
> a long way toward explaining itself" is subject to the
> same restriction, i.e. you need to understand the human
> language in which the implementor chose to write the
> variable and function names.
Yes, but it does really just boil down to variable and function names -
and it's a lot easier to look those up using a dictionary than it is to
understand the full language needed to read comments.
I've been there before with both Spanish and German code (neither a
language that I know) and if the code's written well it's just a few
minutes extra armed with a dictionary before it all makes sense, without
really the need for the comments.
Actually, I've seen a lot of pretty meaningless English comments over
the years which only serve to mask bad code - I guess there's no
substitute for programmers actually understanding the (coding) language
which they're writing in (which seems to be a rarer thing as time goes one)
> Or do you believe that
> running decent code through a "shrouding" program
> will have no effect on your ability to understand it?
I'm not saying yes you your question, but interesting observation:
Personally I find that the layout and use of whitespace in higher-level
langauges goes a long way toward making it understandable. It's still
possible to quickly parse code with meaningless variable / function
names providing it's well laid out.
Of course, that's subject to the app/driver/whatever being sufficiently
modular and of good design in the first place. I've seen some really
nasty stuff over the years where it's next to impossible to understand :-)
Actually, bad memories flooding back here! One of the worst situations I
came across was a function of several thousand lines of code, doing many
different jobs, and without a single comment. This in a high level
language too. Variable names were human-readable (not just 'i' or
whatever), but only valid contextually once within the several thousand
lines of code (and not necessarily the first time they were used,
either). Various statements never even got reached for all possible
valid inputs, *and* the function was recursive for certain input states.
Picking that apart was something of a challenge...
More information about the cctalk