Re: Compiler warnings
toggle quoted messageShow quoted text
Yep, I think we think alike on this. I think Ron Cain was the inventor of Small C and I remember using that on my 8080/CP/M machine. Then I found Zeor Zollman's BDS C and I tried to get him to add floating point and structs to it...even met with him in Boston while he was at MIT...but couldn't convince him to do it. My company ended up writing our own C compiler, Eco C-88: the first with a complete IDE...even before Turbo C. (We needed the floating point because we developed and sold an advanced statistics package.)
You're right, there's a lot of what I call RDC (Really Dumb Code), and not all of it's by beginning programmers. I was hired as a consultant by a company that wrote banking software. One piece of commercial code had a 31 level if-else block, where one routine ran each day and all the others were ignored. Some banks using the code had over two million customers. Given that, on average there would be 15 failed comparisons for millions customers each day, we figured some banks were throwing away over 30 minutes of CPU time each day versus using a switch statement. I pointed this out in a code walk through stating it was a really stupid piece of code. I was fired that afternoon. Turns out, the person who hired me wrote the code and everyone in the room knew it!
As far as the Arduino environment, I do like it and think it's a great way to a lot of people to experience what programming's all about, yet have some fun at the same time. I do wish, however, that people who write libraries for the IDE would stay on top of their libraries and fix the warnings that keep popping up as the compiler checks get tighter.
It seems like most knowledgeable EE types, like yourself, are also accomplished programmers. Alas, I'm living proof that it doesn't go the other way. I enjoy reading your comments and I know all of us have benefited from them.
On Monday, July 2, 2018, 10:46:16 PM EDT, ajparent1/KB1GMX <kb1gmx@...> wrote:
I like your rules Jack.
My standard for a function or any subroutine is simple do one thing.
I guess that matches your no swiss knives. I call them overloaded functions.
I think the best example of that is the SD library as it drags in FAT. Its huge
and if all you want to do is read or write blocks FAT is not needed or even
a file system. Or you can just do tag and bag directory and teach the PC
to use a simpler system to talk to a block device. That is only one example.
Took me a while to tear the whole thing down to block_Write(blockNum, Buffer)
and block_read(blockNum, Buffer) Where buffer is a 512 byte area, and
blockNum is a 32bit int. The difference is more than 10K of code!
Global variables are ok if used for that only. Not be cause the tuning math
needed a variable to store and intermediate result.
The offense i've seen is long ints when the counter never exceeds maybe 10
and floats when the value is going to be an integer. Its remarkable that
people forget the iron they are programing is basically a 8 bit byte machine.
C and for that fact C++ is a small language, the libraries are where people
get their shorts eaten. You don't need a full string library for a little 8bitter.
C seems to be there when others have come and gone. Just about all the
others are easy (Ruby, Python, Java) if you know C.
A a long time PDP11 user (I have Unix V2.11 and Ultrix V6(BSD flavor).
ITs funny to thing the 11 is a near native C machine (very CISIC) and
the origin point for C and typically 128K bytes was a big machine.
It teaches one brevity, modularity, and with care clarity.
I still use Small-c on many micros because it is C (more K&R than ansi but hey
it was the 70s and ANSI was over a decade later) and small. I like it because
it allows me to get as close to the irn as I care to and yet hide the iron when I