Should I be learning C?
DynamoBen
Posts: 366
So I'm noticing an increased focus on C by Parallax which got me thinking, should I be learning C? While we can debate the merits of C over Spin what I'm wondering is if future products like the Prop II might be based on C over Spin. If so then learning C now with the Prop I would be wise. Thoughts?
Comments
http://forums.parallax.com/showthread.php/160359-C-You-Later
This being said, Parallax has not, and will not, reduce its support and investment in Spin (the PropellerIDE project and new Jon Titus book are examples of recent Spin initiatives). Supporting multiple programming languages with our products naturally becomes a balancing act as we try to accommodate and account for the needs of every audience, from educators, to DIY hobbyists, to commercial customers.
Which language(s) you choose to learn and program in should ultimately be your decision. From a personal standpoint as part of the education team here at Parallax, I would be thrilled if you gave our Propeller C Learning System a chance, but the goal of providing you with multiple options is to allow you to customize your own experience with our products.
C was developed at a time when it was needed to serve mainframe computers that needed portable programs... mostly single CPU machines that were shared by many. Then it became the mainstay of computers with OSes. The Propeller 1 is a microcontroller that generally is used without an OS.
While the C language itself is fairly straight-forward -- the libraries are architecture dependent and that pretty much breaks the ideal of portable programs. Also, the Propeller has 32Kbytes of hub ram, which is very tight for modern C applications.
I tend to feel that C will perform better on the Propeller 2 (which is supposed to provide 512Kbytes hubram) and it is still worth focusing on SPIN and PASM to get the most out of the Propeller 1.
OBEX is a mature and useful reference resource for SPIN and PASM.
============
I had some high hopes of simple porting of Arduino programs to the Propeller, but the Arduino programs can come from all sorts of Arduinos - some with far more resources than the Propeller 1 AND the so-called Arduino code may have been yet another C program that is not original to Arduino. So things can get heavily bogged down in trying to transfer programs that seem quite simple from Arduino to the Propeller.
Some C programs may transfer nicely, but many are far more than most can handle. You will find yourself dedicating a big chunk of time in learning the ins and outs of C compiler error and warning messages. Spin will seem heavenly.
So at this juncture, I just don't see much advantage for myself. I end up in an endless maze of GCC and C++ documents from many different sources and projects often die in confusion.
***********************
If you desire to learn C on the Propeller, use the Propeller tutorials and the Propeller Simple libraries. You will get a lot further in a shorter amount of time.
And don't expect to get much done with floating point. Beginning C users seem to never realize that integer maths (signed and unsigned) are much faster and waste less resources.... they don't have to on a big desktop. But floating point libraries on the Propeller tend to demand a lot. The Propeller is a microcontroller, not a microcomputer. It doesn't have 4Gbytes of Ram and a math co-processor.
+++++++++++++++
In other words, if you learn C in the Propeller way, it can be delightful. But trying to learn how to master C for many different platforms as a means to borrow code for the Propeller can be quite daunting.
If you have an end goal that includes <insert language>, then you will be motivated, so go ahead and learn <insert language>.
If you enjoy exploring and playing with different languages and have the time, then learn <inset language>.
As Courtney said, C is considered a foundational programming language. So it is good to learn it to some degree.
If your goal is a Propeller project, then Spin could be your better choice. Unless someone fires Chip, I doubt if Spin will become a non-player on any Propeller.
Whatever language you choose, your underlying goal should be to learn to program. Languages change and you end up learning (and forgetting) many. The underlying programming concepts are relatively transferable.
I do not know why everyone is beating around the bush, instead of giving you sound advice. With C or C++, you will have a vast array of resources to pull from and it may even be an overwhelming amount resources. It is always better to have more than not enough. Additonally, by gaining C or C++ programming skills, you can apply this knowledge to many different aspects of programming, from personal computers to a wide variety of microcontrollers.
Not that I have anything against SPIN, because I like the language a lot, but the resources and documentation are limited to basically parallax.com, and odds are that you will never use the SPIN language on anything besides a Propeller microcontroller.
Of course, you will have to decide for yourself, what is important to you, but from my viewpoint, by learning C or C++ you will most certainly be upgrading your skillset, as well as having more resources at your disposal.
Bruce
1) There is already a C/C++ driver for it
2) There is an OBEX object that is easy to port and you're willing to do the port yourself
3) If both of the above fail, post your needs here and someone will probably help you
4) There is a C/C++ driver that is incompatible with the Propeller, but can easily be ported, and you are willing to do the port yourself.
My programming "roots" were in BASIC many years ago, which led me to the BASIC Stamp, and then PICBasic. When the Prop was introduced I taught myself Spin which lead to Python. So as others have suggested, and I agree with, while the language may change the concepts remain the same.
Given that Spin is here to stay I think I'll stick with it, but might dabble in C as time permits. Thanks for the input!
The answer is always yes!
~A devoted fan of C++ on microcontrollers
And on a more serious note...
I'll give some relevant background about me:
I love C++ on the propeller because...
So... choose for yourself. But be sure to choose C++ and PropWare.
I think this is the coolest thing I've heard someone do with C/C++ on the prop! Good job!
Yes of course you should learn C. But more on that later.
Spin/PASM on the Propeller is a wonderful thing but in no way is Spin similar to Python. Spin does not have tuples or dictionaries or lists. Spin does not have first class functions, or lambdas. Spin cannot do this: I could continue. Apart from the white space indentation Spin and Python have almost nothing in common.
You have BASIC, Spin and perhaps Python under your belt. That is good.
Certainly you should learn C as a prime example of "imperative programming". It's very commonly used and very useful.
You should look at one, and only one of: C++, Java, C# and others as a view of object oriented programming.
Then then have a look at Haskell for an idea about the "functional programming" approach.
Have a look at Scheme for an idea of how simple and powerful a language syntax can be.
Look at Forth, stack based systems are a concept to behold.
What I am saying here is that there are many different ways to look at programming and it's interesting to explore them.
As a practical matter, if you are using a Propeller use Spin and PASM. If you are using an Arduino use C++. If you are using a Raspberry Pi or whatever you have a lot more choices. If you want to make use of the huge array of C/C++ code out there change to a chip that can run it nicely.
Either way the more you learn the more you will know what to use when.
I said capacity not memory because I never completely understood the cause of my problems. My the user interface code uses several linked lists and a large state machine. I was experiencing a lot for strange problems as I increased the size of the state machine and heavily exercised the linked lists. Increasing the stack size was not the answer. I asked for help on the forum and it was suggested that I was banging up against some limits in garbage collection. All my problems could have easily been of my own makings, however, the code does run fine on the bone.
I am not complaining, I really like the prop and propGCC. I was attempting to do something on it that it was not designed to do. Plus, I wanted to see if I could distribute the application across the two platforms.
Let's not forget that I wasn't so much interested in a debate about the merits of C, I'm well aware of the merits was just wondering about the future direction of Prop when it came to languages.
Your opening question gives no hint that you are "well aware of the merits". After all, if you have to ask "Should I be learning C" that implies you do not know the merits or otherwise of C. So forgive any misguided replies.
Let's get to the next part "...if future products like the Prop II might be based on C over Spin."
I do not believe so.
The Propeller and the Propeller 2 are the visions of one man, Chip. That is not just the chip architecture, it's the instruction set, it's the Spin language, the Spin compiler, the byte code interpreter, it's the Propeller Tool.
Spin/PASM is not going away with the P2.
If the Prop II was emphasising the running of C code efficiently it would have a very different architecture.
Sorry, I guess I could have been clearer. I know what it's like to ask the "which language is better" question so I try to avoid that, I was just wondering if C was the future of the Prop which seems to not be the case. Thanks!
May I suggest...
0) Put on your big boy/girl pants and write the object/library yourself.
Only if that fails -- after a serious attempt -- should the next steps be considered.
Wait... what? There is a team of internal and external resources that are making sure anyone who wants to use C with the Propeller has good tools to do that. The great news is that it's a choice, not a mandate. I don't like C, and unless forced to use it I don't. All of my professional development is in Spin and PASM. It works for me.
Now take a bloke like Peter Jackaki. He loves Forth so much that he created a kick-@ss Forth environment for the Propeller (he's not the first or only, his project, Tachyon, seems to have the most coverage). Bean created PropBASIC.
As David pointed out the Propeller architecture is very flexible; this allows -- maybe even encourages -- the development of a variety of tools for it.
If you want C, you've got it and will aways have it.
I take strong issue with that. Some people are here to learn programming, and thats AWESOME! Others just want to turn a lamp on automatically in their house. They couldn't care less how it's done, but a Propeller seems like a good idea. I think that's equally awesome, and I don't think they should have to even attempt to write their own drivers if someone else already did it.
a big thing about the Prop is that there is a huge pile of working objects in OBEX and elsewhere that make what you want to do easy.
Not only that, but unlike single core devices, you can mix and match many such objects in your project without them tripping over each other timing wise and failing to do what you expect.
I have to say I have no idea if such a variety of "plug-n-play" libraries exist for C on the Propeller yet.
The real reply is that any microcontroller that provides C or C++, also has an Assembler available somewhere in its toolkit.
In this case, Parallax provided SPIN as an enhanced IDE inclusive of an Assembler, and has made a genuine commitment to C in order to be a part of mainstream coding.
So at this point, I suspect that Parallax will always have both The SPIN (with PASM) and C. These are generally accepted as a minimum set of programing tools for educational and industral uses.
More debatable are other programs --- Basic, Forth, Python (Heater is passionate about Python), etc. These are the one's that might fade in and out from time to time-- much depends on an independent contributor's abilities and resources.
C or C++ can be used on just about anything out there.
If you're dedicated to Propeller, like me, then you only would probably need C if you want to try to get someone else to use your project.
I'd say it's always a good idea to learn C, all technical reasons aside, it is in my opinion one of the most highly transferable skills an engineer can acquire. I cannot think of a single industry that does not make good use of the C language in one way or another and "time served" in C programming is a very significant benefit for prospective employers.
Get a good knowledge of C and you'll find that other technical skills become a lot easier to accumulate. You'll be set for life if you get good enough at C
If you are NOT a CS major and are learning C, their is no one to teach you good practices, and you may develop them yourself if you are very brilliant (as did many of this forums members and many programming professionals). On the other hand, you may develop -attrocious- habits like many self taught hacker and many programming "professions" did and still do.
To a programming professional the selection of langauge and hardware are arbitrary, and are dictated by the current projects need. If one only has knowledge and expertise with a single tool, one is less flexible and at a disadvantage for large and/or complex projects.
So the answer is "depends on what you are planning to do", which determines what you need to understand.
Since you've already learned several languages then why not give C a whirl. C is used all over the place so you will encounter it sooner or later.
Also, many new devices and accessories are designed for the Arduino which uses C, and most chip companies will have sample C code for using their products.
Propeller C has only been around for 1-1/2 years while Spin and PASM started when the Propeller first came out.
Andy Lindsay wrote the Propeller C Tutorial on the Learn website and he is very good at breaking down things into manageable bites.
I learned C years ago but only used it once for a class. Andy even makes pointers look easy (pointers "point" to the memory location or value of a variable).
Now we have the best of all worlds; C for those who like C, Spin for those who like Spin, etc, etc.
Imagine going to Italy and telling everyone you met that they really should speak english because it's better. They'd look at you like you had two heads!
Sandy
I'd also say give plain old C a shot.
At its core, its really not that difficult aside from some ; and { rules.
I think you can even forget Pointers* and such initially and a quick google turned up this:
http://www.embedded.com/design/prototyping-and-development/4006703/Saving-space-with-Pointer-less-C
FWIW, you can get the K&R C bible from ebay or Amazon used books for $12 or so, many students just get rid of them after their first/only C class.
Or, if you want something a little less dry, with a more superficial entry, try one of Dan Gookin's C for Dummies. Can also be found cheaply.
I found CfD pretty nerdishly funny, quite a bit longer than it needed to be (but maybe thats better for beginners), and definately far less depth by an order of magnitude than K&R.
But don't take my word for it, take a look for yourself: http://www.control.aau.dk/~jdn/edu/doc/arduino/litt/CForDummies2.pdf