ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5887
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 9:22 pm

DavidS wrote:
Tue Nov 20, 2018 9:06 pm
Ok fair. May I ask why many packages releated to BASIC (at least last I looked), from Diabian ARMHF are not present in Raspbian?
RPF/T don't run raspbian.org. Raspbian itself is a rebuild of Debian armhf for armv6. We take Raspbian, add our own repo on top and build images. If something is missing, it's because it's missing from Raspbian itself. This usually happens when the package doesn't automatically build for whatever reason. Then plugwash (the maintainer of Raspbian) has to go in and manually fix things.

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 9:27 pm

I realized that ABC can target RISC OS modules, looking through the documentation to see if it is possible to build a module written in ARM BASIC (BBC BASIC V) that does not have any dependancies (like CLib). If it is possible I think I will write things for my OS Project in BBC BASIC V, compiled (at first) with ABC. Then I can redirect my compiler efforts to working on a replacement BBC BASIC Compiler (one that is open source, thus fitting the new OS).

Also having done a search it actually seems like BBC BASIC is the universal version of BASIC as it seams to have a good number of users on RISC OS, Linux (including ARM Linux), Windows, DOS, Haiku OS, and others.
jahboater wrote: So if I were to use or learn another language, it would be mostly for academic interest, with no real purpose.
... ...
I'm sorry, but I cant see any reason why I should spend time learning modern BASIC.
That's not bashing BASIC. I accept it has lots of appeal for many people.
Nothing wrong with that. You are already happy with other languages.

C is without question a good language, one of the languages I like, and use.

BASIC and ARM assembly are where I have the most fun personally, and where I tend to get the most done.

I will admit I only know a few programming languages myself. The short incomplete list (off the top of my head) of languages I know is; BBC BASIC V, FreeBASIC, CBM BASIC 2, ARM Assembly, x86 Assembly, 6502/65816 Assembly, I8080 Assembly, DEC PDP-11 Assembly, 680x0 Assembly, Pascal, Charm, C, LOGO, and a few others. The limited number of programming languages I know has likely aided in my current views, as I think is the case for all people.
hippy wrote:
DavidS wrote: Thoguh there IS a pervasive dialect of BASIC that IS supported on most platforms (even more platforms than Python). That is FreeBASIC.
I was on board with FreeBasic from its inception when I was looking to support X86 Linux as well as DOS/Windows. Unfortunately what started off as "Multi-Platform QBasic" took a turn towards something else, was creeping away from what fitted with the QBasic way of doing things and its syntax, seemed to want to become 'Basic for C programmers' from what I remember, became a complete mess, and we parted company. It seems to have better rationalised itself so I may bear it in mind for the future.
I am not sure if FreeBASIC is the better known or if it is BBC BASIC (just did a search of comparison). It actually seems as if there are now a lot more BBC BASIC users than there used to be, and many have never touched RISC OS.

Though I hear you as far as the early days of FreeBASIC, when it seemed they were going out into left feild with the language. There are still things in the language that are beyond, though at least now it sticks to a reasonable syntax.
You'll be pleased to know the VideoCore IV compiler I am writing ( in Python ) compiles a language which is a Basic variant
Cool now we will have BASIC compiled to run native on VideoCoreIV, as well as ARM, that is encomposing the RPI all the way :) .
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
bensimmo
Posts: 4162
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 10:16 pm

TL:DR
You do realise Python has a huge job market, it's not small and not just for 'hobby makers'
It's used in Uni for large scale number crunching and analysis, industry too.
Facebook use it to run parts of Facebook, they recently updated code to Python3 to speed it all up, that's just one example
and jobs, they are loads of them.
For example, based on job advert
https://www.techworld.com/picture-galle ... s-3612638/

The only BASIC that crops up is VB.net and VBA in adverts is.

I think you need to get out and actually look at what the world currently wants, not what a small subset of it is using.

--
As for not RPi not wanting it,
https://www.raspberrypi.org/blog/learn- ... with-eben/ a few months back
and few years back too
https://www.raspberrypi.org/blog/celebr ... -of-basic/

maybe some more?

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 10:21 pm

Thinking about a bit we see that the very question of this post's title is loaded with at least two assumptions that one has to assume are true before it even makes sense as a question: Why Avoid BASIC on RPi?

1) It assumes Pi users and/or perhaps the Pi Foundation specifically are actively avoiding BASIC.

As jamesh points out actively supporting X does not imply avoiding Y. It just means one is doing X rather than Y. There is not enough time and resources to do everything all the time.

2) More basically (get it?) it assumes anyone is actively avoiding BASIC.

This is rather like asking why I avoid speaking Mongolian or Norwegian. Well, thing is, I don't. It's just not a thing in the circles in which I move. Never thought about it. I'm sure they are perfectly fine languages.

It's a classic "Have you stopped beating your wife" question.

Of course there is the assumption that somehow all those people not using BASIC would somehow be better off if they did. Well, perhaps. I have yet to hear any reason why that may be so. Let's assume BASIC is on a parity with the languages people do use. That is not sufficient to get anyone to move over.

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 10:53 pm

@Heater:
I had missed your post at the bottom of the first page, do to page wrap timing.

To answer that post:

On a Raspberry Pi 3B in ARM BASIC on RISC OS interpreted the time to calculate FNFibo(4784969) is 2.3 seconds. Running the same compiled (with ABC) gives a time of 0.05 seconds. That is using the space optimized dynamic programming algorithm for calculation Fibonacci sequence values.

Is that good enough time for you? For some reason I thought you were asking for the equivlent of FNFib(1000000000), which would take a very long time.

That is with roll over, it would be about 3 times slower if I actually accumulated the entire result, though I was just doing a quick one.
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

plugwash
Forum Moderator
Forum Moderator
Posts: 3439
Joined: Wed Dec 28, 2011 11:45 pm

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 11:12 pm

DavidS wrote:
Tue Nov 20, 2018 9:06 pm
Ok fair. May I ask why many packages releated to BASIC (at least last I looked), from Diabian ARMHF are not present in Raspbian?
If they in Debian armhf but not in the same release of raspbian it's probablly one of the following.

1. They failed to build.
2. They built but the resulting packages were armv7 contaminated, so were blocked from entering the archive.
3. One of their build-dependencies is missing due to points 1 or 2
4. There is a build-dependency loop which needs to be manually broken.

If you can name particular packages I can take a look and give you more details.

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 11:17 pm

plugwash wrote:
Tue Nov 20, 2018 11:12 pm
DavidS wrote:
Tue Nov 20, 2018 9:06 pm
Ok fair. May I ask why many packages releated to BASIC (at least last I looked), from Diabian ARMHF are not present in Raspbian?
If they in Debian armhf but not in the same release of raspbian it's probablly one of the following.

1. They failed to build.
2. They built but the resulting packages were armv7 contaminated, so were blocked from entering the archive.
3. One of their build-dependencies is missing due to points 1 or 2
4. There is a build-dependency loop which needs to be manually broken.

If you can name particular packages I can take a look and give you more details.
I will get back to that issue when I have time to manually walk the two repos again.

I will let you know when I get the info again.
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

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 11:21 pm

DavidS,
Is that good enough time for you?
Actually no. Your claimed execution time sounds very unlikely.

50ms to calculate fibo(4784969) is almost twice as fast as using libgmp's fibo function in C on my 3GHz PC.

Forgive me if I'm a bit suspicious about that result.

Please show your code. Plus some evidence of it running and some of the output.

Edit:

Ah I see. You have edited your post to say "That is with roll over, it would be about 3 times slower if I actually accumulated the entire result, though I was just doing a quick one."

So actually you did not calculate fibo(4784969) at all. I assure you it would take a lot more that 3 times as long if you did.

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 12:08 am

@Heater: (follow up to my avove post, have not yet read your new post):
Ok I was incorrect it takes about 23 seconds for the Interpreted version to calculate the result, with full accumulation. Did not run the compiled version at all.

I think that 23 seconds is prety good all considered, that is running in single tasking (of course).


Just read your new post: and realize that I also just answered your new post.

EDITED to correct error, in testing. I was running the interpreted version, not the compiled (oops).
Last edited by DavidS on Wed Nov 21, 2018 2:01 am, edited 1 time in total.
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
Gavinmc42
Posts: 3645
Joined: Wed Aug 28, 2013 3:31 am

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 1:21 am

Did you know that there is also a 99% Linux compatible Kernel written in FreeBASIC?
Nope, did not know.
FreeBASIC looks interesting if it can get that high in compatibility.
I remember the MS QuickBasic and QuickC days, did lots of coding using those.
QuickC was my favorite IDE for a very, very long time.

Can FreeBasic be made into an embedded interpreter?

But more important is, could it make a Baremetal OS like Ultibo?
The Free Pascal in Ultibo is great(actually really good) but it is NOT a beginners language.(depends on the beginner?)
I would like to see more options for baremetal on Pi's.
Ultibo is nearly there in taking compiled libraries from many other languages, perhaps even FreeBasic one day?
The Linux OS can get in the way of coding, well for me it did.
Wasted too much time learning Linux and not coding.

These days after 6 years in Pi world, languages are not avoided, I use whatever works.
I am slowly coming around to object coding methods too :oops:
Turns out code reuse actually can be done with the right language and tools.
The more units I make the more I reuse and the less my main app gets.

Some people might say you are not a coder until you write 10,000 lines(100,000? 1M?).
If I can do the same application in 100 lines, how good a coder do I need to be?
I am not a coder, I am a hardware guy who uses Pi cpu's because I cannot make hardware that cheap or reliable or fast or.....
I want these fancy 64bit 1GHz+ multicore cpu's to be very easy to use, for me the language is now irrelevant.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 1:43 am

Gavinmc42 wrote: Can FreeBasic be made into an embedded interpreter?
FreeBASIC is not an interpreter it is a compiler.
But more important is, could it make a Baremetal OS like Ultibo?
Yes it can, and has for example FROST is an OS written in FreeBASIC. I do not think that anyone has done this on an ARM based system yet, though it could be done.
he Free Pascal in Ultibo is great(actually really good) but it is NOT a beginners language.(depends on the beginner?)
I would like to see more options for baremetal on Pi's.
Ultibo is nearly there in taking compiled libraries from many other languages, perhaps even FreeBasic one day?
It is possible. Maybe one day someone will achieve that goal on the Raspberry Pi.
The Linux OS can get in the way of coding, well for me it did.
Wasted to much time learning Linux and not coding.
And why I still use RISC OS. When it comes to programming RISC OS does not have much of a learning curve, and it allows you to directly access HW behind its back with a minimum of effort.
These days after 6 years in Pi world, languages are not avoided, I use whatever works.
I am slowly coming around to object coding methods too :oops:
Turns out code reuse actually can be done with the right language and tools.
The more units I make the more I reuse and the less my main app gets.
Code reuse only takes modular programming. No need to use Object Oriented stuf to get there. I do it all the time in procedural languages (like C, BASIC, and Assembly).
Some people might say you are not a coder until you write 10,000 lines(100,000? 1M?).
If I can do the same application in 100 lines, how good a coder do I need to be?
Lines of code has been proven to be a bad metrix of performance of a programmer. It is often possible to do more with less code, and have it run faster. No mater how good our algorithms get someone out there will figure out how to do it better with less code.

I do not know if you remember the days of the Boot Sector Demos on the PC compatible, or the 4K Demos on Atari ST, Amiga, and RISC OS. Every time you thought that there is no way to fit more in 4KB of machine code and data someone would come out with something even more capable that is under the limit. There were simple 4KB compilers, all kinds of 4KB or less games, Graphics Demos, etc, all to prove what can be done.
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: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 1:53 am

@Heater:
Well here is the code that runs in 23 seconds average for your chalenge:

Code: Select all

ON ERROR PRINT "LINE : " + STR$(ERL) + " ERROR : " + REPORT$ : E

MaxSize% = 1000 * 1000 / 12

DIM A0%(MaxSize%)
DIM A1%(MaxSize%)
DIM A2%(MaxSize%)

time% = TIME
PROCFibo(4784969)
PRINT "Time = "; (TIME-time%)/100; " Seconds"
END

DEF PROCFibo(n%)
MaxCur%=0
FOR cnt%=0 TO MaxSize%-1 STEP 1
  A0%(cnt%)=0
  A1%(cnt%)=0
  A2%(cnt%)=0
NEXT
A1%(0)=1
FOR cnt%=2 TO n% STEP 1
  FOR cnta%=0 TO MaxCur% STEP 1
    A2%(cnta%)=A0%(cnta%)+A1%(cnta%)
    IF A2%(cnta%) < 0 THEN
      A2%(cnta%) = A2%(cnta%) AND &7FFFFFFF
      A2%(cnta%+1) += 1
    ENDIF
    A0%(cnta%) = A1%(cnta%) : A1%(cnta%) = A2%(cnta%)
  NEXT
  IF A2%(MaxCur%+1) THEN
    MaxCur% +=1
  ENDIF
NEXT
ENDPROC
yea yea I did not comment. Each element in each of the three arrays contains 31 bits of the result (using the sign overflow to carry).

If you see any errors, as I did throw this together rather quickly, please let me know.

BTW: I realized that I did not test the compiled version after correcting the source to accumulate the values, all the tests after that were done with the interpreted version. As such I would imagine that it is a lot faster once compiled.

And the attached image is for proof of life. It runs about a second faster in single tasking mode, this window shot was taken in a task window (multitasking).
Attachments
window0.gif
Proof Of Life.
window0.gif (8.7 KiB) Viewed 2397 times
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
scruss
Posts: 2420
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 2:57 am

DavidS wrote:
Tue Nov 20, 2018 9:06 pm
… May I ask why many packages related to BASIC (at least last I looked), from Debian ARMHF are not present in Raspbian?
I didn't find any missing in Raspbian compared to Debian.

Ubuntu 18.04.1 LTS x86_64 & Beaglebone Debian GNU/Linux 9 (stretch) armv7l

Code: Select all

basic256 - educational BASIC programming environment for children
brandy - BBC BASIC V interpreter
bwbasic - Bywater BASIC Interpreter
sdlbasic - BASIC interpreter for game development
yabasic - Yet Another BASIC interpreter
Raspbian Raspbian GNU/Linux 9 (stretch) armv7l

Code: Select all

basic256 - educational BASIC programming environment for children
brandy - BBC BASIC V interpreter
bwbasic - Bywater BASIC Interpreter
sdlbasic - BASIC interpreter for game development
yabasic - Yet Another BASIC interpreter
rtb - Return to Basics
rtb is Gordon's interpreter. I found these with a simple query (apt-cache search basic | egrep -i '(basic.*interpreter|rtb|basic256)') that may have missed some packages. But there's definitely no FreeBASIC, X11-BASIC, bas, cbmbasic or Decimal BASIC in any of the repos.

BASIC's time has been and gone. Yeah, it would be nice to have a load-and-go language right there with the modern equivalent of the “Ready” prompt when you start up the computer, but there are now many more options.

on preview: David, your fibo BBC Basic code ran out of memory on both Richard Russell's BBCSDL and on Matrix Brandy.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 3:07 am

scruss wrote:
Wed Nov 21, 2018 2:57 am
BASIC's time has been and gone. Yeah, it would be nice to have a load-and-go language right there with the modern equivalent of the “Ready” prompt when you start up the computer, but there are now many more options.
I am glad that kind of BASIC is gone. Modern BASIC is so much better.

Also thank you for that comparison. I guess that things have changed since last I looked at the repos. At least when by name, still need to see about a few others (whose names do not contain the string 'basic' or any case varient thereof).
on preview: David, your fibo BBC Basic code ran out of memory on both Richard Russell's BBCSDL and on Matrix Brandy.
On RISC OS I have to allocate 3MB for the next task before running it single tasking, or open a task window with at least 3MB allocated to run it in the task window.

I am not sure what the equilevent action would be for Matrix Brandy BASIC or BBCSDL, as I have not used either (though I am glad to see them both).
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: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 4:34 am

I do thank everyone for the positive participation in this thread.

I probably should have worded a few things differently, as I now see.

Some things to figure out.
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

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 8:10 am

scruss wrote:
Wed Nov 21, 2018 2:57 am
Yeah, it would be nice to have a load-and-go language right there with the modern equivalent of the “Ready” prompt when you start up the computer,
You could do this on the Pi I would have thought:

Append "init=/usr/bin/basic" to /boot/cmdline.txt

It should just boot directly (very quickly) to the BASIC prompt without starting anything else, not even systemd.

Never tried it though.

DavidS,

23 secs for the fibo program is fine - its the same ball park as the other interpreted langauges.
Thanks for running it.
Last edited by jahboater on Wed Nov 21, 2018 8:14 am, edited 1 time in total.

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 8:13 am

I do not know if you remember the days of the Boot Sector Demos on the PC compatible, or the 4K Demos on Atari ST, Amiga, and RISC OS. Every time you thought that there is no way to fit more in 4KB of machine code and data someone would come out with something even more capable that is under the limit. There were simple 4KB compilers, all kinds of 4KB or less games, Graphics Demos, etc, all to prove what can be done.
They are still around.
Those 4k demoscenes guys are so far beyond me they may as well be in another universe.
https://www.theverge.com/2012/5/14/3014 ... e-fractals

Could it be done on Pi's?
Is using start.elf cheating?

viewtopic.php?t=104571
Whoops 3 years ago and DavidS has now volunteered to show us how to do it? :lol:

250k is the smallest Ultibo anyone has tried.
USB boot mode for a Zero, that way no need to have SD card software?.
What is the smallest kernel.img that can do video demoscenes?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 8:21 am

jahboater wrote:
Wed Nov 21, 2018 8:10 am
You could do this on the Pi I would have thought:

Append "init=/usr/bin/basic" to /boot/cmdline.txt

It should just boot directly (very quickly) to the BASIC prompt without starting anything else, not even systemd.

Never tried it though.
I'm not sure which Basic interpreters are good at reaping zombies.

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 9:02 am

Hijacking this post, sorry
GLES2 27KB kernel.img files :o
https://github.com/LdB-ECM/Raspberry-Pi
So 64kB demoscenes are doable on Pi's now.

Time to learn LdB's methods, perhaps I could be in the same Universe?
Learn assembler and I'm in DavidS space?
What can be done with 4 cores? :shock:

That is what I hate about Pi's they make it seems so simple to even think about coding in those guys league.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 9:06 am

ejolson wrote:
Wed Nov 21, 2018 8:21 am
jahboater wrote:
Wed Nov 21, 2018 8:10 am
You could do this on the Pi I would have thought:

Append "init=/usr/bin/basic" to /boot/cmdline.txt

It should just boot directly (very quickly) to the BASIC prompt without starting anything else, not even systemd.

Never tried it though.
I'm not sure which Basic interpreters are good at reaping zombies.
Only a problem if BASIC leaves zombies.
You can do init=/bin/sh which works fine, and BASIC is presumably just a similar interpreter.
I am just going to try init=/usr/bin/python to see if a turnkey python box works

Edit: Wahoo! it works!
I added init=/usr/bin/python3.5 to /boot/cmdline.txt
It boots immediately into the Python prompt.

You get the four Raspberries and directly below them is Python !!!!

There were none of the usual Linux startup messages.

I am sure it would work with BASIC, giving you something similar to the old Basic PC's that booted straight to the BASIC ready prompt.

Edit: hmm. Doesn't work with brandy, just get a blank screen.
Probably needs graphics to run SDL.
Last edited by jahboater on Wed Nov 21, 2018 9:41 am, edited 3 times in total.

User avatar
PeterO
Posts: 4954
Joined: Sun Jul 22, 2012 4:14 pm

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 9:10 am

DavidS wrote:
Tue Nov 20, 2018 4:36 pm
PeterO wrote: Library support ? Without it BASIC is useless for working with all the hardware addons that need libraries to make them easily useable.
PeterO
What BASIC are you using that does not have library support?
No one produces basic libraries for their hardware, that's the point.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 12:22 pm

jahboater wrote:
Wed Nov 21, 2018 8:10 am
You could do this on the Pi I would have thought:

Append "init=/usr/bin/basic" to /boot/cmdline.txt

It should just boot directly (very quickly) to the BASIC prompt without starting anything else, not even systemd.
That's what MMBASIC does on the Raspberry Pi, I think. I didn't keep it around long enough to find out.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 12:53 pm

DavidS wrote:
Wed Nov 21, 2018 3:07 am
On RISC OS I have to allocate 3MB for the next task before running it single tasking, or open a task window with at least 3MB allocated to run it in the task window.

I am not sure what the equilevent action would be for Matrix Brandy BASIC or BBCSDL, as I have not used either (though I am glad to see them both).
It's been years since I had to tell a program how much memory I wanted it to use. Can't see that being a big draw with the learners. Anyway, with Matrix Brandy, this gets you a 4 MB work space, runs the program and quits immediately:

Code: Select all

tbrandy -size $((4*1024*1024)) -quit fibo.bas
Runs in a decent 21.3 s on a 3B+, or 52 s on a Zero. Doesn't produce any output, so I can't check if it's doing the right thing.

Contrast that with this:

Code: Select all

#!/usr/bin/env perl6

my constant @fib = 1, 1, *+* ... *;
say @fib[4784969];
which happily took about 15 minutes to chew up over 28 GB of memory on this i7 before being zapped by the OOM killer process. I knew it wouldn't be fast and was likely to fail, but I didn't need to give it permission to allocate memory.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

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

Re: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 1:53 pm

As far as booting directly into a BASIC interpreter (please do not), you can just use RISC OS Pico, which is a very stripped down RISC OS ROM Image to boot directly into BASIC (can also set the command language to the BASIC interpreter in other versions of RISC OS).
scruss wrote:
Wed Nov 21, 2018 12:53 pm
DavidS wrote:
Wed Nov 21, 2018 3:07 am
On RISC OS I have to allocate 3MB for the next task before running it single tasking, or open a task window with at least 3MB allocated to run it in the task window.

I am not sure what the equilevent action would be for Matrix Brandy BASIC or BBCSDL, as I have not used either (though I am glad to see them both).
It's been years since I had to tell a program how much memory I wanted it to use. Can't see that being a big draw with the learners. Anyway, with Matrix Brandy, this gets you a 4 MB work space, runs the program and quits immediately:

Code: Select all

tbrandy -size $((4*1024*1024)) -quit fibo.bas
Runs in a decent 21.3 s on a 3B+, or 52 s on a Zero. Doesn't produce any output, so I can't check if it's doing the right thing.

Contrast that with this:

Code: Select all

#!/usr/bin/env perl6

my constant @fib = 1, 1, *+* ... *;
say @fib[4784969];
which happily took about 15 minutes to chew up over 28 GB of memory on this i7 before being zapped by the OOM killer process. I knew it wouldn't be fast and was likely to fail, but I didn't need to give it permission to allocate memory.
It usually is not needed to allocate memory for most applications. when writing in BASIC on RISC OS the default Next Slot is 640KB, most applications change that to what they need (usually less, sometimes more) before they load the main executable (which can be a BASIC program, as BASIC is built in to the OS). So running a bare BASIC program allows for 640KB, which is enough that people learning are very unlikely to hit it until they begin learning about memory management a little.

Had I done it the better way for RISC OS, which is to allocate a dynamic area for the large data, then it would not have been portable, though it would not have required any manual allocation either.
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: Why Avoid BASIC on RPi?

Wed Nov 21, 2018 2:01 pm

The compiled version of the Fibonacci sequence example runs in 0.84 seconds. That is compiled BBC BASIC V on RISC OS.

Compiled with ABC version 4.18.
RISC OS 5.24 RPi
Raspberry Pi 3B, full speed at 1200MHz, throtted speed 600MHz.
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

Return to “Off topic discussion”