Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 9122

Other programming languages • Re: Basic on Raspberry

$
0
0
I think the idea of Basic is that it's for beginners.
For beginners, yes, (that's what the B in BASIC stands for) but not only for beginners! Modern BASICs are almost all intended for the full range of applications that, say, Python can be used for. I'd hardly describe the applications described here as being the kind that would be written by beginners. :D

This is what it says at the very start of the BBC BASIC manual: "BBC BASIC is the programming language originally specified and adopted by the British Broadcasting Corporation for its groundbreaking Computer Literacy Project of the early 1980s. It was designed to be simple enough to be used by a complete beginner yet powerful enough to cope with the demands of the very largest and most complex programs, and that remains true today".
It seems the library documentation for Linux is...
The version of BBC BASIC that is being discussed here is BBC BASIC for SDL 2.0 which is the current cross-platform version for Windows, MacOS, Linux, Android, iOS and web (in-browser).
Note the Windows page does not include the remark about an argument to PROC_initsockets.
The number of sockets is not limited in BBC BASIC for Windows, so no parameter is needed. It's only in BBC BASIC for SDL 2.0 that it must be specified at initialisation time (this follows directly from the different underlying libraries, in the case of BBCSDL it's the SDL2_net library).
I wonder which Basics have a good AI assistant.
DeepSeek is pretty good at writing BBC BASIC code, and I have used it for that a few times. Its BBC BASIC coding skills can be improved by uploading the relevant manual (using the paperclip button on the DeepSeek front page) before entering the prompt.

This is a matrix inversion routine in BBC BASIC that DeepSeek wrote without that extra help (just one line needed altering to make it work, and that wasn't exactly a mistake by DeepSeek but an invalid - if reasonable - assumption about the language):

Code:

      DEF PROCinvert(input(), output())      LOCAL N%, aug(), i%, k%, pivot_row%, max_val, temp, factor      N% = DIM(input(), 1) + 1      IF DIM(input(), 2) + 1 <> N% THEN ERROR 100, "Matrix not square"      DIM aug(N%, 2*N%-1)      FOR i% = 0 TO N%-1        aug(i%, 0 TO N%-1) = input(i%, 0 TO)        aug(i%, N% TO 2*N%-1) = 0        aug(i%, i%+N%) = 1      NEXT      FOR k% = 0 TO N%-1        pivot_row% = k%        max_val = ABS(aug(k%,k%))        FOR i% = k%+1 TO N%-1          IF ABS(aug(i%,k%)) > max_val THEN            pivot_row% = i% : max_val = ABS(aug(i%,k%))          ENDIF        NEXT        IF max_val = 0 THEN ERROR 101, "Matrix singular"        IF pivot_row% <> k% THEN FOR i% = 0 TO 2*N%-1 : SWAP aug(k%,i%), aug(pivot_row%,i%) : NEXT        temp = aug(k%,k%)        aug(k%,k% TO 2*N%-1) = aug(k%,k% TO 2*N%-1)/temp        FOR i% = 0 TO N%-1          IF i% <> k% THEN            factor = aug(i%,k%)            aug(i%,k% TO 2*N%-1) -= factor * aug(k%,k% TO 2*N%-1)          ENDIF        NEXT      NEXT      FOR i% = 0 TO N%-1        output(i%,0 TO N%-1) = aug(i%,N% TO 2*N%-1)      NEXT      ENDPROC

Statistics: Posted by RichardRussell — Sat Mar 29, 2025 10:19 am



Viewing all articles
Browse latest Browse all 9122

Trending Articles