PDA

View Full Version : Starting to feel alone with my spin compiler.



Oldbitcollector (Jeff)
04-01-2009, 12:26 AM
With all this recent activity with two C compilers for the Propeller,
I'm starting to feel like I'm one of the last guys still holding onto his Spin compiler.

I'm curious (and perhaps this could only be answered officially) if there
will be a push toward C over Spin in the future of the Propeller products
to align it more with industry standards.

Should I be purchasing C books now?

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?

Visit the: The Propeller Pages (http://www.warrantyvoid.us/tiki-index.php?page=Propeller) @ Warranty Void.

jazzed
04-01-2009, 12:41 AM
OBC,

You have nothing to fear :) C can't really compete with SPIN until someone comes up with a C that produces code as compact as that produced by SPIN. Even then SPIN is the officially supported language for Propeller. Your "push question" is obviously for Parallax.

Knowing C will allow you to look at other opportunities in programming including writing Linux or Windows applications. Why not learn it on your favorite processor? There are many C educational resources and tutorials available free on the web.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve


Propalyzer: Propeller PC Logic Analyzer (http://www.brouhaha.com/~sdenson/Propalyzer)
http://forums.parallax.com/showthread.php?p=788230 (http://forums.parallax.com/showthread.php?p=788230)

Phil Pilgrim (PhiPi)
04-01-2009, 12:46 AM
OldBitCollector said...
Should I be purchasing C books now?

No — unless you have a pointy-haired boss who has a low comfort level with anything new, like Spin. http://forums.parallax.com/images/smilies/smile.gif

Spin was designed for the Prop. It's not going away. And assembly is still the best choice for performance-driven apps.

-Phil

Mike Green
04-01-2009, 12:57 AM
Spin still has the advantage that it's well matched to the capabilities of the Propeller and its native instruction set. The programs produced are very compact and fast enough for most uses. For example, a Spin-only program can easily do 9600 Baud serial I/O, control 8 servos, process GPS info and still have a few cogs left over.

A modified Spin bytecode interpreter, optimized for C could certainly be done and would solve many of the shortcomings of the existing C compiler (and their LMM interpreters), mostly that of memory hungry programs in a small memory microcontroller. A mixture of bytecodes / LMM / native code would be ideal. You need a good optimizer for LMM and native code to be practical and only ImageCraft's compiler has that at present.

What I'm implying is that C will continue to be a secondary programming language for the Propeller, but that Spin with a little bit of assembly will continue to be the primary language.

I do think you should buy an introductory C book and start experimenting with it. There will always be applications where Spin is just too slow and it's too much trouble to write something complicated in assembly while C and LMM is just perfect for your needs.

heater
04-01-2009, 01:47 AM
Yes you should be getting into some C books. After all you may want to program a PIC or AVR or, dare I say, it a Z80 one day. Ouch .. stop throwing those shoes at me. Second thoughts, learning C is a good idea, learning it with ImageCraft or Catalina on the Propeller may be a whole lot easier. No fighting with all those millions of special purpose registers and interrupts and...

I don't see any need for SPIN to take a back seat. The Propeller and PASM and SPIN are in perfect harmony. SPIN is an excellent language for those new to programming or just new to programming micro-controllers. I certainly prefer it to BASIC. It is compact. It's a tad slow but that is balanced by the fact that PASM is also easy to learn/use (compared to many other assemblers) when needed.

We have 8 COGs at a time to play with. A different language on each one I say:)

Trick is to get all these different languages to talk to each other easily.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Bill Henning
04-01-2009, 01:49 AM
Obc,

I've been programming in C practically forever (I think I started in '79 or '80), and one of the driving forces behind coming up with lmm was to see about a possible C port.

However something strange has happened... I got used to Spin, and like it for quick prototyping.

Mind you, I think Spin has some flaws that should be addressed:

- string handling is horrible, I hate string(). Since "a" is used for char constants, a future rev of spin should use 'this is a string return its address' instead of string()
- since floating point constants are implemented, I'd like to see a 'float' data type and at least + - * / remainder == <> < > => =< support
- some way of having shared libraries, too much space is wasted if a library object is pulled in by several objects
- two/three dimensional arrays (bsc addresses this)

Future extension:

- data structures
- built-in debugger (ViewPort is good for this)

Regardless of my griping, I like Spin, and I am sure it will be around for as long as the Propeller is. I think it may even be easier for beginners than C.


Oldbitcollector said...
With all this recent activity with two C compilers for the Propeller,
I'm starting to feel like I'm one of the last guys still holding onto his Spin compiler.

I'm curious (and perhaps this could only be answered officially) if there
will be a push toward C over Spin in the future of the Propeller products
to align it more with industry standards.

Should I be purchasing C books now?

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com (http://www.mikronauts.com) - a new blog about microcontrollers

Phil Pilgrim (PhiPi)
04-01-2009, 02:04 AM
Bill Henning said...
I think Spin has some flaws that should be addressed ... some way of having shared libraries, too much space is wasted if a library object is pulled in by several objects

Spin does that now. The code and DAT areas are shared; the VARs are not.

Playing devil's advocate to the C bandwagon now: I've been programming for forty years. I've never learned C, don't need it, and would never use it. The reason is simple: for any given processor, there's always a better option that's either more attuned to it, as a high-level language, closer to the metal, as an assembler, or provides higher-level services under the hood, such garbage collection, as do Perl and Python for the PC. C is attempt to have your cake (i.e. portability) and eat it, too (performance). At best, it's a poor compromise that I wouldn't waste my time with.

-Phil

Kye
04-01-2009, 02:27 AM
Personally if the spin language supported floating point and some of the data structures I think it would be fully better than C.

Comparing C to spin, spin if much better but lacking in a few things. If spin were made into a multi platform language with a portable interpreter I would use it always over C.

On of the best things about spin is that it allows you complete control in a more fundamental way than C. I also just love the way the code is structured.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

heater
04-01-2009, 02:53 AM
Gosh Phil "C is attempt to have your cake (i.e. portability) and eat it, too (performance). At best, it's a poor compromise..." Do you think we should let Linus Torvalds know that he's made a big mistake in writing Linux in C?

What language should we suggest he should have used?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

jazzed
04-01-2009, 03:03 AM
Perl :)

Languages are tools. Everyone has preferences. C has big short commings but can make many things possible too for many people. It's kind of like choosing between barter and money. If I make caskets and need bread, I may end up "using" one of my caskets before I find someone willing to trade for equivalent value of bread. C or other common languages enable a better use of resources for customers. If you don't need something that's fine too :)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve


Propalyzer: Propeller PC Logic Analyzer (http://www.brouhaha.com/~sdenson/Propalyzer)
http://forums.parallax.com/showthread.php?p=788230 (http://forums.parallax.com/showthread.php?p=788230)

Post Edited (jazzed) : 3/31/2009 8:13:46 PM GMT

Nick McClick
04-01-2009, 03:15 AM
I've learned php and java, but not really C / C++. I regret it - I'm playing with the AVR's and I'm at a total loss. I understand why SPIN is used on the prop (if it were C based, would I have picked it up?), but it's not portable. I agree with kye - it's a great low level language, just wish my spin skills were transferable.

I can't compare spin to C, but I find spin a nice transition from higher level languages; it retains some of the most useful oop stuff without a lot of conceptual overhead. And it feels fluid entering in and out of pasm.

I'm not familiar with other assembly languages, but is it as easy to mix high & low level languages like in the prop? I really like how I can run a fast pasm routine in one cog, and a SPIN control structure in another.

Another random thought - does anyone use the SPIN video commands? Maybe it's just me, but it seems that video's always done in pasm, anyway.

@jazzed - exactly; common languages means the developer doesn't have to spend 6 months ramping up. Maybe the SPIN divide is among hobbyists, who just enjoy learning, and developers who need to ship.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Gadget Gangster - Share your Electronic Projects (http://www.gadgetgangster.com) - Sign up as a Designer and get a free 4-pack of Project Boards!

Post Edited (Nick McClick) : 3/31/2009 8:22:53 PM GMT

hippy
04-01-2009, 03:19 AM
C brings with it the capabilities the language provides which exceed those of Spin in a number of respects ( notably data structures, function pointers and a wider range of types, especially floating point ) and it can potentially offer faster execution than Spin. On the downside, unless there is some leap forward, code density is unlikely to match that of Spin.

The Propeller is an unusual processor in that it has a small CPU (Cog) but lage shared memory, so it is ideally suited to small PASM/compiled programs or large interpreted programs, LMM being the halfway house; quite fast, larger programs. Spin suits that model very well, C not so well at present.

That's no reason not to pick up a book on C or having a go with the ImageCraft demo or Catalina.

One area where C would arguably be better for the Propeller over Spin is where execution from external memory is involved, and as the memory size of the Propeller grows it will fit better anyway. That said, LMM from external memory is possible and little reason that Spin could not be extended to use external memory either; it only requires the tools and someone to tweak the interpreter.

The best argument for C is that it is a convenient tool for generating LMM with.

I personally cannot see Parallax pushing C over Spin, and not on the grounds of pursuing industry standards - If they thought that way we'd likely never had the Propeller as it is, it would have been tailored towards C generated object code from the start. What I expect is more likely to happen is that the shortcomings of Spin are addressed.

Post Edited (hippy) : 3/31/2009 8:24:40 PM GMT

heater
04-01-2009, 03:34 AM
Kye, that's an interesting statement "...complete control in a more fundamental way than C". I'd be interested to see one example of what you mean by that. I have always seen C as about as fundamental as one can get without going to assembler.

However I may have to review my opinion there given the nature of the C implementations on the Propeller, but that is an implementation issue is it not?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

Leon
04-01-2009, 03:43 AM
With the right sort of architecture, such as ARM, C compilers can be nearly as efficient as assembler written by a skilled programmer, and will create much better code than most people can manage in assembler.

Leon

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle

Phil Pilgrim (PhiPi)
04-01-2009, 04:27 AM
heater said...
Do you think we should let Linus Torvalds know that he's made a big mistake in writing Linux in C?

That's water over the dam at this point. 'No sense rubbing it in. (Poor guy!)


heater said...
What language should we suggest he should have used?

Why, Modula 2, of course! http://forums.parallax.com/images/smilies/smile.gif

-Phil

RiJoRi
04-01-2009, 04:39 AM
With all this recent activity with two C compilers for the Propeller, I'm starting to feel like I'm one of the last guys still holding onto his Spin compiler.

I'm curious (and perhaps this could only be answered officially) if there will be a push toward C over Spin in the future of the Propeller products to align it more with industry standards.

Should I be purchasing C books now?

OBC

I'd be happy to see Spin moving on to other micros. Of course, the neat cog-specific stuff may have to go, unless they get modified into OS-type commands to create, activate, and kill threads, but that would probably mean the dreaded "I" word! (Interrupt http://forums.parallax.com/images/smilies/nono.gif )

As to purchasing C books, or learning the language, there are only two reasons for that: (1) you really want to learn the language, or (2) your boss says you must know C for your job. If you decide to get a book or twelve, also check out the "How To Avoid Sneaky Errors in C" types of books and magazine articles. (I like the errors like



while(1);
{
doSomething(); /* do Something */
doMore(); /* do Something else */
}



)

There! I've counseled OBC AND fed a Pet Peeve all in one posting! http://forums.parallax.com/images/smilies/shocked.gif

--Rich

Baggers
04-01-2009, 04:45 AM
OBC, Spin is here to stay, it's one of the major parts in what made the prop such a success, it's ease of use, it's compact size, both perfect matches for the prop :)
I will still use it quite often, moreso than C
Probably not as much as PASM :D but I'll still use it an awful lot.
Especially with my demos for PropGFX. ( other than a few FemtoBasicGFX ones obviously lol )

But, if you want to learn it for your own personal gain, then go for it.
You've learnt Spin, it's not a million miles away from that.
just remember ; at the end of a line and {} are used with (or instead of) indents.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite



Post Edited (Baggers) : 3/31/2009 9:51:09 PM GMT

mirror
04-01-2009, 04:48 AM
Hi Rich,

Love the error demo... very subtle.

My favorite was always:

if (i = 0)
{
doSomething();
}

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

RossH
04-01-2009, 05:10 AM
Hi OBC,

I think SPIN's role as the premier language for Propeller development is safe for a while yet.

But I'll warn you now - my next project is going to be an Ada compiler for the Propeller http://forums.parallax.com/images/smilies/freaked.gif

Ross.

Cluso99
04-01-2009, 06:43 AM
Answering a few things raised...

Maybe I should try and find the time to debug my fasterer spin interpreter - it's all but complete. From memory (I do have senior moments), my testing indicated about a 20% gain. I have a little space available in the cog, so some extensions could be done with LMM and overlay techniques. My overlayer will run at least as fast, if not faster, than LMM, but you need to have the space in the cog in the first place. Of course, the compiler(s) would also require the extensions.
I built a debugger for it, so it uses the output from homespun to trace spin (bytecode) instructions in the listing, and you can go down to pasm level debugging (within the interpreter or a pasm program), and it is zero footprint within the cog. The PC end needs some GUI work.

Personally, I've got by for 40 years without much C. It is to hyroglyphical (how the hell is that spelt?) so sometimes very hard to read by some who exploit it. I prefer assembler, although I've written quite a bit in VB some years back. However, lots of professionals think C should be available and these 2 compilers now provide that.

So, if it takes your fancy, learn C.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Links to other interesting threads:

· Home of the MultiBladeProps: TriBladeProp (http://forums.parallax.com/showthread.php?p=786418), SixBladeProp (http://forums.parallax.com/showthread.php?p=780033), website (Multiple propeller pcbs) (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index (http://forums.parallax.com/showthread.php?p=778427))
· Search the Propeller forums (via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

CounterRotatingProps
04-01-2009, 06:52 AM
> C. It is to hyroglyphical (how the hell is that spelt?) so sometimes very hard to read by some who exploit it. I prefer assembler

Had to chuckle when I read that, Cluso :) My handwriting has be compaired to assembler ... as in unreadable http://forums.parallax.com/images/smilies/wink.gif

From about 1988, I'd say, professional programmers had to know C - and it's still pretty much a requirement.

Venturing a tad off thread here:
Now if you really want to learn a cryptic language, try Haskell
For cool, really nice languages, try Ruby or, my latest favorite, Io - which combines the best of python, perl, ruby, and SmallTalk --- and yes, SmallTalk is still alive and doing well.

- Howard in Florida
(programming since 1974 - yikes!)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buzz Whirr Click Repeat

Oldbitcollector (Jeff)
04-01-2009, 11:11 AM
The general opinion is to learn a little C.. (Since I'm self-employed I don't have a pointy haired boss or TPS reports to fill out, so I have the time.)

I really wasn't considering it before, but Catalina has pushed me over the edge so to speak,
so I may be one of those who start with the "freebie" and move onto a more commercial
product like Imagecrafts if it sticks. So from a marketing standpoint, the "freebie" isn't a
bad thing to happen to Imagecraft.

OBC

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
New to the Propeller?

Visit the: The Propeller Pages (http://www.warrantyvoid.us/tiki-index.php?page=Propeller) @ Warranty Void.

Post Edited (Oldbitcollector) : 4/1/2009 4:25:02 AM GMT

QuattroRS4
04-01-2009, 04:04 PM
OBC,
Firstly - a good question. Personally, I learnt C a number of years back - old Dos based apps on P.C's and the dreaded PIC for control. Since I have been converted to the Prop in 06 - it has been all Spin & PASM for hardware - virtually no C .. My PC apps are mostly VB.NET now - that said - I have used C# for a number of apps (pretty nice). In terms of hardware - customers now seem to be more results driven - what the app was written in seems to be of lesser concern than before. I suppose I have been lucky that my customers have embraced the Propeller and thus SPIN/PASM as 'new technology' early on - based purely on results of the initial installations - since then it has been plain sailing! I wouldn't 'write off' the idea of using C - just wait until you want to 'port' some code to SPIN/PASM - it'd be pretty damn handy then. One of the best examples of this would be the Microchip enc28j60 - all available documentation and sample code was C based once the basic concepts were understood it was easier to port to SPIN .. I am sure 'Harrison' would agree. - Put simply - if you can program in SPIN you will have no issue with C - so why not !

Regards,
John Twomey

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Necessity is the mother of invention'

Those who can, do.Those who can’t, teach.

Robot Freak
04-01-2009, 04:46 PM
I started in 2005 with programming Lego Mindstorms robots.
After using the drag-and-drop language from Lego for about 2 weeks, then I threw it away and started with a C variation NQC (Not Quite C).

The possibilities of the Lego Mindstorms kit where not enough for me, so I bought a Javelin Stamp in 2007.
The Java language turned out to be a great language to structure sensor objects, behaviours and artificial routines.
One BIG downside: the price, $90 for just the processor.

In 2008 I bought a Propeller ProtoBoard, because of the active forum (Javelin forum is really quiet), low costs and high processing speeds.
The Propeller architecture is a great way to get things done in no-time but sometimes results in mind-breaking code constructions.

Now, in 2009 I study Electrotechnics in the Netherlands and have to learn about the ATmega32 microcontroller from Atmel with the C programming language.
The interrupts seemed very difficult because of all previous controllers didn't have them. Now I'm used to it.
Being back to the C programming language, I like it for the simplicity and the fact that it is available on almost all systems.
One microcontroller costs $3!!!

That looks a lot like I'm just posting my CV, but the above is just an explanation for the lists below.

My list of favourite languages:
- Java
- C
- Spin
- Drag-and-drop

My list of cost-efficient languages:
- C
- Spin
- Drag-and-drop
- Java

My list of nice-concept languages:
- Spin
- Drag-and-drop
- Java
- C

BradC
04-01-2009, 06:54 PM
Robot Freak said...
The Propeller architecture is a great way to get things done in no-time but sometimes results in mind-breaking code constructions.



Wow! Mind-breaking?

I guess I'm lucky in that I come from a Pascal and assembler background, but I find SPIN incredibly natural. I've really not come up against anything I had to try and mangle the language to work around. PASM is so simple, deterministic and orthogonal it's a doddle compared to most of the other chips I've played with.

C is great 'n all, and I've learned it so I could do some linux kernel stuff and a few other open source projects here and there, but I've never found much of a use for it myself outside of that.

Frankly I tend to think if the only tool you know how to use is a hammer, everything looks like a nail. Learn everything you can get your hands on and always use the right tool for the right job. I don't *always* do that, and I have a ~2,500 line bash script here to prove it ;)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cardinal Fang! Fetch the comfy chair.

Kye
04-01-2009, 08:53 PM
So @heater, what I meant by spin has more fundamental control is that there are no data types.

I hate data types, after you know enough to understand every thing at the lowest level I find them quite reprehensible.

I mean, when you just waht to pass bits in a long arround spin beats plain old C.

No casting, no data type mismatch, just pass variables.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Mike Green
04-01-2009, 10:07 PM
Kye,
Type checking has benefits even though it seems to create more work. I've written large programs in C and in an extended Pascal designed for systems programming. The type checking in the Pascal helped me with bugs more times than you might expect. There's a sort of "do you really mean to do that?" that the compiler can provide with the additional information and it also helps with the compiler's ability to optimize the generated code. This is particularly important when you use pointers ... a major source of bugs ... and power.

bambino
04-01-2009, 10:26 PM
I was vb when vb wasn't cool. I went to java for an elective because I had already taken arobic walking and c wasn't offered.
When I got my first pic, I found C to be pretty simple to understand after having taken java, but everywhere I turned their was some sort of error. This library, that library, blah, blah. I actually finished one app with C, but then along came the prop!!!!!

I can honestly say now that I don't know how to use C. Or java for that matter! Ocassionally I play with Pbasic and VB6 and VB.net but even if I knew C I don't have all the other credentials that would get me hired as a C programmer. If ever I got to where one Propeller couldn't handle the situation I would throw another prop at it before I put my head thru C again. Not because of it's syntax, but because of all it's parameters. Large code, small code. It was basically the fact that the compiler IDE itself assumed that I knew what it was saying. Yes there were some explanations of stuff in the compiler, but what they didn't explain made me feel like a real dumb...
I'm not saying anything about Imagecrafts attempts towards the prop, frankly I haven't looked at it. But spin is good and Pasm is better.

I just want to have fun and make killer apps! Going back to the drawing board just to keep my anti-drug hobby makes arobic walking look alot more appealing!

Kye
04-01-2009, 11:26 PM
Oh, I understand the benifts of type checking, its just tedious work.

Type checking has helped me too before when working in C, but for the most part its added overhead I have to think about when writing code.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

heater
04-02-2009, 02:53 AM
There's the thing Kye, you have to think about types when you are coding. NOT during the long hours of frustrating debugging:)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.

CannibalRobotics
04-02-2009, 09:01 AM
OBC,
Hang on to Spin. I've climbed mount C several times for specific projects but it has it's limitiations too. I've never seen a successful uProcessor controller product that did not have a couple of levels of languages to meet different development demands.
Jim-

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Signature space for rent!
Send $1 to CannibalRobotics.com.