Shop OBEX P1 Docs P2 Docs Learn Events
Only to know about C program ( using Propeller) — Parallax Forums

Only to know about C program ( using Propeller)

markustermarkuster Posts: 184
edited 2009-10-20 10:30 in Propeller 1
Hi

Only to understand why I have to pay if I want to use
C with the Propeller and if I use an other microcontroller
the C is free.

Sorry, but I don't understand.

Do you know?

Thanks, Mark.

Comments

  • BradCBradC Posts: 2,601
    edited 2009-10-17 17:09
    markuster said...
    Hi

    Only to understand why I have to pay if I want to use
    C with the Propeller and if I use an other microcontroller
    the C is free.

    Sorry, but I don't understand.

    There is a *free* (as in both beer and the other one) version of C for the Propeller in addition to the commercial compiler.

    The reason you get a free compiler for the other microcontroller is someone has written one (or modified one) and given it away gratis.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    lt's not particularly silly, is it?
  • LeonLeon Posts: 7,620
    edited 2009-10-17 17:17
    C compilers often have to be paid for, for other MCUs, although free versions with some features missing may be available, as well as open source offerings.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-17 17:35
    There ain't no such thing as a free lunch (TANSTAAFL!)

    BradC is basically correct. Because of the open-source movement and Linux, there are a number of toolchains for building compilers, particularly C compilers, available for people to use. These have been applied to many different processors. Even with the toolchains, it's very difficult to make a good compiler (one that produces compact, efficient code) for a microcontroller. Some companies (like ImageCraft) have done this and done it well and expect to be paid reasonably for their efforts. In other cases, a large manufacturer has done the work in-house like Microchip and distribute their compilers for free or inexpensively as a way to get people to use their chips. Keep in mind that C is not the best language for most microcontrollers although it's not bad and is the "Lingua Franca" of the computing world.

    Parallax is a small company that has developed a unique microcontroller. In the process of developing the hardware, they also developed their own programming language (Spin), well matched to the hardware. Among other things, it enables an efficient interpreter to be wholy contained in the local memory of any of the processors on the chip. The IDE also includes an assembler integrated into the compiler. It might have been possible to develop a C compiler for this interpretive code, but it would need non-standard extensions to efficiently make use of a lot of the features of the hardware and it would have been a problem to give up some of this efficiency in trying to keep to the C standard for the initial development system.

    Parallax itself does not have the resources to support a 2nd language and development system. ImageCraft, which has commercial compilers for other platforms, took a chance and, using their toolchain and expertise, produced a C development system for the Propeller that's available inexpensively. Since then, one of the forum members took an open-source C compiler toolchain and developed a code generator and basic library that's now available for free (Catalina). It doesn't generate as efficient code as ImageCraft's, but it does have some unique features like multiple code interpreters including one for large external RAM. Both ImageCraft's compiler and Catalina produce interpretive code that's mostly the same as the Propeller's instructions (called LMM - Large Memory Model) and can be interpreted several times faster than Spin, but take several times the amount of memory for the same functionality.
  • jazzedjazzed Posts: 11,803
    edited 2009-10-17 19:36
    markuster said...
    Hi

    Only to understand why I have to pay if I want to use
    C with the Propeller and if I use an other microcontroller
    the C is free.

    Sorry, but I don't understand.

    Do you know?

    Thanks, Mark.
    GNU already has support for most microcontrollers (not Propeller), and GNU is free.
    Parallax is a private company that relies on others' contributions, thus Catalina (free) and ImageCraft C.
  • waltcwaltc Posts: 158
    edited 2009-10-17 20:23
    markuster

    Imagecraft has a fully functional 45 day version of their C compiler for free, after that there is code size is limited to non-commercial use.

    Can't go wrong with using their product.
  • ericballericball Posts: 774
    edited 2009-10-18 16:30
    markuster said...
    Only to understand why I have to pay if I want to use C with the Propeller and if I use an other microcontroller the C is free.
    Just to supplement Mike's explanation - C is typically a poor fit for the Propeller and the Propeller is a poor fit for C. C programs typically assume they are running on a single processor with a large amount of memory (often backed up by virtual memory). But the Propeller has 8 independent processors each with a very small amount (496x32 bits) of local memory for each processor and a small amount (32Kbytes) of shared memory.

    The Propeller also has an onboard SPIN interpreter. The SPIN language was developed for the Propeller, so it is a good fit for the hardware.

    So while C compilers have been created for the Propeller, there are significant advantages to using the "native" SPIN and assembly languages.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • waltcwaltc Posts: 158
    edited 2009-10-18 18:04
    C isn't a poor fit for micro-controllers, parallel or multicore processors for that matter, nor does it require VM(only if you're running Windows or Linux). Heck C has almost become the defacto language for programming micros today. You won't find a evaluation board for the newest 8, 16 or 32bit micro that doesn't include a C compiler with it. The problem is that C just doesn't really fit the Propeller due to its weird architecture. You either go the bytecode or PASM route.
  • RossHRossH Posts: 5,516
    edited 2009-10-18 23:04
    Hi Mark

    There is a free C compiler for the Propeller - called Catalina. It is not supported, sponsored or endorsed by Parallax in any way, but it works quite happily nonetheless smile.gif

    Both compilers significantly outperform SPIN in terms of program execution speed, but both generate much larger executables than the SPIN equivalent.

    Whether you would be better of with Catalina or with Imagecraft depends both on your needs and your budget. Imagecraft is a reasonable deal for hobbyists if you don't mind code size limits - both the code size limits imposed of the the "free" version of Imagecraft, as well as the code size limits inherent in a compiler that must fit its code and data entirely within the 32k available internally on the Propeller. Catalina can run programs with code and data size up to 16Mb by using external RAM (several hardware platforms with external RAM are currently supported, more are being added). Catalina outperforms Imagecraft on some benchmarks, but generally doesn't do as well as it in both speed and code size (but it's improving all the time).

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2009-10-19 01:01
    PASM is the best way to program the propeller IMO.
    SPIN is great but not super speedy compared to PASM.

    If you are going to use the propeller for serious work
    then you absolutely must become comfortable in PASM.

    An hour a day for a few weeks will get you well into PASM.

    The unique qualities of the propeller are worth spending the
    time to learn PASM, trust me on this smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Where am I? Where am I going? Why am I in a handbasket?"
  • Dave HeinDave Hein Posts: 6,347
    edited 2009-10-19 15:09
    ericball said...

    Just to supplement Mike's explanation - C is typically a poor fit for the Propeller and the Propeller is a poor fit for C. C programs typically assume they are running on a single processor with a large amount of memory (often backed up by virtual memory). But the Propeller has 8 independent processors each with a very small amount (496x32 bits) of local memory for each processor and a small amount (32Kbytes) of shared memory.

    The Propeller also has an onboard SPIN interpreter. The SPIN language was developed for the Propeller, so it is a good fit for the hardware.

    So while C compilers have been created for the Propeller, there are significant advantages to using the "native" SPIN and assembly languages.
    A·C program could do anything that a SPIN program can do, and just as easily.· Most processor manufacturers provide a C compiler as part of their standard development tools.· Processor-specific features are implemented as intrinsic function calls.· Quite often, these are converted directly into assembly instructions rather than actually calling a function.
    I'm not sure why Parallax chose to create the SPIN language with it's unique syntax elements and its arbitrary indentation requirement.· Much of the SPIN syntax is similar to C, but it requires the programmer to memorize a whole new set of language quirks that are specific only to SPIN.· There is an incredible amount of open source code written in C.· It would be much easier to port open source C code than convert it to the SPIN language.
    The only reason that I can see for inventing a SPIN language was to control what could be done in the language so an interpeter would fit in a COG's memory.· However, I think the LMM C compilers will eventually eliminate the requirement to write programs in SPIN.
    Dave
  • potatoheadpotatohead Posts: 10,261
    edited 2009-10-19 15:40
    Well, not to start a language war, but I have to comment on "easy" and C vs SPIN. SPIN + PASM is really easy to do most things, and it's very efficient. At the end of the day, if you want to really push the chip, SPIN + PASM is going to deliver the most. If you just want some quick stuff to happen, or tinker, learn, etc... the combination is also quite effective, particularly for those people without a lot of C experience.

    SPIN has less "baggage", which makes it "easier".

    These things make the Propeller really accessable, without a huge investment in time, tools and such. The unique design of the chip more or less warranted an environment for it. Let's say C was the default, as shipped, programming environment. A quick look back through the pioneering times would have shown quite a few new comers, myself included, not having quite the good time of it they did otherwise. That's SPIN + PASM in play here, and that's a strong differentiator for the Propeller. The cost, is having to learn a thing or two, but the pay off is a nice, simple, rapid dev environment.

    For seasoned pros, or those with limited experience outside of C (and do those people exist?), it's a bit of a burden for the learning. I see that. But I really can't warrant "easier" because of it. IMHO, too many factors in play.

    **And I like C and have some moderate skill with it. SPIN + PASM is cake by comparison, in a whole lot of ways. The primary one being it's just so low overhead. That comes with no structures and such, but it also means just more or less writing something, and that product being close to what is really needed to run it. Where C does require a bit more investment to accomplish the same thing.

    One final thing, given the limited memory available, not having SPIN would be a huge disadvantage. SPIN runs at about the same speed as older chips run assembly. (I'm talking 8 bit computer assembly) That's plenty fast to organize and control things at higher levels, leaving PASM / LMM to do the grunt work. With that in play, a whole lot can be done in the 32K. I guess that can stand as to why it was done. Best use case for the chip resources kind of thing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
    Safety Tip: Life is as good as YOU think it is!

    Post Edited (potatohead) : 10/19/2009 3:46:29 PM GMT
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-10-19 15:58
    Doug (Mr. Potatohead [noparse]:)[/noparse]> That's SPIN + PASM in play here, and that's a strong differentiator for the Propeller.
    > The cost, is having to learn a thing or two, but the pay off is a nice, simple, rapid dev environment

    Yes, this is well said. IMO, if you can program in C, you can do SPIN. There's only a few odd things at first: the indentation requirement - but if you write clean C code, then you'll be indenting anyway. Just think of all the time you'll save having to write matching braces {} :-} The other things ... minor syntactical stuff ... some new keywords. The new language elements don't seem like a big deal to me. Consider how much you have to learn and keep track of when you're using a C library - or, worse, GUI stuff...
    document.items("FooWidget").Object.("Object").Hello(); anyone?

    SPIN is easy if you get a few references, study some of the code others have done here.

    @Mark (OP) - Ross's Catalina compiler is very nice ... why not try it ... and do some SPIN on the side? Could broaden your horizons... not that SPIN would be killer to have on your resume. On the otherhand Propeller Assembler (PASM) might be - "Assembler" is often thought of as one of those "hard things to do". "And Propeller Assembler" justs sounds too cool not to take advantage of [noparse]:)[/noparse])

    - Howard

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • SRLMSRLM Posts: 5,045
    edited 2009-10-19 17:57
    said...
    Just think of all the time you'll save having to write matching braces {}

    I'm not sure why Spin proponents always bring up the curly braces thing. I've been coding in C for a year now (for school), and I've never had any problems with curly braces. Any editor worth it's salt should automatically highlight the matching brace, and most editors will autoformat your code. If the error makes it past there, then the compiler will probably catch it. If you are still having problems, then I think you have too many nested structures and need to break some out into functions.
    said...
    document.items("FooWidget").Object.("Object").Hello();
    Likewise with the function calls. It simply translates to a sentence: "Get the FooWidget from the document, then the Object from FooWidget, and call it's Hello function." Personally, I wish spin had more OOP support so that it is a full OOP language.

    Still, Spin and C are like a hawk and a falcon: they both look different, and there are some internal differences, but for the most part they use the exact same principles. I don't see what all the fuss is about when somebody doesn't want to learn a new language. Fundamentally, most languages are very similar in the implementation of algorithms. Some are faster and some take more memory, but they all have the same properties.
  • heaterheater Posts: 3,370
    edited 2009-10-19 18:32
    Perhaps this has been said already but a cursory review of the Propeller architecture would convince most that it is not well suited to supporting the C language.

    Compiling from C to native Propeller assembler is a no-no because the instructions set does not directly support stacks or indexed addressing etc but mostly because of the restriction of the 496 instruction space within a COG. Hardly worth all the effort of creating a compiler.

    That would leave compiling to some byte code system as in some Pascal systems, Java, C# or indeed Spin itself. But then the byte code interpreter would ideally fit in a COG (496 LONGS) which probably has repercussions on the capability of the byte codes available. Which again may not be suitable for a C compiler.

    Question: Why has no one stepped up and created a C compiler that produces Spin bytes code for execution by the built in interpreter ?

    Enter Spin and it's bytes codes and the built in interpreter. All in all an impressive piece of work.

    Now also don't forget what I believe to be in the back of Parallax's mind, they have a target market of beginners, hobbyists, educational institutions etc. The C language is one sure way to put all those people off. That would naturally lead us back to BASIC as in the STAMPS but Parallax bravely went ahead with Spin and produced a gloriously simple development environment. Almost "type and go" like the good old BASIC on C64 days. Very attractive to anyone who does not want to get bogged down in compilers, linkers, header files and all that other C junk.

    At the beginning of this post I said "convince most". But there are some crazy people who have created C compilers for the Prop. Based on the idea of LMM. Basically have a PASM program running in a COG that runs PASM from HUB by fetching it on instruction at a time, executing it, fetching the next, etc etc. Something that can be done very easily with the Prop and perhaps not many other micros.

    If I understand correctly not even Parallax realized this was a possibility until Bill Henning pointed it out.

    The trade off here is that the C compilers produce faster code than Spin but use a lot more space in HUB.

    Anyway if you want to use C on the Prop I recommend using the worlds first working C compiler for the Prop. BDS C running under CP/M under the ZiCog Z80 emulator. Slow but compact. Comes with a complete dev environment that runs on the Prop as well.
    Sorry just had to get that in [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Dave HeinDave Hein Posts: 6,347
    edited 2009-10-19 18:35
    SRLM said...

    Still, Spin and C are like a hawk and a falcon: they both look different, and there are some internal differences, but for the most part they use the exact same principles. I don't see what all the fuss is about when somebody doesn't want to learn a new language. Fundamentally, most languages are very similar in the implementation of algorithms. Some are faster and some take more memory, but they all have the same properties.
    I can see that Spin has some useful things that aren't in C, such as the bit manipulation features.· I have done some programming on the Propeller, and I have been learning Spin.· I just wonder why some of the syntactical stuff was re-invented, and not re-used from C.· Why use "=>" and "=<" when it would have been just as easy to use ">=" and "<="?· Why not use curly braces instead of indentation?· Why not use "=" instead of ":=", and "==" instead of "="?· Maybe it had to do with conventions that Parallax uses in their other products.
    Anyhow, I know I will be doing more Spin programming as time goes on, so I'm cetainly willing to master the Spin language.· The Propeller object exchange is a really useful aspect to using the processor, and I hope to contribute to it in the future.
    Dave
  • Bill HenningBill Henning Posts: 6,445
    edited 2009-10-19 18:54
    You understand correctly [noparse]:)[/noparse]

    I came up with LMM when trying to figure out how to get C onto the Propeller.
    heater said...
    Perhaps this has been said already but a cursory review of the Propeller architecture would convince most that it is not well suited to supporting the C language.

    Compiling from C to native Propeller assembler is a no-no because the instructions set does not directly support stacks or indexed addressing etc but mostly because of the restriction of the 496 instruction space within a COG. Hardly worth all the effort of creating a compiler.

    That would leave compiling to some byte code system as in some Pascal systems, Java, C# or indeed Spin itself. But then the byte code interpreter would ideally fit in a COG (496 LONGS) which probably has repercussions on the capability of the byte codes available. Which again may not be suitable for a C compiler.

    Question: Why has no one stepped up and created a C compiler that produces Spin bytes code for execution by the built in interpreter ?

    Enter Spin and it's bytes codes and the built in interpreter. All in all an impressive piece of work.

    Now also don't forget what I believe to be in the back of Parallax's mind, they have a target market of beginners, hobbyists, educational institutions etc. The C language is one sure way to put all those people off. That would naturally lead us back to BASIC as in the STAMPS but Parallax bravely went ahead with Spin and produced a gloriously simple development environment. Almost "type and go" like the good old BASIC on C64 days. Very attractive to anyone who does not want to get bogged down in compilers, linkers, header files and all that other C junk.

    At the beginning of this post I said "convince most". But there are some crazy people who have created C compilers for the Prop. Based on the idea of LMM. Basically have a PASM program running in a COG that runs PASM from HUB by fetching it on instruction at a time, executing it, fetching the next, etc etc. Something that can be done very easily with the Prop and perhaps not many other micros.

    If I understand correctly not even Parallax realized this was a possibility until Bill Henning pointed it out.

    The trade off here is that the C compilers produce faster code than Spin but use a lot more space in HUB.

    Anyway if you want to use C on the Prop I recommend using the worlds first working C compiler for the Prop. BDS C running under CP/M under the ZiCog Z80 emulator. Slow but compact. Comes with a complete dev environment that runs on the Prop as well.
    Sorry just had to get that in [noparse]:)[/noparse]
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
    Morpheus & Mem+dual Prop SBC w/ 512KB kit $119.95, 2MB memory IO board kit $89.95, both kits $189.95
    www.mikronauts.com - my site 6.250MHz custom Crystals for running Propellers at 100MHz
    Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
  • jazzedjazzed Posts: 11,803
    edited 2009-10-19 19:52
    I'm so glad this didn't digress into a language war [noparse]:)[/noparse] I'm a C programmer, but it is not such a sacred cow to me as many industry types I know.

    Everything that @heater said is truly what I feel on the subject ... except one paragraph [noparse];)[/noparse].

    As far as a Spin byte-code C variant goes, I agree that this has merit and something was started with Small C by Peter Verkaik in 2007 here ... wish it was finished. I've seen one quote today where even Bill Henning thought something similar was a good idea [noparse]:)[/noparse] ... before the "advent" of LMM on P8X32A.
  • heaterheater Posts: 3,370
    edited 2009-10-19 20:09
    Jazzed: That paragraph is not an exception. When I posed the the thing about a C to Spin byte code interpreter as a question it was not meant to put a downer on the idea. No, it was an honest question. I mean, why not? Is there some thing important missing from the Spin byte code capability that would make C difficult or not worthwhile?

    I had not heard of Peter Verkaik efforts. So at least someone thought it was worth a shot.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • jazzedjazzed Posts: 11,803
    edited 2009-10-19 20:20
    Peter's work was not exactly something that emits byte-code. It is more or less and interpreter and it relies on one of his spin modules. ... I forgot about that part. It seems like something could be leveraged although I don't have much time today. I see my intent to obfuscate which paragraph I disagreed with worked fine [noparse];)[/noparse] ... I prefer to not be too direct in that regard.
  • Dave HeinDave Hein Posts: 6,347
    edited 2009-10-19 20:33
    Are there any utilities that convert C to Spin, or Spin to C?· This would be useful for developing code on a platform that doesn't have a Spin compiler, and then porting it to the Propeller.

    Dave
  • ericballericball Posts: 774
    edited 2009-10-19 20:55
    Dave Hein said...
    Are there any utilities that convert C to Spin, or Spin to C? This would be useful for developing code on a platform that doesn't have a Spin compiler, and then porting it to the Propeller.
    I basically did a Search & Replace converting my Z Interpreter from C to SPIN. I know the filesystem part of fsrw was written in C and then converted to SPIN; the scripts they used are on Sourceforge. However, you have to be careful as there are some significant & subtle differences between the two (differences in precedence). And even after you get a working conversion, you can go back and optimize for SPIN.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • CounterRotatingPropsCounterRotatingProps Posts: 1,132
    edited 2009-10-19 21:19
    Yes - no language wars *please* ... each lang has its faults and virtues!·· (I love and hate C ... just like I love and hate my car.)

    SRML,

    funny thing about the {} ... didn't know others had mentioned that!

    It's not so much having to match them as it is having to type them at all ! [noparse]:)[/noparse]· And I haven't met an IDE yet that could autocomplete·the trailing " } "· ... how could it know?·

    > I've been coding in C for a year now (for school)

    wait until you hit 30 + years like me (and C will probably still be in use then [noparse]:)[/noparse])

    Hmmm... let's see ... " {·" times say 100 lines of code a day, maybe 30 of which have a·{ or }, times·six days a week,·times 32 years, with two weeks off for bad behavior...

    Yikes! - that's 288,000·squiggly bracket's! No wonder my keyboards ESC, space bar, enter, and { } keys break first.
    said...
    said...
    document.items("FooWidget").Object.("Object").Hello();
    Likewise with the function calls. It simply translates to a sentence: "Get the FooWidget from the document, then the Object from FooWidget, and call it's Hello function."
    Yes, but how do you know to call the object's object? Why not simply: document.items("FooWidget").Hello(); ?· Because you have to memorize this, or look it up. (And may the Code Gods have mercy on you if you ever have to traverse Outlook's object model! {Foo.Folder.Folders("name1").Folders.Folder("name2").NuggingFuts();} )· The point was simply that you have to memorize or reference·many things when coding - this should not be a hinderence to using SPIN, PASM --- or any language for that matter.


    smile.gifsmile.gif

    Cheers!

    {//Howard();}


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • jazzedjazzed Posts: 11,803
    edited 2009-10-19 23:33
    CounterRotatingProps said...

    RE: document.items("FooWidget").Object.("Object").Hello();

    Yes, but how do you know to call the object's object? Why not simply: document.items("FooWidget").Hello(); ? Because you have to memorize this, or look it up. (And may the Code Gods have mercy on you if you ever have to traverse Outlook's object model! {Foo.Folder.Folders("name1").Folders.Folder("name2").NuggingFuts();} ) The point was simply that you have to memorize or reference many things when coding - this should not be a hinderence to using SPIN, PASM --- or any language for that matter.
    Several of today's IDEs have "Intellisense" like features that can lead you on an enlightened path ... unless you're using someone else's library archive. I miss it in SPIN for sure, but SPIN is simple enough to remember most of the time until you hit unfamiliar objects with weird CON or PUB identifiers. Even I stop using VI when Intellisense-like IDEs are available [noparse]:)[/noparse] Do you have syntax coloring for SPIN on VI by chance?

    Since you mention it, my right-brace IS more shiny than my left-brace. I often use it to reformat blocks of code in some IDEs ... beats the heck out of running a beautifier utility. Of course that would be a terrible habit in old code bases that get branched and resync'd all the time. Reinvestment can be a wonderful cure don't you think? ... It seems "IP depreciation" should be allowed in accounting rules.
  • RossHRossH Posts: 5,516
    edited 2009-10-19 23:54
    @heater

    This has been discussed in previous threads. I originally though about making Catalina emit SPIN byte codes, but I decided it was not really a good idea. SPIN is missing too many fundamental operations required for an efficient implementation of C.

    SPIN and C are not really very much alike. Those who claim the languages are similar are really just pointing out that both languages are procedural, share some syntactic "sugar", and that both are "turing complete". But this doesn't necessarily mean it would be efficient to use one to implement the other. For example, SPIN byte codes have no support for either floating point or structures - parts of the C language that would be difficult and inefficient to implement using the existing byte codes.

    Another option (and I considered this as well) would be to come up with an "extended" set of SPIN byte codes. But this would not really be SPIN compatible, would not run in a single cog (there's no space left!) and in any case would make C execute as slowly (probably even more slowly) than SPIN does - whereas both Catalina and Imagecraft C currently execute between 3 to 8 times faster than SPIN (depending on which benchmark you use). In any case, I finally decided that if you didn't like SPIN and really wanted a byte-coded language on the Propeller then Java would a better bet than C - but Java is both big and slow when compared to C, and would probably be even slower than SPIN.

    A "SPIN to C" preprocessor would be a good solution, and fairly easy to build. Any volunteers?

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • hippyhippy Posts: 1,981
    edited 2009-10-20 10:30
    heater said...
    Question: Why has no one stepped up and created a C compiler that produces Spin bytes code for execution by the built in interpreter ?
    Good question, as it's easy enough to do. There are generally three options for C generated code -

    1) Spin bytecode
    2) Own bytecode
    3) LMM-style PASM

    Ross gives some reasons for not doing C to Spin bytecode, another is that a C program generating Spin bytecode would unlikely be quicker than Spin. For those who are 'language neutral' ( "you can do it in Spin, you don't need C" ), it can be seen as re-inventing the wheel for little gain, it doesn't bring anything extra for programmers ( eg allow huge memories ).

    You therefore need someone motivated enough to do it, can see a valuable purpose in doing it, can 'create' a compiler, and understands Spin bytecode enough to produce the object code.

    An alternative is to generate Spin source code from C, again, easy enough to do. With a few mods to Homespun, goto and function pointer calls could be presented as 'native Spin' which would simplify things. Even without, it can still be done.
Sign In or Register to comment.