Menu β–Ύ β–΄

syntax

2020-04-02
2020-04-20
  • Jim giordano

    Jim giordano - 2020-04-02

    How does everyone feel about adding more C syntax to GCB? Please speak up!

     
    πŸ‘
    1
    • Chris Roper

      Chris Roper - 2020-04-02

      BASIC is an old and relatively simple language but over the years as computer technology and programming techniques have improved the BASIC Language has evolved along with it.

      Just because BASIC, no matter the Dialect, contains new features originally found in C, Assembler, PASCAL, LISP or any other syntax, and yes BASIC has inherited from all of those, does not mean that you have to use the inline assembler or any other modern extensions to BASIC.

      You can still use LineNumbers, Goto, Gosub and Call statements.
      You do not have to use the Do .. Loop construct but it is there if you wish.
      You should Dimension every Variable but you don’t have to.
      REM still works for your comments but most People use an apostrophe.

      If BASIC had not adopted best practices from other Languages over the years it would have been impossible to implement on an 8 bit PIC as it would still be interpretive and RAM intensive. As part of that move to a compiler for 8 Bit devices GCBasic generates nateve assembler and as such it supports inline assembler. If you take out all of the libraries that complicate C and look only at its core syntax then C it is a high level assembler, rather than a high level language, and in that context the ability to support certan C syntax is only logical.

      If you are porting code from another platform, experimenting with a new peripheral module, an oscillator configuration or generating a software implementation of a missing hardware peripheral, then having access to assembler and the C style tools for low level access and debugging are invaluable. Once the new feature is working it is embedded in the core compiler or Libraries and hidden from the user, to them it appears as a new BASIC Statement or Function, the C and Assembler syntax is gone. Only the Systems Programmers know that it's there.

      As time moves on, Processor Designs improve in power, performance and capability and so Languages have to move with the times. If that means that Great Cow BASIC needs to inherit good Practices from C or any other language then I am all for it.

      I don't have to Like it or Use it but if it helps others improve the compiler then I will let them have the tools they need.

      Cheers
      Chris

       
      πŸ‘
      1
  • Anobium

    Anobium - 2020-04-02

    Some background.

    We have supported syntax such as variable++ and variable--, and, a few more commands.

    I have added C like comment support to aid one use case. The use case is the inclusion of external source files from MPLAB-IDE to aid support. I will expain. When testing and supporting Great Cow BASIC I use MPLAB-IDE to understand what MPLAB-IDE would 'do' to setup a chip and/or chip capabilities. So, I #include source files generated by MPLAB-IDE MCC for testing; If MPLAB-IDE code works that tells me that I need to investigate Great Cow BASIC. This operation takes time, a lot of time. Therefore, the new comments feature is there to ease support.

     
  • Jim giordano

    Jim giordano - 2020-04-02

    Chris-
    I have no problem with including new capabilities (as long as they are not described as some unintelligible gobbledygook misuse of words that have other meanings like the oop and c proponents are wont to do). The question is syntax. New capabilities should be provided in a Basic like syntax, not copying the syntax from another language.

    Evan-
    So you "#include source files generated by MPLAB-IDE MCC ". There must be a lot more problems doing this than the comments! Are you planning on distributing these files unchanged with GCB?

     
    • Anobium

      Anobium - 2020-04-02

      @jimgiordano. These files are using for debugging setup/config issue. Nothing will be distributed.

       
    • Chris Roper

      Chris Roper - 2020-04-02

      I am not sure how you use a BASIC like syntax for a feature that has never been a part of BASIC.

      Even's examples of variable++ and variable-- are a case in point, how would you do that in a BASIC like syntax.

      When I created the shift functions I was trying to replicate the C functions of X<<Y but I did so with a BASIC like convention of FnLSL(x, y) so I do understand your stance but it is unrealistic to assume that all new features should bare no resemblance to C syntax when that is the most elegentand efficient way to do things.

      I would love to be able to use X != Y ? X : Y it is far easy than

      If X <> Y then
        Result = X
      Else 
        Result = Y
      End if
      

      But it is definitely too C like so was not included.

       

      Last edit: Chris Roper 2020-04-02
  • Jim giordano

    Jim giordano - 2020-04-02

    in basic, that would be-

    Result=iif(X<>Y,X,Y)
    

    iif

    no need for cryptic c syntax.

     
    • Chris Roper

      Chris Roper - 2020-04-02

      But obfuscation is the best part of coding in C ...........

       
      • Jim giordano

        Jim giordano - 2020-04-02

        You would have loved apl

         
        • Chris Roper

          Chris Roper - 2020-04-02

          I do, even the name is aTLA.

          Never actualy used it for coding though and as I said earlyer I only use C as an assembler, BASIC is my preferance other than Motorola 6800 assembler.

           
        • Chris Roper

          Chris Roper - 2020-04-20

          "Tis the dream of each programmer,
          Before his life is done,
          To write three lines of APL,
          And make the damn thing run."

           
          πŸ˜„
          1
  • Jim giordano

    Jim giordano - 2020-04-02

    Evan-
    Then I would suggest you keep that for yourself, and don't promote the usage of non-basic comment statements.

     
    • Anobium

      Anobium - 2020-04-02

      Agreed.

       
  • stan cartwright

    stan cartwright - 2020-04-03

    I never got on with BBC basic. Seemed it used Pascal style with procedures and was not like
    other basics at the time.
    GCB looks a simple Basic compared to others I've looked up and the only free Basic compiler
    for AVR.
    If I understood C I would probably have used the Arduino IDE but I don't.
    EDIT I just found B4R which is free and BASCOM which isn't but has a 4K limit demo.

     

    Last edit: stan cartwright 2020-04-03
  • William Roth

    William Roth - 2020-04-04

    "Even's examples of variable++ and variable-- are a case in point, how would you do that in a BASIC like syntax."

    "Variable = Variable + 1 "
    "Variable = Variable - 1"

    Generates the exact same ASM as Variable++ and is understandable.

    As far as this discussion goes, I am strongly against using C like syntax when BASIC syntax can do the job just as well, "elegance" be damned.

    I like code that is readable and makes sense, not some "elegant" gobbledygook that is only decipherable by the initiated ones. I like code that a relative newbie can look at and can get a general idea of what's going on. This IMO, is one of the things that makes GCB attractive to many.

    GCB is getting more and more complex already as new stuff is added. The use of C like systax for new features when BASIC syntax will work, only adds to the complexity. I would avoid it as much as is practical.

    William

     
  • mkstevo

    mkstevo - 2020-04-07

    I have no great preference for any particular syntactic differences between languages, I just want to get on and get things done. That isn't intended as any criticism of any language, I don't particularly mind whether I program in Basic, Pascal, OPL or COBOL.

    The reason I use and love Great Cow Basic is that I can indeed "get things done". Mostly quickly, without referring to too much reference material.

    Yes, I was an enourmous fan of Delphi (Pascal) and loathed Visual Basic. But that was down to the fact that programs written in Visual Basic only worked on about 40% of installations, whereas the Delphi ones not only worked in about 99.9999% of installs. Not only that, but the user interface of those Delphi programs looked drastically better and ran faster too. Add into the mix the wonderful articles on Delphi by Huw Collingbourne in PCPlus magazine and Delphi won.

    Fast forward to the present day and I'm (partially) employed to write software for PICs. I tried other programming languages for PICs but none of them came as close to fitting inside the "memory map" in my own head as Great Cow Basic does. Not only can I "get things done" but I can see how things work, how I want them to work, and how to make that happen. So I use Great Cow Basic.

    I don't care whether I have to write:

    Let Variable = Variable + 1
    

    or:

    Let Variable++
    

    or:

    Inc Variable(1);
    

    Personally in Great Cow Basic I tend to use the first one, it suits my thought process better than the second. If I had the option, I'd choose "Inc" "Variable" "(IncrementStep)" as it fits into my "memory map" perfectly: It is concise and explicit while having the flexibility of variation of the amount to increment by. But we're not all the same and I don't suppose everybody would choose that would they?

    And Chris' Example of:

    X !=Y ? X : Y
    

    Makes zero sense to me at all. I much prefer:

    If X <> Y then
      Result = X
    Else 
      Result = Y
    End if
    

    To summarise, if and when things are added, I don't want to impose my blinkered view of things on how that syntax is implemented. If the new syntax is detailed somewhere, I can read it, digest it and (hopefully) understand it.

     

    Last edit: mkstevo 2020-04-07
  • stan cartwright

    stan cartwright - 2020-04-10

    Get things done...true gcb can let you realise your thoughts in logical flowing code..with subs, also logical, so makes sense style, if needed.
    Gcb can be written to be difficult for others to read the flow of the code, or can easy to follow.
    If it's easy to follow, I'm guessing it's more efficient. dunno?
    Syntax ie commands, there's plenty to learn as is, with new basic functions added regulary.
    But it's still basic basic. Which is why I use it.

     

Log in to post a comment.