Shop OBEX P1 Docs P2 Docs Learn Events
How would you describe Spin as a language? — Parallax Forums

How would you describe Spin as a language?

Peter JakackiPeter Jakacki Posts: 10,193
edited 2011-11-10 02:52 in Propeller 1
Hi guys (n gals),

I was just writing up a new datasheet and I decided to expand on the short description I normally give to the Propeller and in particular the way it is programmed. In a C centric world saying that the Propeller is programmed in Spin is not very helpful. I could say it is Pascal-like maybe? But they may draw the wrong conclusions (them, not me). To me a language is a language, all of them have pro's and con's but how would you describe Spin as language and do so succinctly and positively?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*Peter*
«13456789

Comments

  • Bill HenningBill Henning Posts: 6,445
    edited 2009-10-30 00:36
    Hmm... Spin is closest to Python methinks
    Peter Jakacki said...
    Hi guys (n gals),

    I was just writing up a new datasheet and I decided to expand on the short description I normally give to the Propeller and in particular the way it is programmed. In a C centric world saying that the Propeller is programmed in Spin is not very helpful. I could say it is Pascal-like maybe? But they may draw the wrong conclusions (them, not me). To me a language is a language, all of them have pro's and con's but how would you describe Spin as language and do so succinctly and positively?
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
    Morpheusdual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory IO board kit $89.95, both kits $189.95
    Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz
    Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-10-30 00:39
    How so Bill? I was just mentioning in the datasheet that the Spin runtime execution is a bit like Java byte code execution (actually, I reckon it's more like Forth at this level). But the high level source code could a mix of several languages so in what ways would it be similar to Python?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • localrogerlocalroger Posts: 3,452
    edited 2009-10-30 00:52
    An original language, designed to teach concepts and to be learned easily no matter what previous languages you know. Has even more whitespace awareness than the many variants of BASIC, in an obvious bid to force good indentation practices. C-like in that it uses null terminated strings in fixed-length assigned storage and doesn't enforce data types or array bounds, as well as bracket syntax for array indeces. Python-like with its powerful and sometimes obscure expression evaluator. Forth-like in its bytecode implementation. One of the few languages to truly enforce Djikstra's admonition about GOTO by not implementing it, at all. You cannot find any one language or development tool and say "This is what Spin is a clone of." It truly is a synthesis of the strengths (in a very particular manner of evaluation) of many different approaches.
  • mparkmpark Posts: 1,305
    edited 2009-10-30 01:01
    localroger said...
    ...
    Python-like with its powerful and sometimes obscure expression evaluator.

    Example, please? I'm not seeing it.
    localroger said...
    ...
    Forth-like in its bytecode implementation.

    I don't know about this. The Spin "virtual machine" is stack-based, but it takes more than that to be Forth-like (in particular, I believe most Forth people would say a defining characteristic of Forth is its separate data and return stacks).
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-10-30 01:15
    As a Forth person (though not much recently) and having written various Forths for different processors including a byte-token version. I can say that terminologies asides that the Spin run-time is very Forth-like. Of course Spin uses local variable stacks but such things can be and are implemented in Forth as my versions would also sport a separate loop stack rather than use the return stack etc.

    Now, how about a description....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • Bill HenningBill Henning Posts: 6,445
    edited 2009-10-30 01:27
    As I recall Python also uses indentation to indicate scope, and also compiles to a byte code.
    Peter Jakacki said...
    How so Bill? I was just mentioning in the datasheet that the Spin runtime execution is a bit like Java byte code execution (actually, I reckon it's more like Forth at this level). But the high level source code could a mix of several languages so in what ways would it be similar to Python?
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
    Morpheusdual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory IO board kit $89.95, both kits $189.95
    Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run 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-30 01:34
    It is an "object.method" language similar in some ways to all the languages you love except for a few extra weird equality operators.
  • waltcwaltc Posts: 158
    edited 2009-10-30 02:37
    Its Basic with just a touch of C and Pascal and a dash of OOP. Not industrial strength OPP like Smalltalk but a smattering.
  • RvnPhnxRvnPhnx Posts: 36
    edited 2009-10-30 12:20
    I'd just say that it's a nearly typeless whitespace-aware programming language with minimalist OOP.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --RvnPhnx
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-30 18:02
    as you would like to invoke interest in it

    to professional programmers a description that makes them feel challenged what I should not be able to learn it ?

    to newbees a description that gives confidence:
    you will learn it almost as quick as basic but if you have learned you are fare above
    of what basic-programmers can do. And you are well prepared for other languages

    Or to say ot similar like localroger quote "It truly is a synthesis of the strengths (in a very particular manner of evaluation) of many different approaches."

    It takes the best from the most popular programming languages and combines them to suit very well to the hardware of the propeller.
    As the propeller is a multi-core-microcontroller, start by using a single core. Use a second core as easy as starting a second program on your PC for backround-drivers
    to replace easily interrupt-programming.
    By the time add more an more cores as you drive up the learning-curve leaving other microcontrollers behind.
    Where others are fiddling around to speed up IRQ-subroutines stay relaxed by just starting another core.

    In my eyes Chip did a really great job. The architecture, SPIN-syntax, the propeller-IDE everything well developed to work effectivly

    best regards

    Stefan

    Post Edited (StefanL38) : 10/30/2009 10:29:18 PM GMT
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-10-30 22:09
    Spin is a basic patchwork of different languages. The result is:
    * Weird operators that redefined standards set by other languages.
    * Bended and blended different meanings into one scope (byte, word, long; whenever I read that, I slam my head; word should be 32 bits on on 32 bit processor).
    * Took buzzwords from other languages to make it shine ("objects", but it's not OO).
    * Completely untyped and thus not suited for education
    * Lacks concepts for save coding
    * Designed by someone with no background in language-design

    Sorry, had to write that, but its true. And I'm tired of the repeated hurras about SPIN. SPIN is Smile, but it works and its a compact language. And only worth learning because it comes along with the processor.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-10-30 22:09
    Spin is a basic patchwork of different languages. The result is:
    * Weird operators that redefined standards set by other languages.
    * Bended and blended different meanings into one scope (byte, word, long; whenever I read that, I slam my head; word should be 32 bits on on 32 bit processor).
    * Took buzzwords from other languages to make it shine ("objects", but it's not OO).
    * Completely untyped and thus not suited for education
    * Lacks concepts for save coding
    * Designed by someone with no background in language-design

    Sorry, had to write that, but its true. And I'm tired of the repeated hurras about SPIN. SPIN is Smile, but it works and its a compact language. And only worth learning because it comes along with the processor.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • potatoheadpotatohead Posts: 10,261
    edited 2009-10-30 22:50
    LOL!!!

    I would describe SPIN as lean, useful, easy to learn, and well matched to the processor hardware attributes. There is nothing else like SPIN + PASM.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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!
  • localrogerlocalroger Posts: 3,452
    edited 2009-10-31 01:22
    OK, let's have a flame war!· Nick said (twice, just to make sure we got it)...

    Spin is a basic patchwork of different languages. The result is: 
    * Weird operators that redefined standards set by other languages.
    

    With a couple of exceptions (most notably the very efficient but hatedly obscure ~ and ~~ operators) everything in Spin is found somewhere else.· They aren't all found in one language, but are a distillation of what works best and (particularly) is most memory efficient in all of them.· This is not an unreasonable design goal on a platform that is deliberately memory-limited.

    * Bended and blended different meanings into one scope (byte, word, long; whenever I read that, I slam my head; word should be 32 bits on on 32 bit processor).
    

    This is as stupid as the Comp Sci teacher I had back in 1981 who insited "byte" meant "any subdivision of a word" instead of "8 bits."· He was wrong then, time having marched on,·and you are wrong now.· On embedded platforms in particular a word is 16 bits just as a byte is 8.· "Long" is a reasonable extension to assert 32.· As for using the word length of the machine in any meaningful way, that's been dead since IBM advertised the 8088-based IBM PC as a "16-bit" processor back in 1982.

    * Took buzzwords from other languages to make it shine ("objects", but it's not OO).
    

    Only because it doesn't do YOUR VERSION of OO.· In 1970 it would have been considered quite radically OO.· (No GOTO?· No, really, you mean no GOTO at ALL?· And if I need to send some data to the video, and it's in southland object, and I just well you mean I really can't just send it the data from northpark object?· AT ALL?· I mean they're in the SAME MEMORY SPACE man, DO YOU REALIZE HOW CRAZY THAT IS?· /1979 self)

    * Completely untyped and thus not suited for education
    

    If by "education" you mean "educating people how to write modern high-level code" then maybe yah.· But if you mean "educating people how the damn computer works and therefore how to write better code in their modern high-level environments" then you fail it.

    * Lacks concepts for save coding
    

    I suppose it is an example of my philistinism that I can't even figure out what you are talking about here.· Unless you mistyped "safe" in which case I'd say the first tool in writing safe code is learning the hard way to write safe code in an unsafe environment.· After a few crashes and three day debug fests to find the missing ~ you learn not to depend on the tools, which don't always work.· The tools are great when they do work but when they don't work if you can't do it the old-fashioned way you are teh screwz0r3d, and the Prop is meant to teach you to do it the old-fashioned way.

    * Designed by someone with no background in language-design
    

    And by the same criterion I insist to this day Grandma Moses can't possibly be an artist, because nobody ever taught her how to paint right.
  • ericballericball Posts: 774
    edited 2009-10-31 01:43
    Nick Mueller said...
    * Weird operators that redefined standards set by other languages.
    In other words, not propogating the broken C precedence, and using <= and >= as assignment operators instead of comparisons.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Composite NTSC sprite driver: Forum
    NTSC & PAL driver templates: ObEx Forum
    OnePinTVText driver: ObEx Forum
  • jazzedjazzed Posts: 11,803
    edited 2009-10-31 02:03
    I *always* forget the redefinition of >= compared to C and it costs me hours of misery. @ericball, maybe some light on the brokenness of the C definition is in order ?

    At least "word" is defined by the language as 16 bits which I hope does not change. It is a trap we already fell into once with "int" and hope we don't get a repeat.

    Actually method signatures are typed as "long" whether one likes it or not. Of course there is no warning if one accidentally abuses that.

    Post Edited (jazzed) : 10/31/2009 2:14:03 AM GMT
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-10-31 03:32
    Nick Mueller said...
    ....byte, word, long; whenever I read that, I slam my head...

    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long
    byte, word, long

    Hey, Nick, how does your head feel now? tongue.gif
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-10-31 03:40
    Just out of curiosity, and not to start anything, has anyone ever used >= and <= for their defined purposes? If so, how and why? They're rather odd in that they change the intrinsic type of a "number" variable to "boolean", which is a strange thing for any modify-and-assign operator to do.

    -Phil
  • BradCBradC Posts: 2,601
    edited 2009-10-31 07:25
    Phil Pilgrim (PhiPi) said...
    Just out of curiosity, and not to start anything, has anyone ever used >= and <= for their defined purposes? If so, how and why? They're rather odd in that they change the intrinsic type of a "number" variable to "boolean", which is a strange thing for any modify-and-assign operator to do.

    I initially found a few of the assign operators peculiar, but when you look into the interpreter source and you see how the compiler builds assignments like that I suspect it was almost easier to let all operators that could be assignments be so rather than special case them so they don't. If you get my drift.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If you always do what you always did, you always get what you always got.lt's not particularly silly, is it?
  • localrogerlocalroger Posts: 3,452
    edited 2009-10-31 12:24
    Actually, I've used <= and >=, generally when I have a temp var that starts out as a value and ends up as a flag for future reference after the operation. But BradC is right that they probably ended up that way more for consistency than usefulness, and it wouldn't break my heart if Spin did that more like Basic.

    One thing I really like about Spin is the way it handles Boolean operations. The usual way of using bitwise operators for Boolean is elegant but when you start using source values other than 0 and -1 it can get tricky. Having the distinct Boolean operators that coerce all nonzero values to -1 is very handy, very readable, and especially useful when you're mixing data types like mad to save RAM and your byte -1 looks like 255 compared to your word -1.
  • SapiehaSapieha Posts: 2,964
    edited 2009-10-31 13:04
    Hi all.

    My litle addition on naming BYTE, WORD, LONG it is most logical.

    BUT some assembly languges name it BYTE, WORD, DUBLE Word, and at last 64 bits ... Quad Word.

    In my opinion no mather what name is ... Only it that name is understandable.

    All "weired" operators that some CALL it ... WHT it is so much discusion on that .... It is not to hard to learn!!!!

    What about describing SPIN ...... It is just SPIN Language not mather if it are Like other -- Diference Give it its new possiblites that are needed for Propeller to function.

    Istead of time to discus that .... Give it TIME to Learn IT. Then it will be Yours next language.

    Ragards
    ChJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer.
    Don't guess - ask instead.
    If you don't ask you won't know.
    If your gonna construct something, make it·as simple as·possible yet as versatile as posible.


    Sapieha
  • JoJo Posts: 55
    edited 2009-10-31 15:45
    I'm with Nick on this. SPIN is a very strange language.
    Sure, relatively easy to learn ... *BUT* no easier than many other idiosyncratic dead programming languages.
    Very few people coming to this hobby come into it from a vacuum; most everyone here has had some programming
    experience and SPIN being so different from everything leverages very little of that experience.

    Fundamentally SPIN exists because Chip found it easier/more enjoyable to create a new language than to
    understand and do the work to adopt an existing language to the propeller. And I wouldn't discount the
    economic point for Parallax to have a captive audience by having a proprietary language.

    If SPIN was such a wonderful thing, how come that nobody outside this Propeller community uses or is even aware of SPIN?
    How come SPIN has not been adopted by anybody else?
    And if SPIN is so wonderful, how come there are so many development efforts here to create alternative compilers/languages?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    Jo
  • waltcwaltc Posts: 158
    edited 2009-10-31 16:47
    Got to agree with Nick on a few points

    Spin is totally unsuited to teaching beginners programming or learning about micro-controllers for that matter.

    Its saving grace is that Parallax included a bunch of useful objects when it was released and that it came free with the Prop.

    I just hope the PropII isn't tied to Spin like the current version is.
  • jazzedjazzed Posts: 11,803
    edited 2009-10-31 19:18
    waltc said...
    Spin is totally unsuited to teaching beginners programming or learning about micro-controllers for that matter.
    I suppose that depends on the teacher and what needs to be taught [noparse]:)[/noparse]
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-10-31 19:49
    It would be interesting to see a survey of Spin approval ratings vs. age of the respondents. If a person is hidebound by experience with traditional languages, would he be less apt to like Spin? Would those who are less experienced be more likely to embrace Spin for its terseness and utility, despite its iconoclasms?

    I hope that Spin (perhaps with a few tweaks and extensions) persists with the Prop II. Despite being difficult to categorize, it's the right tool for the Propeller.

    -Phil
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-10-31 20:51
    > With a couple of exceptions (most notably the very efficient but hatedly obscure ~ and ~~ operators) everything in Spin is found > somewhere else. They aren't all found in one language,

    That's exactly the point I meant with patchwork!
    I'm not complaining of the ritch set of operators, but the fact that they are taken from languages that are quite orthogonal. A much clearer solution to add those extra ops would have been:
    Take a route that is known (like Pascal, or C) for the common operators and add the extra ones by function-lookalikes. That wouldn't have added more code.

    > This is as stupid as the Comp Sci teacher I had back in 1981 who insited "byte" meant "any subdivision of a word" instead
    > of "8 bits."

    Fortunately, I didn't say that! smile.gif And even didn't want to say it.

    > On embedded platforms in particular a word is 16 bits just as a byte is 8.

    On 16 bit processors? So, I'm right.

    > As for using the word length of the machine in any meaningful way, that's been dead since IBM advertised the 8088-based IBM
    > PC as a "16-bit" processor back in 1982.

    So they were the first one to make that nonsense? Websters dictionary: Word ... and which functions as the smallest meaningful unit of a language.

    > Only because it doesn't do YOUR VERSION of OO. In 1970 it would have been considered quite radically OO.

    What date do we have now? "Object" has a quite well defined meaning in any programming-language taht is OO. And Parallax's use is an abuse of it.


    > But if you mean "educating people how the damn computer works and therefore how to write better code in their modern
    > high-level environments" then you fail it.

    So there is no need at all for a high(er) level language. Bite the PASM thing or die!

    > Unless you mistyped "safe"

    I did that. It's hard for Germans to distinguish safe and save.

    ... the first tool in writing safe code is learning the hard way to write safe code in an unsafe environment.

    Well PASM. See above. No need for SPIN.

    > And by the same criterion I insist to this day Grandma Moses can't possibly be an artist,
    > because nobody ever taught her how to paint right.

    OK, so it is naive art! LOL!

    My point is not, that SPIN is different. My point is, that it is different in needless places.
    There are derivates of languages like Tiny Pascal, or Tiny C or whatever you want. They do work, they do have shortcuts and additions are welcome to.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • heaterheater Posts: 3,370
    edited 2009-10-31 23:44
    Sapieha, "It is not true... Look on This Doc ... How near that are Spin programings MODEL"

    Not sure I see the programming model connection here. Apart from a superficially similar concept of data being divided into "shared" and "private" areas. A cursory glance at that document shows me that OpenMP is more to do with enabling the programmer to have parts of his algorithm parallelized. For example being able to write a loop construct which iterates over an array in such a way that the array can be divided into chunks each to be handled by a different CPU. More processors automatically getting you faster processing of the array with no recoding.

    Spin comes nowhere near those ideas.

    Now if RossH could get OpenMP working with his C compiler....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • heaterheater Posts: 3,370
    edited 2009-11-01 00:00
    Spin seems to be getting a lot of flak here.

    The idea that it may be a dud because it was designed by a non language design guru does not wash. ADA, as one example, was designed by a whole tribe of language gurus, see how popular that turned out. On the other hand when C was bashed out by Dennis Ritchie I'm not sure he was in the language guru class.

    How can Spin not be a great introductory language for teaching programming or micros? It has the least amount of cruft required to understand in order to get from knowing nothing to getting a LED to flash whilst being quite capable of complex tasks as one learns. A role that BASIC was used for and Logo was designed for.

    As for Spin adoption vs age/experience. What's the problem? I've programmed in a lot of languages over the years, all the way back to Algol. Spin is just another one, with it's own quirks. Seems to fit the task at hand very well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • PavelPavel Posts: 43
    edited 2009-11-01 00:35
    I work with high school students as a scientific advisor for sounding rockets program (I'm software engineer by profession) and we use Propeller chips for custom designed avionics. I find Spin an excellent language for fast prototyping (especially code-reuse is really easy with Spin). The high school students I work with usually have at least some Java experience and I myself prefer object oriented languages. Whether Spin is object oriented or not, I'll leave to CS majors to argue. What's important to me is that the variables are bundled with methods so Spin objects are sufficiently encapsulated and easily reusable (this is not as easy to achieve in say C and is outright impossible in P-BASIC). My students do not see any appeal in BASIC, but Spin gets their attention.

    What I really like about Spin is that you can use it to teach microcontroller programming on different abstraction levels. I have students who will never progress past simple
        Object.Method (arguments)
    
    



    calls (using objects that others wrote), but I also have students who can write bit-banging drivers and flirt with the assembler. So Spin is suitable both for those who want to work on the high level (say write the code for in-flight trajectory prediction) and those who are more intrigued by getting a particular piece of silicon work (say writing the driver for ADC or flash memory chip).

    Obviously the major problem of Spin is its very limited speed but conceptually it's a sound language well fitted to the size and capabilities of the host platform (those of you calling for full OO capabilities please consider the cost especially executable code size wise) .
Sign In or Register to comment.