C & Spin translator needed
I have been trying to learn C programming. I know how to program in spin and would like to be able to have some sort of reference that would translate somewhat and explain the differences between the languages.
Has someone done this already in some other place?
It seems like this could be beneficial to all new spin learners as well.
Has someone done this already in some other place?
It seems like this could be beneficial to all new spin learners as well.
Comments
Anyway, it's probably easiest to just buy a couple of begining C (or C++) books, and learn from that. You'll be able to compare what you know to what is written, but without the older language getting in your way. If you're looking for a guide that compares the two, I think you're out of luck. First, the Spin language is relatively new and fairly limited in it's impact on the computer world, and I think most Spin publications (how many, like 3?) are focused on learning the language, not on helping you learn others. Also, although they may be similar in some ways, they do fundamentally different things: Spin is for dirrectly interfacing with electronics and working with I/O pins, while C++ is more concerned with the traditional algorithms and GUIs associated with desktop computers.
BTW, I'm going the other way: Java -> PBasic -> C++ -> Spin
Whitespace (CR, Tab, space) in Spin matters to associate commands together, while in C++ whitespace is merely to make it format nicely; all the association is done in other ways.
C++ prefers to use as many local variables as possible, while Spin uses global.
C++ is not broken into blocks like Spin
Spin does not have a GUI system like C++ (at least not as advanced)
C++ is much more difficult to learn, and has many more variations, than does Spin. It also doesn't have a true central authority or reference on the subject.
C++ is not limited (in any practical way) on memory or space requirements
C++ and Spin both have pointers
C++ does not limit the number of Objects created, while Spin does (based on Cogs)
C++ objects may emulate a real world object, but they don't generally interface with them like in Spin.
C++ is more difficult to get up and running when compared to Spin
Spin is more expensive ($100 for demo board), while C++ can be free (see the Borland or GCC compilers and IDE)
Objects in C++ are broken into two files: a header file (.h) and a CPP file (.cpp)
There is no version of assembly language in C++
______________________________________________
I hope this helps.
SRLM
I am using a pic24 starter kit and to follow a path through the software is somewhat difficult.
I have even considered sticking with assembly but there is very little documentation for usb and misc in assembly.
Thanks for the above. Every little bit helps to bring it all together in the mind.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
If you get down to just the basics there's very little difference IMO and I would say mainly in the syntax department ( how code is actually written ), the way pointer use is coded, and the greater number of variable types that C has.
Most Spin constructs have an equivalent in C and the same functionality can be achieved although the code may look very different as a result. I'm not sure it's that useful to have a guide to similarities and differences of C to Spin as it's really more about knowing how to achieve a result in either language.
I'm not proficient in C, don't particularly like it as a language ( even more so for C++ ), but have had no problem in using C for some PICmicro projects. I've generally used it ( B Knudsen Data's CC5X and CC8E ) as a super-Assembler which suits me fine as I don't like the PICmicro assembler instruction set. With just a basic knowledge of C I've had some quite impressive results which would have taken much longer in assembler with all the advantages a high level language brings.
I've not used Microchip's C ( not that keen on MPLAB other than for simulation and debugging ) and it may be worth looking at alternative C compilers if there are any which offer different flavours of C or alternative development environments. If you are using Microchip C code then it's likely that you'd be better of using Microchip tools.
Learning any language can be difficult if you dive in at the deep end. Perhaps try some simpler things first then once you've got your foundations sorted you can build on that and more complicated constructs become simpler to understand.
Another thing I have to say is the microchips forum doesn't seem to be very helpful. There is around 70 different english forums to decide from. The parallax forum is much more active.