Shop OBEX P1 Docs P2 Docs Learn Events
How about a tutorial converting BS-basic to SPIN ? — Parallax Forums

How about a tutorial converting BS-basic to SPIN ?

StefanL38StefanL38 Posts: 2,292
edited 2008-09-07 13:19 in Propeller 1
Hello everybody,

right now there were some postings about Basic and SPIN
or more precise people are saying i want to stay in basic
(and between the lines because i'm used to it and SPIN seems to be as cryptographic as old agyptian hyroglyphes)

How about a tutorial showing how to transfer BS-basic to SPIN ?

a lot of small codesnippet examples like

-if-then-else condition,
- loop for-next
- gosub

etc.

including all the work done in BS2_Functions.spin
and even there with PBasic-examples and how they are done using BS2_Functions.spin

best regards

Stefan

Post Edited (StefanL38) : 9/6/2008 1:59:50 PM GMT

Comments

  • PaulPaul Posts: 263
    edited 2008-09-06 14:04
    If you download BS2 Functions.spin from the OBEX, and read through each function, you will probably learn a lot about each language. I'm sure someone is working on a Basic interpreter/compiler out there.

    Many of the best features of the Propeller (counters, etc.) do not have an equivalent BS2 basic function and would be sorely missed.

    If you would like to contribute a tutorial you can always post it here or the propeller wiki.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki Rocks! - propeller.wikispaces.com
  • MovieMakerMovieMaker Posts: 502
    edited 2008-09-06 14:08
    How do you get the BS2 Object to run??? I loaded Boebasic and tried to load BS2 on top of it. How does it work?
  • hippyhippy Posts: 1,981
    edited 2008-09-06 15:00
    StefanL38 said...
    right now there were some postings about Basic and SPIN or more precise people are saying i want to stay in basic (and between the lines because i'm used to it and SPIN seems to be as cryptographic as old agyptian hyroglyphes)

    How about a tutorial showing how to transfer BS-basic to SPIN ?

    I think that's a good idea. There's probably a reasonably large PBASIC user base out there which isn't feeling confident enough to to take the jump to the Propeller as it's outside their comfort zone.

    Spin gives the false impression of being daunting when it isn't. I wasn't looking forward to using yet another language with some odd looking features but was pleasantly surprised. I had a motivation to learn but others may have taken one look and be more reticent about making the move.

    It's very easy for professional programmers who use the Propeller to forget that not all potential users have the skills and experiences they do and moving to a new processor and a new language is a bigger step and a lot more effort than they see it.
    Paul said...
    If you download BS2 Functions.spin from the OBEX, and read through each function, you will probably learn a lot about each language.

    True, but I think what a lot of people want is something which leads to understanding Spin in terms of what they are familiar with because they simply don't understand Spin or are feeling out of their depth and those BS2 functions are a step to far.

    I believe what Stefan was suggesting was something which could show how to turn a line of PBASIC into its Spin equivalent. Something to help get PBASIC users onto the Propeller to start with, to show them it's not as hard or as alien as it may look.

    I think a "Migrating from PBASIC to Spin" guide is a good idea. As with everything though, it needs someone to step forward as a product champion and do it or lead the way - Any volunteers ?
    Paul said...
    Many of the best features of the Propeller (counters, etc.) do not have an equivalent BS2 basic function and would be sorely missed.

    Not by the people who aren't (yet) interested in using them smile.gif

    I don't think the fact that PBASIC on Propeller wouldn't expose all the chip's wonderful functionality is a problem. It means PBASIC programmers are missing out but it's their choice. If they want the functionality they'll have to move up to Spin and PASM or Prop PBASIC gets enhanced.
    MovieMaker said...
    How do you get the BS2 Object to run??? I loaded Boebasic and tried to load BS2 on top of it. How does it work?

    That is a case for reading the BS2 Object code. Use it just like any other object, call it when needed. Trying to throw objects together doesn't generally work, there needs to be design and reason to it.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-06 15:01
    MovieMaker,
    Please, please take some time to learn how objects work in Spin. There are examples in the Propeller Manual. There are examples and exercises in the Propeller Education Kit tutorials. You don't "run" the BS2 object. You incorporate it into your program. It's functionally a library of subroutines and functions that you can call from your program (like the BoeBotBasic interpreter). You have to write your Spin program to use it. The BoeBotBasic interpreter would have to be rewritten and recompiled (with the BS2 object) to be able to use it.
  • MovieMakerMovieMaker Posts: 502
    edited 2008-09-06 15:08
    I see.
  • Mike HuseltonMike Huselton Posts: 746
    edited 2008-09-06 16:47
    Something similar to www.nutsvolts.com/media-files/734/Aug07-DesignCycle.pdf would be useful, if the subject was Basic Stamp to Spin examples.

    MovieMaker, you must do some of the work yourself - the forum members can't be expected to do all of the work for you. You must get in the habit of study, and that comes more easily to some than to others.

    Self-education is hard work; you cannot be expected to have it handed to you on a platter.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH - Electronics: Engineer - Programming: Professional

    Post Edited (Quantum) : 9/6/2008 4:56:46 PM GMT
  • MovieMakerMovieMaker Posts: 502
    edited 2008-09-07 03:49
    Gotcha!
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-09-07 05:16
    If one were to write such a tutorial, I think it would be a good thing to construct it in a language-agnostic fashion. After all, the constructs in any language are used to solve many common problems that are also solved in other languages.

    Take for example loops. Most languages provide ways of doing loops. And most languages have certain types of loops to choose from:

    1. Loop for a specified number of times, optionally using an index between some starting and ending value with some specified increment (think For-Next loop)
    2. Loop until a condition is true (Do-Until) - always executes at least once because the test is at the end
    3. Loop while a condition is true (While-Do) - may never execute, because the test is at the beginning
    4. Loop for every element in a list -often referred to as an iterator

    Most languages also support the concept of a function call (with parameters that may be passed by value or reference), although many versions of Basic do not support this.

    If one were to start with the general concept, and then explain how it can be done in, say, Basic and Spin, then the big picture starts to become evident to the reader.

    I find that many of the unique features of Spin as a language are driven by the unique nature of the Propeller processor. After all, why else would Chip and his team invent a new programming language when there are so many good ones to choose from? To get at these unique features, you must understand more than just the language, you must also understand the architecture of the processor. Otherwise, you're stuck using only one cog for example.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup

    Post Edited (Ken Peterson) : 9/7/2008 5:28:32 AM GMT
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-09-07 11:45
    Hello Ken,

    I agree with you. Explaining the things in a general way is a good idea.
    And i agree the propeller-chip has special features that need special commands

    I took a look into the PBasic reference. There are some highlevel-commands
    that in SPIN would be already methods like done in BS2_function.spin

    Anyway to make it easier to get into SPIN I think it will be a good starting point
    to begin with things that can be ported 1:1 from PBasic to SPIN

    And then the tutorial has to go on on a basic level and take time and easy to understand
    words to explain everything. F.e. for the concept of pointers I would take 4-5 PAGES with
    pictures showing RAM as small boxes with the adresses and lots of arrows showing the details
    using numbers that are easy to understand (meaning not real Hex-adresses like DCE1A but
    low decimal numbers like 1-50)

    The manual is written in a style that is common for code-manuals: the manual expects that you know the basic concepts
    of programming.

    And I can understand why some people get upset if they don't find the equalent expression for
    PBasic-commands like "DTMFOUT", BUTTON etc.

    It is frustrating to see: "oh i don't know SPIN and first of all i have to learn it until i can do something
    like the PBasic-command BUTTON instead of having this command

    Here i think Parallax should make a statement what has to be done to get into SPIN
    and showing the limits of the basic-command-set of SPIN
    Of course EVERYTHING that PBasic offers can be programmed in SPIN and even MUCH MORE
    but for some things you have to code it on your own.

    Maybe a table comparing the commands of PBasic and SPIN would be a start.
    This table shows what is similar and what has to be programmed.
    Or: if the BS_Function.SPIN would contain ALL PBasic-commands this would be a great deal - or not ?
    Hm - here i'm unsecure if this is a good way.
    SPIN offers more structured programming than PBasic and just delivering PBAsic-command equalents
    keeps this users on the PBasic-level

    That's the actual point of my thinking about this

    best regards

    Stefan
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-09-07 13:19
    I wouldn't necessarily rely on Parallax to get into extensive educational documentation. There is a lot of documentation written by people here in the forum that goes above and beyond what is in the manual. Often when there is a need, someone will take it upon themselves to do the research and fill that need for the benefit of others.

    Let Parallax concentrate on the Prop II !! [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"I have always wished that my computer would be as easy to use as my telephone.· My wish has come true.· I no longer know how to use my telephone."

    - Bjarne Stroustrup
Sign In or Register to comment.