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.I'm not hearing any screaming about Python, php or Perl running with root privileges.
You mean if configure GCC with "--prefix=/home/pi/bin" or some such?
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.
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.
Out of that grew the fibo(4784969) challenge as a demonstration of a possible reason to avoid BASIC.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.
There is a certain brilliance to the title in that it can be interpreted in two ways:ScriptBasic wrote: ↑Sat Apr 06, 2019 9:09 pmMy comment wasn't to offend any gender. It was an analogy how the title sounded to me.
That sounds great. Thanks!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.
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.
Code: Select all
LINE INPUT x
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]:~ $
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]:~ $
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))
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"
Did you say that ScriptBasic can also compile the code?ScriptBasic wrote: ↑Sun Apr 07, 2019 3:38 amHere is the Fibonacci recursive benchmark for Python and ScriptBasic.
Python[email protected]:~/sbrpi/examples $ time python fibonacci.pyCode: 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))
46368
real 0m0.764s
user 0m0.726s
sys 0m0.030s
[email protected]:~/sbrpi/examples $
ScriptBasic[email protected]:~/sbrpi/examples $ time scriba fibonacci.sbCode: 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"
46368
real 0m0.863s
user 0m0.858s
sys 0m0.001s
[email protected]:~/sbrpi/examples $
The -C option creates a C wrapper around the tokenized code and uses libscriba.so as the BASIC interpreter.Did you say that ScriptBasic can also compile the code?
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
$
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
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.Does Python even run in 512 MB of system memory?