Ertugrul Söylemez a écrit :
I think you're confusing two related concepts here, namely elegance and
conciseness. They are related in that elegant code is usually also
concise, but the contrary isn't true.
Well, you may have overslept the technological advances of the last two
decades, but note that we measure RAM in GiB today. Hard disk space is
measured in TiB for many people already, so your code restructuring
wasn't great or elegant, but rather a waste of time converting correct,
safe code into smaller, incorrect code to do just the same thing.
You are completely WRONG.
A small program has many advantages:
o It fits more program in the processor caches. As you (may) know
processor caches are much more limited than RAM. A smaller program
will run FASTER than a bloated one because costly RAM access will be
fewer.
o There is nothing that runs FASTER than a DELETED instruction. Yes,
sometimes you need to add code to make it run faster, but in most
cases eliminating unneeded operations accelerates the program.
o Your point of view is the one of most programers today. Do not care
about efficiency. That means that instead of passing the results of
hardware progress to the user and making programs that effectively
run FASTER in today's hardware we KEEP those advances for us programmers
and we run as slow as 20 years ago. Read about the contest between
a MAcintosh 512K and a Vista AMD64, and you will see that in many aspects
that are important to the end user, the Mac 512K run faster than vista.
Why?
Because of your mentality: BLOATED IS BETTER. Just do not use your brain and
program like a pig. Nobody cares.
o I presented an article about code bloat with the JAVA example in this group
several weeks ago. Re-read it. There I show why I like C and think that C has
a bright future.
I'm sure your IDE/compiler suite isn't going to run on small embedded
systems, so you may want to reconsider your priorities. Nobody will
complain about your program, if it has 3 MiB instead of 800 KiB.
Of course not, but they will complain about slow response times, and
long download time!
> After
all modern IDEs take hundreds of megabytes of disk space and nobody
complains about them either.
Yes. Take for instance Eclipse, that took around 5 minutes to start in
an AIX system. Yes, that's right: 5 minutes. Nice isn't it?
And yes, I did not complain. There was no point in complaining.
Java is like that.
Everybody in Java thinks like you:
PROGRAM LIKE A PIG!
Nobody cares.
Then, to read a 4 digit year from character into an integer you use
several temporary objects, by reading the characters into a list
container temp, that calls a general routine to convert a list
container into a boxed multi-precision integer that gives a boxed
integer that is converted into an unboxed one... eventually.
Obviously nobody cares until this is used in an inner loop and then...
Well then, the user waits, or they buy yet another server box.