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

How would you describe Spin as a language?

1356789

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-11-02 08:37
    RossH said...
    Yes, this is useful - but it a function of one particular IDE, not a function of the SPIN language.
    I think you've made my point for me: it doesn't need to be part of the language, given an appropriately designed IDE.
    RossH said...
    Also, it only works for the current file, ...
    But you can always click on another tab or an object name in the hierarchy tree to see other project files in an instant.
    RossH said...
    ... and it doesn't know about PASM functions at all.
    How could it? There's no such thing as a PASM "function" defined by the language. There's no encapsulation, nor any syntactic or semantic imperative that implies it, save a few scattered labels and maybe some ret instructions. They're just data that may or may not be treated as machine instructions. But that's the nature of assembly coding, especially when every bit of cog RAM has to count for something.

    -Phil
  • heaterheater Posts: 3,370
    edited 2009-11-02 08:58
    Ah but Phil, there is a long tradition that the language should be independent of any particular IDE. The idea that the programmer should be able to use whatever editor he chooses. As you know editor debates can be as heated as language debates. And what happens when the required IDE is not available for your computer, as was the case when I was using HomeSpun on Linux before BST came along.

    Hence my suggestion above. Header files, if needed at all, and documentation could well be generated from the source code. So whatever editor you use you end up with a consistent set of headers and docs after compilation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-11-02 14:24
    > Bah, header files, I hate header files. That's exactly the kind of cruft that a newbie programmer should not have to be confronted
    > with. They just want to be able write some simple lines of code that tackle the task at hand without being distracted by that
    > unnecessary baggage.

    Well, then go along without them and you're happy. You can use (sorry) C without header files. But they are very handy for briefly describing what's going on in that library. Also, they do help in the design-process. Start thinking about what that lib should do and look like to the user. Write the header until you are happy. Ctrl-a & Ctrl-v to copy that to your implementation file and start filling in the code, and adding private functions and vars.

    > Strictness is a crutch.

    Strictness is a means for better design. Lack of strictness is an invitation for spaghetti-code and hacks. People should learn to start thinking in data-flow and stepwise refinement. I always like to make the parameters to a function as strict as possible (by defining types, enums etc.).
    How I hated the BASIC on my first computer (Apple ][noparse][[/noparse]) and how happy I was when I got the language-card together with Pascal. That was the best present from my parents (beside the Apple). And I'm still thankful after 30 years.

    > A brilliant programmer made some mistakes which he would
    So it's just a mistake, but not bad design? Well, I really can't understand what you want to explain me here. If he didn't think well enough about the environment his code will run on and he only had his "brilliant" design in his head ... it was bad design!

    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-11-02 15:01
    Nick, I agree in principal about design and headers.
    But it has gone horrible wrong somewhere.
    In support of this I would like you to login to any Linux box and have a look at the header file for one of the most basic and widely facilities in C. That is the ISO C 99 standard /usr/include/stdio.h.

    I think you will agree that there is noway a newcomer to programming is going to have anything but a headache being given that as description of C's I/O facilities. There is no way stdio.h is "briefly describing what's going on in that library" as you say.

    Not sure how that looks in the Windows world though.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • potatoheadpotatohead Posts: 10,261
    edited 2009-11-02 16:31
    This dilemma is what all those quick reference books are for!

    And that says something kind of ugly about how it all ended up going.

    I can strongly identify with purists where language is not dependent on tools. Agreed, and without this being true, open computing is at risk. The core of me is all about open and that's really for computing freedom kinds of things. We've all had a few bad experiences involving tool changes, DRM, trusted computing, etc...

    So here's the twist on that regarding Propeller.

    I simply trust Parallax, where I wouldn't trust many others. The holistic design of the propeller, it's tools, languages and such is really attractive. It's not like there are competing models or anything. Using the set as given then makes a whole lot of sense and is productive. Part of the fear I have surrounding this ends up being an artifact of so many companies using investments like that to "extract revenue from the customer / user". God that pisses me off, and is what originally started me down the road to understanding and using open code and open data.

    At this particular time in my life, I know I've got the skills I need to make use of open computing tools. Most of us here, could dumpster dive, pull out some goodies, and have a proper environment up and running for the cost of internet access and some sweat. Damn cool stuff.

    With the Propeller, it's known the longer term outlook is not to abuse peoples investments, and I simply believe that where I just wouldn't otherwise. So then, I'm quite happy to run the Prop, Prop tool on my XP laptop that I carry for professional reasons, and life is just good. If something bad happens, the necessary bits have been documented, and open alternatives are there and working, in some cases, in ways superior to the Parallax tool set. This is a good thing, but not a mandatory thing.

    What it means to me is that my trust is warranted and insured. (thanks to those who went the distance to get this done, BTW)

    Newbies are interested in doing stuff. The default, reference set of tools gets that done with a potency not seen elsewhere. I believe this is an artifact of the holistic design, and even though that does build in a dependency, the rewards in terms of just making the stuff go, are well worth that violation of principle, particularly given how Parallax appears to operate.

    The end result is I'll easily make that investment, feeling secure in being able to use it in the longer term.

    I like the Prop tool a lot. To me, it's extremely easy, and it adds a lot of value to SPIN in how it works to present the language to me. And the overhead is just low all across the board. To an experienced hand, it's different, which brings the hysterisis of skill transfer, but to most others, it's a net gain, not worth bending to satisfy those who feel the overhead in this way. The reason is there is no real barrier to alternative tools, and seeing those spawn, grow and see use, really validates all of that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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!
  • jazzedjazzed Posts: 11,803
    edited 2009-11-02 16:59
    heater said...
    There is no way stdio.h is "briefly describing what's going on in that library" as you say.

    Not sure how that looks in the Windows world though.
    It's worse for C in Windoze ... security hacks. You may be delighted to know .net does not use header files [noparse]:)[/noparse]
  • potatoheadpotatohead Posts: 10,261
    edited 2009-11-02 17:32
    +1 for .net

    [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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!
  • Dave HeinDave Hein Posts: 6,347
    edited 2009-11-02 19:10
    I am actually working on a C to Spin pre-processor, so I have noticed similarities and differences between C ans Spin.· Spin is similar to a subset of the C language that contains only the char, short and long types, and no struct.· Spin has an odd feature where global variables can be one of the three storage types -- byte, word or long, but all function parameters and local variables can only be longs.

    The operators used in Spin are similar to those used in C, and in some cases are identital.· Spin contains a few extra operators to compensate for the limitation in variable types.· Spin also includes very nice features for performing bit manipulation.· Macros or functions·would be·required to duplicate this functionality in C.

    Spin has the built-in capability to start up code in other cogs, and to do remote function calls.· Macros or functions would be required to do this in C.

    In my opinion, the lack of braces and the indentation requirement of Spin makes it harder to identify blocks of code in Spin.· Even though indentation is not requred in C, almost every piece of C code that is written uses it.

    ·
  • SamMishalSamMishal Posts: 468
    edited 2009-11-02 21:02
    Nick Mueller said...
    You can use (sorry) C without header files.
    Not true............unless you have a program void of any function. To do ANYTHING in C you need header files.
    Nick Mueller said...
    How I hated the BASIC on my first computer (Apple ][noparse][[/noparse]) and how happy I was when I got the language-card together with Pascal. That was the best present from my parents (beside the Apple). And I'm still thankful after 30 years.
    I used the Apple II (with BASIC) to write simulation models·for river flow to assist in the design and·planning of a DAM. I used it to write programs that did soil stability analysis. I used it to write programs to do three dimensional frame bending moments, shear stresses and deflection analysis. I used the very same BASIC to write programs to solve the differential equations for finite element analysis. I wrote BASIC programs to log and carry out all the calculations for Surveying data of an entire town.
    ·
    I used the very same BASIC to write Graphical Games (ok not great ones). I used the very same BASIC to write my own Word Processor and DataBase manager (they did not exist at the time as commercial programs).
    ·
    The amount of PRODUCTIVITY and fun I had with the Apple II and its BASIC is beyond enumeration. The partners of the Consulting Company I was working for at the time were amazed at what this young engineer bringing along to his cubical his own personal computer (the IBM PC was not yet invented) to do what other engineers were waiting for days to do on the company's mainframe (due to job queuing). I later used the same Apple+BASIC to write numerous programs to assist me in·doing the analysis and calculations for my Masters thesis (they were ALL in BASIC). I of course also used the University's mainframe with Fortran to do the final reports. But the freedom I had using the Apple II at home instead of having to be tied up always waiting for my turn to use the Mainframe was just so LIBERATING.
    ·
    So while some people were debating the impurity of BASIC and·how it does not help develop good programming practices, I was actually PRODUCING not just practicing USEFUL and RELEVANT programs that RESOLVED and MET a NEED. I did not care if it was better to use Cobol, or Fortran or PL/I.
    ·
    I had a tool and I used it. It achieved the job and met the required parameters....I did not care what the puritans were saying. While they were·DEBATING I was DOING.
    ·
    Nick Mueller said...
    Strictness is a means for better design. Lack of strictness is an invitation for spaghetti-code and hacks. People should learn to start thinking in data-flow and stepwise refinement. I always like to make the parameters to a function as strict as possible (by defining types, enums etc.).
    Psychiatrist: "Tell me why are you afraid to step out of your house"
    Patient······· : "There are too many roads. Ones leading to the right, ones leading to the left and ones going straight on....I just cannot
    ··············· ······ decide which road to take....I am just too afraid if I take the one to the left it would take me in the wrong direction."
    Psychiatrist: "But you know where you want to go. Just pick the road that goes in that direction. Ignore the others."
    Patient······· :·"I cannot doctor. There are just too many choices. I wish they would just come and block off all the roads but one. That way I can just
    ······················ take that one and I would not have to decide."
    Psychiatrist: "But what if they block off the road that you need and only leave you the road that goes in the wrong direction."
    Patient········: "I do not care. I want someone to decide for me. I cannot do it myself. It is safer if someone makes the decisions for me."
    Psychiatrist: "Ok I will make a decision for you. How about we cart you off to the LOONY BIN and shut you up in a room for the rest of your life
    ··· ················· you pitiful CRAZY FOOL".


    Post Edited (SamMishal) : 11/2/2009 9:12:11 PM GMT
  • RossHRossH Posts: 5,516
    edited 2009-11-02 22:23
    SamMishal said...
    ............unless you have a program void of any function. To do ANYTHING in C you need header files.
    Not true. You can have perfectly valid C functions (or in fact entire C programs) without any header files at all. I think you probably mean "library" functions - and this was one of the points I made in an earlier post in this thread. Whether you love them or hate them (and I agree they are very easily abused), C header files (and libraries as well) are the way C supports encapsulation and information hiding. SPIN has no equivalent. This means that there is a certain level of complexity that is more easily supported in C than in SPIN.

    Put simply, C supports "programming in the large" (albeit not very well) whereas SPIN is intended for "programming in the small" (see here ). This is not intended as a criticism of SPIN - it is a reflection of the fact that SPIN was originally intended as a language for microcontrollers, but is now being considered in a much wider context (just as the Propeller itself is being used in ways the original designers didn't anticipate). What is entirely appropriate for a language whose programs can never exceed a few dozen pages, which are usually written by one programmer over a few days or weeks is not appropriate for a language whose programs routinely consist of tens of thousands of pages, are usually written over many years, and usually by many programmers.

    Of course, many languages are better at this stuff than C - but very few would be worse at it than SPIN. Funnily enough, BASIC is one of the ones most people would probably list (I mean the original BASIC, not the various "tarted up" versions). Like you, I have fond memories of BASIC and the freedom and power it brought to microcomputers. But I don't use it to write large or complex applications - BASIC suffers from many of the same limitations as SPIN (and for much the same reasons).

    Ross.

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

    Post Edited (RossH) : 11/2/2009 11:41:52 PM GMT
  • photomankcphotomankc Posts: 943
    edited 2009-11-02 23:40
    Well, I won't get too wrapped in to this discussion except to say that my prior experience in programming has been with Java, C++, and various flavors of basic on PCs. When I tried my first project with an MCU (68HC11) probably 11 years ago, I was lost in the amount of working hardware to get going before you could even know if one #$%$# byte of code was executing. I made various attempts at it but my OOP/IDE background just didn't jibe with the rather primitive tools that I had access to for it. ASM was and still is something that I have great difficulty even starting off with so I gave it up without ever seeing so much as a blinking light. Never again looked at MCUs until a few months ago.

    I stepped into the Propeller with almost no difficulty. I find the SPIN language easy as sin to use and with enough 'object' to it to be useful and no more. It has definite limits in that perspective but it allows me to keep a modular approach to code which I just can't get into BASIC for lack of. The Propeller is simple to get started with in both hardware and software and there is a lot to be said for that. I am simply amazed at what the combination has allowed me to get done in a few weeks when 11 years back I was ready to stomp puppies trying to get an LED to blink. I really think the chip and language work very well together. I do want to explore what, if any, extra performance can be seen with C on it but for now I get a lot done with SPIN. PASM is on my list of things to get to know as well.

    I can't really relate it to other languages I have used. I mean there are some reminders of C/C++ in there but enough is different to make calling it similar a stretch. I never used forth, python, or smalltalk or pascal so I have no way to compare it.
  • RossHRossH Posts: 5,516
    edited 2009-11-02 23:47
    @photomankc

    Exactly. SPIN is good (I'd even go so far as to say excellent) at this type of small scale development - that's what it was designed for.

    But you'd have to be a lunatic to try writing an operating system with it - mind you, I believe there are several well-known and highly respected lunatics in these forums doing just exactly that tongue.gif

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • Bill HenningBill Henning Posts: 6,445
    edited 2009-11-03 00:41
    Actually, (as a probable hinted-at lunatic) I'd have to say that initially I thought Spin would be horrible to write an OS in.

    In actuality it is not bad at all.. the Largos prototype (written in Spin) is far better than I expected.

    A few minor tweaks to spin, and faster bytecode interpretation, and it would be better yet.
    RossH said...
    @photomankc

    Exactly. SPIN is good (I'd even go so far as to say excellent) at this type of small scale development - that's what it was designed for.

    But you'd have to be a lunatic to try writing an operating system with it - mind you, I believe there are several well-known and highly respected lunatics in these forums doing just exactly that tongue.gif

    Ross.
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    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
  • RossHRossH Posts: 5,516
    edited 2009-11-03 01:01
    @Bill,

    roll.gif

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • cgraceycgracey Posts: 14,256
    edited 2009-11-03 04:26
    Spin is the product of both love and hate.


    Some·loves:

    1) Terse,·but obvious, coding syntax - so it's easy to learn, write, and read.

    2)·Keeping binary phenomena·unobscured - it's the way that computers really work·and·pretending otherwise leads to trouble.

    3)·IF, CASE, REPEAT -·do you really need anything else?

    4) \method and ABORT - all that is needed to·pop you out of deep·holes.

    5) Encapsulation·of code & variable modules - made especially useful·in multi-processing.

    6) Functional documentation embedded in source code, being instantly extractable.


    Some·hates:

    1)·VARIABLE TYPES·- they've presented nothing but headaches to me in other languages, never an advantage, and never "safety", just fun-killing·rigidness that often requires digging·to get around. I think being taught to program within the myriad of strictures presented by typed languages·is a sure way to build blockages to true understanding of computing in a person. The only meaningful delineation I see is between bit-lengths (with some particular length being perfect for pointers, which can, incidentally, point to z-strings). Everything else would come at the expense of subtle expression syntax rules for each class of type. No thanks!!!!! A float type may be a·worthy·exception. Structure support would be a useful addition to Spin, for sure.

    2) TYPING ANYTHING TWICE - header files and function prototypes are unnecessary, redundant drains that·kill the joy of programming. Imagine having a hobby, but then remembering that before you engage in it, you must fill out government paperwork on each occassion. No way.

    3)·"Properties" getting squirreled away in oft-HIDDEN MENUS, particulary within flaky IDEs. I'll take a source code·file any day.

    4)·HIDDEN LIBRARIES·of possibly rotten code. You should be able to see what's going into your project, and this is often necessary, anyway. Programming Windows can be like trying to build a jet engine from parts you buy at WalMart.


    There's a lot more, but that's all I have time to write now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.

    Post Edited (Chip Gracey (Parallax)) : 11/3/2009 4:40:11 AM GMT
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-11-03 05:12
    Thanks Bill... I think I might be one of the lunatics too· confused.gif

    I think (well I hope)·that we know when to use spin and when to use PASM (or LMM, etc). And in many cases it's OK to use spin to test a theory and if more speed is required, convert it to·PASM.

    Chip: Thanks for your comments too. There has been a lot of flack in this thread. SPIN is fantastically simple provided you keep the summary nearby for the obscure operators. SPIN is just so simple to get started.

    How many micro chips can you get running with a couple of statements? I only know of ONE. Each time I think about other micros, I remember the time it takes to get a basic set of instructions working. Admittedly, you only have to do this once for a shell, but you do have to get all the register hardware definitions setup before the micro will do anything simple, even flash a LED. The prop can turn a LED on in 2 lines (DIR and OUT).

    How simple is this to make a LED flash (the repeat 10000 may need adjusting - I haven't tried it)

    Pub Main            'make a LED flash
      dira[noparse][[/noparse]23] := 1     'make pin 23 output (has resistor and LED attached
      repeat
        outa[noparse][[/noparse]23] := 1   'pin 23 = 1
        repeat 10000    'delay
        outa[noparse][[/noparse]23] := 0   'pin 23 = 0
        repeat 10000    'delay
    

    I used·SPIN to write my SPIN & PASM Debugger. Why? It was simple, easy to understand, and when you are debugging you do not need it to be fast.

    Heater & I use SPIN for the slower sections of ZiCog - the actual hardware emulation and the initialisation sections. The Z80 instruction emulation is of course·in PASM.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)
    · Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-03 05:46
    I hear a lot of grousing about the speed of Spin. There are an awful lot of tasks where Spin is more than fast enough. For goodness sakes, Spin code can do half duplex 19200 Baud serial. Canned objects with the low level stuff done in assembly take care of a lot of the tasks where Spin isn't fast enough and it doesn't take a lot of assembly code at that. Look at what was accomplished with the hardware Z80 and instructions that executed in about the same order of magnitude as the more complex Spin bytecodes. Sphinx is a good example of what low level (and some high level) functionality can be moved into the cogs' memory to free up hub memory ... TV text output (with the screen buffer in the cog), a keyboard driver, and an SD card filesystem, all in 5 cogs.
  • RossHRossH Posts: 5,516
    edited 2009-11-03 10:33
    Mike, Chip ...

    I don't disagree with either of you - the Prop is excellent at what it was designed for (as well as many things it wasn't) - and SPIN is the ideal language for many Prop developments. And as Chip points out, it certainly does bring joy back to software development.

    But for large and complex apps? No, I wouldn't choose SPIN for that. There I want as much help as I can get from my toolset - if I can get it, I would always opt for absolute type safety, enforcable interface contracts, and as much information hiding as I can possibly get. Not to mention platform independence, resuable libraries, and generic programming. Not for any idealogical reasons - just because decades of hard slog eventually taught me that these things can increase my own productivity many, many, many times over.

    But I accept that my needs and wants are not the same as all Prop users - possibly not even a significant minority. And it is a credit to Chip and Parallax that we are now having these discussions about a microcontroller costing a few dollars. I remember the days when squeezing a general purpose computer in a single room was a big deal. Then a single cabinet. Then a single board. Now a single chip. Where to next?

    Ross.

    P.S. If A = float and B = structures, then of course SPIN + A + B = C smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-11-03 10:53
    > In support of this I would like you to login to any Linux box and have a look at the header file for one of the most basic and
    > widely facilities in C. That is the ISO C 99 standard /usr/include/stdio.h.

    Heater! That was a good argument! smile.gif)
    The problem is, that it has to be very configurable for different models. But if you go back to your own little world, things are much easier. Even in big projects (in C++) with many man-decades of work I do not recall header-files like the one you cited.

    > With the Propeller, it's known the longer term outlook is not to abuse peoples investments, ...

    Full ACK!

    > To do ANYTHING in C you need header files.

    For your own code? Thats dead wrong, even if you change you font to 34 points.

    > "Ok I will make a decision for you. How about we cart you off to the LOONY BIN and shut you up in a room for the rest of your life
    > you pitiful CRAZY FOOL".

    You are running out of arguments again? Not the first time that I have to read such a nonsense from you. I already gave the advice which route to take, that doesn't require a psychiatrist in your wrong metapher.


    Nick

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

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • SamMishalSamMishal Posts: 468
    edited 2009-11-03 11:41
    Nick Mueller said...
    > To do ANYTHING in C you need header files.

    For your own code? Thats dead wrong, even if you change you font to 34 points.
    I defy you to show me ANY C program that does any kind of minimal user I/O that does not requires a header file usage.
    ·
    To qualify for the challenge I or anyone has to be able to cut and paste the code you give us AS IS without any additions or modifications into a C compiler and be able to compile and run it.(BTW pasting the header file inside the program as a whole is a cheat and is not allowed).
    ·
    Here is a pseudo code for a minimal program ..... I defy you to implement·it in a C program without having to use a header file.......I mean without an #include of any kind.
    ·
    ==============
    Prompt user for· a·name
    Obtain·the name
    Prompt the user for year of birth
    Obtain year
    Calculate Age
    Display "Hello "+User Name+" you are "+Age+" years old"
    ==============
    ·
    Very simple...no? If you can show me a program that·implements the above pseudo code without having a single #include in it ..... I will retract my words....if not then you must admit that saying "Thats dead wrong" is dead wrong.............
    ·
    Or even better......show me a program in C that can accomplish what Cluso99's program shown·above in Spin does. And I mean flashing an actual LED not a screen simulated one. But I will grant you a simulated screen one too.

    If you can show me a C program that can do that without the use of any #include files then you are a GURU.
    ·
    Sam


    Post Edited (SamMishal) : 11/3/2009 12:18:47 PM GMT
  • BaggersBaggers Posts: 3,019
    edited 2009-11-03 11:43
    My turn for a 2p's worth [noparse]:D[/noparse]

    The way I see it is Spin is not only the glue but also the candy that entices newcomers til they feel confident/comfortable enough with to then jump into PASM.

    It has more than enough features to carry out the many many tasks we throw at it, you only have to look at the amount of apps the prop has to see how good it is.

    Also, for example, proof of how good it is, I originally started microcontroller coding on the PIC chips, thanks to Rickard Gunee's console web site, I then got a Velleman pic programmer board from Maplin and got into that, learning the fuse setting etc was a PITA, when swapping to a different PIC cos I needed more speed having to re-learn the fuse settings etc, and then realising that there was bugs in the serial side of the chip, and having to work around that. then I came across the Prop, which is a LOT faster than any pic, yes it may have 40 mips, bit you can't have 8 of them going at once [noparse]:D[/noparse] anyway, to me, Spin was the Candy, as it's so easy to learn and pick up, yes I do have the advantage like most of you here, that I've been professionally programming for 24 years, and as a hobby for 4 years prior to that, while I was still at school, so yes, it was easier than a total noob, again, back to spin, if you needed more speed, like with pics, or an extra function you don't need to get a different pic, and have to re-learn setting it up etc, you can jump into PASM, there are tutorials on here, and a LOT of people who can help.
    Also again with the joy of Spin and the prop in general, a while back, I very very briefly looked at another microcontroller, Leon may tell you what it's called now and again, but I won't here, anyway, I looked at it, and didn't like coding it at all, it was too much messing around to do what you want it to do, and you don't really have a clue of how the memory is laid out, or split, so it now gathers dust [noparse];)[/noparse]. To me, the prop is EXACTLY like what it says in one of the first advert picture I saw for it, can't find the pic, just looked now, google is not my friend today lol, anyway it was along the lines of, bringing back the good old days when programming was fun. [noparse]:)[/noparse] it's certainly been a joy to write everything that I've done on the prop, and everything that I'll do in the future also.

    Well that's my 2p's worth anyway [noparse]:)[/noparse]

    Baggers.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    http://www.propgfx.co.uk/forum/·home of the PropGFX Lite

    ·
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-11-03 12:01
    I way I see it there are no fools here, we are certainly not normal though, otherwise we would not be using that gimmicky and "amateurish" Propeller chip.

    So the fact that we are Propeller people is not a good thing in the eyes of the "normal" people. How they must look at us both with disdain and wonderment.

    What in blue blazes is going on here! Last time I looked at a propeller (the real thing) it had multiple blades, not all of them were on the same side either. I think they do that for function and balance.

    Do we all drive the same car? No!
    Do we all speak the same language? No!
    Do we all like the same food? No!
    etc etc
    Do we all like the Propeller? Yes!

    See, we don't have much in common except this odd little chip and it's rather odd way of doing things. I don't have a problem with that because this odd little chip actually works, rather surprisingly well in fact, and goes on surprising. In turn I have come to appreciate the whole package and I don't think the Prop would be the same without Spin. In turn every computer language has it's deficiencies, it's just that we get used to them, like English, but to us English speakers it's our "preferred" choice, it's natural for us, whether it's good or bad as a language in the eyes of others, it doesn't matter.

    But Spin is simple enough yet powerful enough to let the creative juices flow so to speak without the conventional overheads that stop you in your tracks making you do it the "right" way or conversely too simple that you run into a brick wall. Yep, I can see a lot of shortcomings with Spin, but absolutely anybody can see that as there has never been a language that has been exempt. Being able to see the potential and make use of it is what we have been doing and that sets us apart from those other forums that are bogged down with debugging and trying to convince their mainstream language and tools to blink an led. This Propeller forum is a direct reflection of that creative energy, let's channel it, together.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • SamMishalSamMishal Posts: 468
    edited 2009-11-03 12:08
    Nick Mueller said...
    You are running out of arguments again? Not the first time that I have to read such a nonsense from you. I already gave the advice which route to take, that doesn't require a psychiatrist in your wrong metapher.

    As a metapher my metaphor might be wrong.
    ·
    But as a metaphor you have not gotten the point. Your advice is not necessarily the one I want to go with. I want to be able to do my own thinking by myself. I want the freedom to do what I want. I do not want to be restricted by people who think that they know what is best for me and everybody else.
    ·
    I want a system that allows freedom of choice. I am able to decide by myself and am able to take the responsibility for my own action.
    ·
    ·
    Sam
  • RossHRossH Posts: 5,516
    edited 2009-11-03 12:36
    @SamMishal ...

    #define HMI 1
    
    extern long _sys_plugin(long code, long param);
    
    int _short_plugin_request (long plugin_type, long code, long param) {
        return _sys_plugin (plugin_type, (code<<24) + param);
    }
    
    int k_wait() {
        return _short_plugin_request(HMI, 3, 0);
    }
    
    int t_string (unsigned curs, char *str) {
       return _short_plugin_request(HMI, 23, ((curs&1)<<23) + (int)str);
    }
    
    
    void main() {
       char name[noparse][[/noparse]10];
       int i;
       t_string(1, "enter your name\n");
       for (i = 0; i < 9; i++) {
          name[noparse][[/noparse] i ] = k_wait();
          if ((name[noparse][[/noparse] i ] == '\n') || (name[noparse][[/noparse] i ] == '\r')) {
             break;
          }
       }
       name[noparse][[/noparse] i ] = '\0';
       t_string(1, "hello ");
       t_string(1, name);
       t_string(1, "\n");
    
       /* etc etc */
    }
    
    
    



    Compiles with catalina and runs on the Prop (I tried it).

    I'll leave it to you to add the rest of the logic you wanted.

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-11-03 12:49
    > Here is a pseudo code for a minimal program ..... I defy you to implement it in a C program without having to use a header file.
    > ......I mean without an #include of any kind.

    You challenge is to have multiple files without any #include?
    Quite funny!
    I'm giving that challenge back to you to do it in SPIN. Also without any kind of '#include' (read 'object').
    Now if you end up with a c & p of all needed files into one single file, you shouldn't be too challenged to do the same in C.


    > If you can show me a program that implements the above pseudo code without having a single #include in it .....
    > I will retract my words....if not then you must admit that saying "Thats dead wrong" is dead wrong.............

    What's your challenge? I wrote "own libraries". Not those of others, simply because they were written to work with header-files. HEADER-FILES, not includes!

    Do yourself and the readers a favour: Read the posts of others and re-read your own posts before you hit return!

    EOD for you now!

    Nick

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

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • SamMishalSamMishal Posts: 468
    edited 2009-11-03 13:31
    #define HMI 1
    
    [b]extern long _sys_plugin(long code, long param);
    [/b]
    int _short_plugin_request (long plugin_type, long code, long param) {
        return _sys_plugin (plugin_type, (code<<24) + param);
     
    [noparse][[/noparse]....]
    
    

    Hi Ross,
    ·
    I think the Catalina is AWESOME........How is the BOLDED extern resolved upon compiling? What do I use for input and output?
    ·
    Unfortunately I cannot·try the program. I am not versed with the Catalina. But I think that you can do such a thing on the Propeller is a wonderful testament to the Propeller.
    ·
    I can do the above very easily with Spin too and I can do it on any platform for the propeller. I can use FullDuplexSerial which is my favored method since I can do both Keyboard Input and Screen output all in one cog and on the development platform.
    ·
    I can·use TV_Text/ VGA_Text and Keyboard.....but then I have to wire up and plug in a keyboard and a TV/VGA screen.
    ·
    But the point is that SPIN gives me the choices and the abilities to do things the way I want.
    ·
    Also I am very interested to see the equivalent to Cluso99's program above in·Catalina.
    ·
    I do admire and applaud your work with the Catalina.....if I get the time some time I WILL DEFINITELY try it out....it is worthy of admiration......
    ·
    Unfortunately I have limited time.....I do not know how you guys on this forum can manage such AWESOME work and still SLEEP.
    ·
    A very important point HOWEVER.....I picked up the Propeller and with Spin in a day I was able to write programs that accomplished AMAZING things that had me jumping for joy at what I saw being done. (e.g. blinking two LEDs totally independently with their own timing).
    ·
    If I were to do the same with anything other than SPIN I would have not done it in a DAY....A DAY......this is the MOST IMPORTANT thing about SPIN.............any one can pick it up and be productive on the propeller with it IN A SHORT TIME............later if one requires more power he has the CHOICE to use PASM and the FLEXIBILITY of the OBEX objects and and and..........
    ·
    ·
    So SPIN is ·EASY, CAPABLE, and is the best way to get things done with the propeller even for a novice to· programming.
    ·
    The main thing is that it allows FLEXIBILITY combined with ABILITY.
    ·
    Sam

    Post Edited (SamMishal) : 11/3/2009 2:12:04 PM GMT
  • SamMishalSamMishal Posts: 468
    edited 2009-11-03 14:08
    Nick Mueller said...

    Do yourself and the readers a favour: Read the posts of others and re-read your own posts before you hit return!

    I am reading your posts.......I find nothing but·insulting critical naive·nonsense...........here is one·.....
    Nick Mueller said...
    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

    I don't see anything designed by you.... the almighty GURU.......and I am sure it would be Smile anyway...............
    ·
    At least Chip has designed something USEFUL and WONDERFUL (despite your opinion) and is ENABLING people to ACHIEVE things that are amazing.
    Whether SPIN meets YOUR faulty standards or not it is immaterial. It WORKS and works VERY WELL at that.
    ·
    So when you PRODUCE something as good or better .....come back and talk to us......for now you are irrelevant....
    ·
    Sam
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-03 14:45
    @Sam & Nick - These forums are supposed to be a place for civil discourse. People can have strong disagreements and, at some point, maybe should agree to disagree, but be careful about personal attacks.

    @Nick - My graduate school advisor was an expert in computer graphics among other things and was the head of the Computer Science department. He happened to be blind since childhood and thought of that as an advantage since he wasn't constrained (in terms of the graphics area) by what he could see. Having formal education in computer language design is handy because you may be exposed to tools and ideas that you might not have otherwise, but it's not necessary to produce good work. Remember that many of the designers and implementers of the foundational ideas and tools in this area had no formal training in it because they created it in the first place.
  • RossHRossH Posts: 5,516
    edited 2009-11-03 14:49
    @Sam,

    The _sys_plugin function is not a normal function - it is Catalina's equivalent of a "supervisor call" - i.e. a direct call into the Catalina kernel. This is a standard technique for giving programs (especially C or assembly programs) access to underlying system functions (see here).

    If you know how to invoke supervisor functions you can do much the same thing on most C compilers (this is one reason C is usually considered a low level language akin to assembler, and not a high level language at all). Because the mechanics are different on every machine they are usually hidden from the programmer inside various library functions. All I am doing here is invoking them directly.

    In this case I am using the _sys_plugin call to invoke a couple of functions provided by Catalina's HMI (Human Machine Interface) plugin - a "plugin" is just a driver (or some other helper program) which runs in a separate cog and is known to the kernel - effectively "extending" the kernel. Catalina provides a very simple but standard interface that all plugins use (other examples include various floating point libraries, the SD card access functions and the real time clock). The HMI plugin provides all the basic terminal I/O functions which underly the more traditional C library functions like "printf". All C compilers (at least all ANSI C compilers) must provide the same set of such functions. They should really be considered part of the language.

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2009-11-03 14:55
    @Sam and Nick - Come on lads leave it out ! - this is not what the forum is about.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    'Those who can, do.Those who can’t, teach.'
    'Convince a man against his will, he's of the same opinion still.'

    ·
Sign In or Register to comment.