Shop OBEX P1 Docs P2 Docs Learn Events
Is 'Hybrid' programming possible? — Parallax Forums

Is 'Hybrid' programming possible?

LoopyBytelooseLoopyByteloose Posts: 12,537
edited 2012-10-21 06:47 in Propeller 1
I have been studying C for Catalina C and GCC. There has always been Spin and Assembler that can run together. Now I am looking at PropForth.

So I am wondering can different cogs in one Propeller run PropForth, a variation of C, Spin/Assembler in a working relationship all at the same time. I imagine the RAM space for each cog would be limited to 2K, just because the variety would interfer with larger memory models.

It is possible? or is there something that makes these mutually exclusive?

Comments

  • SapiehaSapieha Posts: 2,964
    edited 2012-10-12 11:50
    Hi Loopy Byteloose

    Theoretically I don't see any problem with that.
    In practice that need smarter compiler that that separate languages have.


    I have been studying C for Catalina C and GCC. There has always been Spin and Assembler that can run together. Now I am looking at PropForth.

    So I am wondering can different cogs in one Propeller run PropForth, a variation of C, Spin/Assembler in a working relationship all at the same time. I imagine the RAM space for each cog would be limited to 2K, just because the variety would interfer with larger memory models.

    It is possible? or is there something that makes these mutually exclusive?
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-10-12 13:41
    Loopy: I don't know anything about Forth. Catalina is able to run pasm and spin programs as plugins. It depends on how forth would interact with it. Catalina loads up the top of hub with parameters and registry and forth would need to not trample over it.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-13 03:48
    PropForth seems to run under a .spin image to its own cogs -- at least in some cases. So it does seem likely.

    I was just wondering. I am not sure if this is appealing to anyone. I was thinking of running the VGA display and keyboard alongside a cog with Forth and thought that even more might be achieved.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-15 19:13
    I was thinking of running the VGA display and keyboard alongside a cog with Forth and thought that even more might be achieved.

    You can run VGA using forth, just as any assembler program. See JupiterACE in propforth 3.5

    You CAN run propforth along other programs, BUT

    other programs do not define any interface, so we don't know how to talk to them. Propforth defines a common standard interface to all the tasks (cogs) and user tasks, (serial driver, MCS/CSP channels, etc) so all that's left to implements is the OTHER side in spin, C, PASM, etc.

    If anybody wants to define a different standard interface we can talk to that, all we need is the definition of the interface.

    I suggest it would be easier to implement something that matches the propforth interface, since that already exists and is known good.
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-10-15 22:36
    The prop can work well with a multi language application. I've done this on several platforms. As prof_braino says, some Propeller languages may require an interface.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-10-16 03:48
    @Humanoido,

    Could you please post the code for an example of this. I'm sure many of us multi-language folk would love to see some examples of hybrid programming on the prop.
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-10-16 03:53
    The problem that I see is that the interpreted languages (pretty much anything besides PASM and COGC) require memory support from the HUB and once you introduce multiple memory mapping expectations onto the HUB memory space, you introduce all kinds of complexities.

    Running COGs with independent binary blobs generated from either PASM or as COGC code shouldn't be a big problem. Proprforth does that with some modules.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-16 20:17
    mindrobots wrote: »
    The problem that I see is that the interpreted languages (pretty much anything besides PASM and COGC) require memory support from the HUB and once you introduce multiple memory mapping expectations onto the HUB memory space, you introduce all kinds of complexities.

    If you could start in on getting folks to consider a standard interface it could happen.
    For example, if we reserve the first 8 * X bytes in the hub for the message buffer for each cog, we could set up a simple protocol.
    I'd be interested to see how far we get. This is certainly doable, and need not be hard.
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-10-16 23:27
    mindrobots wrote: »
    @Humanoido, Could you please post the code for an example of this. I'm sure many of us multi-language folk would love to see some examples of hybrid programming on the prop.
    The code is back at the company where I did work on machine controllers and assembly robots. It was not a Propeller platform. There are several ways to combine languages. 1) incorporation of code from one language integrated into another 2) time based boot loading multiple languages and parameters passing 3) common access storage language technique, and 4) access to online residency languages. On the prop, a language hub interface would make things simple as indicated by prof_braino. What would we put on the prop? Basic, C, Forth, Spin/Pasm, Logo?
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-17 03:25
    I guess with a 'Standard Interface' either at the bottom or top of the Hub RAM (Does C aready have something at the bottom of HUB RAM?), this would open up different users to collaborate with code from different sources running on various Cogs. It is an interesting idea, but I am not sure if youall really want to do something so organized.
  • Heater.Heater. Posts: 21,230
    edited 2012-10-17 03:55
    What you are talking about has already been discussed at length here: http://forums.parallax.com/showthread.php?137119-A-technique-for-communicating-with-cogs-from-any-language
    Ross has written a standard for it and implemented it in Catalina.
    The intent there was more to do with using PASM driver and other binary blobs from any language rather than mixing HLLs in a single application but I guess the same considerations apply.

    All in all I'm wondering why you would want to do this. Binding two languages together is always a pain. Just now I'm working on an app that is mostly Pascal with bits of C thrown in. Linking C and Pascal is one of the simpler cases but still a pain. Setting up communications between processes written in different languages might be the easier or indeed only way to go in many cases. Then of course if you are mixing say Forth and C you have two kernels to fit into memory reducing space for real functionality.

    All in all there would have to be a really compelling reason to want to get into multi-language applications.
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-10-17 06:23
    Heater. wrote: »
    All in all I'm wondering why you would want to do this...all in all there would have to be a really compelling reason to want to get into multi-language applications.
    On the one hand, it's like the thrill, challenge and successful reward of climbing Mt. Everest. On the other hand, work on enough projects will create an app specifically suited for multi-language. It can be an enjoyable relaxing project for hobbyists and a learning experience. Or it can be interesting for experimenters and academicians. Professionally, the concept allows the union marriage of two dissimilar machines that each speak their own special language version. It can also save time which equates to money saved for the company.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-17 07:29
    @Heater
    In my own case, it will be a long time before I'll be creating anything in a hybrid sense. I was just wondering if it was possible.

    But for others, it may be rewarding. In Linux, I run across support for all sorts of hybrids; but I tend to shy away from them. Usually C is somehow involved and assembler. For some that feel this is a needed career skill, starting small on the Propeller may be a lot easier than doing it on a desktop.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-18 09:45
    i've had requests to use interactive forth command line in one cog with standard spin object in another cog.so we can interactively exercise the spin for diagnostic and test.

    the effort of getting the spin so it could play nice has so far been greater then implementing the function in forth.

    if the spin could be converted to some standard, this alone would be worth it for many developers
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-18 11:10
    Actually, the reason this question firt came to mind was because I am learning PropForth and wondering how much I will have to redevelop items that might already be well supported in the OBEX.

    I really am enjoying PropForth, but it seems rather odd to have to rewrite all and everything in Forth to get something working.
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-10-19 06:18
    I really am enjoying PropForth, but it seems rather odd to have to rewrite all and everything in Forth to get something working.
    Then I think you are in favor of a language-based OBEX type of repository, one which includes Forth. People could submit code in the prop language of their choice.
  • MicksterMickster Posts: 2,694
    edited 2012-10-19 06:26
    Humanoido wrote: »
    Then I think you are in favor of a language-based OBEX type of repository, one which includes Forth. People could submit code in the prop language of their choice.


    Hear Hear!

    I am in favor of this also so that we can do the same with PropBASIC code.

    Mickster
  • Heater.Heater. Posts: 21,230
    edited 2012-10-19 06:30
    Just get an account on github or other source code repository system. Then you can share whatever code in whatever language you like. It's not so hard.
  • RsadeikaRsadeika Posts: 3,837
    edited 2012-10-19 06:44
    Originally Posted by Humanoido View Post
    Then I think you are in favor of a language-based OBEX type of repository, one which includes Forth. People could submit code in the prop language of their choice.

    Hear Hear!

    I am in favor of this also so that we can do the same with PropBASIC code.

    PropBASIC is already included in OBEX under the title of Basic. bean has some submissions in OBEX, and they are under that title. I believe that they are still in the process of improving your experience with OBEX.

    Ray
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-19 10:03
    Humanoido wrote: »
    Then I think you are in favor of a language-based OBEX type of repository, one which includes Forth. People could submit code in the prop language of their choice.

    A repository would certainly be nice. But I have had a certain amount of frustration with the OBEX way of doing things. It just has never been easy to navigate and locate what you want - it is somewhat like looking at a messy bulletin board in a university dorm.
  • HumanoidoHumanoido Posts: 5,770
    edited 2012-10-19 21:50
    A repository would certainly be nice. But I have had a certain amount of frustration with the OBEX way of doing things. It just has never been easy to navigate and locate what you want - it is somewhat like looking at a messy bulletin board in a university dorm.
    The Obex is really a fantastic resource but there's something different about the organization and search. A blog appears to have better search results with its key word attachments. Sometimes, all too often, a key word from the title of an object or its category in the Obex search is never found, yet I know it's there. Then one must go to google and search again. The object is usually found after this time consuming effort. On the other hand, if one tries to go by the object categories, some objects don't really fit one particular class, or knowing where it was dropped can be challenging.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-20 02:11
    Humanoido wrote: »
    The Obex is really a fantastic resource but there's something different about the organization and search. A blog appears to have better search results with its key word attachments. Sometimes, all too often, a key word from the title of an object or its category in the Obex search is never found, yet I know it's there. Then one must go to google and search again. The object is usually found after this time consuming effort. On the other hand, if one tries to go by the object categories, some objects don't really fit one particular class, or knowing where it was dropped can be challenging.

    Makes me wonder why the OBEX is the way it is and what happened. I tend to rely on the SPIN examples that came with the original SPIN IDE before I bother with OBEX as these are far more important to study and to learn to modify.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-20 06:24
    Makes me wonder why the OBEX is the way it is and what happened. I tend to rely on the SPIN examples that came with the original SPIN IDE before I bother with OBEX as these are far more important to study and to learn to modify.

    The OBEX is just "a place for folks to post code". There is nothing about standard interfaces, or common way of dong things, besides the spin rules for the individual functions and indenting. Folks discover and post many things, mostly about the hardware they are focusing on. Concerning how to communicate code from one individual to the next, we've discovered that the OBEX is in some way lacking.

    The Gold Standard Repository is an attempt to move a step further. It is a step in the right direction, but obviously there are many steps in a journey. I'm on that team for a "software development process" perspective. I tend to stress the importance of requirements, testability, clarity, and interfaces. But we haven't gotten to that point yet, we are still looking at coding standards, formatting, etc. As I side, this is a long journey with many steps.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-10-20 10:23
    As long as we have resources like Git repositories that inspired users are independently managing their own projects, we are moving forward. This is open source and everyone is going to choose their own ways to participate.

    The Gold Standard Repository is a new useful tool for those that cannot or prefer not to waste time with the more creative solutions provided by individuals. I was just extremely frustrated with the OBEX headings that tend to have items listed under multiple characterizations, while searches were not quite up to snuff.
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-20 18:07
    This is true, but concerning 'hybrid programming', to make this possible, we need to define and agree on some basic, lowest level interface.

    The material heater referenced in #12 is already too high level and assumes too many specifics (peculiar to C?), which forces design decisions too early.

    For example, a simple interface could be something like:

    "The first available 8 longs (or words or bytes) in HUB are always allocated to the interface. offset 0 is for cog 0, offset 7 is for cog 7. When a cog wishes to communicate to other cogs, it places a value in it's own slot. The other cogs can read this value if they choose."

    This would be a simple way to start. At this point, it would be up to the developer to define what and how to communicate further to the other cogs. For example value X means ready, value Y means next value is a pointer to a buffer in HUB that has all the data to transfer, etc. But whatever it is, it needs to be simple. Then folks can built on it 'as they write programs that communicate.' So far, nobody as tried this, (to my knowledge) so we have no business restricting any options till forced.
  • Heater.Heater. Posts: 21,230
    edited 2012-10-21 03:58
    Braino,

    I didn't thhink RossH's suggestions had an C language specifics or any language specifices. After all it is about communicating between COGs in any language.

    Feel free to invent your own solution to communicating between languages on the same machine (Which is essentially the same as communicating between COGS unless a binary is built from two or more langugaes compiled and linked together which I don't think is on the table here).

    The more standards we have the better:)
  • prof_brainoprof_braino Posts: 4,313
    edited 2012-10-21 06:47
    Post #26 is the complete standard for communicating between two cogs on the same machine in different languages at this point.
    Until someone actually tries to do a multi - language app, we have no way of evaluating any other rules as "helpful" or "hindrance".

    I must disagree with your previous post, everything in RossH's suggestion is brilliant BUT its at least two levels too deep to serve as a starting point.

    On a tangent, I feel that should be fewer, more general standards that say things like "play nice, and be considerate of the next person that has to deal with what you are leaving behind, and don't make decisions that affect others without discussing it or at least letting them know". If folks follow this "standard" most "stupid" problems in this life could not happen.
Sign In or Register to comment.