- Edited
This one is mainly oriented to xterm, following a conversation we had on the irc channel. I'm posting it on the forum so all the programmers here could give their opinions.
xterm was telling me that one of the reasons he stays clear from java is that the code is too verbose, meaning that you write too much to say simple things. This makes the code difficult to understand, so harder to maintain.
My question is: how important is really verbosity?
A simple example in C. These two bits of code do the exact same thing:
And that's not the only case where adding complexity and verbosity boosts performance. Take the quick sort for example.
So where's the exact balance between readability and performance? Is it reasonable to abandon a technology simply based on the fact that it's harder to read?
Python for example is one of the less verbose languages that I know. It doesn't get much simpler than
PS: In case you do not understand the second portion of the code, here's a more readable version of the same instructions.
xterm was telling me that one of the reasons he stays clear from java is that the code is too verbose, meaning that you write too much to say simple things. This makes the code difficult to understand, so harder to maintain.
My question is: how important is really verbosity?
A simple example in C. These two bits of code do the exact same thing:
int i;
double data[1000];
for (i=0; i<1000; i++) data[i] = 0.0;
and:
int i;
double data[1000], *copy, *end;
end = data+1000;
for (copy = data; copy < end; *(copy++) = 0);
The second while a lot more verbose and seemingly complicated, relies on the simple understanding that an array in C is a pointer. The execution time of the second one is faster. (Not entirely true, depending on your compiler, but let's assume it is for now).And that's not the only case where adding complexity and verbosity boosts performance. Take the quick sort for example.
So where's the exact balance between readability and performance? Is it reasonable to abandon a technology simply based on the fact that it's harder to read?
Python for example is one of the less verbose languages that I know. It doesn't get much simpler than
print "Hello World"
Does it make it an optimal language?PS: In case you do not understand the second portion of the code, here's a more readable version of the same instructions.
for (copy=data; copy<end; copy ++)
*copy = 0.0;
;)