ZXDunny
Posts: 117
Joined: Sun Jul 08, 2012 7:57 pm

Re: Introduction to BBC BASIC

Tue Jul 23, 2019 8:40 am

ejolson wrote:
Tue Jul 23, 2019 4:47 am
Imagine how much easier it would be if the tokenised form of

10 X=2^0.5
20 PRINT X
30 STOP

automatically appeared as

10 X=2^0.5
20 लिखो X
30 विराम

when edited with the correct localisation set. I suppose one could also render the numerals correctly and even the X.
I am working on this exact system at work right now - automatic translations of our software. We're using gnuGetText utilities. Source is prepared simply by surrounding each string with a function call; it uses _('string') which is pretty easy. Then using a tool, all of these are gathered up and built into a .po file, which is then sent to the translators. We get it back filled with new stuff, and the gnuGetText system automatically converts from english to the desired language at runtime with very little performance overhead.

I'm currently up at around 5,000 strings so our translators have quite a lot to do, but the result looks lovely.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Tue Jul 23, 2019 10:14 am

ejolson wrote:
Tue Jul 23, 2019 4:47 am
Speaking of colour, I understand there was an American edition of BBC Basic such that the COLOUR statement appeared as COLOR when the exact same tokenised source code was loaded into the editor.
That's right. All versions of BBC BASIC will accept either COLOR or COLOUR on input (or when loading a program in plain-text format) but they get tokenised the same so how they are listed depends on whether it's a British or American version (as fitted in the US model of the BBC Micro). However I've never gone as far as making this a customisable option in my versions, even though it would be straightforward.

miab3
Posts: 4
Joined: Mon Jul 01, 2019 12:50 pm

Re: Introduction to BBC BASIC

Tue Jul 23, 2019 10:24 am

Richard,

Why hanoi.bbc in bbcsdl for Windows is about 10 times slower than in bbcwdem6 for Windows?

Michal

plugwash
Forum Moderator
Forum Moderator
Posts: 3463
Joined: Wed Dec 28, 2011 11:45 pm

Re: Introduction to BBC BASIC

Tue Jul 23, 2019 12:20 pm

RichardRussell wrote:
Tue Jul 23, 2019 10:14 am
ejolson wrote:
Tue Jul 23, 2019 4:47 am
Speaking of colour, I understand there was an American edition of BBC Basic such that the COLOUR statement appeared as COLOR when the exact same tokenised source code was loaded into the editor.
That's right. All versions of BBC BASIC will accept either COLOR or COLOUR on input
IIRC the original BBC basic I and II would only accept COLOUR. The American version (basic III iirc) which would accept either and list as COLOR came later. I think that basic IV (master 128) and basic V (riscos) would also accept either, not sure if there was an american variant of the Master and RISCOS BBC basics..

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Tue Jul 23, 2019 1:12 pm

plugwash wrote:
Tue Jul 23, 2019 12:20 pm
IIRC the original BBC basic I and II would only accept COLOUR.
Maybe. When I say "all versions" I mean all current versions, i.e. all versions that will run on today's hardware. I know a few people still play with those early versions, mostly in emulation, but they hold no interest for me and I tend to ignore them, sorry.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Tue Jul 23, 2019 1:27 pm

miab3 wrote:
Tue Jul 23, 2019 10:24 am
Why hanoi.bbc in bbcsdl for Windows is about 10 times slower than in bbcwdem6 for Windows?
It's because of the *REFRESH command in PROCHANOI(). In BBC BASIC for Windows *REFRESH sets a flag to indicate that the screen should be updated at the next opportunity, and then returns immediately. In BBC BASIC for SDL 2.0 *REFRESH actually waits for the next vsync, which means it may not return for up to 16 milliseconds or so.

Generally the newer behaviour in BBCSDL is more useful, because it forces your program to synchronise to the display refresh rate (something that is quite difficult to do in Windows) but in some circumstances, and HANOI is an example, it can result in the program running more slowly.

This is called out in the differences document where (in section 4f) it states "In BBCSDL *REFRESH waits for 'vsync', synchronising your program to the display's refresh period. In BB4W it does not (waiting for 'vsync' in BB4W is more difficult)".

If you delete the *REFRESH command you should find that HANOI runs at a similar speed on the two versions, but you will probably also find that it runs far too fast to see what is happening!

miab3
Posts: 4
Joined: Mon Jul 01, 2019 12:50 pm

Re: Introduction to BBC BASIC

Tue Jul 23, 2019 2:28 pm

RichardRussell wrote:
Tue Jul 23, 2019 1:27 pm
If you delete the *REFRESH command you should find that HANOI runs at a similar speed on the two versions, but you will probably also find that it runs far too fast to see what is happening!
Indeed it is.
Maybe it's worth adding something like REFRESH 0 / REFRESH 1

Michal

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Tue Jul 23, 2019 2:44 pm

miab3 wrote:
Tue Jul 23, 2019 2:28 pm
Maybe it's worth adding something like REFRESH 0 / REFRESH 1
My hands are tied because of the way SDL2/OpenGL work. The renderer is created with the SDL_RENDERER_PRESENTVSYNC flag so screen refreshes are always synchronised with vsync. I would have done the same in BB4W had there been any straightforward way, but there isn't (surprisingly, synchronisation isn't supported by GDI32 at all, you need DirectDraw or OpenGL or similar to achieve that).

This isn't, generally, a significant compatibility issue. Hanoi is the exception, to the extent that you see a slowdown, but in fact it's the slow (BBCSDL) version that's working 'as intended'! The idea of the *REFRESH is that you should be able to see each step in the solution, by displaying it for at least one refresh period. That works in BBCSDL, but not in Windows when some steps may never be rendered.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Thu Jul 25, 2019 2:51 pm

I have released version 1.05a of BBC BASIC for SDL 2.0, the cross-platform programming language for Windows, MacOS, Linux, Raspbian (Raspberry Pi), Android and iOS. The changes in this version are as follows:

  1. BASIC Interpreter / Run Time Engine

    Fixed a bug causing MOUSE and graphics coordinates to diverge if the window is resized without doing a VDU 26.

    Incorporated Jonathan Harston's modification to ignore SOUND statements specifying non-internal sound channels.

  2. IDEs and Utilities

    The SDLIDE list of functions and procedures can now be scrolled using the PgUp and PgDn keys.

    SDLIDE will now load programs in plain text (.bas) format even if they contain TAB characters.

    Added a Go To Line menu selection to SDLIDE, similar to that in BBC BASIC for Windows v6.12a.

    Modified the search utility to fix a problem with it not having keyboard focus initially.

  3. Libraries

    dlglib.bbc now supports comboboxes!

    Fixed a bug in datelib.bbc causing the FN_date$() function to misbehave with months starting with an M (March and May). D'oh!

    The DejaVuSans font has been updated to a newer version with more Unicode symbols.

    Added the (incomplete) bigint.bbc library in case somebody fancies developing it further.

  4. Example Programs

    Added a graphics demo fluid.bbc which uses GPU shader code to create a plasma-like effect.

    Modified dlgdemo.bbc to demonstrate the new combobox capability of the dialogue box library.

    Modified hangman.bbc to remove code which worked around the now fixed coordinate disparity.

    Added a 3D animation to accompany skaters.bbc. This has a rather risqué Easter Egg, can you find it?!
This new version may be downloaded, for all the supported platforms, from the usual location. The GitHub repository has been updated (used to build the MacOS, Raspbian, iOS and 64-bit Linux editions, currently).

hippy
Posts: 6089
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Introduction to BBC BASIC

Thu Jul 25, 2019 4:04 pm

ejolson wrote:
Tue Jul 23, 2019 4:47 am
Imagine how much easier it would be if the tokenised form of

10 X=2^0.5
20 PRINT X
30 STOP

automatically appeared as

10 X=2^0.5
20 लिखो X
30 विराम

when edited with the correct localisation set. I suppose one could also render the numerals correctly and even the X.
Some software already tries to do that. The problem is that doing it automatically or programmatically is difficult because semantics and grammar are involved. Get it wrong and it's like giving an English speaker a terrible translation of a foreign document. What looks to be a satisfactory translation to an English speaking originator may be anything but to the targeted audience.

Even translating phrases or lines at a time isn't simply. The carelessness of "1 errors" always annoys me and its easy to create similar annoyances for other language users.

I would usually code that explicitly as "No errors", "1 error", "2 errors" etc. Would twiddle "I have an <object>" to be "an" or "a" as appropriate for the object name. To do it well in a foreign language one has to know all their similar idiosyncrasies. "<colour> <object>" may need to be "<object> <colour>", and is that masculine or feminine, or something else ?

And then, particularly in GUI stuff, one's nice and succinct "quit" button label may turn out to be a boundary-busting "splattenblitzen" or similar.

There's a lot more to internationalisation than one first imagines. The above is one of the reasons international software tends to use a vertical list of options rather than the grids of check boxes and radio buttons we have been familiar with in the English speaking world.

The most amusing internationalisation mistake I see is people translating the names of languages which can be selected into the language which is currently selected.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Thu Jul 25, 2019 4:27 pm

RichardRussell wrote:
Thu Jul 25, 2019 2:51 pm
This has a rather risqué Easter Egg, can you find it?!
Try not to cheat by looking at the code! Adding an Easter Egg to a short program which is published in source form is a whole new level of stupidity (not that I've been silly enough to draw attention to it with a comment).

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Wed Jul 31, 2019 11:17 pm

In another thread the matter of arrays in BASIC has been discussed. It is interesting to note that some of the very earliest BASICs supported 'whole array' operations using the MAT keyword. For example the statement MAT B = A would copy every element of the array A() into the corresponding element of array B(); a limited number of whole-array arithmetic operations were also supported using a similar syntax, e.g. MAT c = a * b. There were also statements for transposing and inverting matrices held in two-dimensional arrays, and more.

For some reason the whole-array operations were usually omitted in early microprocessor BASICs, and even today they are not common. BBC BASIC is something of an exception in supporting quite a number of whole-array operations, but it doesn't use the traditional MAT syntax. Instead it identifies a whole array by the presence of an opening and closing parenthesis with nothing in between: ().

Some of the things you can do in BBC BASIC:

Code: Select all

      a() = 1, 2, 3, 4, 5  : REM Initialise the array from a list of values
      a() = 0 : REM Initialise every element of the array to the same value
      b() = a() : REM Copy all of array a() into array b()
      d() = a() * b() + c() : REM Perform arithmetic on every element
      a() += n : REM Add n to every element of array a()
      c() = a() . b() : REM Calculate the 'dot' (scalar) product
      t = SUM(a()) : REM Add up all the elements of array a()
      m = MOD(a()) : REM Calculate the modulus (square root of the sum of squares)
      PROCx(a()) : REM Pass the entire array as a parameter
      LOCAL a() : REM Make a whole array 'local'
Occasionally whole-array operations can be invaluable and save a tremendous amount of time. In a 'planetarium' program I have been working on recently I need to rotate the 3D positions of stars (potentially meny thousands of them) from their equatorial coordinates into the frame of reference of an observer so they can be plotted where he can see them in the sky. In BBC BASIC that can be done in one statement using the dot product:

Code: Select all

      seen() = rot() . stars()

User avatar
scruss
Posts: 2570
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Introduction to BBC BASIC

Wed Jul 31, 2019 11:53 pm

Neat!

But I was a bit surprised that

Code: Select all

      DIM a(4)
      a() = 1, 2, 3, 4
      PRINT a(1)
prints '2'. The equivalent code in ANSI Basic

Code: Select all

DIM a(4)
MAT READ a
PRINT a(1)
END
DATA 1,2,3,4
prints '1'.

It's extra nice that you can use calculated values:

Code: Select all

a() = 1, SIN(RAD(30)), 3, 4
does exactly what you'd expect.

Can you initialize multi-dimensional arrays?
How do you print a whole array? I was disappointed that PRINT a() was an error.

BASIC's data handling has pretty much been a throwback, with DATA statements a bit like data cards included after one's Fortran code ...
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Thu Aug 01, 2019 12:15 am

scruss wrote:
Wed Jul 31, 2019 11:53 pm
I was a bit surprised that PRINT a(1) prints '2'.
The BASIC you were using probably has the OPTION BASE statement which allows you to specify whether the array indices begin at 0 or 1, with it defaulting to OPTION BASE 1. BBC BASIC has never supported this option: all arrays have zero-based indices.
It's extra nice that you can use calculated values:
There's a nice trick you can use to implement a ring or shift-register:

Code: Select all

      DIM a(4)
      a() = a(1), a(2), a(3), a(4), a(0) : REM Rotate the entire array
Can you initialize multi-dimensional arrays?
Yes, but BBC BASIC assumes that all arrays are row-major, so you must list the values in the correct order with the column changing faster:

Code: Select all

      DIM a(2,2)
      a() = 0,1,2,3,4,5,6,7,8
I was disappointed that PRINT a() was an error.
Me too. For some reason BBC BASIC doesn't implement an equivalent of MAT PRINT. You'd have to ask Sophie why although my guess is that it's because printing is an inherently slow operation so you wouldn't gain a significant benefit compared with coding it yourself in a user-defined procedure:

Code: Select all

      DEF PROCmatprint(a())
      LOCAL i%
      FOR i% = 0 TO DIM(a(),1)
        PRINT a(i%);
      NEXT
      PRINT
      ENDPROC
Not having an equivalent of MAT INV or MAT TRN are arguably more serious omissions.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Thu Aug 01, 2019 12:52 pm

RichardRussell wrote:
Thu Aug 01, 2019 12:15 am
BBC BASIC has never supported this option: all arrays have zero-based indices.
Just to expand on that a little, BASICs which support the OPTION BASE stetement or equivalent usually implement DIM as follows:

Code: Select all

      OPTION BASE 0
      DIM a(4) : REM Array has 4 elements with indices 0, 1, 2, 3
      OPTION BASE 1
      DIM b(4) : REM Array has 4 elements with indices 1, 2, 3, 4
When Acorn developed BBC BASIC in 1981 they didn't want the complication of supporting OPTION BASE, but they (and the BBC) wanted to maximise compatibility with other BASICs. So they came up with a scheme which I consider to be a stroke of genius in its simplicity and effectiveness:

Code: Select all

      DIM a(4) : REM Array has 5 elements with indices 0, 1, 2, 3, 4
Although it may seem odd for DIM a(4) to declare an array with 5 elements, it achieves compatibility with both the base-0 and base-1 options at the expense of a little wasted memory (element a(4) is unused in the former case and a(0) in the latter case). If you are coding specifically for BBC BASIC you can take advantage of the full size of the array.

User avatar
scruss
Posts: 2570
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Introduction to BBC BASIC

Sat Aug 03, 2019 1:19 am

RichardRussell wrote:
Thu Aug 01, 2019 12:52 pm
…When Acorn developed BBC BASIC in 1981 they didn't want the complication of supporting OPTION BASE, but they (and the BBC) wanted to maximise compatibility with other BASICs. So they came up with a scheme which I consider to be a stroke of genius in its simplicity and effectiveness:

Code: Select all

      DIM a(4) : REM Array has 5 elements with indices 0, 1, 2, 3, 4
Most MS BASICs support this too:

Code: Select all

10 DIM A(10)
20 FOR I=0 TO 10
30 A(I)=11-I
40 NEXT I
50 FOR I=0 TO 10
60 PRINT "A(";I;")=";A(I)
70 NEXT I
80 END
READY.
RUN
A( 0 )= 11
A( 1 )= 10
A( 2 )= 9
A( 3 )= 8
A( 4 )= 7
A( 5 )= 6
A( 6 )= 5
A( 7 )= 4
A( 8 )= 3
A( 9 )= 2
A( 10 )= 1
I'm still all at sea trying to work out the subscripting for a simple 2d rotation matrix. BBC BASIC needs it dimensioned precisely, where ANSI BASIC tends to do it for you
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Aug 03, 2019 9:23 am

scruss wrote:
Sat Aug 03, 2019 1:19 am
I'm still all at sea trying to work out the subscripting for a simple 2d rotation matrix. BBC BASIC needs it dimensioned precisely, where ANSI BASIC tends to do it for you
It's complicated by there often being a choice of two alternatives: having the rotation matrix as the second term in the dot product, or swapping the row and column indices in the object array and having the (transposed) rotation matrix as the first term in the dot product. They give identical results but occasionally one has an advantage over the other; for example if you want to sort the objects according to their Z-coordinates (typically when plotting in 3D when you want to draw the furthest objects first) that may impose a specific row-column order.

That probably makes things even less clear, so I would suggest you study the example program torus2d.bbc supplied with all editions of BBC BASIC for SDL 2.0. Although BBC BASIC supports accelerated 3D graphics using the GPU to do the heavy lifting, this program illustrates how you can leverage the dot-product (and the sort library) to achieve it in pure BASIC code and 2D plotting.

Key elements of the program are the object array itself, which is declared with an unconventional column-row order to allow sorting by Z-coordinate:

Code: Select all

      REM  Array to hold the balls' positions in '3D space'
      DIM p(2, NUMBALLS - 1)
Here the first subscript takes the value 0, 1 or 2 corresponding to the x, y and z-coordinates of the object respectively, and the second subscript is the object index. Then there is the rotation matrix, which is constructed from the rotations around the three axes:

Code: Select all

      REM  Rotation matrices
      DIM a(2,2), b(2,2), c(2,2), r(2,2)
...
      REM  Create the rotation matrix
      a() = 1, 0, 0, 0, COS(a), -SIN(a), 0, SIN(a), COS(a)
      b() = COS(b), 0, SIN(b), 0, 1, 0, -SIN(b), 0, COS(b)
      c() = COS(c), -SIN(c), 0, SIN(c), COS(c), 0, 0, 0, 1
      r() = b() . a()
      r() = c() . r()
(one could express it all in one go using the standard 3D rotation matrix but it's neater - and there is less opportunity for error - to let BBC BASIC calculate it).

Then finally there is the main rotation of the object array itself (and in this case also of the normals which are used for lighting):

Code: Select all

      REM  Rotate the 3D positions of the balls
      REM  (and also rotate the normal vectors)
      q() = r() . p()
      o() = r() . n()
I hope that's helpful.
Last edited by RichardRussell on Sat Aug 03, 2019 2:56 pm, edited 1 time in total.

User avatar
scruss
Posts: 2570
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Introduction to BBC BASIC

Sat Aug 03, 2019 11:26 am

thank you so much, Richard! It was extremely helpful.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sun Aug 04, 2019 9:12 am

RichardRussell wrote:
Sat Aug 03, 2019 9:23 am
and in this case also of the normals which are used for lighting
On the subject of normals, it is normal for normals to need to be normalised! That is, usually the normal vector needs to be of unit length. This can be very conveniently arranged by combining a couple of BBC BASIC features, as follows:

Code: Select all

      normal() /= MOD(normal())
What this does is to calculate the modulus of the vector (the square-root of the sum of the squares) and divide all the elements of the vector by this quantity. This achieves the required condition of the vector's length being 1.0. You can only do this with a single vector though, there's no way of normalising a whole array of vectors in one go using this technique.

ProDigit
Posts: 374
Joined: Tue Aug 30, 2011 1:24 am

Re: Introduction to BBC BASIC

Sat Aug 10, 2019 5:13 am

From the comments, it appears that this is the goto for BASIC on the Pi.
I haven't been able to locate it in the Pi's repositories.
Snap, apt-get or npm don't seem to have it.
What is the installation code?
I prefer not to build configure packages, if I don't have to.
But if there's no other way, a little help in getting it installed would be greatly appreciated!

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Aug 10, 2019 9:04 am

ProDigit wrote:
Sat Aug 10, 2019 5:13 am
From the comments, it appears that this is the goto for BASIC on the Pi.
I haven't been able to locate it in the Pi's repositories.
It's downloadable as this Zip file. You can find more details here.
But if there's no other way, a little help in getting it installed would be greatly appreciated!
It's supplied as a binary so there's no need to build it from scratch (unless you particularly want to!). There's a text file install-rpi.txt in the Zip containing the simple installation instructions.

Please note that if you have a Raspberry Pi 4 BBC BASIC does not work entirely correctly because of a known issue with the V3D graphics driver in Raspbian Buster. Hopefully this will be fixed in a subsequent OS upgrade but in the meantime you may notice minor graphical glitches in the IDE and a few of the supplied example programs (jigsaw.bbc is one that won't work properly).

ejolson
Posts: 3713
Joined: Tue Mar 18, 2014 11:47 am

Re: Introduction to BBC BASIC

Sat Aug 10, 2019 3:33 pm

RichardRussell wrote:
Sat Aug 10, 2019 9:04 am
Please note that if you have a Raspberry Pi 4 BBC BASIC does not work entirely correctly because of a known issue with the V3D graphics driver in Raspbian Buster. Hopefully this will be fixed in a subsequent OS upgrade but in the meantime you may notice minor graphical glitches in the IDE and a few of the supplied example programs (jigsaw.bbc is one that won't work properly).
Are the 3D problems with Raspbian Buster in general or just when running on the Pi 4B?

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Aug 10, 2019 7:51 pm

ejolson wrote:
Sat Aug 10, 2019 3:33 pm
Are the 3D problems with Raspbian Buster in general or just when running on the Pi 4B?
Only when running on the RPi 4. The bug/omission is in the V3D driver, which is only used on the RPi 4; on the RPi 3 the VC4 driver is used instead and that doesn't suffer from the same issue. Indeed the fix for V3D involves incorporating the technique used in the VC4 driver (if I've understood it correctly).

CarlGundel
Posts: 30
Joined: Wed Mar 21, 2012 9:53 pm
Contact: Website

Re: Introduction to BBC BASIC

Sat Aug 10, 2019 8:49 pm

RichardRussell wrote:
Mon Jul 15, 2019 8:18 am
ScriptBasic wrote:
Sun Jul 14, 2019 11:44 pm
I wonder if interpretive tokenized code is worth the effort these days?
I'm not sure what point you're making here. There is obviously less "effort" involved in interpreting a program compared with compiling it (using those terms in their traditional senses) and tokenisation is simply a method of saving memory and speeding up execution - it's a step on the road to the 'bytecode' used by some modern languages. There are interpreted languages that don't tokenise at all (Liberty BASIC is an example).
Well, let me split some hairs. Liberty BASIC isn't technically an interpreter. It compiles to an object model that executes on top of a bytecoded dynamic translator (similar to Java).

User avatar
RichardRussell
Posts: 590
Joined: Thu Jun 21, 2012 10:48 am

Re: Introduction to BBC BASIC

Sat Aug 10, 2019 9:26 pm

CarlGundel wrote:
Sat Aug 10, 2019 8:49 pm
Liberty BASIC isn't technically an interpreter. It compiles to an object model that executes on top of a bytecoded dynamic translator (similar to Java).
The interpreter/compiler distinction lost its 'binary' nature decades ago, and these days it is best considered to be a continuous spectrum with 'pure interpreter' at one end and 'pure compiler' at the other, with most modern languages lying some distance away from those extremes (and perhaps even on a sideshoot!).

One key feature of a language, which can help determine where it lies on this spectrum, is whether it knows about variable names at run time. Generally speaking 'interpreted' languages do but 'compiled' languages don't: in the latter, variables and other objects are represented as abstract entities such as a memory address rather than the name allocated by the programmer.

If the language knows about variable names at run time it makes it possible to support an EVAL() function, which accepts an arbitrary numeric or string expression (typically containing variable and perhaps user-defined function names) and 'evaluates it'. Using that criterion Liberty BASIC, like BBC BASIC, is an interpreter because it supports EVAL.

Return to “Other programming languages”