Feature: C Programming Editorial
Posted by Nick on 13 May 2000, 07:06 GMT
Scott Dial of the TCPA (both of which are down because Dim-TI's server is acting up again =[ ) has written our next (belated) feature on C programming on calculators. It's opinionated, so I have to say that Scott's opinions don't reflect my opinion or that of ticalc.org's. The use of C on a calculator is a horrible waste of space. I love the idea as much as the next guy, but there simply isn't enough space for all the bloated code. GCC doesn't produce the most optimized code by far. *gasp* I understand using it to ruff in some program that you need real quick, but any complex program is going to bloat that much more. I even particurally like the fact that I can port a program for my pc to the 89 relatively easily.
What I can't stand is how many people think that C is so much better than asm... There are some real complex things you can do with C that I would be wary of attempting with ASM, but it still could be done cleaner in ASM. The GCC compiler isn't exactly optimal either. Anyone ever looked at the source (-S) it produces? Who in their right mind would use moveq.l #0,d0 to clear it? It has no clue that there is even a better choice... Or how about it moves values on the local stack that don't even need to be preserved or referenced in that method... movew d0,-2(a6) \ tst.w -2(a6). No one can replace the human mind.
I would hate to see all the programmers of tomorrow using C because it is easier... nothing great is ever easy. C is the lazy mans excuse to not learn to really program the calculator. What's that you say? The AMS was written in C... well yes it was and I hate TI for it. Space is not a luxury on such a small memory capacity. If every new programmer that comes in starts writing everything in C then space becomes even less of a luxury. Long live assembly!
|
|
|
The comments below are written by ticalc.org visitors. Their views are not necessarily those of ticalc.org, and ticalc.org takes no responsibility for their content.
|
|
Re: Feature: C Programming Editorial
|
Harper Maddox
(Web Page)
|
I cannot believe that ticalc.org would post this "rant". This piece contains very few examples, which are based solely on the author's opinion. I looked at this on the main page and thought that I would find something interesting and perhaps informative on how to write programs for the TI calculators in C. Here is a counterpoint to your thoughts:
Why program for calculators in C?
1. It's faster
2. Less lines of code = less chance for errors
3. More Portable
4. Easier to understand
5. Tons of existing code is available ( ie. MINIMAX chess engine)
|
|
13 May 2000, 19:12 GMT
|
|
My $.02
|
Daniel Bishop
|
ASM programs may be faster and smaller than C programs but ASM has so many disadvantages
1. It's not portable (an asm program for the 83 must be totally rewritten to run on the 86)
2. It's hard to debug.
3. Most people don't understand it. I know you don't think this should be a issue because any serious programmer should learn asm. However, it does mean that there are fewer people who can help you find errors in your source code.
4. More lines of code (about 6 times as many lines as C equivalent) means more opportunities for errors.
I don't think that C should replace asm but C does have a purpose. There are many good programs that probably wouldn't have been written at all if the author had to use asm.
|
|
13 May 2000, 20:24 GMT
|
|
GCC
|
Kenneth Arnold
|
GCC may not be the best optimizer, but it's a good all-around compiler. But the whole reason that TIGCC is based on it is because it is open-source, and thus modifying it to compile for the TI-89/92+ was not a big deal, and recompiling it for Windows using cygwin was easy, too. Unfourtunately, the guy who did the modifications to GCC had a hard drive crash (so Xavier Vassor says) before he could distribute the code, so no more modifications can be done to TIGCC for Windows, not to mention that it's illegal because GCC is GPL'ed.
Henri Moilanen redid the modifications to GCC and released it as TIGCC for Linux (even though it is not based on TIGCC). This is legal, because he included a patch to the GCC source. He's working with Xavier Vassor to port this back to Windows &c.
If you want, since you can get the source, you can tune GCC's optimization. (But always put -O2 / -O6 / (I've even seen -O20) in your TIGCC command lines.) For example, if you want to change that move.l to clr, find the M68000 optimization section of the (rather big) GCC archive and code this in. I haven't explored the GCC source myself because it is ~ 9 MB and I have lots of other stuff to download first, but I'm sure it's well organized.
So basically if you don't like it, fix it yourself. Submit your patch if it works. If you're not a good C coder, always generate ASM source and hand-optimize that. Don't want to do that? Then don't complain.
Kenneth
|
|
13 May 2000, 21:03 GMT
|
|
Re: Feature: C Programming Editorial
|
WashBasin
(Web Page)
|
hey i was going to make a C game and then use TI-GCC, and this opinionated article has not changed my mind.
anyways, yeah i took the Calculus AP test, but i took AB; it was easier than i thought it was going to be and i thought the calculator section =) was easier than the non-calculator part. the free-response questions were pretty straightforward and none were unanswerable. i think there is just a lot of hype about this test; its not as hard as you might think.
|
|
13 May 2000, 22:46 GMT
|
|
C was a joke
|
YodaToad
(Web Page)
|
I don't know how valid this is, but I heard from somewhere (I don't remember where) that the guys who made C really meant it as a joke.... Apparently when the compiler got released, people liked it so much that they kept adding things to the language...
Like I said before, I don't know how valid this is, so don't go bashing me for it.
-Erik Davidson
|
|
14 May 2000, 00:34 GMT
|
|
1 2 3 4 5 6
You can change the number of comments per page in Account Preferences.
|