ticalc.org
Basics Archives Community Services Programming
Hardware Help About Search Your Account
   Home :: Archives :: News :: Feature: C Programming Editorial

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  Account Info
(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

Re: Re: Feature: C Programming Editorial
Sebastian Reichelt  Account Info

I agree. One more thing: It will be easy to port between AMS and ROM versions because you don't have to change any code.

     13 May 2000, 19:36 GMT


Re: Re: Re: Feature: C Programming Editorial
Scott Dial
(Web Page)

ASM is just as portable as C is between rom version... the kernel is the determinant for the portability of the binaries

     14 May 2000, 05:34 GMT


Re: Re: Re: Re: Feature: C Programming Editorial
Sebastian Reichelt  Account Info

OK, I might be a little uninformed here. But you just have to look at the many ASM programs that had to be rewritten for AMS 2.03 or HW2. If the programmers had used C, using a lot of high-level routines instead of direct ROM calls and 68k instructions, the programs would just have to be recompiled to work. Just think of what will happen when AMS 3 comes out...

     14 May 2000, 06:37 GMT


Re: Re: Re: Re: Re: Feature: C Programming Editorial
Scott Dial
(Web Page)

Again, it is obvious that you hadn't programmed for the 89 prior to the upgrade of the AMS. The problem was that up until AMS 2.xx the file handles where at a certain handle, when the switch happened, the binaries had to be recompiled to have the kernel replace the correct value depending on the AMS. Regardless, TIGCC didn't exist yet, thus none of the C programs were effected. If TIGCC had been around, it would have most likely produced a similar problem, although most C programs to date don't use external files. The second problem was that the jump tables changed, and again C programs would have had the same problem.

     15 May 2000, 22:37 GMT


Re: Re: Re: Re: Re: Re: Feature: C Programming Editorial
Zeljko Juric  Account Info
(Web Page)

You are not quite right. I am suggesting in TIGCCLIB documentation to AVOID all things which may be problematic with changing AMS versions. Programmers want to access handles directly. I am speaking strictly AGAINST it. Why to access VAT handles directly if TIOS has a lot of nice functions for LEGAL accessing VAT table, like SymFind, SymAdd, SymFindFirst, FolderAdd, etc??? And, I made TIGCCLIB nearly COMPLETELY based on AMS 1.xx, and it is shown that everything works CORRECTLY on AMS 2.xx. Why? I don't used in TIGCCLIB anything which is not LEGAL. And what is not legal? Everything which is not in TIOS jump table. For example, the assumption that the handle of the folder list is 8 and the handle of the main folder is 9 is really a stupidity. Everyone may expect that this need not to remain true in the future. And the practice shows just this: these numbers are changed in AMS 2.xx!!!

     16 May 2000, 07:30 GMT


Re: Re: Re: Re: Re: Re: Re: Feature: C Programming Editorial
Scott Dial
(Web Page)

For simplicities sake, TIGCC wasn't around so there is no point in arguing over it.

     16 May 2000, 22:46 GMT


Re: Re: Feature: C Programming Editorial
HydroCarbon10  Account Info

Well said, I had the same thoughs myself. I expected something that would aide me in writing C programs also. It seems as though this rant missed something all together in that the poster appears to want to wipe out C from the face of the earth. Games have and always will have more complex requirements than normal programs, and because of this assembly is well suited for them. Programs on the other hand don't require real-time graphics or super speed. Because of this, C is an excellent language to write calculator programs in (not games, but programs that accomplish a task). The ability to use C will only lead to better and more complex programs in the future.

     13 May 2000, 19:46 GMT

My $.02
Daniel Bishop  Account Info

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

Re: My $.02
Doug Torrance  Account Info
(Web Page)

I wouldn't say it's not portable. It takes some tweaking to port an 83 game to the 86, but a large part of the code stays the same. And it may be harder to debug, but that's the best part of programming. :)

     14 May 2000, 03:03 GMT


Re: My $.02
Scott Dial
(Web Page)

> 1. It's not portable (an asm program for the 83 must be totally rewritten to run on the 86)
As for calculators, that statement is thoroughly uniformed... you can't use C on either of those. The issue of portability is worthless since calculator C is only on 89\92+.

As for the other points, fine... You have your opinions, just as I have mine

     14 May 2000, 05:29 GMT


Re: Re: My $.02
Patrick Davidson  Account Info
(Web Page)

Actually, there is a C compiler for both of those calculators, in the ticalc.org archives even. It's a little hard to locate as its filename is:

/dos/asm/8xccb5.zip

The TI-85 version is more sensibly named 'small_c.zip' though. However, there isn't really much of a point in knowing that this compiler exists, as it generates terribly inefficient code, and its syntax isn't quite the same as normal C either.

     14 May 2000, 05:45 GMT

GCC
Kenneth Arnold Account Info

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  Account Info
(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


Re: Re: Feature: C Programming Editorial
SirNAOF Account Info
(Web Page)

I'm right with you on the AP test. That was so simple. Our class of 4 took the 1998 AP test as a practice test and as our final. Grading it like the AP test, I got a 5. I also thought that the test this year was so much easier. The non-calculator part was simple! I couldn't believe it. The only hard part was the non-calculator free response. That was tough.

I'm working on learning ASM, I know C, but why wouldn't you want to learn another language? It just makes you that much more experienced. Maybe it's not the nicest thing to look at, but hey, in the long run, you'll be able to make smaller, more optimized programs. I think it's worth the time to learn.

     14 May 2000, 17:15 GMT

C was a joke
YodaToad  Account Info
(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

Re: C was a joke
Dark_Ninja

I think there is actually -some- validitiy to your story. But, I don't think it was the C language that was a joke. There is another language that almost nobody has heard of called B. (C was it's sister.) I think this was the joke. C evolved from B, and C++ evolved from C. That, I believe, is the story.

Dark Ninja

     14 May 2000, 00:48 GMT

Re: Re: C was a joke
JrJinfinity  Account Info
(Web Page)

That's funny I heard there was a language called A, then someone made a language based off it as a joke called B, then someone made C based off it, then C++ evolved from that.

I don't know how valid this is, it's just a rumor I heard a while back...

-JrJinfinity

     14 May 2000, 01:22 GMT


Re: Re: C was a joke
Lars E.  Account Info

A few college students were trying to make a better programming language. They came up with something called BCLP. BCLP eventually became B which became C which became C++ which became Java...

Lars

     14 May 2000, 21:03 GMT

Re: C was a joke
Sebastian Reichelt  Account Info

I heard about A, B, C, and C++ from my Computer Science teacher, but I don't know which of them were jokes. What I do know is that PASCAL was invented for teaching a college class, because the author thought BASIC sucked so much. Then it became so popular that all kinds of people started using it. Eventually Modula 2 came out, and also Object Pascal and Delphi.
Interesting, isn't it?

     14 May 2000, 07:05 GMT


Re: Re: C was a joke
bilal
(Web Page)

Dang.. you're lucky you HAVE a teacher! I taught myself C++ for my computer science AP :)

     14 May 2000, 14:52 GMT


Re: Re: Re: C was a joke
Sebastian Reichelt  Account Info

He was not much help anyways. ;-) Most of the stuff I learned about C++ came from books. Of course, they were his books...

     14 May 2000, 15:28 GMT

Re: C was a joke
Daniel Bishop  Account Info

I read an article called "Creators Admit Unix and C Were a Hoax." I don't think it's completely true but it is interesting.

You can find it in this book:
Davison, Andrew, ed. Humor the Computer. MIT, 1995. p. 178-179.

     14 May 2000, 16:45 GMT


Re: Re: C was a joke
Andy Selle  Account Info
(Web Page)

I read this in the Unix Hater's Guide... In any case, it was intended to be a joke. A parady, because UNIX sometimes seems hopelessly and needlessly complex

     14 May 2000, 23:34 GMT


NOT TRUE!!!!! INFAMY
JollyRoger  Account Info
(Web Page)

The C language was invented by one man...Dennis Richie. He worked at Bell Labs which used the B language (I dont think there was an A). C is based on B. And C++ is one increment from C. "++" in C language is the increment command.

     17 May 2000, 03:41 GMT

1  2  3  4  5  6  

You can change the number of comments per page in Account Preferences.

  Copyright © 1996-2012, the ticalc.org project. All rights reserved. | Contact Us | Disclaimer