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

Re: Why Avoid BASIC on RPi?

Sun Apr 07, 2019 11:43 pm

ScriptBasic wrote:
Sun Apr 07, 2019 5:41 pm
Richard's BBC BASIC isn't open source and is a BASIC compiler.
Someone's already covered the open source bit, but BBCSDL is an interpreter.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

User avatar
John_Spikowski
Posts: 1602
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 11:58 pm

Thanks scruss for the clarification. Last I heard Richard was thinking of throwing in the towel. Sounds like he got a second wind and a little smarter.

Just read your profile. I was SE Asia MARS net control towards the end of the Vietnam days. Barry Goldwater was always my first state side contact to come online. -- over --

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 1:18 am

Here are the numbers for the updated Fibonacci.py code.

Code: Select all

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

print(recur_fibo(24))
[email protected]:~/sbrpi/examples $ time scriba fibonacci.sb
46368

real 0m0.904s
user 0m0.900s
sys 0m0.000s
[email protected]:~/sbrpi/examples $ time python fibonacci.py
46368

real 0m0.293s
user 0m0.273s
sys 0m0.020s
[email protected]:~/sbrpi/examples $

The question is can someone viewing the program execution results (not using time) tell you which seems faster?

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 1:32 am

scruss wrote: I don't really have much interest in compiling ScriptBASIC. So much of its setup code is the kind of 1990s horrid Perl spaghetti code that Python programmers still go on about. It's not even using reasonable Perl idioms of the time. It might still work, but it's going to be virtually impossible to test.
@ejolson,

You took a stroll down SB lane and I'm curious if you agree with the above statement?

I'm also curious if that means he won't try the runtime executables either?

Is Python easier to build from source?

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 2:01 am

Building Python from source.
Raspbian follows Debian Stretch ARMHF, for the RPF to offer a newer package would mean hours of testing for compatibility, time and money which could be better spent on the fulfilling of the Charitable Aims.
Sounds pretty ugly.

Open source software shouldn't get to a point where community improvements are too difficult to submit.

Scriptbasic can morph into just about any enviornment it needs to run under. Isn't that the point of the RPi to morph into whatever your project calls for without knowing more than the BASICs?
Last edited by John_Spikowski on Mon Apr 08, 2019 2:50 am, edited 1 time in total.

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 2:50 am

ScriptBasic wrote:
Mon Apr 08, 2019 1:18 am
The question is can someone viewing the program execution results (not using time) tell you which seems faster?
There are plenty of interpreters slower than ScriptBasic that are in widespread use. The exact same recursive Fibonacci code written in bash looks like

Code: Select all

#!/bin/bash
fibo_work(){
    case $1 in
1|2)    let y=1;;
*)      let x=$1-1; fibo_work $x; local fa=$y
        let x=$1-2; fibo_work $x; local fb=$y
        let y=$fa+$fb;;
    esac
}
fibo_work 24
echo $y
and on the Pi Zero obtains a execution speed of

Code: Select all

$ time ./fibo.sh 
46368

real    0m58.811s
user    0m57.875s
sys 0m0.010s
which is about 30 times slower than ScriptBasic.
Last edited by ejolson on Mon Apr 08, 2019 2:56 am, edited 2 times in total.

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 2:53 am

One could write in less than 10 lines of C code a program that would use libscriba.so. This means your runtime executable is about 12 KB. With the interpreter resident in memory as a shared object and a tiny executable, calling ScriptBasic from your shell scripts should be painless.
Last edited by John_Spikowski on Mon Apr 08, 2019 4:58 am, edited 3 times in total.

User avatar
Gavinmc42
Posts: 3936
Joined: Wed Aug 28, 2013 3:31 am

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 3:38 am

No bashing Bash, it is a perfectly usable language :lol:
Some of my most reliable code is done in shell script, been running for years.

But why is Basic not used as shell script, it would be easier to write and read ;)
Sometime felt like I need gotos in shell :P
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 3:42 am

ScriptBasic can be used in a shell script as it supports STD/IN/OUT/ERROR.

User avatar
Gavinmc42
Posts: 3936
Joined: Wed Aug 28, 2013 3:31 am

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 4:32 am

Can ScriptBasic be embedded in an OS?
https://ultibo.org/forum/viewtopic.php?f=16&t=1302

I tried installing it on the weekend, no success yet.
Tried on Windows, Linux Mint and Pi's.
Debs are missing?
So downloaded and tried that way, seemed to install but no exe for scriptb.
Just takes a bit more effort than usual, not holding my tongue in the right position? ;)
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 4:51 am

ejolson,
If all programming languages are terrible, why avoid Basic?
I'm not sure I single out BASIC in particular. I've had to try hard to avoid Python, Perl, PHP, Smalltalk, Lisp, Scheme, PL/M, Coral, Lucol, Ada, Forth, Fortran, Java, C#. Perhaps others I have forgotten. Of course in the modern world there are many new languages one might have to avoid, Ruby, Rust, Go, Haskell, Clojure ... God knows what the kids have been dreaming up to catch you out.

Just now there is only a handful of languages I cannot avoid if I want to get anything done:

C/C++ - Because they are easily available everywhere for everything. Has proper definition and standards. Ideal for small and/or fast.

Javascript - For most everything else. Dead simple but sophisticated. Has proper definition and standards. Great for event driven systems. Performance is pretty good. Available everywhere, browser, server, micro-controllers.

Verilog - For FPGA experiments.

Scala - A terrible language with a sloppy syntax, no standard, and crippled in it's performance and semantics by it's use of the JVM. Which also makes it ludicrous memory hungry. However turns out to be a great way to define hardware and generate Verilog.

Python - Because that damn thing has infected pretty much everything. A terrible language with a sloppy syntax no standard crippled in it's performance and semantics just by being Python.
Memory in C++ is a leaky abstraction .

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 5:11 am

Can ScriptBasic be embedded in an OS?
ScriptBasic by design is an embeddable scripting engine. (In your application)

scriba was created by Peter Verhas as a means to demonstrate the embedded and extension APIs. It took on a life of it's own and here we are.

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 5:20 am

ScriptBasic,
Open source software shouldn't get to a point where community improvements are too difficult to submit.
I'm not sure what you mean by that.

An open source project developer/maintainer is not obligated to accept changes from anybody. It's his project. I would not expect maintainers to accept changes willy-nilly from anybody if they want their code to remain functional and move in the direction they like. Integrating and testing any change is a lot of work.

When it comes to an entire operating system like Debian/Raspian hundreds of people spend thousands of hours testing things and trying to ensure it remains stable. That is not just "stable" as in does not crash but stable in that all the hundreds of parts work together correctly, random changes in API's, config file formats, etc, etc don't break peoples systems.

The Linux kernel, perhaps one of the biggest software projects ever with the most contributors, is quite rightly very fussy about changes they accept.

Being open source you are of course free to fork things and make whatever changes you like. If you want to take on the burden of maintaining the thing yourself.
Isn't that the point of the RPi to morph into whatever your project calls for without knowing more than the BASICs?
Sure, why not. You can do what you like with the Pi. That does not imply one need never progress past the basics.
Memory in C++ is a leaky abstraction .

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 5:26 am

ScriptBasic,
scriba was created by Peter Verhas as a means to demonstrate the embedded and extension APIs. It took on a life of it's own and here we are.
Well, there you are. Peter Verhas seems to do everything in Java and Javascript now a days.
https://github.com/verhas?after=Y3Vyc29 ... positories
Memory in C++ is a leaky abstraction .

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 5:30 am

My goal with the RPi ScriptBasic project is to give its user the freedom of taking the base source and do anything they wish with it with no strings attached. Hopefully members will share their creations and improvements. Some concepts have been adapted by its maintainers.

Most language improvements are in the form of extension modules.

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 5:40 am

An admirable goal. And one that you share with every other piece of software in Raspbian, Linux systems and the Free and Open Source world in general. That is the reason we are all here.

Edit: Except the closed source video core blob.
Memory in C++ is a leaky abstraction .

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 5:47 am

Well, there you are. Peter Verhas seems to do everything in Java and Javascript now a days.
Peter wrote a ScriptBasic interpreter in Java if you would like to give it a try. I think financial incentives and a 9 year run with SB without major adoption is how I ended up as the project manager / facilitator.

Peter has already written a few books on Advanced Java. He does't need a translator, he speaks in at least 12 different languages.

ScriptBasic still needs a professional set of clothes but AIR has done a great job of keeping the code base up to current standards on all platforms.

We have a sandbox but no toys.

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 9:17 am

ScriptBasic,
Peter wrote a ScriptBasic interpreter in Java if you would like to give it a try.
That is not really my cup of tea. All the limitations of BASIC with all the bloat and complication of the JVM. I have been having a hard time with that kind of idea with Scala recently.

Amazingly Peter Verhas has less stars on github than I do. I'm sure his projects there are far more sophisticated and useful than anything I have up there. I'll give him a star to catch up.
Memory in C++ is a leaky abstraction .

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 1:36 pm

Most people here are using the shell builtin "time" command to print execution times.
The gnu time command is much more informative - for recursive fibo(24):

Code: Select all

$ /usr/bin/time -v python3 fibo.py
46368
	Command being timed: "python3 fibo.py"
	User time (seconds): 0.95
	System time (seconds): 0.02
	Percent of CPU this job got: 80%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.20
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 6552
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 30
	Minor (reclaiming a frame) page faults: 631
	Voluntary context switches: 70
	Involuntary context switches: 83
	Swaps: 0
	File system inputs: 8000
	File system outputs: 0
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0
C version ....

Code: Select all

[email protected]:~ $ /usr/bin/time -v ./fibo
46368
	Command being timed: "./fibo"
	User time (seconds): 0.01
	System time (seconds): 0.00
	Percent of CPU this job got: 66%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.01
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 1108
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 0
	Minor (reclaiming a frame) page faults: 67
	Voluntary context switches: 2
	Involuntary context switches: 2
	Swaps: 0
	File system inputs: 16
	File system outputs: 0
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0
The file system inputs (stuff actually read from the physical disk) is interesting: 16 for the C program and 8000 for Python.
If run a second time the disk figure goes to zero because its in the cache.

If your Pi does not have /usr/bin/time then "sudo apt install time" will get it.
"man 1 time" gives all the details.
GNU time has a handy formatted output (see the -f option).

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 1:49 pm

Cool. Never knew that.
Memory in C++ is a leaky abstraction .

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 1:54 pm

Here is an example of the format option:

Code: Select all

$ /usr/bin/time -f "Disk %I, Resident Memory %M, User CPU %U" python3 ./fibo.py
46368
Disk 8000, Resident Memory 6456, User CPU 1.01
$ /usr/bin/time -f "Disk %I, Resident Memory %M, User CPU %U" ./fibo   
46368
Disk 16, Resident Memory 1088, User CPU 0.00 

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 2:40 pm

Heater wrote:
Mon Apr 08, 2019 9:17 am
Amazingly Peter Verhas has less stars on github than I do. I'm sure his projects there are far more sophisticated and useful than anything I have up there. I'll give him a star to catch up.
I don't think the star system in GitHub is very accurate. For example, the Fibonacci repository has zero stars while this thread has over 60000 views. Maybe, if the BBC Basic and Visual Basic codes were included the repository would also catch up.

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 3:19 pm

I tried installing it on the weekend, no success yet.
Tried on Windows, Linux Mint and Pi's.
Use the Inno install for Windows. Everything else build it from source (sandbox - cleanup branch) is your best bet. For the RPi 3 B an AppImage and DEB are available. (see ScriptBasic.org forum)
Last edited by John_Spikowski on Mon Apr 08, 2019 5:40 pm, edited 1 time in total.

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 3:33 pm

ejolson,

I'm sure the star system in github is pretty much as any other "like" system on the net. It just means somebody, somewhere, clicked some button for some reason.

Actually I was misunderstanding what the stars figure on a users github page means. It is actually the number of other repositories they have starred. If you click on it it shows a list of the repos that user likes.
Memory in C++ is a leaky abstraction .

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

Re: Why Avoid BASIC on RPi?

Mon Apr 08, 2019 7:07 pm

I just ordered a Raspberry Pi Zero which should arrive tomorrow. I'll get a ScriptBasic build for it posted soon.

Where is the best place to get a copy of Raspbian for the Zero?

Return to “Off topic discussion”