Heater
Posts: 13691
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 4:57 pm

Some people don't care but in general I try to avoid having to give root to anything that does not come from a source that I trust. I have had bad experiences in the past installing .debs from places other than my operating systems repositories.

It should not be necessary to get root to install. I have all kind of things installed that don't. Versions of gcc and llvm, cross compilers, etc, etc.

I am not suggesting you are not to be trusted or that there is any issue with the install process. But them's the rules around here.
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 5:08 pm

ScriptBasic can run out of your home directory without root privileges. As scruss suggests you can install it in your home bin directory.

I'm not hearing any screaming about Python, php or Perl running with root privileges.

The system install of ScriptBasic is normally used when running the SB application proxy server.

The RPi is a $35 computer for those wishing to learn programming and hardware interfacing. You guys sound like I'm asking you to trust SB for your ATM application. The source is available to inspect before you compile ScriptBasic. Nothing is being hidden from you.
Last edited by John_Spikowski on Sat Apr 06, 2019 5:27 pm, edited 2 times in total.

Heater
Posts: 13691
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 5:18 pm

ScriptBasic,
I'm not hearing any screaming about Python, php or Perl running with root privileges.
That is because they all come installed out of the box in ones operating system or are available as packages to install from the operating system maintainers. They only run with root privs when the OS is running them for it's own purposes. If we can't trust our OS providers we are doomed.

That is a lot different than installing .debs from random places on the net or handing root privs to install systems from untrusted locations.

The question then is: Can ScriptBasic be built and installed with out running anything as root? Like for example GCC, Clang/LLVM, node.js etc, etc...?

If so we are good to go.
Memory in C++ is a leaky abstraction .

jahboater
Posts: 4777
Joined: Wed Feb 04, 2015 6:38 pm

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 5:25 pm

Heater wrote:
Sat Apr 06, 2019 5:18 pm
The question then is: Can ScriptBasic be built and installed with out running anything as root? Like for example GCC, Clang/LLVM, node.js etc, etc...?
You mean if configure GCC with "--prefix=/home/pi/bin" or some such?
So that the subsequent "make install" doesn't require root.

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 5:38 pm

I build ScriptBasic out of my home directory with no root privileges. I can do a 'system' like install in home as well. Look at the mkdeb.sh for how SB builds its directory structure and basic.conf file.

You can run ScriptBasic with just the scriba file on your system even without the configuration file. You just won't have use of it's extensive extension module functionality.

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

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 6:22 pm

Heater wrote:
Sat Apr 06, 2019 4:57 pm
It should not be necessary to get root to install.
It appears that the perl-based build tools necessary for generating the ScriptBasic parser and headers are asking to be installed in system directories. Note that /usr/local also seems an option; however, it would be nice if a person could build ScriptBasic without needing to install anything at the system level beyond the signed packages in the distribution repository.

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 6:29 pm

Peter Verhas (original author 1997-2006) created ScriptBasic which is pretty much unchanged except for AIR and I adding extension modules.

The current Windows Inno version of ScriptBasic was built using TDMGGC32 and a make file AIR created. The SB build system wasn't used. (uses MSVC) It doesn't build headers or docs from C source and uses previous generated copies of them. Perl isn't needed.

Note: The COM extension module (created by Dave Zimmer) uses VS2012 as it's a VB6 centric ext. module.

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 8:21 pm

The title of this thread is confusing. It sounds like why you should marry an ugly women. :(

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

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 8:54 pm

ScriptBasic wrote:
Sat Apr 06, 2019 8:21 pm
The title of this thread is confusing.
I think it would be clearer to point out that there are many different programming languages called Basic and that different people will have different preferences concerning which to avoid.

This thread and the forum in general is intended to be a friendly place for all people interested in computing and Raspberry Pi to gather, share ideas and help one another. Therefore, it is important that no post be of a nature that might offend or cause someone to avoid learning how to program. While such rules may seem overly strict, the surest way to avoid the impending digital apocalypse is for everyone to be included.
Last edited by ejolson on Sat Apr 06, 2019 9:07 pm, edited 2 times in total.

Heater
Posts: 13691
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 9:01 pm

Ah yes. Our opening poster here, DavidS, is very much into BASIC, especially on his favorite OS, RISCOS. He was a bit miffed that the Pi Foundation promotes Python, Scratch and the like as teaching languages and was basically asking why they avoid BASIC. As he said:
BASIC is a good usable language, that is discouraged. It is a good fit on the Raspberry Pi for many reasons, and indeed is a big part of one of the Operating Systems that runs on the RPi.

Though yet it seems as if the RPi Foundation discourages the use of BASIC, in preference to languages that have a higher barrier of entry to new programmers, and in some cases are more limited.
Out of that grew the fibo(4784969) challenge as a demonstration of a possible reason to avoid BASIC.

Oddly enough, it was others that rose to the challenge of creating fibo(4784969) in BASIC. There are some strange folks around here :)
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 9:09 pm

My comment wasn't to offend any gender. It was an analogy how the title sounded to me.

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

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 9:18 pm

ScriptBasic wrote:
Sat Apr 06, 2019 9:09 pm
My comment wasn't to offend any gender. It was an analogy how the title sounded to me.
There is a certain brilliance to the title in that it can be interpreted in two ways:

1. As a request to make a list of reasons for avoiding something.

2. As as exhortation that something should not be avoided.

I'm ready to try ScriptBasic on the Zero with a new version of Raspbian, but it's a sunny day so there may be some delays.

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 9:21 pm

For me C is the ingredients and ScriptBasic the Pi.

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sat Apr 06, 2019 9:25 pm

I'm ready to try ScriptBasic on the Zero with a new version of Raspbian, but it's a sunny day so there may be some delays.
That sounds great. Thanks!

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 12:40 am

Wow!

The Raspberry Pi Zero is only $5.

Does Python even run in 512 MB of system memory?

FYI: The current AppImage build script doesn't include adding the runtime dependencies. The AppImage I posted is AIR's beta of Appimage with dependencies included. I have asked AIR to push the new AppImage build script to the sandbox.

User avatar
Paeryn
Posts: 2706
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 1:03 am

ScriptBasic wrote:
Sun Apr 07, 2019 12:40 am
Does Python even run in 512 MB of system memory?
Are you serious? Python can run on systems with a lot less than 512MB, I've used it on a system with only 32MB before now.
She who travels light — forgot something.

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 1:12 am

In that case you should have plenty of room to spare with ScriptBasic.

Code: Select all

LINE INPUT x
pmap

Code: Select all

[email protected]:~ $ sudo pmap -x 671
671:   scriba lineinput.sb
Address   Kbytes     RSS   Dirty Mode  Mapping
00010000     508     380       0 r-x-- scriba
00010000       0       0       0 r-x-- scriba
0009e000       4       4       4 r---- scriba
0009e000       0       0       0 r---- scriba
0009f000      64      64       8 rw--- scriba
0009f000       0       0       0 rw--- scriba
02016000     132      28      28 rw---   [ anon ]
02016000       0       0       0 rw---   [ anon ]
76cce000      88      88       0 r-x-- libpthread-2.24.so
76cce000       0       0       0 r-x-- libpthread-2.24.so
76ce4000      60       0       0 ----- libpthread-2.24.so
76ce4000       0       0       0 ----- libpthread-2.24.so
76cf3000       4       4       4 r---- libpthread-2.24.so
76cf3000       0       0       0 r---- libpthread-2.24.so
76cf4000       4       4       4 rw--- libpthread-2.24.so
76cf4000       0       0       0 rw--- libpthread-2.24.so
76cf5000       8       4       4 rw---   [ anon ]
76cf5000       0       0       0 rw---   [ anon ]
76cf7000       8       8       0 r-x-- libdl-2.24.so
76cf7000       0       0       0 r-x-- libdl-2.24.so
76cf9000      60       0       0 ----- libdl-2.24.so
76cf9000       0       0       0 ----- libdl-2.24.so
76d08000       4       4       4 r---- libdl-2.24.so
76d08000       0       0       0 r---- libdl-2.24.so
76d09000       4       4       4 rw--- libdl-2.24.so
76d09000       0       0       0 rw--- libdl-2.24.so
76d0a000     436      64       0 r-x-- libm-2.24.so
76d0a000       0       0       0 r-x-- libm-2.24.so
76d77000      64       0       0 ----- libm-2.24.so
76d77000       0       0       0 ----- libm-2.24.so
76d87000       4       4       4 r---- libm-2.24.so
76d87000       0       0       0 r---- libm-2.24.so
76d88000       4       4       4 rw--- libm-2.24.so
76d88000       0       0       0 rw--- libm-2.24.so
76d89000    1192     720       0 r-x-- libc-2.24.so
76d89000       0       0       0 r-x-- libc-2.24.so
76eb3000      60       0       0 ----- libc-2.24.so
76eb3000       0       0       0 ----- libc-2.24.so
76ec2000       8       8       8 r---- libc-2.24.so
76ec2000       0       0       0 r---- libc-2.24.so
76ec4000       4       4       4 rw--- libc-2.24.so
76ec4000       0       0       0 rw--- libc-2.24.so
76ec5000      12      12      12 rw---   [ anon ]
76ec5000       0       0       0 rw---   [ anon ]
76ee0000      20      20       4 r-x-- libarmmem.so
76ee0000       0       0       0 r-x-- libarmmem.so
76ee5000      60       0       0 ----- libarmmem.so
76ee5000       0       0       0 ----- libarmmem.so
76ef4000       4       4       4 r---- libarmmem.so
76ef4000       0       0       0 r---- libarmmem.so
76ef5000       4       4       4 rw--- libarmmem.so
76ef5000       0       0       0 rw--- libarmmem.so
76ef6000     132     132       0 r-x-- ld-2.24.so
76ef6000       0       0       0 r-x-- ld-2.24.so
76f22000      16      12      12 rw---   [ anon ]
76f22000       0       0       0 rw---   [ anon ]
76f26000       4       4       4 r---- ld-2.24.so
76f26000       0       0       0 r---- ld-2.24.so
76f27000       4       4       4 rw--- ld-2.24.so
76f27000       0       0       0 rw--- ld-2.24.so
7e95b000     132      12      12 rw---   [ stack ]
7e95b000       0       0       0 rw---   [ stack ]
7e9f6000       4       0       0 r-x--   [ anon ]
7e9f6000       0       0       0 r-x--   [ anon ]
7e9f7000       4       0       0 r----   [ anon ]
7e9f7000       0       0       0 r----   [ anon ]
7e9f8000       4       4       0 r-x--   [ anon ]
7e9f8000       0       0       0 r-x--   [ anon ]
ffff0000       4       0       0 r-x--   [ anon ]
ffff0000       0       0       0 r-x--   [ anon ]
-------- ------- ------- ------- 
total kB    3124    1604     136
[email protected]:~ $ 

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 1:57 am

Here is the Python story.

Code: Select all

x = input()

Code: Select all

[email protected]:~ $ sudo pmap -x 8919
8919:   python python_input.py
Address   Kbytes     RSS   Dirty Mode  Mapping
00010000    2732    1548       0 r-x-- python2.7
00010000       0       0       0 r-x-- python2.7
002ca000       4       4       4 r---- python2.7
002ca000       0       0       0 r---- python2.7
002cb000     360     248      88 rw--- python2.7
002cb000       0       0       0 rw--- python2.7
00325000      84      76      76 rw---   [ anon ]
00325000       0       0       0 rw---   [ anon ]
016e2000     588     544     544 rw---   [ anon ]
016e2000       0       0       0 rw---   [ anon ]
76a8c000     256      68      68 rw---   [ anon ]
76a8c000       0       0       0 rw---   [ anon ]
76acc000    1644     396       0 r---- locale-archive
76acc000       0       0       0 r---- locale-archive
76c67000     768     768     768 rw---   [ anon ]
76c67000       0       0       0 rw---   [ anon ]
76d27000    1192     916       0 r-x-- libc-2.24.so
76d27000       0       0       0 r-x-- libc-2.24.so
76e51000      60       0       0 ----- libc-2.24.so
76e51000       0       0       0 ----- libc-2.24.so
76e60000       8       8       8 r---- libc-2.24.so
76e60000       0       0       0 r---- libc-2.24.so
76e62000       4       4       4 rw--- libc-2.24.so
76e62000       0       0       0 rw--- libc-2.24.so
76e63000      12      12      12 rw---   [ anon ]
76e63000       0       0       0 rw---   [ anon ]
76e66000     436      64       0 r-x-- libm-2.24.so
76e66000       0       0       0 r-x-- libm-2.24.so
76ed3000      64       0       0 ----- libm-2.24.so
76ed3000       0       0       0 ----- libm-2.24.so
76ee3000       4       4       4 r---- libm-2.24.so
76ee3000       0       0       0 r---- libm-2.24.so
76ee4000       4       4       4 rw--- libm-2.24.so
76ee4000       0       0       0 rw--- libm-2.24.so
76ee5000      88      64       0 r-x-- libz.so.1.2.8
76ee5000       0       0       0 r-x-- libz.so.1.2.8
76efb000      60       0       0 ----- libz.so.1.2.8
76efb000       0       0       0 ----- libz.so.1.2.8
76f0a000       4       4       4 r---- libz.so.1.2.8
76f0a000       0       0       0 r---- libz.so.1.2.8
76f0b000       4       4       4 rw--- libz.so.1.2.8
76f0b000       0       0       0 rw--- libz.so.1.2.8
76f0c000       8       8       0 r-x-- libutil-2.24.so
76f0c000       0       0       0 r-x-- libutil-2.24.so
76f0e000      60       0       0 ----- libutil-2.24.so
76f0e000       0       0       0 ----- libutil-2.24.so
76f1d000       4       4       4 r---- libutil-2.24.so
76f1d000       0       0       0 r---- libutil-2.24.so
76f1e000       4       4       4 rw--- libutil-2.24.so
76f1e000       0       0       0 rw--- libutil-2.24.so
76f1f000       8       8       0 r-x-- libdl-2.24.so
76f1f000       0       0       0 r-x-- libdl-2.24.so
76f21000      60       0       0 ----- libdl-2.24.so
76f21000       0       0       0 ----- libdl-2.24.so
76f30000       4       4       4 r---- libdl-2.24.so
76f30000       0       0       0 r---- libdl-2.24.so
76f31000       4       4       4 rw--- libdl-2.24.so
76f31000       0       0       0 rw--- libdl-2.24.so
76f32000      88      88       0 r-x-- libpthread-2.24.so
76f32000       0       0       0 r-x-- libpthread-2.24.so
76f48000      60       0       0 ----- libpthread-2.24.so
76f48000       0       0       0 ----- libpthread-2.24.so
76f57000       4       4       4 r---- libpthread-2.24.so
76f57000       0       0       0 r---- libpthread-2.24.so
76f58000       4       4       4 rw--- libpthread-2.24.so
76f58000       0       0       0 rw--- libpthread-2.24.so
76f59000       8       4       4 rw---   [ anon ]
76f59000       0       0       0 rw---   [ anon ]
76f73000      20      20       4 r-x-- libarmmem.so
76f73000       0       0       0 r-x-- libarmmem.so
76f78000      60       0       0 ----- libarmmem.so
76f78000       0       0       0 ----- libarmmem.so
76f87000       4       4       4 r---- libarmmem.so
76f87000       0       0       0 r---- libarmmem.so
76f88000       4       4       4 rw--- libarmmem.so
76f88000       0       0       0 rw--- libarmmem.so
76f89000     132     132       0 r-x-- ld-2.24.so
76f89000       0       0       0 r-x-- ld-2.24.so
76fb4000       4       4       0 r---- locale-archive
76fb4000       0       0       0 r---- locale-archive
76fb5000      16      12      12 rw---   [ anon ]
76fb5000       0       0       0 rw---   [ anon ]
76fb9000       4       4       4 r---- ld-2.24.so
76fb9000       0       0       0 r---- ld-2.24.so
76fba000       4       4       4 rw--- ld-2.24.so
76fba000       0       0       0 rw--- ld-2.24.so
7efa1000     132      28      28 rw---   [ stack ]
7efa1000       0       0       0 rw---   [ stack ]
7efca000       4       0       0 r-x--   [ anon ]
7efca000       0       0       0 r-x--   [ anon ]
7efcb000       4       0       0 r----   [ anon ]
7efcb000       0       0       0 r----   [ anon ]
7efcc000       4       4       0 r-x--   [ anon ]
7efcc000       0       0       0 r-x--   [ anon ]
ffff0000       4       0       0 r-x--   [ anon ]
ffff0000       0       0       0 r-x--   [ anon ]
-------- ------- ------- ------- 
total kB    9088    5084    1676
[email protected]:~ $ 
An interesting comparison would be running the same code in 5 threads.

Curious. Is Python embeddable?
Last edited by John_Spikowski on Sun Apr 07, 2019 5:16 am, edited 2 times in total.

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 3:38 am

Here is the Fibonacci recursive benchmark for Python and ScriptBasic.

Python (Parcially Recursive)

Code: Select all

def recur_fibo(n):
   if n <= 1:
       return n
   else:
       return(recur_fibo(n-1) + recur_fibo(n-2))

nterms = 25

if nterms <= 0:
   print("Plese enter a positive integer")
else:
   for i in range(nterms):
      recur_fibo(i)
   print(recur_fibo(i))


[email protected]:~/sbrpi/examples $ time python fibonacci.py
46368

real 0m0.764s
user 0m0.726s
sys 0m0.030s
[email protected]:~/sbrpi/examples $


ScriptBasic (true recursive function)

Code: Select all

FUNCTION Fibonacci(n)
  IF n <= 2 THEN
    Fibonacci = 1
  ELSE
    Fibonacci = Fibonacci(n - 1) + Fibonacci(n - 2)
  END IF
END FUNCTION

PRINT Fibonacci(24),"\n"
[email protected]:~/sbrpi/examples $ time scriba fibonacci.sb
46368

real 0m0.863s
user 0m0.858s
sys 0m0.001s
[email protected]:~/sbrpi/examples $
Last edited by John_Spikowski on Sun Apr 07, 2019 5:18 am, edited 4 times in total.

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

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 3:40 am

ScriptBasic wrote:
Sun Apr 07, 2019 3:38 am
Here is the Fibonacci recursive benchmark for Python and ScriptBasic.

Python

Code: Select all

def recur_fibo(n):
   if n <= 1:
       return n
   else:
       return(recur_fibo(n-1) + recur_fibo(n-2))

nterms = 25

if nterms <= 0:
   print("Plese enter a positive integer")
else:
   for i in range(nterms):
      recur_fibo(i)
   print(recur_fibo(i))
[email protected]:~/sbrpi/examples $ time python fibonacci.py
46368

real 0m0.764s
user 0m0.726s
sys 0m0.030s
[email protected]:~/sbrpi/examples $


ScriptBasic

Code: Select all

FUNCTION Fibonacci(n)
  IF n <= 2 THEN
    Fibonacci = 1
  ELSE
    Fibonacci = Fibonacci(n - 1) + Fibonacci(n - 2)
  END IF
END FUNCTION

PRINT Fibonacci(24),"\n"
[email protected]:~/sbrpi/examples $ time scriba fibonacci.sb
46368

real 0m0.863s
user 0m0.858s
sys 0m0.001s
[email protected]:~/sbrpi/examples $
Did you say that ScriptBasic can also compile the code?

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 3:52 am

Did you say that ScriptBasic can also compile the code?
The -C option creates a C wrapper around the tokenized code and uses libscriba.so as the BASIC interpreter.

The -E option appends the tokenized code to a copy of scriba with the name you selected. Scriba always checks before loading any code (or processing any options) to see if there is a script attached. Anything following the executable is treated a COMMAND() passed argument

jahboater
Posts: 4777
Joined: Wed Feb 04, 2015 6:38 pm

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 6:05 am

Here is the same function in C to compare the speed of compiled ScriptBasic against:

Code: Select all

$ cat fibo_rec.c
#include <stdio.h>

static int
Fibonacci( const int n )
{
  if( n < 2 )
    return n;
  return Fibonacci(n-1) + Fibonacci(n-2);
}

int
main( void )
{
  printf( "%d\n", Fibonacci(24) );
}

$ gcc -O3 -s fibo_rec.c -o fibo
$ ls -l ./fibo
-rwxr-xr-x 1 jah jah 4384 Apr  7 07:03 ./fibo
$ time ./fibo
46368

real	0m0.001s
user	0m0.000s
sys	0m0.000s
$ 

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 6:33 am

The cool thing about ScriptBasic is I can create C based extension modules when iteration code needs to run at max speed.

Here is a Mandelbrot example in ScriptBasic that calls a C routine for the iteration work.

Code: Select all

    ' ScriptBasic GFX - Mandelbrot
     
    IMPORT gfx.bas
     
    s = gfx::Window(640,480,"ScriptBasic RPi SDL_gfx Mandelbrot")
    ts = gfx::Time()
    FOR y = 0 TO 479
      FOR x = 0 TO 639
        cx = (x - 320) / 120
        cy = (y - 240) / 120
        rit = gfx::Mandelbrot(cx, cy, 510)
        gfx::PixelRGBA s, x, y, rit * 32, rit * 16, rit * 8, 255
      NEXT
    NEXT
    te = gfx::Time()
    gfx::stringColor s, 20, 15, "Time: " & FORMAT("%.4f",(te-ts)/1000) & " Seconds." & CHR(0), 0x000000ff
    gfx::Update
    WHILE gfx::KeyName(1) <> "+escape"
    WEND
    gfx::Close
Attachments
mandelbrot_rpi.png
mandelbrot_rpi.png (31.52 KiB) Viewed 509 times
Last edited by John_Spikowski on Sun Apr 07, 2019 7:00 am, edited 3 times in total.

Heater
Posts: 13691
Joined: Tue Jul 17, 2012 3:02 pm

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 6:48 am

ScriptBasic,
Does Python even run in 512 MB of system memory?
Wow, what a question. Python may be gigantic compared to the BASICs we know and love from the early 1980's but a running Python script on Linux is only a handful of megabytes.

Micropython runs on a variety micro-controllers, minimum suggested memory requirement is 128K ROM/8K RAM but it will work in less.
https://micropython.org/

Thanks for the Python fibo solution. Unfortunately it will not work for fibo(4784969) because:

a) It runs out of stack

b) If it did not run out of the stack it might take longer than the age of the universe to finish.

We do have a Python solution already though whose run time is down to 18 seconds, on a PC at least.
https://github.com/ZiCog/fibo_4784969/b ... 4784969.py

The challenge is then can you do that in ScriptBasic?
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1589
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 6:56 am

Sorry, I don't see the point of wasting my time on nonsense. :roll:

Return to “Off topic discussion”