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

Re: ScriptBasic

Thu May 09, 2019 5:14 pm

I don't like the Python VM created under the covers and emulations as in threading. It has a huge footprint yet everything useful needs to be imported.

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

Re: ScriptBasic

Thu May 09, 2019 5:16 pm

jamesh wrote:
Thu May 09, 2019 4:13 pm
Cannot remember specifics, I was just fed up with getting two or three complaints a day about it. Now I get no complaints a day about it. So that's a win for me.

If you want to start another thread more targetted at what that thread was covering, please go ahead. Link back to original thread if you wish.
In a way locking a thread preserves it--none of the posts can be easily modified by any of the original participants. Given the information currently contained in that thread, preserving it is, in my opinion, a good thing. What do you think about making it a sticky?

Back on topic, a scripting language suitable for embedding into disposable microcontrollers such as Script Basic is likely very different than a general-purpose language designed for large software-engineering projects such as C++ which in turn may be quite different than a language designed for teaching such as Scratch.

A scripting language needs to be small, self-contained, adaptable and easy to understand. In contrast, C++ is huge, all encompassing, tied to an international standard and impossible to understand. While Scratch is understandable, adaptable and relatively small, it also requires a graphical interface and depends on Smalltalk or a web-browser.

An electrical engineer designing a smart lightbulb without help from a team of professional programmers is probably happier with a scripting language. HVAC is likely similar.

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

Re: ScriptBasic

Thu May 09, 2019 5:26 pm

ScriptBasic is my replacement for bash.
BaCon comes in a version written in bash and a version written in itself. I think @ejolson posted a script showing bash being 30 times slower than ScriptBasic.

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

Re: ScriptBasic

Thu May 09, 2019 6:20 pm

ejolson,
In a way locking a thread preserves it--none of the posts can be easily modified by any of the original participants. Given the information currently contained in that thread, preserving it is, in my opinion, a good thing. What do you think about making it a sticky?
I like the attitude. Leave it be, perfectly formed and immutable, a monument to curiosity and heroic explorations!

A lot of content in there might make for a good sticky thread. A list of language that make working with huge numbers convenient for example. The thread itself, not so much, it's ridiculously long and rambling. Too much to expect anyone to wade through and get anything useful from.

I might find a time to boil it down to the essentials eventually.
Memory in C++ is a leaky abstraction .

User avatar
jahboater
Posts: 7711
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: ScriptBasic

Thu May 09, 2019 6:31 pm

How about a new challenge.

Implement a Dartmouth BASIC interpreter in your language of choice:
As defined here:-
https://www.dartmouth.edu/basicfifty/ba ... l_1964.pdf

The measure of success would be a simple fibo(25) run (say).

I cannot remember if Dartmouth BASIC supported recursion, if not the BASIC equivalent of this simple code will do:

Code: Select all

  int a = 0, b = 1;

  for( int term = 1; term < 26; ++term )
  {
    const int n = a + b;
    a = b;
    b = n;
  }

  printf( "%d\n", b );
Fibo(25) needs only 32-bit integer arithmetic.

It must run on any model of Raspberry Pi, running the Raspbian OS.

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

Re: ScriptBasic

Thu May 09, 2019 7:09 pm

jahboater,

I love the preface to that BASIC manual about language requirments, in précis:

1. It should be very easy to learn...

2. It should be possible compile to machine code quickly...

3. It should be a stepping-stone to more advance languages.

4. It should be general purpose.


Then the example they give of it's ease of understanding by non-programmers:

Code: Select all

    LET X = (7+8)/3
    PRINT X
    END
What I take away from these requirments is:

a) Things like "LET" should be compulsory in BASIC. That satisfies requirement 1). Makes the meaning obvious immediately for beginners.

b) BASIC compilers are totally acceptable, even mandated.

c) BASIC should not support multiple statements per line separated by colon or whatever. That violates requirement 1) by reducing readability for beginners. Quite likely it violates requirement 2) as well.

d) Nothing carrying the name BASIC should ever have been extended with additional features from structured programming, or classes or all that junk that experienced programmers think is necessary. That violates requirement 1) and 3)

By the way, we can get all the way to fibo(44) with the 9 digit decimal integers that original BASIC specified.
Memory in C++ is a leaky abstraction .

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

Re: ScriptBasic

Thu May 09, 2019 7:54 pm

The world doesn't need another toy BASIC. We have a hundred or so abandoned efforts already.

ScriptBasic took almost 9 years to complete.

If you're craving your BASIC past, here is something fun to play with.

http://www.vintage-basic.net

All BASIC review of Vintage BASIC

Challenges like MD5 that have a useful purpose is my vote.
Last edited by John_Spikowski on Thu May 09, 2019 9:13 pm, edited 1 time in total.

User avatar
jahboater
Posts: 7711
Joined: Wed Feb 04, 2015 6:38 pm
Location: Wonderful West Dorset

Re: ScriptBasic

Thu May 09, 2019 8:22 pm

Well I might actually use it if I have written the interpreter myself (or persuaded yacc to write it for me) :)
It would not be a toy, it would be a modern implementation of the one true Basic ....

Long ago (late 70's) I used Basic on a Research Machines 380Z computer, later I used it again on a Sinclair ZX80 - which was so bad I bought a Jupiter Ace which was the same hardware, but ran Forth instead and was much faster.
I don't know what type of Basic ran on those machines.
ScriptBasic wrote:
Thu May 09, 2019 7:54 pm
Challenges like MD5 that have a useful purpose is my vote.
We have the md5sum command already.
See "man md5sum" on the Pi.

User avatar
RichardRussell
Posts: 1128
Joined: Thu Jun 21, 2012 10:48 am

Re: ScriptBasic

Thu May 09, 2019 8:47 pm

Heater wrote:
Thu May 09, 2019 7:09 pm
Nothing carrying the name BASIC should ever have been extended with additional features from structured programming, or classes or all that junk that experienced programmers think is necessary. That violates requirement 1) and 3)
It doesn't so long as those extended capabilities are added in a compatible fashion, that is in such a way that programs not needing or using them run just the same as they did previously. A language doesn't cease to be "easy to learn" because there are more advanced features that the beginner doesn't need to use or even be aware of.

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

Re: ScriptBasic

Thu May 09, 2019 9:30 pm

I use LIKE and SPLITA in ScriptBasic extensively. It's not standard BASIC syntax but I couldn't live without them.

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

Re: ScriptBasic

Thu May 09, 2019 9:46 pm

Heater wrote:
Thu May 09, 2019 6:20 pm
ejolson,
In a way locking a thread preserves it--none of the posts can be easily modified by any of the original participants. Given the information currently contained in that thread, preserving it is, in my opinion, a good thing. What do you think about making it a sticky?
I like the attitude. Leave it be, perfectly formed and immutable, a monument to curiosity and heroic explorations!
Indeed! The story unfolds with the drama and humour of Anton Chekhov where all the action occurs behind the scenes and none of the personalities quite understand each other.

How much do you think nicely-bound printed copies of the full transcript would sell for on Amazon CreateSpace? Maybe we could donate the proceeds to some worthy cause.

How about an animal shelter for all F(4784969) of Fibonacci's rabbits?

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

Re: ScriptBasic

Thu May 09, 2019 10:57 pm

RichardRussell,
It doesn't so long as those extended capabilities are added in a compatible fashion, that is in such a way that programs not needing or using them run just the same as they did previously. A language doesn't cease to be "easy to learn" because there are more advanced features that the beginner doesn't need to use or even be aware of.
That sounds very reasonable, at least to those of us who have done a non-trivial amount of programming. We are not often phased by the concepts that we find represented, in varying ways, in such extensions. Except in C++, but more on that later....

I would argue that it violates the requirements, principles, of the original BASIC concept in the following ways:

A) I interpret requirement 1) "Easy to learn" as meaning easy for someone who has never programmed before, who has a minimal maths background, to be reading and writing in very short time with minimal effort.

I further posit that this "Easy to learn" principle should apply to all programs ever written in BASIC. Such a beginner to programming should never find themselves confronted with a program in BASIC that contains "advanced" notations or constructs that phase them.

Extending BASIC with "functions" or "classes" or even block scope and so on is introducing concepts that are not immediately obvious to our programming beginners.

We can think about this a being like the concept of a "reading age" in the world of writing. If your publications are intended for an audience with a reading age of 10, you will never be writing anything in those publications that use words or complex concepts that a 10 year old would not be expected to understand.

If the above means that one never writes large complex programs in BASIC because one would like the support of advance concepts and constructs to so so, then that is OK. Because...

B) Adding advanced concepts and constructs to the language violates the original requirement 3) "It should be a stepping-stone to more advance languages." Here they acknowledge that BASIC is not an advanced language or ever intended to be. By referring to "stepping stone" they suggest that it should impart enough understanding of programming for anyone mastering it to move on to advanced languages that are more suited to their problems.

I take "should be a stepping-stone" to mean that those schooled in BASIC should be able to move on to the next step. Not that BASIC should be evolved into a more complex animal.

I was happy to read those requirements by Krutz, there. Since decades ago I have never understood the drive to bend BASIC into a more Pascal, ALGOL, C like language. Or add classes or whatever. Why do that when we already have languages developed with those things? It's an original requirement of the language specification that it is not extended like that. Or, when creating a totally different language in that way, don't use "BASIC" in it's name.

About C++.... C++ has become huge and complex. Nobody understands it all. People often make arguments similar to yours when discussing this complexity. They say "you don't have to use features you find difficult or have not mastered yet". That is all true, but if you use C++ at all you will soon find yourself eyeballs deep in that complexity. In the standard library, if you use libraries from elsewhere, in code that other team members have written and so on. You find yourself having to read stuff that is unfathomable even if you are trying to keep your writings simple.
I claim Kurtz did not want that to happen to BASIC, as expressed in the language requirements he wrote.
Memory in C++ is a leaky abstraction .

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

Re: ScriptBasic

Thu May 09, 2019 11:41 pm

I recommend BBC BASIC for beginners as its history has been focused in that area.

ScriptBasic is an embeddable scripting engine with a seamless extension API. My continued efforts for the RPi with ScriptBasic will be focused on hardware integration. I really don't have anymore time to contribute to code challenges. Sorry!

I also recommend that the continuation of the Fibonacci challenge be a thread here on the Other programming languages board.

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

Re: ScriptBasic

Fri May 10, 2019 3:31 am

Here is the final ScriptBasic version of the Fibonacci Classic in QuickBasic and run on FreeBASIC to allow the 1 mil digits. So far BBC BASIC and ScriptBasic are the only known BASIC interpreters able to run the code. It would be great if someone would give this a try in another QB compatible BASIC interpreter.

FWIW: In theory, ScriptBasic could do a 2 mil digit run due to array size can be as large as available memory. I can't imagine how long that would take to run. (3500084 elements)

I've asked this twice already but does someone have an execution time for BBC BASIC running this code.

Code: Select all

' 100 rem classic.bas -- Compute the nth Fibonacci Number
' 110 rem Written December 25, 2018 by Eric Olson
' 120 rem
' 130 rem This program demonstrates the expressiveness of the original
' 140 rem versions of Microsoft BASIC as measured by explicitly coding
' 150 rem Karatsuba multiplication for big-number arithmetic and then
' 160 rem using the doubling formula
' 170 rem
' 180 rem     F(2k) = F(k)[2F(k+1)-F(k)]
' 190 rem   F(2k+1) = F(k+1)[2F(k+1)-F(k)]+(-1)^(k+1)
' 200 rem   F(2k+1) = F(k)[2F(k)+F(k+1)]+(-1)^(k)
' 210 rem   F(2k+2) = F(k+1)[2F(k)+F(k+1)]
' 220 rem
' 230 rem to compute the nth Fibonacci number.
' 231 rem
' 232 rem Version 2:  Minor changes to optimize the O(n^2) multiply and
' 233 rem prevent overflow when running on MITS BASIC.
' 235 rem
' 236 rem To run this program on early versions of Microsoft BASIC please
' 237 rem remove line 241 to set the default back to single precision
' 238 rem and change n so the resulting Fibonacci number fits in memory.
' 240 rem
' 241 defdbl a-z

q1 = 0
q2 = 0
S$ = ""

251 n = 4784969
'   n = 7499
252 gosub 8500
270 d9=int(n*log((1+sqr(5))/2)/log(b8)+7)
    m9=14
' 280 dim m[d9*m9)
    splita string(d9*m9,"0") by "" to m
    m0=1
300 a=m0
    m0=m0+1+d9
    b=m0
    m0=m0+1+d9
310 t1=m0
    m0=m0+1+d9
    t2=m0
    m0=m0+1+d9
400 r0=n
    gosub 1000
420 r7=b
    gosub 7000
430 stop
1000:
    rem Compute nth Fibonacci number
' 1010 rem    inputs: r0 the value of n
' 1020 rem   outputs: b the value of F(n)
1040 if r0<2 then
       m[b]=1
       m[b+1]=r0
       return
     end if
1060 n1=r0
     r0=int((n1-1)/2)
     gosub 1500
1070 p1=n1-4*int(n1/4)
1080 if p1=1 or p1=3 then goto 1200
1090 r1=t1
     r2=a
     r3=a
     gosub 2000
1110 r1=t2
     r2=t1
     r3=b
     gosub 2000
1120 r1=t1
     r2=b
     r3=t2
     gosub 4000
1170 r1=b
     r2=t1
     gosub 5000
     return
1200 r1=t1
     r2=b
     r3=b
     gosub 2000
1210 r1=t2
     r2=t1
     r3=a
     gosub 3000
1220 r1=t1
     r2=b
     r3=t2
     gosub 4000
1230 if p1=3 then goto 1250
1240 r1=t1
     gosub 6000
     goto 1260
1250 r1=t1
     gosub 6500
1260 r1=b
     r2=t1
     gosub 5000
     return
1500:
     rem Recursive work for nth Fibonacci number
' 1510 rem    inputs: r0 the value of n
' 1520 rem   outputs: a the value of F(n)
' 1530 rem   outputs: b the value of F(n+1)
1540 if r0=0 then
       m[a]=1
       m[a+1]=0
       m[b]=1
       m[b+1]=1
       return
     end if
1600 m[m0]=r0
     m0=m0+1
     r0=int(r0/2)
     gosub 1500
1610 m0=m0-1
     r0=m[m0]
1620 p1=r0-4*int(r0/4)
1630 if p1=1 or p1=3 then goto 1720
1640 r1=t1
     r2=b
     r3=b
     gosub 2000
1650 r1=t2
     r2=t1
     r3=a
     gosub 3000
1660 r1=t1
     r2=a
     r3=t2
     gosub 4000
1670 r1=a
     r2=t1
     gosub 5000
1680 r1=t1
     r2=b
     r3=t2
     gosub 4000
1690 if p1=2 then goto 1710
1700 r1=t1
     gosub 6000
     goto 1711
1710 r1=t1
     gosub 6500
1711 r1=b
     r2=t1
     gosub 5000
     return
1720 r1=t1
     r2=a
     r3=a
     gosub 2000
1730 r1=t2
     r2=t1
     r3=b
     gosub 2000
1740 r1=t1
     r2=b
     r3=t2
     gosub 4000
1750 r1=b
     r2=t1
     gosub 5000
1760 r1=t1
     r2=a
     r3=t2
     gosub 4000
1770 if p1=3 then goto 1790
1780 r1=t1
     gosub 6500
     goto 1800
1790 r1=t1
     gosub 6000
1800 r1=a
     r2=t1
     gosub 5000
     return
2000:
     rem Big-number addition
' 2010 rem  outputs: r1 the value of a+b
' 2020 rem   inputs: r2 the value of a
' 2030 rem   inputs: r3 the value of b
2050 if m[r3]>m[r2] then
       i9=m[r3]
     else
       i9=m[r2]
     end if
2060 for i=1 to i9+1
       m[r1+i]=0
     next i
2070 for i=1 to i9
       c=0
       t=m[r1+i]
2080 if i<=m[r2] then t=t+m[r2+i]
2090 if i<=m[r3] then t=t+m[r3+i]
2110 if t>=b8 then
       c=1
       t=t-b8
     end if
2120 m[r1+i]=t
     m[r1+i+1]=m[r1+i+1]+c
     next i
2130 m[r1]=i9+1
2140 r4=r1
     gosub 7500
2150 return
3000:
     rem Big-number subtraction
' 3010 rem  outputs: r1 the value of a-b
' 3020 rem   inputs: r2 the value of a
' 3030 rem   inputs: r3 the value of b
3050 for i=1 to m[r2]
       m[r1+i]=0
     next i
3060 for i=1 to m[r3]
       t=m[r1+i]+m[r2+i]-m[r3+i]
3070 if t<0 then
       t=t+b8
       m[r1+i+1]=m[r1+i+1]-1
     end if
3080 m[r1+i]=t
     next i
3090 for i=m[r3]+1 to m[r2]
       t=m[r1+i]+m[r2+i]
3100 if t<0 then
       t=t+b8
       m[r1+i+1]=m[r1+i+1]-1
     end if
3110 m[r1+i]=t
     next i
3120 m[r1]=m[r2]
3130 r4=r1
     gosub 7500
3150 return
4000:
     rem Big-number multiplication
' 4010 rem  outputs: r1 the value of a*b
' 4020 rem   inputs: r2 the value of a
' 4030 rem   inputs: r3 the value of b
4040 if m[r2]>80 and m[r3]>80 then goto 4300
4050 i9=m[r2]+m[r3]
     for i=1 to i9
       m[r1+i]=0
     next i
4070 for i=1 to m[r2]
       for j=1 to m[r3]
4080 t=m[r1+i+j-1]+m[r2+i]*m[r3+j]
4090 if t<b7 then goto 4120
4100 m[r1+i+j-1]=t-b7
4110 m[r1+i+j]=m[r1+i+j]+b6
     goto 4130
4120 m[r1+i+j-1]=t
4130 next j
     next i
4140 c=0
     for i=1 to i9
       t=m[r1+i]+c
4150 if t<b8 then
       c=0
       goto 4170
     end if
4160 c=int(t/b8)
     t=t-b8*c
4170 m[r1+i]=t
     next i
4180 m[r1]=i9
4190 r4=r1
     gosub 7500
4230 return
4300:
     rem Big-number Karatsuba algorithm
4310 if m[r2]<m[r3] then
       i8=m[r3]
     else
       i8=m[r2]
     end if
4320 i8=int(i8/2)
4330 z0=m0
     m0=m0+1+2*i8+1
4332 z2=m0
     m0=m0+1+2*i8+3
4334 z1=m0
     m0=m0+1+2*i8+5
4340 z3=m0
     m0=m0+1+i8+2
4350 z4=m0
     m0=m0+1+i8+2
4360 r5=z4
     r6=r3
     gosub 4500
4370 r5=z3
     r6=r2
     gosub 4500
4380 gosub 4600
     r1=z1
     r2=z3
     r3=z4
     gosub 4000
     gosub 4700
4400 q1=m[r2]
     if i8<q1 then m[r2]=i8
4405 q2=m[r3]
     if i8<q2 then m[r3]=i8
4410 gosub 4600
     r1=z0
     gosub 4000
     gosub 4700
4420 m[r2]=q1
     m[r3]=q2
4430 q3=q1-i8
     q4=q2-i8
     if q3<0 or q4<0 then
       m[z2]=0
       goto 8000
     end if
4440 q1=m[r2+i8]
     m[r2+i8]=q3
     q2=m[r3+i8]
     m[r3+i8]=q4
4450 gosub 4600
     r1=z2
     r2=r2+i8
     r3=r3+i8
     gosub 4000
     gosub 4700
4460 m[r2+i8]=q1
     m[r3+i8]=q2
4470 goto 8000
4500:
     rem Add high to low
' 4510 rem  outputs: r5 the sum of high(a)+low(a)
' 4520 rem   inputs: r6 the value of a
' 4530 rem   inputs: i8 the split point
4540 c=0
     for i=1 to i8+1
       t=c
4545 if i<=i8 and i<=m[r6] then t=t+m[r6+i]
4550 if i+i8<=m[r6] then t=t+m[r6+i+i8]
4560 if t>=b8 then
       c=1
       t=t-b8
     else
       c=0
     end if
4570 m[r5+i]=t
     next i
     m[r5+i8+2]=c
4590 m[r5]=i8+2
     r4=r5
     gosub 7500
4595 return
4600:
     rem Save frame
4610 m[m0]=z1
     m0=m0+1
     m[m0]=z2
     m0=m0+1
     m[m0]=z0
     m0=m0+1
4620 m[m0]=i8
     m0=m0+1
     m[m0]=q1
     m0=m0+1
     m[m0]=q2
     m0=m0+1
4630:
     rem Save parameters
4640 m[m0]=r1
     m0=m0+1
     m[m0]=r2
     m0=m0+1
     m[m0]=r3
     m0=m0+1
4650 return
4700:
     rem Restore frame
4710 gosub 4750
4720 m0=m0-1
     q2=m[m0]
     m0=m0-1
     q1=m[m0]
     m0=m0-1
     i8=m[m0]
4730 m0=m0-1
     z0=m[m0]
     m0=m0-1
     z2=m[m0]
     m0=m0-1
     z1=m[m0]
4740 return
4750:
     rem Restore parameters
4760 m0=m0-1
     r3=m[m0]
     m0=m0-1
     r2=m[m0]
     m0=m0-1
     r1=m[m0]
4770 return
5000
     rem Big-number copy
' 5010 rem  outputs: r1 the value of a
' 5020 rem   inputs: r2 the value of a
5030 r4=r2
     gosub 7500
5040 for i=1 to m[r2]
       m[r1+i]=m[r2+i]
     next i
5050 for i=m[r2]+1 to m[r1]
       m[r1+i]=0
     next i
5060 m[r1]=m[r2]
5070 return
6000:
     rem Big-number decrement
' 6010 rem   inputs: r1 the value of a
' 6020 rem  outputs: r1 the value of a-1
6040 i=1
     c=1
6050 if c=0 then goto 6080
6060 if m[r1+i]<1 then
       m[r1+i]=b8-1
     else
       m[r1+i]=m[r1+i]-1
       c=0
     end if
6070 i=i+1
     goto 6050
6080 r4=r1
     gosub 7500
6100 return
6500:
     rem Big-number increment
' 6510 rem   inputs: r1 the value of a
' 6520 rem  outputs: r1 the value of a+1
6540 m[r1]=m[r1]+1
     m[r1+m[r1]]=0
     i=1
     c=1
6550 if c=0 then goto 6590
6560 t=m[r1+i]+1
6570 if t>=b8 then
       m[r1+i]=t-b8
     else
       m[r1+i]=t
       c=0
     end if
6580 i=i+1
     goto 6550
6590 r4=r1
     gosub 7500
6600 return
7000:
     rem Big-number print
' 7010 rem   inputs: r7 the value to print
7020 if m[r7]=0 then
       print "0"
       return
     end if
7030 for i=m[r7] to 1 step -1
7040 s$=str$(m[r7+i])
7045 if mid$(s$,1,1)=" " then s$=mid$(s$,2,len(s$)-1)
7050 if i=m[r7] or b9<=len(s$) then goto 7070
7060 s$=mid$("0000000000000",1,b9-len(s$))&s$
7070 print s$
     next i
     print
     return
7500:
     rem Big-number trim
' 7510 rem    inputs: r4 the value of a
' 7520 rem   outputs: r4 the trimmed value of a
7530 if m[r4+m[r4]]=0 and m[r4]>1 then
       m[r4]=m[r4]-1
       goto 7530
     end if
7540 return
8000:
     rem Tail of Karatsuba
8003 t4=m0-1-2*i8-5
8005 gosub 4630
     r1=t4
     r2=z1
     r3=z0
     gosub 3000
8010 r1=z1
     r2=t4
     r3=z2
     gosub 3000
     gosub 4750
8020 r4=z1
     gosub 7500
8030 i9=m[r2]+m[r3]
     i7=2*i8
     c=0
     for i=1 to i9
       t=c
8040 if i<=m[z0] then t=t+m[z0+i]
8050 if i>i8 and i-i8<=m[z1] then t=t+m[z1+i-i8]
8060 if i>i7 and i-i7<=m[z2] then t=t+m[z2+i-i7]
8070 if t<b8 then
       c=0
       goto 8090
     end if
8080 c=int(t/b8)
     t=t-b8*c
8090 m[r1+i]=t
     next i
8092 m[r1]=i9
     r4=r1
     gosub 7500
8100 m0=z0
8120 return
8500:
     rem Get dynamic range
' 8510 rem    outputs: f0 the largest integer
' 8511 rem    outputs: b7 carry threshold
' 8512 rem    outputs: b8 radix of limbs
' 8513 rem    outputs: b9 exponent to b8=10^b9
8520 f9=1
8530 f7=f9+1
     if f7>f9 then
       f9=f9*2
       goto 8530
     end if
8540 f0=f9
8550 f7=f0+1
     if f7=f0 then
       f0=int(f0/2)
       goto 8550
     end if
8560 f4=0
8565 f5=int(0.5*(f0+f9)+0.5)
8570 f7=f5+1
     if f7=f5 then
       f9=f5
     else
       f0=f5
     end if
8580 if f5=f4 then goto 8600
8590 f4=f5
     goto 8565
8600 f0=f0/2
8610 b9=int(log(sqr(f0))/log(10))
8620 b8=int(exp(log(10)*b9)+0.5)
8630 b7=f0-2*b8^2
     if b7/b8^2<4 then
       b9=b9-1
       goto 8620
     end if
8640 b6=int(b7/b8)
     b7=b8*b6
8700 return
9999 end

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

Re: ScriptBasic

Fri May 10, 2019 5:02 am

ScriptBasic,

How did you run that under FreeBasic?

I saved your posted code as file fib.sb and run it below, with the QuickBasic option. Sadly it fails to compile:

Code: Select all

$ fbc --version
FreeBASIC Compiler - Version 1.06.0 (11-22-2018), built for linux-x86_64 (64bit)
Copyright (C) 2004-2016 The FreeBASIC development team.
$
$ fbc -lang qb -b fibo.sb
fibo.sb(35) error 10: Expected '=', found 'string'
    splita string(d9*m9,"0") by "" to m
           ^
fibo.sb(55) error 28: Expected pointer, before '='
       m[b]=1
           ^
fibo.sb(56) error 28: Expected pointer, before '='
       m[b+1]=r0
             ^
fibo.sb(108) error 28: Expected pointer, before '='
       m[a]=1
           ^
fibo.sb(109) error 28: Expected pointer, before '='
       m[a+1]=0
             ^
fibo.sb(110) error 28: Expected pointer, before '='
       m[b]=1
           ^
fibo.sb(111) error 28: Expected pointer, before '='
       m[b+1]=1
             ^
fibo.sb(114) error 28: Expected pointer, before '='
1600 m[m0]=r0
          ^
fibo.sb(119) error 28: Expected pointer
     r0=m[m0]
            ^
fibo.sb(185) error 28: Expected pointer, before '>'
2050 if m[r3]>m[r2] then
             ^
fibo.sb(185) error 133: Too many errors, exiting
$
Memory in C++ is a leaky abstraction .

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

Re: ScriptBasic

Fri May 10, 2019 5:07 am

You would need to run the original not my conversion of it.

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

Re: ScriptBasic

Fri May 10, 2019 5:37 am

But you said:

"Here is the final ScriptBasic version of the Fibonacci Classic in QuickBasic and run on FreeBASIC"

So I tried with my FreeBasic.

Sadly I can't run BBC Basic for Linux just now. It seems to depend on X Windows and my Debian here is headless. Also I'm not installing 32 bit architecture support just to run BASIC.

Is there any chance of fixing up a version that runs with ScriptBasic and FreeBasic or some other sane BASIC on Linux?
Memory in C++ is a leaky abstraction .

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

Re: ScriptBasic

Fri May 10, 2019 6:04 am

The original QuickBasic 'classic.bas' in the repo is what I understood ran on FreeBasic. I posted my version for BASIC languages that don't support multiple statements per line.

The line numbers as labels is unique to ScriptBasic.

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

Re: ScriptBasic

Fri May 10, 2019 6:22 am

The original QuickBasic 'classic.bas' in the repo is what I understood ran on FreeBasic.
That is correct. It does.
I posted my version for BASIC languages that don't support multiple statements per line.
I like the one statement per line approach. Makes things much more readable. That's why I wanted to run your latest version.

Sadly that version has introduced other changes which make it a different language and I don't have a means to run it.
Does not work in VisualBasic either.

I might have expected a new BASIC on the block to be compatible with some other, older, well know BASIC variant. Is it?
Memory in C++ is a leaky abstraction .

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

Re: ScriptBasic

Fri May 10, 2019 6:25 am

Heater wrote:
Thu May 09, 2019 7:09 pm
d) Nothing carrying the name BASIC should ever have been extended with additional features from structured programming, or classes or all that junk that experienced programmers think is necessary. That violates requirement 1) and 3).
Structured programming is arguably easier than goto and gosub. Kemeny and Kurz had already realized this in 1975 with structured Basic. Later they wrote a book called

Image

which might be interesting, but I haven't read it.

The 4th point concerning what properties a language designed for beginners should possess goes on too say
Basic Instruction Manual wrote: ...every kind of machine computation should be programmable in it.
In the terminology of our previous thread this idea was described as the programming language being digitally liberating: Anyone who learns that language is then able to convey any algorithm they are able to think up efficiently to the computer processor.

The reason this is important in a programming language designed for beginners is that many people will only learn that one language.
Last edited by ejolson on Fri May 10, 2019 6:45 am, edited 7 times in total.

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

Re: ScriptBasic

Fri May 10, 2019 6:28 am

I don't have a means to run it.
It runs in ScriptBasic. Have you tried it with that?

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

Re: ScriptBasic

Fri May 10, 2019 7:31 am

ejolson,
Structured programming is arguably easier than goto and gosub.
That is clearly true for those who have done some non-trivial amount of programming writing.

My concern here is two fold:

1) For raw beginners structured programming introduces a whole slew of advanced concepts they are not familiar with and have to learn: functions, parameters, return values, local variables, global variables, scopes, etc, etc.

It's not just the semantics of the thing. Introducing such concepts into a language carries with it a lot of syntactic baggage that gets in the way for raw beginners and detracts from the "stay as close to ordinary English" requirement.

2) If people get enough experience and whish to progress further they will then be in a postion to realize why structured programming is a good idea and tackle language constructs that support such things. It's time for them to step off the "BASIC stepping stone" and move to an advanced language, in the ALGOL tradition, as Kurtz said in the requirments for BASIC.

As such, mutating BASIC into an ALGOL like language is not required and I argue detrimental to it's intended purpose.
Kemeny and Kurz had already realized this in 1975 with structured Basic.
Structured programming was "the thing" in 1973 already. I recall they spent a non-trivial amount of time and effort trying to get us to understand and use structured design in the latter parts of our A Level CS curriculum. Nassi-Shneiderman diagrams and all that. At first one wonder why one needs all that complexity, mostly the programs we produced were not big or complex enough to need it. By the end of the course I started to feel the need for order, it's time to move on to ALGOL. Which is exactly what I did.
Later they wrote a book ...
I'd love to get hold of that.
...every kind of machine computation should be programmable in it.
I believe original BASIC is "Turing Complete" as they say. Requirement met.

Mind you, to that end I think later BASICs on bigger faster machines should have a single number type that caters for arbitrarily huge/precise numbers. That would make a lot of things possible whist not detracting from the language design requirements.
The reason this is important in a programming language designed for beginners is that many people will only learn that one language.
Perhaps. The original BASIC concept was not that it be the only language people learn. It's just a stepping stone to more advanced languages suitable to the things people want to do.
Memory in C++ is a leaky abstraction .

User avatar
RichardRussell
Posts: 1128
Joined: Thu Jun 21, 2012 10:48 am

Re: ScriptBasic

Fri May 10, 2019 8:30 am

Heater wrote:
Fri May 10, 2019 5:37 am
Also I'm not installing 32 bit architecture support just to run BASIC.
Why would you want to? The main reason for a 64-bit Linux edition of BBC BASIC being available is precisely to make it unnecessary to do that. But, yes, it relies on SDL 2.0 (the clue is in the name!) so you will need a windowing system that the version of SDL2 from your repository supports (not necessarily X11).

User avatar
RichardRussell
Posts: 1128
Joined: Thu Jun 21, 2012 10:48 am

Re: ScriptBasic

Fri May 10, 2019 8:49 am

Heater wrote:
Thu May 09, 2019 10:57 pm
I further posit that this "Easy to learn" principle should apply to all programs ever written in BASIC. Such a beginner to programming should never find themselves confronted with a program in BASIC that contains "advanced" notations or constructs that phase them.
I disagree with you quite fundamentally, as did the BBC (and its advisors) in 1980! If you insist that a beginners' language must not be capable of advanced functionality it goes against an important educational principle: that a student should be able to progress at his own pace.

At some point it will obviously be necessary to introduce those advanced concepts, and your proposal would mean that the only way of doing so is at the same time to learn a brand new language. This has two unfortunate consequences: firstly the student has to acquire a whole load of peripheral knowledge (like a new IDE, different syntax, different keywords etc.) at exactly the same time as he is trying to take in the new concept; this is not conducive to learning. Secondly, in a practical classroom context everybody has to switch to the new language at the same time, which is not appropriate when there are students of different abilities and different stages of development.

The advice the BBC received (from some of the UK's top educational experts at the time) was the opposite of what you propose, that a language should be chosen which was ideally suited to beginners but which at the same time had the power and sophistication to allow teaching of more advanced concepts such as structured programming without having to switch to a new language. That has remained my philosophy for the succeeding 38 years, during which I have steadily added to BBC BASIC's capabilities whilst obsessively maintaining compatibility with the original.

User avatar
bensimmo
Posts: 5534
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: ScriptBasic

Fri May 10, 2019 8:51 am

I don't think you realise how much a beginners can understand, 'FUNCTIONS' (or call it NEW KEYWORD "DRAWSQUARE" ) are something they can understand.

Even BBC BASIC 'deprecated*' GOTO, GOSUB etc for functions. It was left there only for compatibility. It even say so in the manual.

If 'teachers' from before that time didn't understand it and only knew goto/GOSUB because that's what they new, that wasn't the fault of the children.

They can quite happily cope with the concept. Scope with Python can get them, but no more so than having white space a bit wrong.
No reason to use scope in a BASIC beginners setup ?

Perhaps it is so long since being a beginner that you just can't get back down to that level?

*Was that term used back then?

Return to “Other programming languages”