Best alternative for learning C .
markuster
Posts: 184
Hi,
I have the BoeBot and I would like to learn C language
Do you know if changing the Basic Stamp by the Propeller and using the Catalina C
is enough to start moving motors, using sensors, etc. . Is this hardware enough to
start learning C. ?
I like a lot the Stamps in Class program and I am looking for the same but C.
It seems that Parallax doesn't have some PDFs like Stamp in Class to learn
C with the BoeBot . Do you know something about ? , Some PDFs about how
can I add the servos , or a sensor will be very good.
Thanks,
I have the BoeBot and I would like to learn C language
Do you know if changing the Basic Stamp by the Propeller and using the Catalina C
is enough to start moving motors, using sensors, etc. . Is this hardware enough to
start learning C. ?
I like a lot the Stamps in Class program and I am looking for the same but C.
It seems that Parallax doesn't have some PDFs like Stamp in Class to learn
C with the BoeBot . Do you know something about ? , Some PDFs about how
can I add the servos , or a sensor will be very good.
Thanks,
Comments
http://learn.parallax.com/PropellerBoeBot
But it's not C though, so maybe not much help.
*Parallax is apparently working on some PropGCC based material. It hasn't been released yet, however.
Your best bet for learning C would be to start on the desktop with GCC, and learn the basic elements. From there, it's more or less the same for the Propeller.
But do you know if Spin is similar to C language.
Or , people that understand Spin could understand C faster ?
Thanks.
Having said that, it does not help with the peculiarites of any specific system, like the Prop for example.
Be sure, Parallax is working very hard on providing such documentation and tutorials for the use of C on the Prop. I'm sure it will be very good but it is early days yet as it is only recently that Paralax has supported C on the Prop.
Spin and C are in the same family of block structured languages as Pascal, ALGOL, and many others, once you know one you know them all, give or take some syntactic details.
Try looking for the original ANSI C written by the founding author, Richie and Kernighan. Though it is not everything you need to know, it is one of the best introductory presentations.
It is written with Standard I/O in mind. With the Propeller, the i/o pins are NOT the 'Standard i/o' and that is mostly where you will have to adapt C to use on the Propeller. This should not be a big issue. Once you learn to loop and branch and get the timing you want, it all gets very easy.
I would stick with ANSI C, and avoid C++ at first. The Propeller PropGCC can do both, but C++ requires you to learn a lot more. Learn to walk, before trying to run.
http://zanasi.chem.unisa.it/download/C.pdf
Yes, it's a semantics problem. Standard IO in C usually refers to standard input/output interfaces such as a serial port or a disk. The IO in a MCU (microcontroller) has some "generic" features associated with pin input/output. GPIO is a common acronym for that (General Purpose Input Output).
You can learn C on an MCU (microcontroller), but learning it on a PC will be a more rewarding experience because you generally won't use up all of a PC memory - there are exceptions LOL. MCUs tend to have limits that a PC will not have. On the other hand, a PC can't do some specialized things that some MCUs can do.
Spin has many more operators than C. Also ">=" does not mean the same thing in both languages .... Then there is this thing "->" ....
Large spaces do have their positive attributes as the imagination soars.
Use both wisely.
in use, they are completely different, and the superficial similarities tend to cause confusion.
c on a PC is very different from c on microcontroller for the reasons described.
if you want to learn c, best start on a PC and work on that. if you want to use the prop, best start with spin. c on the prop will be a bit further down the road, as you have to go through two learning curves to get there.
http://www.pellesc.de/
Just look at and search for GCC (which includes ANSI C and optional C++). It really is not so much that the programing language might vary. The guts and glory of C is in the Libraries that handle specific aspects of computing. If the Libraries are non-standard, you have to re-write the code to move over to something else.
Most of the annoying study is caused when using Microsoft and the Windows environment. Why so?
GCC was created for Unix/Linux and the Apple OS is a variant, but all three do use the Unix type file system. Microsoft started out by ignoring Unix and had a simpler file system based on CP/M. It has become more Unix-like, but due to competative antagonisms -- it will never be 100% compatible with Unix.
And Unix was orignially married to C. So if you want C in Windows, and then later want the 'real C'; you are going to have learn the MS way and the Unix way.
MS feels that it just has to always make its users feel dependent and afraid to stray into free-ware provided by Linux. Alternatively, you can use Ubuntu Linux or even Puppy Linux on a LiveCD to program and compile in true Unix based C on a computer that has only Windows installed. These LiveCDs can be used in a way that never affects your installed OS or hard disk.
But since PropGCC uses FAT32 files systems, and not Unix/Linux file systems, there may be nothing really gained by learning C in Unix/Linux OS.
Just don't feel daunted by the idea that the first C you learn on may require later study to be used on whatever is your target device. This is a common situation.
http://personal.ee.surrey.ac.uk/Personal/R.Bowden/C/dos-gcc/index.htm
1. It allows larger memory models and it can use memory differently, more fully than Spin.
2. It may run a bit faster than Spin code.
3. The C libraries that do work with the Propeller allow you to acquire knowledge that can be applied to any other device that compiles C.
I would put it totally the other way around. Spin is nothing like C to look at. White space block delimiters in stead of curly brackets. The lack of extraneous round brackets, the way local variables are declared, the object "dot" notation, etc etc.
However conceptually they are very similar. They are both simple sequential block structured languages in style of Algol, Pascal, PL/M and many others of that family. They encapsulate the basic ideas of simple program flow, sequence, selection and iteration. Along with subroutines and local variables. Basically if you know one language in the family all the others are easy to pick up.
If you were to ask me what is a very different language, one not in that mould, I might say;
JavaScript: Looks like C, but don't be fooled. With its first class functions (functions as data), lambdas, closures, garbage collection, prototypal inheritance and odd scoping rules it is a lot more of a language than C and enables very different programming styles.
Lisp, Scheme etc: All of the above but with an unreadable syntax.
VHDL, Verilog: Massive parallelism on a statement by statement, operator by operator basis.
Prolog: Rule based. Never did get my head around that,
Let's say "may be very different". The language itself is the same. I have programs that run on the Prop or PC without change. There are examples in the propgcc project.
Of course the environment, libraries etc can be very different. No worries, Spin as a language has none at all.
http://www.lysator.liu.se/c/bwk-tutor.html
If you print it out, it is about 25 pages long and the first 16 pages or so cover all the basics that you can do with a BasicStamp in PBasic. The rest deals will more advanced features.
I personally find it easiest to first read a short intro such as this, then a longer text.. say 100 to 200 pages; and to finally be willing to explore the big books. Starting out with big books is a huge burden and really counter-productive.
The ANSI C Manual: 2nd ed. by Richie and Kernighan would be may choice of a 100 to 200 page text.
I know these books are old... but these are written by the guys that created C and they are much shorter than all the nonsense written today. One really can get up to speed much faster by going back to them.
There are not as many drivers for C as there are for Spin. More are being written but there are some gaps. For instance, if you want a servo driver, I'm pretty sure you would find a Spin one in the Obex. But you might not find one so easily for C.
There is some very clever code that can translate Spin into C and in theory, that would mean the entire Obex would be available in C. But last time I checked it crashed (I think it couldn't handle the \ abort instruction).
Then there is the way one codes. In Spin, I tend to write code in Spin first, then translate that Spin into Pasm to make it run faster. The process for doing this in C is not quite the same but it is similar.
The really nice thing about C is that you can add external memory when the program gets too large.
The challenge (for all of us) is to turn C on the Propeller from something that is advanced, into something that is simpler to use.
So it would seem wisest to start with porting a PASM driver as your first choice from OBEX over to C. The task might be much simpler, as an instertion. And the performance better.
Besides, even if you want to learn C and ignore SPIN, you are likely to want to learn how to occasionally use PASM with C.
Of course, you can save your drivers as C libraries and make the changeover complete.
Maybe in future versions of the Propeller, memory, and performance, won't be the obstacles they are now for Spin (regardless of language, insufficient memory in particular is a Prop weakness). Otherwise, Spin is a perfectly fine HLL for learning and doing with the Propeller--and there is a ton of truly free, ready-to-use Spin code already available.