Shop OBEX P1 Docs P2 Docs Learn Events
Sorry but, Why the Propeller code is called Propeller Object and Basic Stamps — Parallax Forums

Sorry but, Why the Propeller code is called Propeller Object and Basic Stamps

markustermarkuster Posts: 184
edited 2009-07-24 18:31 in Propeller 1
Hi,

Yes , my question is very stupid but I need to understand
why the Propeller code is called Propeller Object and Basic Stamps code
is called rutines or something like that.

Thanks, Mark

Comments

  • W9GFOW9GFO Posts: 4,010
    edited 2009-07-23 22:09
    When you write a program for the Propeller you can reference other programs (objects) that will then become part of your program. Many objects have been uploaded to the Object Exchange where you can freely use any of them in your programs.

    Each .spin file is an object / each object is a .spin file.

    Rich H
  • RossHRossH Posts: 5,512
    edited 2009-07-23 23:33
    Hi Mark,

    This can be a bit confusing at first - particularly if you come to SPIN from an object-oriented background where the terms "object" and "method" tend to have a specific meaning. The fact that SPIN uses such terms often leads people to suppose it is an object-oriented language (which - thankfully! - it isn't).

    On page 86 of the Propeller Manual (v 1.01 - available online here) you find:
    Propeller Manual said...
    Objects are really just programs written in a way that: 1) create a self-contained entity, 2)
    perform a specific task, and 3) may be reused by many applications.
    This section goes on to explain a bit about how SPIN programs are constructed, and is worth reading in detail. As W9GFO points out, SPIN objects are primarily intended to allow packaging and sharing of programs - both in your own applications, and with other people.

    Technically, what SPIN calls an object, other languages would generally call a package or a module. What SPIN calls a method, other languages would generally call a function.

    SPIN objects do have some of the characteristics of a traditional object:
    • A SPIN object is a form of encapsulation that groups together functions and data.
    • A SPIN object defines an interface.
    • A SPIN object allows some limited information hiding (PUB vs PRI)
    However, SPIN objects do not have any of the essential characteristics that differentiate an object-oriented language from a modular language:
    • A SPIN object is not an instance of a class.
    • A SPIN object does not support inheritance.
    • A SPIN object does not support poylmorhpism.
    Understanding the structure (and purpose) of the various parts of a SPIN object is essential to writing effective SPIN programs, and is one of the steeper parts of the learning curve that newcomers face on the Propeller. Once you get that, SPIN becomes reasonably simple. Then you can tackle concurrency and parallel processing, which is where SPIN really shines ...

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina

    Post Edited (RossH) : 7/24/2009 8:44:33 AM GMT
  • Carl HayesCarl Hayes Posts: 841
    edited 2009-07-24 00:18
    These are what is known as "nonce words". That is, a language fad.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
  • jazzedjazzed Posts: 11,803
    edited 2009-07-24 00:27
    markuster said...
    Hi,

    Yes , my question is very stupid but I need to understand
    why the Propeller code is called Propeller Object and Basic Stamps code
    is called rutines or something like that.

    Thanks, Mark
    Nothing wrong with your question.

    In simplest terms that I can write: An object is a "code entity with routines and data" and a routine is a "set of instructions".

    A routine or set of instructions can manipulate data, but as a general rule does not hold the data (there are exceptions).
    An object can hold data and routines. It can also allow other objects access to it's routines if they are public or disallow access.

    Object programming provides tools for managing data so we don't have to worry as much about what routine "owns" the data.

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


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • WNedWNed Posts: 157
    edited 2009-07-24 05:10
    The reason there is a difference between terms for each device, Stamp and Propeller, is because they are very different devices.
    Because of the differences in the way they are designed and used, each has its own language, PBasic for the Stamp, and Spin for the Propeller.
    A house has rooms with dividers called walls. On a ship, the structure used to separate rooms is called a bulkhead... does the same thing, ships and houses both hold people, but they are really very different.
    In addition to the difference in context, the Spin language allows you to include programs inside other programs. For example, if you wrote one program to control a servo and another, separate program to take readings from a Ping sensor, you could include both of those separate programs in a third program that you write to turn a servo mounted Ping sensor in a certain direction and take a reading. You might also include the exact same servo program in a completely different program that you write to control a mechanical arm. So, because each program can be written as a code representation of an individual process or thing, it is convenient to call the program an "object".
    Because PBasic lacks the ability to break a larger program up into re-usable bits (you have to write the whole program in one big block), the term "object" just really doesn't apply very well.

    I hope that helps.

    Ned

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "They may have computers, and other weapons of mass destruction." - Janet Reno
  • markustermarkuster Posts: 184
    edited 2009-07-24 18:31
    hi,

    Thanks to all the people that explained me.

    Thanks, Mark.
Sign In or Register to comment.