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

Re: ScriptBasic

Sat May 18, 2019 2:35 pm

Heater wrote:
Sat May 18, 2019 10:11 am
What to do?
I went through many of the same steps here. I started with a fresh install of Raspbian on a Pi Zero. Rather than giving the install script root access, I set the owner and permissions on one of the system directories in /usr/local so things could build without needing root.

Maybe the thing to do is get a Pi Zero. I'm not sure it still comes as a free gift with a MagPi magazine subscription, so you might have to spend around €9 someplace here .

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

Re: ScriptBasic

Sat May 18, 2019 3:40 pm

What to do?
Most people run ./setup to build the source.

If you follow the steps on the resouce post on RaspberryBASIC.org your build should go smoothly. Over think it an you will be scratching your head for hours.

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

Re: ScriptBasic

Sat May 18, 2019 3:49 pm

ScriptBasic wrote:
Sat May 18, 2019 3:40 pm
What to do?
Most people run ./setup to build the source.

If you follow the steps on the resouce post on RaspberryBASIC.org your build should go smoothly. Over think it an you will be scratching your head for hours.
Thanks for the reminder. That's the name of the script I used to build ScriptBasic. More details are available starting here and in the following posts.

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

Re: ScriptBasic

Sat May 18, 2019 4:17 pm

ScriptBasic,
Most people run ./setup to build the source.
Do they? How would they know?

I have built gazillions of things from their sources. If it's a C project it's generally something like:

Code: Select all

./configure
make
make install
Otherwise there are build directions in a REAME.txt or some such.

I guess "setup" is a Windows world thing. Usually for installing and setting up executables not building from source. Ah well. A little documentation update would fix that.
Over think it an you will be scratching your head for hours.
Not at all. Thanks to your tip I can do this:

Code: Select all

$ cat fibo.bas
FUNCTION sfibo (n)
        IF n < 2 THEN
                sfibo = 1
        ELSE
                m = 0
                p = 1
                q = 0
                FOR i = 2 TO n
                        m = p + q
                        q = p
                        p = m
                NEXT i
                sfibo = m
        END IF
END FUNCTION

        PRINT FORMAT("%.0f",sfibo(78)),"\n"
$ time ./bin/exe/scriba fibo.bas
8944394323791464

real    0m0.026s
user    0m0.000s
sys     0m0.000s
$
Not bad at all.

Wrapping a loop around that so that it does fibo(78) 100 times I get:
$ time ./bin/exe/scriba fibo.bas
8944394323791464
8944394323791464
...
8944394323791464
8944394323791464

real 0m0.053s
user 0m0.016s
sys 0m0.016s
Or about 500uS per fibo. Which is about the same as the Javascript version.

I notice however that it fails at fibo(79) where as the JS version will continue to millions of digits.

More om that in a minute...

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

Re: ScriptBasic

Sat May 18, 2019 4:29 pm

This is a more faithful rendition in Javascript of ScriptBasic's fibo(78) in BASIC from this post : https://www.raspberrypi.org/forums/view ... 0#p1469529

Code: Select all

function fiboScriptBasic (n) {
  if (n < 2) {
    return (1)
  }
  let m = BigInt(0)
  let p = BigInt(1)
  let q = BigInt(0)
  for (let i = 2; i <= n; i++) {
    m = p + q
    q = p
    p = m
  }
  return m
}
When we run it alongside all the other Javascript fibos we have we get:

Code: Select all

$ time node fibo.js
fiboScriptBasic 8944394323791464 in 1ms
fiboIter        8944394323791464 in 0ms
fibo            8944394323791464 in 2ms
fiboFast        8944394323791464 in 0ms
fiboFaster      8944394323791464 in 1ms
fiboScriptBasic 8944394323791464 in 0ms
fiboIter        8944394323791464 in 0ms
fibo            8944394323791464 in 0ms
fiboFast        8944394323791464 in 0ms
...
fiboScriptBasic 8944394323791464 in 0ms
fiboIter        8944394323791464 in 0ms
fibo            8944394323791464 in 0ms
fiboFast        8944394323791464 in 0ms
fiboFaster      8944394323791464 in 0ms

real    0m0.297s
user    0m0.078s
sys     0m0.188s
Dividing the wall clock time by the 500, the number of fibos run in that test, we get

0.297 / 500 = 594uS.

On my old i7 200K PC.

Compare to the 5ms that ScriptBasic gave for ScriptBasic on his 64 bit laptop. Can that lap top really be 10 times slower than my old PC?

Of course the reason the number 78 was chosen by Script BASIC was to demonstrate how JS numbers will run out of integer range after that.

However, as we see, this is not a problem for Javascript. That code above can go to millions of digits of fibo, if you have time to wait. The other fibo algorithms are orders of magnitude faster for big integers.

All code in the fibo() challenge repo: https://github.com/ZiCog/fibo_4784969/b ... pt/fibo.js

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

Re: ScriptBasic

Sat May 18, 2019 4:42 pm

Heater wrote:
Sat May 18, 2019 4:29 pm
Can that lap top really be 10 times slower than my old PC?
Have you tried using a vacuum cleaner with the laptop? Maybe there is some dust lodged in one of the air vents that it slowing is down.

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

Re: ScriptBasic

Sat May 18, 2019 5:00 pm

My old laptop is 2011 vintage hardware. Biggest problem it also acts as my server. (MySQL, Apache, PostgreSQL, Samba, ...)

Interesting that @ejolson's QB fibo will do a 7499 in .05 seconds on the RPi 3B.

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

Re: ScriptBasic

Sat May 18, 2019 5:15 pm

Yes, it amazing.

Such is the awesome power of mathematics: https://www.nayuki.io/page/fast-fibonacci-algorithms

We code monkies can spend forever tweaking and optimizing our creations. That nothing compared to chopping the problem down to size with mathematics first.

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

Re: ScriptBasic

Sat May 18, 2019 5:21 pm

Thanks to your tip I can do this:
Congrats!

I'm glad you have ScriptBasic running on your computer.

If you installed the dependencies and at the end of ./setup everything shows OK, use mkdeb.sh to create a runtime distribution.

./setup --help will give you tips on just compiling a module for example.

You might be able to shave a bit more time off the numbers by saving the script in it's already tolenized binary form an run that. That is the form ScriptBasic apends to itself when making a standalone executable. It is sometimes more advantageous to run a script as an executable when used with a batch file making redirection easier.
Last edited by John_Spikowski on Sat May 18, 2019 8:40 pm, edited 6 times in total.

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

Re: ScriptBasic

Sat May 18, 2019 5:25 pm

Thank you, it's short and sweet to build and runs nicely.

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

Re: ScriptBasic

Sat May 18, 2019 5:33 pm

8-) :o :D

Heater,

Getting you to install ScriptBasic and ending up happy was worth the bans and abuse I endured.

Thanks for not giving up!

Curious. Did you build ScriptBasic for your RPi or 64 bit Linux laptop?

If we can get @hippy on board with ScriptBasic, we have the RPi SB Dream Team.

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

Re: ScriptBasic

Sun May 19, 2019 4:48 am

ScriptBasic,

There are solutions to the fibo(4784969) challenge in 17 different languages some of which have two or more dialects/implementations. ScriptBasic was nothing like the hardest to get installed and running. I would encourage adding some build/install instructions to the source repository though.

I built in on my Intle PC. I am very confident the same procedure would work on a Pi.

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

Re: ScriptBasic

Sun May 19, 2019 5:43 am

Thanks Heater for the feedback!

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

Re: ScriptBasic IUP Extension Module

Sun May 19, 2019 6:56 am

I released the IUP distribution for the Raspberry Pi 3B and the ScriptBasic IUP extension module.

Download and install instructions at the RaspberryBASIC.org Forum

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

Re: ScriptBasic

Sun May 19, 2019 12:50 pm

Heater wrote:
Sat May 18, 2019 10:11 am
What to do?
If you are just looking to build ScriptBasic from source; these instructions worked for me when I tried that -

Code: Select all

cd ~
wget https://sandbox.allbasic.info:8181/scriptbasic/sb-dev/-/archive/cleanup/sb-dev-cleanup.tar.gz
tar -zxvf sb-dev-cleanup.tar.gz
cd sb-dev-cleanup
sudo mkdir /usr/local/lib/site_perl
sudo chown pi:pi /usr/local/lib/site_perl
perl jamal.pl -i
  select /usr/local/lib/site_perl
./setup
I think I posted those some way back in this thread but haven't checked.

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

Re: ScriptBasic

Sun May 19, 2019 4:02 pm

@ejolson,

Have you tried ScriptBasic yet?

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

Re: ScriptBasic

Sun May 19, 2019 4:45 pm

ScriptBasic wrote:
Sun May 19, 2019 4:02 pm
@ejolson,

Have you tried ScriptBasic yet?
On April 7 as described in the link given in this post above.

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

Re: ScriptBasic

Sun May 19, 2019 4:51 pm

hippy wrote:
Sun May 19, 2019 12:50 pm
Heater wrote:
Sat May 18, 2019 10:11 am
What to do?
If you are just looking to build ScriptBasic from source; these instructions worked for me when I tried that -

Code: Select all

cd ~
wget https://sandbox.allbasic.info:8181/scriptbasic/sb-dev/-/archive/cleanup/sb-dev-cleanup.tar.gz
tar -zxvf sb-dev-cleanup.tar.gz
cd sb-dev-cleanup
sudo mkdir /usr/local/lib/site_perl
sudo chown pi:pi /usr/local/lib/site_perl
perl jamal.pl -i
  select /usr/local/lib/site_perl
./setup
I think I posted those some way back in this thread but haven't checked.
Thanks @hippy fo tbe ScriptBasic build helper post.

If you wanr to use the default extension modules that get built in the ./setup process, make sure you install the required dependencies. (see README in the repo)

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

Re: ScriptBasic

Sun May 19, 2019 4:58 pm

ejolson wrote:
Sun May 19, 2019 4:45 pm
ScriptBasic wrote:
Sun May 19, 2019 4:02 pm
@ejolson,

Have you tried ScriptBasic yet?
On April 7 as described in the link given in this post above.
Excellent!

The Dream Team exists. Thanks guys!

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

Re: ScriptBasic

Sun May 19, 2019 5:12 pm

For those that have installed ScriptBasic, what is your intended use or are you just 'dating' the language?

@JamesH mentioned that over half of the RPi's are used in a traditional Linux PC like environment. My hope is that the IUP GUI toolkit will spawn some interest in creating desktop applications.

The IUP distribution I posted for the RPi ARM v7 boards is a standard distribution which can be used with C and Lua for example. There are a bunch of C examples on the IUP project site.

FYI: The author of Lua is also the author of IUP.

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

Re: ScriptBasic

Sun May 19, 2019 6:22 pm

Lua is embeddable in much the same way as ScriptBasic. The API is simple to use. I will more than likely create an extension module for Lua with ScriptBasic.

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

Re: ScriptBasic

Sun May 19, 2019 6:38 pm

ScriptBasic,
For those that have installed ScriptBasic, what is your intended use or are you just 'dating' the language?
Dating?

I'm afraid ScriptBasic and I are just ships passing in the night, strangers on the shore.

For my work it will be:

* C/C++ : For performance critial things. ASN.1 messaging and the like.

* Python : The usual glue tasks

* Javascript : Server side HTTPS, webSockets, database access, messaging wth NATS/MQTT...Browser side for real-time data presentation and 3D aniations (webgl)

* Free Pascal : A major product component, luckily I don't have to deal with that much.

* C# : Not sure how that crept in there.

Meanwhile for current hobby projects I need:

* C/C++ : For the firmware for whatever micro-contollers/SBCs I come accross, SoCs in FPGA (Memory is very limited).

* Scala and Verilog - For my experiments in trying to build my own RISC V core and peripherals for FPGA.

There is no chance of introducing more languages in the work environment. There is precious little time for them hobby wise.

However...

As you mentioned Lua... As I'm adding 32MB of SDRAM to my FPGA RISC V I was contemplating putting some kind of stand alone language run time on it. A JS engine, or Lua or BASIC perhaps.... How easy would it be to cross compile ScriptBasic for a RISC V bare metal system, no Linux or other OS?

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

Re: ScriptBasic

Sun May 19, 2019 7:06 pm

How easy would it be to cross compile ScriptBasic for a RISC V bare metal system, no Linux or other OS?


If the OS has a C compiler, you're good to go. My quick check says it supports gcc.

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

Re: ScriptBasic

Sun May 19, 2019 7:33 pm

I have a GCC cross compiler that runs under Debian on a PC/Pi and targets RISC V.

The RISC V target has no operating system. Bare metal. It's a 32 bit integer only CPU. Floating point would have to be software emulated. I have never tried but I guess GCC adds it's own float libs to the binary to do that.

Whatever engine it would have to be loaded to RAM from some FLASH memory and then run with a minimal run time that only has a UART for a console port. I have yet to even add any interrupts.

Something like what can be done with Lua, MicroPython or the Espruino Javascript engine. Or a BASIC that can be used from a terminal, like the good old days!

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

Re: ScriptBasic

Sun May 19, 2019 7:34 pm

I'm afraid ScriptBasic and I are just ships passing in the night, strangers on the shore.
I'm like the persistent mom trying to find her kid a mate. :twisted:

Return to “Other programming languages”