BBCSDL update postponed

New releases of BB4W and BBCSDL, and other updates, will be announced here
Hated Moron

Re: BBCSDL update postponed

Post by Hated Moron »

On 28/08/2022 22:19, Maksim AbuAjamieh wrote:
I am not sure what your views are on benchmarks, can you elaborate on that please?
In my experience, benchmarks can be very misleading. This is partly because the code in benchmarks is often highly artificial and is rarely representative of 'real' programs. For example a benchmark may time how fast an empty FOR'...NEXT loop runs, but real programs don't have empty FOR...NEXT loops!

Imagine a situation in which Interpreter A executes the NEXT statement in 2ns and Interpreter B executes the NEXT statement in 20ns, but in both interpreters even the shortest 'useful' statement (e.g. assigning a value to a variable) takes at least 100ns. A benchmark timing an empty FOR...NEXT loop would report that Interpreter A runs ten times faster than Interpreter B - wow! But add a single useful statement in the loop and now Interpreter A takes 102 ns per loop and Interpreter B 120ns per loop; not ten times the speed but only 18% faster!

Then there's the issue of benchmarks being manipulated. I have personal experience of this because I did it myself, way back in 1981! When my BBC BASIC (running on a 4 MHz Z80) was benchmarked against Acorn's BBC BASIC (2 MHz 6502) mine was slower. Oh dear! I couldn't find any way to significantly speed up my BASIC, but I realised that the benchmark program (originally written for some earlier BASIC, probably Microsoft) used regular variables to hold integer values.

Now in Acorn's BBC BASICs a regular variable (without any suffix character) is a floating-point variable, and any arithmetic is performed using floating-point calculations, even if the value is an integer (to use fast integer arithmetic you have to add a % suffix character to the variable name). So I modified my Z80 BBC BASIC so that a regular variable containing an integer value used integer arithmetic. Now the benchmark ran much faster, but it was a lie because my interpreter was using integer arithmetic and Acorn's floating-point arithmetic! Adding % suffix characters to both, to establish a level playing field again, restored Acorn's lead.
I will review the IDE again.. but surely it needs community involvement. Some might be completely against touching it.
So make the enhancements optional. Or even offer two different versions (after all there are already two IDEs supplied, adding a third isn't a big deal).
The part that made me sad about QB64, is the reason the project lead stepped down and how things quickly escalated and turned into chaos, which I hop is not a possible scenario with BBC Basic.
I've said quite recently that a risk with making BBC BASIC Open Source was that anybody can then make changes, without any consideration being given to the 'spirit' of BBC BASIC and the ways that things have always been done in the language (admittedly they couldn't call the resulting language BBC BASIC because that name is owned by the BBC and only I have permission to use it).

So far this hasn't happened, but that's probably because I'm still around to make a fuss if it did. But you are right to be concerned about what might happen if I resigned from that role and there was a free-for-all.
Hated Moron

Re: BBCSDL update postponed

Post by Hated Moron »

On 29/08/2022 09:00, Ivan wrote:
And a language, where I can indent freely
Free indentation is a mixed blessing, because you can indent wrongly (that is, according to how you intended the code to work, not how it actually works). For example consider this code, which has been 'manually' indented according to the intention of the programmer:

Code: Select all

      IF my_condition THEN : REM conditional clause
        PRINT "Conditional clause is executed"
      ENDIF
Looks fine, superficially, but when run it won't work at all - the PRINT statement will always be executed! But with automatic indenting, like BB4W and BBCSDL do, it will be listed as follows:

Code: Select all

      IF my_condition THEN : REM conditional clause
      PRINT "Conditional clause is executed"
      ENDIF
Now it's obvious something is wrong, because there's no indentation (what's wrong, of course, is that BBC BASIC does not permit anything after the THEN). To work correctly the code must be edited as follows, and now the automatic indentation confirms that:

Code: Select all

      IF my_condition THEN
        REM conditional clause
        PRINT "Conditional clause is executed"
      ENDIF
So, personally, I think 'free' (manual) indentation is potentially very misleading and can make debugging more difficult.
jbk
Posts: 6
Joined: Tue 03 Apr 2018, 19:42

Re: BBCSDL update postponed

Post by jbk »

yes indeed
Hated Moron

Re: BBCSDL update postponed

Post by Hated Moron »

On 29/08/2022 18:46, Ivan wrote:
My dyslexia wants something like this:

Code: Select all

if condition_1 then                              : rem and I have the possibility to write a comment here
    print "a"
elseif condition_2 then                          : rem or here
    print "b"
else
    print "c"
endif
This is how the BBC BASIC iDEs list it (after the necessary adjustments for syntax):

Code: Select all

      if condition_1 then
        rem and I have the possibility to write a comment here
        print "a"
      elseif condition_2 then;
        rem or here
        print "b"
      else
        print "c"
      endif
(Just a reminder that this won't be formatted correctly in the Discussion Group, because of the bug in phpBB; view it at the forum).

So I'm not sure whether your complaint is the fact that BBC BASIC syntax is different from what you show (obviously there's nothing I or anybody else can do about that) or whether it's because the indentation is 2 spaces rather than 4.

Code: Select all

def proc_a
    a = 2
end proc
We've discussed that before. Indenting the body of a procedure or function isn't compatible with the possible (and indeed relatively common) use of multiple entry points, nor with the (even more common) use of multiple exit points:

Code: Select all

      DEF PROC1(a) : LOCAL b,c,flag : flag = 1
      DEF PROC2(a,b) : LOCAL c,flag : flag = 2
      DEF PROC3(a,b,c) : LOCAL flag : flag = 3
      REM Body of procedure here, acts differently depending on the value of 'flag'
      IF condition THEN ENDPROC
      REM Some more code here
      ENDPROC
Unless you were to make the use of multiple entry and exit points illegal, indentation would misbehave and could be very misleading.
Hated Moron

Re: BBCSDL update postponed

Post by Hated Moron »

On 30/08/2022 08:06, Ivan wrote:
then I did not told you, that I have dyslexia.
You have said many times that you have dyslexia. You have also previously explained why you prefer C++ to BBC BASIC, but this is a BBC BASIC support forum so I do not expect that many members will agree with you.

There are dozens, probably hundreds, of dialects of BASIC. Although they all share common features that identify them as being BASIC (that is questionable in some cases!) the variability between them is substantial, probably more than with any other programming language. Although this lack of standardisation has its disadvantages, it also means that there is probably a BASIC out there to suit almost every taste!

I see my role, such as I have one as my health declines, as acting as a sort of guardian of the 'spirit' of BBC BASIC in trying to explain why things are the way they are (often in a historical context) and pushing back against proposed changes which seem to me to be contrary to that spirit.
Hated Moron

Re: BBCSDL update postponed

Post by Hated Moron »

On 30/08/2022 10:49, Ivan wrote:
mostly the lack features regarding the IDE and debugger for my behalf.
At the risk of repeating myself, BBC BASIC for SDL 2.0 fundamentally does not have an IDE or debugger! The BASIC interpreter / run-time engine has only the traditional command-line interface, otherwise called immediate mode. Of course, the expectation these days is that there will be an IDE and a debugger, so that is quite a limitation. :o

Therefore among the many example programs which come as standard with BBC BASIC for SDL 2.0 there are two which are rather special: examples/tools/BBCEdit.bbc and examples/tools/SDLIDE.bbc which are two alternative IDEs that are themselves written in BBC BASIC! There are a number of benefits of this approach: the user gets a choice of IDE, the IDEs are readily customised and extended, and they act as a showcase of what can be achieved.

It's very common for compiled programming languages to compile themselves, again this acts as a great showcase and also a valuable testbed. That isn't possible with an interpreted language, but coding the IDE in the language is the next best thing. It's a credit to BBC BASIC that its native capabilities and speed are sufficient to reproduce a full mouse-driven GUI, with drop-down menus, toolbar, editing pane, floating dialogue boxes etc.

These two IDEs don't rely on any OS-specific features, they use only native BBC BASIC graphics statements (PLOT, DRAW etc.) and run equally well in BB4W and BBCSDL. Indeed there's a downloadable, free, version of BBC BASIC for Windows (which is not memory-limited like the trial version) that uses SDLIDE as its IDE. :)

So if you like BBC BASIC but don't like the IDE and debugger, there's a simple solution: write your own (or modify one of the existing ones)! You could even integrate the BBC BASIC run-time engine with one of the cross-platform IDEs like Code::Blocks. There cannot be many modern programming languages which offer that flexibility.