User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Sun Jan 27, 2013 1:25 pm

@Gorden:
Ok I can see the desire not to manually load in dynalibs (the use for SYS on linux) and so forth.

I do still think that pointes would be useful. And since most probably do not the long winded way of dealing with structures that BBC BASIC v uses, perhaps a TYPE keyword structure such as used by GSoft BASIC (I figure this one could be good inspiration as it is APPLE IIgs).

As to the loops, I can see what you mean about he loop termination, though what about the loop entry for FOR and WHILE loops at least?
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Sun Jan 27, 2013 1:37 pm

@Gorden:
Most basic interpreters actualy did keep tract of the location of the initial FOR. Though many allowed the strange construct:

Code: Select all

FOR x=n TO ntop STEP S
   FOR y=n2 TO n2top STEP S2
     REM ...
   NEXT X
NEXT Y
which actually had some uses (can not think of any off of the top of my head, though I do remember doing his a time or two). And that does require having a way to seperate the NEXT statements, As the outer/iner loops overlap.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: BASIC - more harmful than useful?

Sun Jan 27, 2013 2:01 pm

DavidS wrote:@Gorden:
Ok I can see the desire not to manually load in dynalibs (the use for SYS on linux) and so forth.
I'm still not sure what there is to load in, really. Can you give me an example of what you're after?
DavidS wrote: I do still think that pointes would be useful. And since most probably do not the long winded way of dealing with structures that BBC BASIC v uses, perhaps a TYPE keyword structure such as used by GSoft BASIC (I figure this one could be good inspiration as it is APPLE IIgs).
OK. I've had a quick skim through the manual. TYPE defines a structure and you can subsequently have arrays of a TYPE. (So no dynamic storage allocation) There is a pointer type, but in the first example I see, it's a pointer to a TYPE - which really boils down to an array index. So this is somewhat interesting, but it's on the back boiler for now.
DavidS wrote: As to the loops, I can see what you mean about he loop termination, though what about the loop entry for FOR and WHILE loops at least?
Well... It's a cold & blustery Sunday afternoon, my wifes out at a W.I. hat making course (or something), I'm supposed to do some gardening, but I have a mug of hot earl grey, so let's see..

I've already on the way to implementing rurwin's do loops, and I'll tacked for loops next, however - one issue is that I will not break existing program functionality. I've written quite a bit in it myself and a few others have to, so I've no plans to remove the existing way of doing things. Fortunately, I can see how to implment alternative ways though...

So watch this space (as they say)

-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: BASIC - more harmful than useful?

Sun Jan 27, 2013 2:05 pm

DavidS wrote:@Gorden:
Most basic interpreters actualy did keep tract of the location of the initial FOR. Though many allowed the strange construct:

Code: Select all

FOR x=n TO ntop STEP S
   FOR y=n2 TO n2top STEP S2
     REM ...
   NEXT X
NEXT Y
which actually had some uses (can not think of any off of the top of my head, though I do remember doing his a time or two). And that does require having a way to seperate the NEXT statements, As the outer/iner loops overlap.
Yes, it's just wrong. Someone, somewhere might have had a use for it as some gross optimisation, but it breaks all the structured programming stuff. I will flag this as an error if I find it. I just tried it on an Apple too - "NEXT WITHOUT FOR ERROR".. so it doesn't work in Applesoft... (***BAD NEXT ERR in IntBasic too)

-gOrdOn (2 O's)
--
Gordons projects: https://projects.drogon.net/

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: BASIC - more harmful than useful?

Sun Jan 27, 2013 2:23 pm

Pointers are only necessary if you are going to construct structs in flat memory. That is not required unless you are talking to some library or OS that requires it. The BASIC way is to have multiple arrays with a single index, or a single multi-dimensioned array. It is simple to use that method to implement trees or linked lists, or anything else. The one thing you cannot do is allocate more space, but you can have an allocation function, a free function and garbage collection. You can experiment with running out of space without allocating 512MB. There is the opportunity to teach more concepts without all the hard-to-detect bugs that pointers entail.

Code: Select all

DIM tree(3,100)
MORE_FIELD = 1
LESS_FIELD = 2
DATA_FIELD = 3

REM HEAD points to the top of the tree, 0 indicates NIL
HEAD = 0

def FN Find(value, node)
local ret
ret = node
if node <> 0 then
  if tree(DATA_FIELD, node) < value then ret= FN Find(value , tree(LESS_FIELD, node))
  if tree(DATA_FIELD, node) > value then ret= FN Find(value , tree(MORE_FIELD, node))
endif
= ret

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: BASIC - more harmful than useful?

Sun Jan 27, 2013 2:37 pm

I remember writing a animal/vegetable/mineral 20 questions guessing game on my BBC model B micro that used a tree held in an array.

It asked the user to enter differentiating questions and the corresponding answers when it made an incorrect guess and the user won, thus expanding the knowledge base.

I was especially proud of that!

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: BASIC - more harmful than useful?

Sun Jan 27, 2013 2:45 pm

pygmy_giant wrote:I remember writing a animal/vegetable/mineral 20 questions guessing game on my BBC model B micro that used a tree held in an array.

It asked the user to enter differentiating questions and the corresponding answers when it made an incorrect guess and the user won, thus expanding the knowledge base.

I was especially proud of that!
Great game! Still is:

http://unicorn.drogon.net/rtb/animals.rtb

Although that uses a tree held on disk.

The last time I showed a young person that they started to input fictional "animals" from various cartoons, pokemon, etc. (then I had to reset the databse) How times change...

-Gordon
--
Gordons projects: https://projects.drogon.net/

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: BASIC - more harmful than useful?

Sun Jan 27, 2013 3:20 pm

Q - Why shouldn't you take a Pokemon into the shower?

A - because he might Pikachu!

Image

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: BASIC - more harmful than useful?

Sun Jan 27, 2013 7:48 pm

Right. There you go. "classic" BASIC for loops and a "do" loop that works the other way round to the existing "cycle" loops. Hasn't broken any of the existing demos by the looks of it.

https://projects.drogon.net/return-to-b ... d-install/

Version is 1.0.4

Please fetch it and have a look and have a play - afterall, you wanted it! (well 1 or 2 did ;-)

I've also updated the Linux x86-32 and 64-bit versions too if you want to run it on your desktop. You'll need the sdl-libraries installing though.

Updated the manual too.

Feedback welcome!

-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: BASIC - more harmful than useful?

Sun Jan 27, 2013 9:54 pm

@Gordon:
Thank you, NOW We have BASIC on both RISC OS and Linux on te RPi. Now all that is needed to ballance the two is to get Charm on Linux, and an up to date Python on RISC OS :) . Now who is oing to do al of this for Plan 9? Then we wil have a completely rounded set of operatin systems (until we get MiNIX anyway).
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: BASIC - more harmful than useful?

Mon Jan 28, 2013 1:49 pm

Had a little look at Gordon's BASIC - the documentation that is, as I dont run Linux.

My personal view is that:

On the one hand - the closer to BBC BASIC the better as that is the inherited educational legacy from the 80s (I bet some people still have their old battered beeb manuals lying around).

On the other - it must be tempting to completely re-invent your own syntax for your own beginner language, but that begs the questions: could you improve on BBC BASIC, should you, and can you be bothered? I'm guessing the answers are no, no and no - but it must be nice to have that ability!

I think that for a beginner unambiguous error messages would be a big help.

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 10:10 am

Python rules ;)

http://www.english.rfi.fr/general/20130 ... hed-nature

(where is the tongue in cheek emoticon)
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26080
Joined: Sat Jul 30, 2011 7:41 pm

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 10:23 am

pygmy_giant wrote:Had a little look at Gordon's BASIC - the documentation that is, as I dont run Linux.

My personal view is that:

On the one hand - the closer to BBC BASIC the better as that is the inherited educational legacy from the 80s (I bet some people still have their old battered beeb manuals lying around).

On the other - it must be tempting to completely re-invent your own syntax for your own beginner language, but that begs the questions: could you improve on BBC BASIC, should you, and can you be bothered? I'm guessing the answers are no, no and no - but it must be nice to have that ability!

I think that for a beginner unambiguous error messages would be a big help.
I still have the manual, but them I still have a BBC micro.#

As to inventing your own syntax, my answers to your questions would be..

1) Yes. Use Python.
2) No, because Python is pretty good already and doesn't need much improvement
3) No, because someone else maintains Python to a very high level of quality.

Yes, where is that tongue in cheek icon?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 12:47 pm

Not sure but if you do this it looks a bit like someone stiking their tounge out

:¬p

Although loads of people already do use Python I have seen some other post on other threads by other people saying things along the lines of "Use BASIC on RISC OS - its faster than Python".

*sigh* some people just won't do as they're told :roll:

I'm a C man myself.

I would be interested to see some comprehensive benchmarking accross many languages on several OS on the Pi.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26080
Joined: Sat Jul 30, 2011 7:41 pm

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 1:09 pm

I don't think there is any doubt that Python will be a bit slower in most circumstances. Whether out and out performance is relevant in a teaching environment is another question!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 1:10 pm

pygmy_giant wrote:Not sure but if you do this it looks a bit like someone stiking their tounge out

:¬p

Although loads of people already do use Python I have seen some other post on other threads by other people saying things along the lines of "Use BASIC on RISC OS - its faster than Python".

*sigh* some people just won't do as they're told :roll:

I'm a C man myself.

I would be interested to see some comprehensive benchmarking accross many languages on several OS on the Pi.
I did some very crude tests of my BASIC against C, PHP and Python. Python was slightly faster. PHP much slower, C was some 80 times faster.

If someone would like to type this into BBC Basic under RISC OS and let me know, I'd appreciate it:

http://unicorn.drogon.net/rtb/ack.rtb

It takes 16 seconds on a standard Pi under Linux in RTB. (0.5 seconds on my 2GHz desktop)
(note that TIME in RTB is milliseconds - s/1000/100/ for BBC Basic)

Please use floating point variables to make the comparison fair. (RTB doesn't have an integer type, just double precision floats) It will use a lot of stack space - I've no idea what BBC Basic under RISC OS needs/uses though, so it if runs out of memory, you may need to give it more stack. (and don't get too excited when it prints the first 3 lines in a second - it's the last line that'll take the time ;-)

It shoud print:

Code: Select all

    1    2    3    4    5    6    7    8
    2    3    4    5    6    7    8    9
    3    5    7    9   11   13   15   17
    5   13   29   61  125  253  509 1021

-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
Burngate
Posts: 6260
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 3:39 pm

I've just typed it into my Virtual RPC,and altered it to BBC BASIC

Code: Select all

PRINT "The Ackermann test. Expect this to run in about"
PRINT "0.5 seconds on a 2GHz Intel CPU."
PRINT
PRINT "Start"
rec=0
start = TIME
FOR y = 0 TO 3
  FOR x = 0 TO 7
    z = FNackermann(y,x)
    PRINT z;  " ";
  NEXT
  PRINT
NEXT
PRINT "Done in ";  (TIME - start) / 100;  " seconds.":REM RISC OS TIME function counts in centiseconds
END

DEFFNackermann(m,n)
IF m = 0 THEN:= n+1
IF n = 0 THEN:= FNackermann(m-1,1)
 = FNackermann(m-1,FNackermann(m,n-1))
On my laptop running Virtual RPC I get

Code: Select all

*/ ackermann3
The Ackermann test. Expect this to run in about
0.5 seconds on a 2GHz Intel CPU.

Start
         1          2          3          4          5          6          7          8 
         2          3          4          5          6          7          8          9 
         3          5          7          9         11         13         15         17 
         5         13         29         61        125        253        509       1021 
Done in 2.34 seconds.
*
On the Pi I get

Code: Select all

*/ackermann3
The Ackermann test. Expect this to run in about
0.5 seconds on a 2GHz Intel CPU.

Start
         1          2          3          4          5          6          7          8 
         2          3          4          5          6          7          8          9 
         3          5          7          9         11         13         15         17 
         5         13         29         61        125        253        509       1021 
Done in 2.63 seconds.
*

User avatar
Burngate
Posts: 6260
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 4:00 pm

And just to complete the set, on a genuine RiscPC with StrongArm, I got 8.1 secs.
And an Arm9home 3.58 secs

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 4:13 pm

Burngate wrote:And just to complete the set, on a genuine RiscPC with StrongArm, I got 8.1 secs.
And an Arm9home 3.58 secs
It's quite impressive!

Some will be down to BBC BASIC being written in assembler (I presume) rather than C though, and I know the way I handle recursion is somewhat "sub-optimal"...

-Gordon "must try harder" ;-)
--
Gordons projects: https://projects.drogon.net/

User avatar
Burngate
Posts: 6260
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 4:55 pm

I was thinking about how to make it even quicker, but having seen the results, I'm going to see if I can slow it down
First thought is to use rather longer variable names, such as changing y to abcdefghijklmnopqrstuvwaaaaaaaaaaaaaaaaaaaaaaaaaay
But that didn't slow it down much
So I tried changing FNackermann to FNackermannackermannackermannackermannackermannackermannackermann
And that didn't slow it down either

So I think the interpreter is doing subtle things before it runs it, such as removing spaces and REMs

User avatar
Burngate
Posts: 6260
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 5:03 pm

I added a line to make it count the number of times the function was called, and it came up with 922,632.
Since I can't see what it's doing, what's the best way to make it last longer - a few minutes?
should I change x or y, and if so what to?

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 5:06 pm

Burngate wrote:I was thinking about how to make it even quicker, but having seen the results, I'm going to see if I can slow it down
First thought is to use rather longer variable names, such as changing y to abcdefghijklmnopqrstuvwaaaaaaaaaaaaaaaaaaaaaaaaaay
But that didn't slow it down much
So I tried changing FNackermann to FNackermannackermannackermannackermannackermannackermannackermann
And that didn't slow it down either

So I think the interpreter is doing subtle things before it runs it, such as removing spaces and REMs
I'd be surprised it it didn't also create a token/symbol table for variable names, etc. too. That's what I do in RTB - so variable names (& functions, etc.) can be as long as you type and they're rendered into a 16-bit value in the program memory and execution time isn't affected. I actually remove all spaces from the program as you type in it (except those in strings & REMs) and the list command re-constructs the lines. (not always perfectly, but good enough :)

-Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 5:20 pm

Burngate wrote:I added a line to make it count the number of times the function was called, and it came up with 922,632.
Since I can't see what it's doing, what's the best way to make it last longer - a few minutes?
should I change x or y, and if so what to?
Er, no. It will increase the recursion depth exponentially. (you'll likely run out of memory) and time.

You can try bumping them up by 1 though... I'd try the inner loop first. Taking it from 7 to 8 takes it from 0.5 seconds to 2.5 seconds on my desktop. (last number 2045) Taking it to 9 then takes 8 seconds (last number 4093) or 250 seconds on a 700MHz Pi.

bumping the outer loop will make it run out of memory.


-Gordon
--
Gordons projects: https://projects.drogon.net/

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 6:22 pm

Just to go off-topic for a moment - someone elsewhere pointed out that Python does seem to be available for RISC OS on the Pi:

https://www.riscosopen.org/forum/forums/11/topics/1341
http://www.cgransden.co.uk/python27.zip

- although I have not tried it myself.

As you were...

User avatar
tonyhughes
Posts: 951
Joined: Wed Dec 26, 2012 3:46 am

Re: BASIC - more harmful than useful?

Tue Jan 29, 2013 7:16 pm

I'm in total agreement with ukscone - I am 36, bought a C64 when the slimline model arrived, and all I had was a few disks and a manual talking about BASIC. No internet, no modem, no BBS (very few in NZ in the 80's let alone my hometown of Blenheim).

Created a full on record keeping program based on a code example from somewhere, and taught myself what works and what doesn't.

Didn't really code again after childhood 'til HTML tickled me. Now I'm into BASH scriping, and about to take the plunge into Python.

BASIC is a great start. No particular reason to start there these days, (Python etc is likely a better place for anyone to start) BUT no reason to proactively avoid it either.

In photography, where people have professional DSLRs (machine code), Point & Shoots (Python) and cellphone cameras (BASIC), there is a saying:

"The best camera is the one you have with you."
(Because the most expensive camera left at home is useless).

And I think that directly translates to programming.

"Whatever programming you start doing is worthwhile."
(Because not programming at all, isn't helping your programming skills).

Ka kite anō au i a koutou.
Big T.

Return to “Staffroom, classroom and projects”