Shop OBEX P1 Docs P2 Docs Learn Events
5 Computer Lanuage similar to PBasic - Page 2 — Parallax Forums

5 Computer Lanuage similar to PBasic

2

Comments

  • Heater.Heater. Posts: 21,230
    Eric,
    Spin is actually not too different from BASIC..
    Hmmm...

    There are no line numbers in Spin.

    Spin has no GOTO

    Spin does not have floating point numbers.

    Spin does not deal with strings easily.

    Spin does have objects.

    Spin can address memory directly.

    But, yeah, they both support "sequence, selection and iteration" and some kind of subroutine so they are essentially the same.

    :)


  • Heater. wrote: »
    That's rather large isn't it?

    A "Hello World" program in C compiled on Windows 10 here is only 8K Bytes. And I'm wondering why that is orders of magnitude bigger than it need be.

    The problems come when one has hundreds of thousands of lines of code written by many people over a long time. And then one wants, or has, to move it to a different platform. Then a standardized language starts to look like a good idea.


    Well, I'm going back 20 years. I haven't programmed for Windows recently.

    My own platitudes bore me so I'm not about to do the same to you guys. Suffice to say that, as a know-nothing programmer who was forced in to learning to write software in 1986, I found myself in business, a year later, with a $1M+ coming in....I was still trying to understand why I had all these data types to choose from and why I'd ever need a multi-dimensional array.

    This was QB and eventually, I hired REAL programmers who both worshipped their K&R bibles. They both insisted on rewriting my code in C. I was cool with this because I wasn't cool with telling my customers that we used BASIC. You know what? The C code never materialised because my megabuck software engineers realised that they couldn't compete with the rapid development/debug that was possible under MS PDS 7.1.
  • kwinn wrote: »
    David Betz wrote: »
    If we're going to talk about BASIC it would be nice to specify a particular implementation. Otherwise it is impossible to comment on its productivity as compared with another language. I'd like to challenge anyone to use PBASIC to implement a compiler for itself. You can certainly do that with C and probably with Visual BASIC. You will have a hard time with PBASIC. There are so many different dialects of BASIC that I guess there is probably some dialect for every imaginable problem domain but there is not a single universal dialect that can handle them all like C can.

    Not a fair or reasonable comparison. C was initially designed to be a high level "assembly" language so it could be adapted to a variety of computer architectures and instruction sets. PBasic was designed as a high level language to make optimal use of the Propeller chip.
    I think you mean that PBASIC was designed to make optimal use of the BASIC Stamp not the Propeller but I get what you mean. I wasn't really serious when I asked if you could write a compiler in PBASIC and I agree it isn't a fair comparison. However, it points out that you can't just talk about BASIC as if it is a single language. If you're going to compare BASIC with C or any other language you have to specify which version of BASIC you're talking about.

  • Heater. wrote: »
    Eric,
    Spin is actually not too different from BASIC..
    Hmmm...

    There are no line numbers in Spin.

    Spin has no GOTO

    Spin does not have floating point numbers.

    Spin does not deal with strings easily.

    Spin does have objects.

    Spin can address memory directly.

    But, yeah, they both support "sequence, selection and iteration" and some kind of subroutine so they are essentially the same.

    :)

    Maybe the correct comparison is PBASIC with Spin. I see Spin as being a grown up version of PBASIC. PBASIC has no floating point numbers or strings and its line numbers are optional.

  • The_MasterThe_Master Posts: 199
    edited 2016-09-20 20:48
    David Betz wrote: »
    If we're going to talk about BASIC it would be nice to specify a particular implementation. .

    It doesn't matter.

    -Most versions of Basic are similar in that they don't use braces and semicolons. Even fans of C/C++/Java/etc (except Heater) will admit this part is a mess

    -Most versions of Basic have fully capable gotos. These are absolutely needed for state machines. If you are truly doing embedded control, a lot of it is about the state machines. And this is the Parallax forum.

    -In any version of Basic, development speed is faster than assembly or byte-toggling. Development speed with C is not faster than Basic, it's slower.
  • The_Master wrote: »
    David Betz wrote: »
    If we're going to talk about BASIC it would be nice to specify a particular implementation. .

    It doesn't matter.

    -Most versions of Basic are similar in that they don't use braces and semicolons. Even fans of C/C++/Java/etc (except Heater) will admit this part is a mess

    -Most versions of Basic have fully capable gotos. These are absolutely needed for state machines. If you are truly doing embedded control, a lot of it is about the state machines. And this is the Parallax forum.

    -In any version of Basic, development speed is faster than assembly or byte-toggling. Development speed with C is not faster than Basic, it's slower.
    Another hopeless language war...
    BTW, C has goto as well so I guess it can be used to implement state machines.

  • Heater.Heater. Posts: 21,230
    Mickster.

    More than 20 years ago I was writing Windows 3.1 code in assembler. Just for fun. I happened to find a book that showed how to do that. At the time I found it easier to put up a window and a message and a button in assembler than C++. The executable was tiny. Wish I could remember that book's author and title.
    I was still trying to understand why I had all these data types to choose from ...
    I agree. You don't. All those types are a low level machine detail that most programmers don't need. They are confusing and a source of bugs when people use them. That is one reason why Javascript is so brilliant, only one number type, 64 bit float.
    ...rapid development/debug
    Sounds like you were ahead of the game. Now a days that is what it is all about. See "agile" development.
  • I have only ever used GOTO in PropBASIC which translates to a JMP. Go figure, all assembly language that I know of has JMP. However, isn't a JMP in Microchip assembly a GOTO?
  • jmgjmg Posts: 15,145
    David Betz wrote: »
    I hate assembler. It takes too much control away from the programmer. It assigns addresses itself so you can't control exactly where anything goes and gives silly names to what are actually numeric addresses. Let's take back total control and go back to binary!
    Hehe...
    Re assembler - I would love to see a macro-assembler for the Prop!
    Funny you should mention that...

    I'm just now digging into fasmg , which continues to impress, the more I find out..
    fasmg is the generic any-mcu macro version of fasm.

    This thing is part script engine, part assembler, and it is truly powerful.
    It is coded in fasm, and comes in at a stunning 48k exe
    Seems to have multi pass, and a means for automatic dead code removal.
    HEX and LST are created via more scripts....

    I posted some examples here
    http://forums.parallax.com/discussion/comment/1387776/#Comment_1387776

    Download with examples, is a compact 236k

    https://flatassembler.net/docs.php?article=fasmg_manual
    https://flatassembler.net/fasmg.zip
  • Heater. wrote: »
    Eric,
    Spin is actually not too different from BASIC..

    There are no line numbers in Spin.

    Spin has no GOTO

    Spin does not have floating point numbers.

    Spin does not deal with strings easily.

    Spin does have objects.

    Spin can address memory directly.

    As David already mentioned, it was PBasic (and to a lesser degree PropBASIC) I was thinking of when I compared to Spin. Which just goes to show what a nebulous topic "BASIC" is!
  • Heater. wrote: »
    Eric,
    Spin is actually not too different from BASIC..

    But, yeah, they both support "sequence, selection and iteration" and some kind of subroutine so they are essentially the same.

    :)

    To elaborate further: yeah, they are essentially the same. Spin is far more similar to PBasic (and other BASICS) than it is to, say, Forth. Or Lisp. Or Haskell, APL, Prolog, and a bunch of other languages I could think of (and I'm sure you could too). Or even Javascript, which under the hood has a whole lot of language features completely alien to BASIC.

    Going back to the original post: why would you want to learn computer languages that are "similar to PBasic" if you already know PBasic? I'd suggest branching out and learning some new languages that will expand your ability. Computer languages are like tools; there's a best one for every job, and none that are best at everything.

    Eric
  • Heater.Heater. Posts: 21,230
    Mickster.

    GOTO in BASIC, JMP in assembler, or MOV PC some address, whatever, all the same.

    Secretly I think GOTO is a wonderful thing. When you need the speed or are in a tricky corner you need GOTO.

    In the beginning we had machine instructions and jumps and we could do what we like.

    Then we had high level languages. Like BASIC. They included GOTO so that you could do whatever you like, as in assembler.

    That all leads to chaos of course.

    But in theory any program can be written with just "sequence, selection and iteration".

    That is to say, one statement after another. An "if" do this or do that. And a "while" some condition, do something.

    And then it was realized that writing code with only "sequence, selection and iteration" makes it much easier to reason about than if it is strewn with GOTOs. Structured programming.

    So started the ban on GOTO and we get "structured" high level languages.

    But, such high level languages, missing the GOTO, had to invent high level ways of doing what GOTO does. And so we have:

    1) case statements. Obviously a HLL way of doing GOTO.

    2) break statements. The HLL way of GOTOing out of a loop.

    3) continue statements. The HLL way of GOTOing back to the top of a loop.

    4) Exceptions. The HLL way of GOTOing the hell out of there when something has gone wrong.

    5) return. Return in functions is the HLL way of GOTOing out of a function in a non-structured way.

    So basically these high level "structured programming" languages break all the rules and are as chaotic and hard to reason about as if they just used GOTO in the first place :)

    That is why the Linux kernel is full of tastefully used GOTOs. :)





  • ercoerco Posts: 20,253
    PBASIC 1 (DOS stamp.exe)
    PBASIC 1.0 Windows
    PBASIC 2 (DOS stamp2.exe)
    PBASIC 2.0 Windows
    PBASIC 2.3.9
    PBASIC 2.5.3
  • David BetzDavid Betz Posts: 14,511
    edited 2016-09-21 01:03
    Say I create a new language I call "ChickenSpeak". How can I tell whether it is a dialect of BASIC? What is it about a language that makes it a dialect or an implementation of BASIC other than the fact that it has the word "BASIC" in its name? If I change my language's name to "ChickenBasic" does it become an implementation of BASIC?
  • The_MasterThe_Master Posts: 199
    edited 2016-09-21 01:45
    David Betz wrote: »
    Say I create a new language I call "ChickenSpeak". How can I tell whether it is a dialect of BASIC? What is it about a language that makes it a dialect or an implementation of BASIC other than the fact that it has the word "BASIC" in its name? If I change my language's name to "ChickenBasic" does it become an implementation of BASIC?

    Correct. As long there is no braces, semicolons, forced structure, and restricted goto, you can call it Basic.

    Maybe we can get Chikfila to be a sponsor, too.

    Keep in mind this is all in the context of embedded control. (thus the Parallax forum) There are a couple people here that apparently design databases for Amazon or have a career where they work 3/hrs a week at a university, and I am kinda surprised to see they're even interested in this forum.

    I am going to go out on a major limb here and suggest there might be a reason Parallax skipped C? Just guessing here...

  • David BetzDavid Betz Posts: 14,511
    edited 2016-09-21 01:47
    The_Master wrote: »
    David Betz wrote: »
    Say I create a new language I call "ChickenSpeak". How can I tell whether it is a dialect of BASIC? What is it about a language that makes it a dialect or an implementation of BASIC other than the fact that it has the word "BASIC" in its name? If I change my language's name to "ChickenBasic" does it become an implementation of BASIC?

    Correct. As long there is no braces, semicolons, forced structure, and restricted goto, you can call it Basic.
    Well, most BASICs have at least some forced structure. There needs to be a THEN for every IF, a NEXT for every FOR, or a WEND for every WHILE for example.


  • The_MasterThe_Master Posts: 199
    edited 2016-09-21 01:52
    THEN for every IF is forced by the processor, not the language.

    Prolly the same for the other stuff as well. (will vary per implemenation)
  • The_Master wrote: »
    I am going to go out on a major limb here and suggest there might be a reason Parallax skipped C? Just guessing here...
    Parallax didn't skip C. They commissioned and funded PropGCC development and are building their Learn cirriculum around it.

  • I already have an idea for a mascot. I think we should call him "Clucky."
  • jmgjmg Posts: 15,145
    edited 2016-09-21 02:46
    The_Master wrote: »
    THEN for every IF is forced by the processor, not the language.
    wow, how ever does the processor reach all the way up to source code, to impose such influence ? ;)

    David Betz wrote: »
    Well, most BASICs have at least some forced structure. There needs to be a THEN for every IF, a NEXT for every FOR, or a WEND for every WHILE for example.

    Is this a "dialect of basic" ? - paste from a language I just happen to have open in my editor right now...
    		if val and 1 = val
    			ez80.l = val
    			ez80.il = val
    			ez80.adl = val
    			ez80.presize = 0
    		else
    			err "illegal value for adl"
    		end if
    


  • kwinnkwinn Posts: 8,697
    David Betz wrote: »
    kwinn wrote: »
    David Betz wrote: »
    If we're going to talk about BASIC it would be nice to specify a particular implementation. Otherwise it is impossible to comment on its productivity as compared with another language. I'd like to challenge anyone to use PBASIC to implement a compiler for itself. You can certainly do that with C and probably with Visual BASIC. You will have a hard time with PBASIC. There are so many different dialects of BASIC that I guess there is probably some dialect for every imaginable problem domain but there is not a single universal dialect that can handle them all like C can.

    Not a fair or reasonable comparison. C was initially designed to be a high level "assembly" language so it could be adapted to a variety of computer architectures and instruction sets. PBasic was designed as a high level language to make optimal use of the Propeller chip.
    I think you mean that PBASIC was designed to make optimal use of the BASIC Stamp not the Propeller but I get what you mean. I wasn't really serious when I asked if you could write a compiler in PBASIC and I agree it isn't a fair comparison. However, it points out that you can't just talk about BASIC as if it is a single language. If you're going to compare BASIC with C or any other language you have to specify which version of BASIC you're talking about.

    I did indeed mean Basic Stamp, but I was working on Propeller software at the time. Sucks to get old.
  • David BetzDavid Betz Posts: 14,511
    edited 2016-09-21 02:59
    jmg wrote: »
    The_Master wrote: »
    THEN for every IF is forced by the processor, not the language.
    wow, how ever does the processor reach all the way up to source code, to impose such influence ? ;)

    David Betz wrote: »
    Well, most BASICs have at least some forced structure. There needs to be a THEN for every IF, a NEXT for every FOR, or a WEND for every WHILE for example.

    Is this a "dialect of basic" ? - paste from a language I just happen to have open in my editor right now...
    		if val and 1 = val
    			ez80.l = val
    			ez80.il = val
    			ez80.adl = val
    			ez80.presize = 0
    		else
    			err "illegal value for adl"
    		end if
    

    I guess it must be. No braces or semi-colons!

  • jmgjmg Posts: 15,145
    David Betz wrote: »
    I guess it must be. No braces or semi-colons!

    :) Then this must be too ?
    print('Start XYRS')
    for Idx,Rn in enumerate(RefNm):
       nPart = pcb.FindModuleByReference(Rn)
    

  • as long as "Basic" is in the name, then Yes.
  • Heater.Heater. Posts: 21,230
    David Betz,
    Say I create a new language I call "ChickenSpeak". How can I tell whether it is a dialect of BASIC
    I'm out of touch with modern versions of so called BASIC but isn't a major distinguishing feature of BASIC it's line oriented nature? After all original BASIC depended on line numbers for its GOTOs. The BASIC editor was line oriented.

    In order to get away from braces and semi-colons one needs to use line breaks to determine what a program means. For example in ChickenSpeak I might write:
    cluck
    cluck
    cluck
    
    Where "cluck" is some expression in chicken.

    Remove the line beaks and I have
    cluck cluck cluck 
    
    Which could have a totally different meaning and require semi-colons or other mark to disambiguate:
    cluck scratch cluck scratch cluck
    
    For chicken to be a dialect of BASIC it will need to have the usual FOR TO STEP IF THEN ELSE GOTO PRINT stuff.
  • Heater. wrote: »
    David Betz,
    Say I create a new language I call "ChickenSpeak". How can I tell whether it is a dialect of BASIC
    I'm out of touch with modern versions of so called BASIC but isn't a major distinguishing feature of BASIC it's line oriented nature? After all original BASIC depended on line numbers for its GOTOs. The BASIC editor was line oriented.

    In order to get away from braces and semi-colons one needs to use line breaks to determine what a program means. For example in ChickenSpeak I might write:
    cluck
    cluck
    cluck
    
    Where "cluck" is some expression in chicken.

    Remove the line beaks and I have
    cluck cluck cluck 
    
    Which could have a totally different meaning and require semi-colons or other mark to disambiguate:
    cluck scratch cluck scratch cluck
    
    For chicken to be a dialect of BASIC it will need to have the usual FOR TO STEP IF THEN ELSE GOTO PRINT stuff.
    As far as I know, PBASIC does not have a PRINT statement. Also, I think most versions of BASIC require a colon between statements on the same line so your example would be:
    cluck:cluck:cluck
    
    In that case, I guess even the original BASIC is not really a dialect of BASIC since there really isn't much difference between using a colon and using a semi-colon.

  • David Betz wrote:
    As far as I know, PBASIC does not have a PRINT statement.
    It does, but it's called DEBUG instead of PRINT. When DEBUG is included in a program the debug (terminal) screen automatically opens when the program is run.

    -Phil
  • David Betz wrote:
    As far as I know, PBASIC does not have a PRINT statement.
    It does, but it's called DEBUG instead of PRINT. When DEBUG is included in a program the debug (terminal) screen automatically opens when the program is run.

    -Phil
    It doesn't count if it has a different name. :-)
    Seriously, people criticize C because it uses different characters in its syntax. I may as well claim DEBUG is not the same as PRINT. Both arguments are silly.

  • Heater.Heater. Posts: 21,230
    Quite so.

    In English print is "print", in Finnish it's "painaa", in Mongolian it's хэвлэх (According to Google)

    "DEBUG" is not "PRINT". Given that in BASIC these things are keywords built into the language we can say that PBASIC is not BASIC.

    As opposed to languages like C, where things like "printf" are not part of the language as such. Just names of functions you may create in the language.

    Python has this problem. Python 2 had "print" as a key word, now Python 3 has print as just another function. Such changes to a language cause all kind of problems.
  • Semantics....please!

    I have spent my life hopping from one rental car to another. The doors all work the same, the steering wheel works the same but other controls might take a few minutes to figure out. I hop from LHD to RHD, from 55mph to the Autobahn...I always get to where I need to be.

    What's the big deal?
Sign In or Register to comment.