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

Why Avoid BASIC on RPi?

Tue Nov 20, 2018 1:38 pm

This is actually multiple parts:
I posted this in Off Topic so it does not dilude the other language section, as any thread about BASIC in any way shape or form tends to get pretty long pretty fast.

Why Are People Turned Off By the Name BASIC?:
I know the arguments, none of which have applied since 1985, at least.

Lets look at the arguments, and show some truth (argument in bold, correction after):
  1. BASIC uses goto and gosub, so is unstructured: C allows goto. I have not used goto or gosub in a BASIC program since 1985. All BASIC's that have been common since them use structured procedures, just like C or Pascal, or whatever else.
  2. Line numbers are not a good target: Again that applies to very old versions of BASIC, and does not apply to any BASIC that has been common since 1985. Any BASIC that still supports line numbers they are usually only used for program entry.
  3. BASIC does not support integer data types directly: This is simply not true. I have never used a version of BASIC that does not support integer variables and data. Just postfix the identifier with a % to allocate it as an integer.
  4. BASIC is not compiled: While many early BASIC versions did not come with a compiler, can you really say that the BASIC compilers for just about every variant of BASIC are not there, when they are?
  5. BASIC does not follow a standard: While technically true, we do have two informal standards that one or the other is followed by most modern BASIC implementations. The two informal standards being BBC BASIC V and MS-BASIC as implemented in BASIC Compiler v2+, and QuickBASIC. These are both good structured BASIC implementations.
  6. BASIC does not have indirection: That usually just is untrue. In any BASIC evolved from BBC BASIC V we have pointers in a very direct way, and in the QuickBASIC derived versions we have multiple methods of implementing indirection.
On points 3 and 4, the learning languages that many suggest today are even worse about distinguishing between data types, and are interpreted only in most cases. So that would make BASIC more of an option than what is often recommended.

Why Not Recommend BASIC For Beginners?
Modern Structured BASIC does not have the bad habit issues of the old 8-bit BASIC implementations. Modern BASIC encourages good practices, structured programming, typed variables, and modular programming. These are good reasons in themselves, though to add more:
BASIC is generally easier to learn than something like Scratch, especially when teaching young children to program. BASIC is more of a truly universal language, making for fairly simple implementation of almost anything that can be written in a language like C, Pascal, C++, etc.

Why not Use BASIC later?:
As BASIC is just as capable as other options, why do some many people frown on its use for bigger projects?

The point:
BASIC is a good usable language, that is discouraged. It is a good fit on the Raspberry Pi for many reasons, and indeed is a big part of one of the Operating Systems that runs on the RPi.

Though yet it seems as if the RPi Foundation discourages the use of BASIC, in preference to languages that have a higher barrier of entry to new programmers, and in some cases are more limited.
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?

Tue Nov 20, 2018 1:47 pm

This is one of the things that seems important enough to discuss in a reasonable manner, not like the old threads of language wars.

It came back to mind as I was doing some work on the parser for script based 3D CAD modeler I am working on for RISC OS. I am using a scripting language inspired by that of OpenSCAD, though syntax and structure that more closely follows ARM BASIC.

I feel it would be good to ask in a real way the question of 'why' on this issue.
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

Andyroo
Posts: 4141
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 2:02 pm

I'll chip in with:

From my point of IT department work it was 3 partly historic (as I am) reasons that killed it for us:

Lack of data structures
Arrays of one simple variable type just do not cut it so file handling and internal data storage was a pain.
You used Cobol for complex data structures

Lack of object orientation and inheritance
Once seen as the be-all and end-all of programming, this was poorly supported and Pascal superseded it and then C came in.

Lack of functions
Line numbers where such a pain and took a long while to go. GOTO / GOSUB created real issues with parameter passing they added a nail in the coffin.

The fourth one (and I programmed a lot in FORTH and {miss it} not):
It was not the latest and greatest
Software houses had to be seen to be keeping up to date 'with the times' and that meant using new technology even if it was a full rewrite (look more revenue as we can sell the upgrade services) or opponent slagging (look, they are using last years technology - do YOU want to get stuck in the past Mr Customer)

Now it has so much ground to make up and is not really used on its own (.NET being a mix of languages) I can understand the foundation promoting a simple language (Scratch) that has very fast results for youngsters and then a more commercial language (Python / C / PHP / Perl / Java / Javascript etc) via Linux than BASIC.

Should it come back - commercial needs will tell
Need Pi spray - these things are breeding in my house...

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 2:11 pm

@AndyRoo:
It apears that you did not read my initial post.

I pointed out that almost all your points are not true, and have not been true since 1985. You are thinking of the old 8-Bit BASIC implementations.

It is true that OO is not implemented, though that is not needed for most beginners, and not used even by many with big projects. Remember OO is still an ongoing debate, with people on both sides of it having very good and valid arguments.


As I pointed out already:
BASIC does have parameterized block functions (called procedures when talking accross languages). BASIC does not use Line Numbers anymore, has not in a very long time.

BASIC does NOT use goto/gosub anymore, has not since 1985. Calling normal parameterized procedures is much more reasonable for most people, so that is how we do it in BASIC.

BASIC does have structured data support. You are again thinking about ancient BASIC.
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: 4598
Joined: Wed Feb 04, 2015 6:38 pm

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 2:21 pm

I looked up Dartmouth Basic which is the sort of BASIC I remember.
https://en.wikipedia.org/wiki/Dartmouth_BASIC

While there I saw this comment:
SBASIC formed the basis of the ANSI-standard Standard BASIC efforts in the early 1980s.
So perhaps it did have an international standard?

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 2:24 pm

jahboater wrote:
Tue Nov 20, 2018 2:21 pm
I looked up Dartmouth Basic which is the sort of BASIC I remember.
https://en.wikipedia.org/wiki/Dartmouth_BASIC

While there I saw this comment:
SBASIC formed the basis of the ANSI-standard Standard BASIC efforts in the early 1980s.
So perhaps it did have an international standard?
Yes there is an ANSI BASIC. Though it is lacking, and not what BASIC of today is based off of. It is based off the two informal standards.

Actually I would say that closer to a standard is BBC BASIC, as it was backed by a national program in a country that is of significant influence.
Last edited by DavidS on Tue Nov 20, 2018 2:25 pm, 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

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 2:24 pm

I suspect it's been overtaken by Python, which has a large user base, and it consistent over all platforms, which is less common with BASIC. Python is slighter better structured, and has more language features.

Nothing really wrong with modern BASICS, but more people use Python.

(Although I started with BASIC and 6502 assembler, I use C exclusively now, with occasional forays in to C++)
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

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 2:36 pm

jamesh wrote:
Tue Nov 20, 2018 2:24 pm
I suspect it's been overtaken by Python, which has a large user base, and it consistent over all platforms, which is less common with BASIC. Python is slighter better structured, and has more language features.

Nothing really wrong with modern BASICS, but more people use Python.

(Although I started with BASIC and 6502 assembler, I use C exclusively now, with occasional forays in to C++)
I also began with BASIC and 6502 assembler (CBM BASIC 2.0). Now I use C, Pascal, BASIC (both BBC BASIC V/ARM BASIC and FreeBASIC), and ARM Assembly. I am not so exclusive on my language usage.

How does Python make a good option to modern BASIC? I thought that python is lacking one of the most important parts of structured programming, explicitly typed variables, which BASIC deos have. I understand that Python has the power of being pushed by many users, still not sure that makes it a good option.

I do understand why people shyed away from the crude forms of BASIC that were seen on the old 8-bit systems. Though I can not think of a single BASIC implementation I have seen that still has the bad of those since the mid 1980's (excepting the ones that attempt to recreate the old experience).


Thank you for the input. It is definitely good input.
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
PeterO
Posts: 4940
Joined: Sun Jul 22, 2012 4:14 pm

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 2:46 pm

Library support ? Without it BASIC is useless for working with all the hardware addons that need libraries to make them easily useable.
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

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5856
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 2:47 pm

In what sense is it discouraged? RPF have chosen python, but I don't see them telling people not to use BASIC if they want to.

I think when people make the decision of what language to use, it's more practical than worrying about goto statement or line numbers. Nobody really cares about any of that, it's just a reason they might give when pressed to give a reason.

What's the job market like for BASIC vs Python? If Python already does what people need, what's the motivation for them to use something else? Why don't Google, MS, Mozilla or anybody else who has the most on the line use BASIC?

If BASIC has an image problem, I'd say lead by example. Release software written in BASIC that outperforms existing solutions and that people love using. Start a BASIC meetup in your area. See if there are any students wanting to introduce BASIC in their schools. If that's not happening, it seems like there's a problem with BASIC itself and that most people just don't enjoy using it as much as other languages.

Python didn't become so widely popular because it was forced on anybody. People just tend to instantly see its merits when using it for a few minutes.

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 2:50 pm

DavidS wrote:
Tue Nov 20, 2018 1:38 pm
BASIC is generally easier to learn than something like Scratch, especially when teaching young children to program.
I wonder just how much personal experience do you have of teaching youngsters Scratch ?

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

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 2:59 pm

DavidS wrote:
Tue Nov 20, 2018 2:36 pm
I do understand why people shied away from the crude forms of BASIC that were seen on the old 8-bit systems.
For me, when I did my CS degree (long ago), the favored languages were things like Pascal, Algol68, and Ada. Languages like B were frowned upon (because B is typeless) despite being a serious systems programming language. BASIC was only mentioned in jest.

Of course I know that BASIC has evolved and improved over years, but that old mindset from the formative years, still lingers....

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 3:07 pm

DavidS,
I thought that python is lacking one of the most important parts of structured programming, explicitly typed variables...
"Structured Programming" as it was formulated in the 1950's / 60's does not say anything about data types or typed variables. neither were those things mentioned when I was taught the principles of Structured programming in the 1970's.

Rather Structured Programming is all about structuring ones flow of execution and specifying it. You know, sequence, selection, iteration, recursion. With some notion of functions and procedures.

Having dynamic typing like Python or Javascript removes a lot of syntactic noise from a language design. Which is of great advantage when starting out rank beginners.

Now, until BASIC can toggle a GPIO pin on a Raspberry Pi 3 at 50MHz or calculate the first million digit Finonacci number in 13 seconds on my PC I see no reason to look at it.
Last edited by Heater on Tue Nov 20, 2018 4:42 pm, edited 1 time in total.

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 3:10 pm

(in the UK)
As an BBC Basic user at the start (and I liked it, it is easy to learn the basics, my son some years back picked it up quickly on a BBC emulator)


People don't use basic because it went out of fashion for teaching and in the recent up surge in computing again in UK schools then scratch at the start and python later on are now the recommend tools. Some use Visual Studio if they want as well and whichever basic/c/.. they wish to use there.
Because they are what people may use when they are in jobs.


It is still taught today but in the forms, for example Microsoft Small Basic used in the lower ages of senior in places until they *have* to move to something else.
It easy to pick up and is modern in is methods.

BASIC still doesn't seem to have a nice IDE to help you along, or has it ?

It need pythons push again and modern look to become the language again for teaching again.

fanoush
Posts: 462
Joined: Mon Feb 27, 2012 2:37 pm

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 3:11 pm

DavidS wrote:
Tue Nov 20, 2018 1:38 pm
Why Are People Turned Off By the Name BASIC?:
...
BASIC is a good usable language, that is discouraged.
I don't think it is so dramatic. There are just often better languages to chose from so there is no need to stick to Basics.
While you can make the list of Basic basic features very long I somehow don't find anything that is better than with other languages.
Yes it is usable language. So what? I grew up with C64 Basic (and Simons Basic) then moved to Amiga (and AMOS) Basic, did (too much) stuff in Visual Basic yet somehow I didn't find anything good in particular that would be worth of sticking with it. And I find the name of the language quite fitting. It tells exactly what is good about it. And once you start adding advanced features to it then it becomes something else and you lost the best feature.

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 3:15 pm

fanoush wrote:
Tue Nov 20, 2018 3:11 pm
And I find the name of the language quite fitting.
It stands for Beginners All purpose Simple Instruction Code

jardino
Posts: 129
Joined: Wed Aug 08, 2012 9:03 am
Location: Aberdeenshire, Scotland

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 4:03 pm

Touching on Heater's post:

I was once hired to prise a Dutch company off their use of BASIC. They had been using it a lot for their commercial systems, then won a contract for a large real-time project and were totally floundering trying to get BASIC to handle multiple interrupts from disparate sensors.
Alan.
IT Background: Honeywell H2000 ... CA Naked Mini ... Sinclair QL ... WinTel ... Linux ... Raspberry Pi.

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 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?
ShiftPlusOne wrote: In what sense is it discouraged? RPF have chosen python, but I don't see them telling people not to use BASIC if they want to.

I think when people make the decision of what language to use, it's more practical than worrying about goto statement or line numbers. Nobody really cares about any of that, it's just a reason they might give when pressed to give a reason.
The lack of any provision for people to learn BASIC, and the strong push of other languages, I think make a huge statement against BASIC by RPi. My view.
What's the job market like for BASIC vs Python? If Python already does what people need, what's the motivation for them to use something else? Why don't Google, MS, Mozilla or anybody else who has the most on the line use BASIC?
They are not on with Python any more than BASIC. There are many other questions about those two companies that would discount that argument in my view. Though this is not about talking about companies.

Neither one has much of a job market (though both do have a small job market).
If BASIC has an image problem, I'd say lead by example. Release software written in BASIC that outperforms existing solutions and that people love using. Start a BASIC meetup in your area. See if there are any students wanting to introduce BASIC in their schools. If that's not happening, it seems like there's a problem with BASIC itself and that most people just don't enjoy using it as much as other languages.
Fair poitn overall, EXCEPT FOR:
Many students do get into modern structured BASIC, and do a lot with it, and really like it. Then they get into university, and there prof tells them something along the lines of "BASIC is evil, it will create bad habbits that can not be reversed" and they run from BASIC on the word of another, usually the prof was talking about the old limited BASIC that was the last he/she used. Often these students are seen to decrese in productivity after they leave BASIC.

AND: BASIC compilers do not get the same attention as C compilers, so optimization legs behind a bit. All because of the poor image of BASIC.
"Structured Programming" as it was formulated in the 1850's / 60's does not say anything about data types or typed variables. neither were those things mentioned when I was taught the principles of Structured programming in the 1970's.

Rather Structured Programming is all about structuring ones flow of execution and specifying it. You know, sequence, selection, iteration, recursion. With some notion of functions and procedures.
This is true. Though I am speaking of structured programming as taught in university.
Having dynamic typing like Python or Javascript removes a lot of syntactic noise from a language design. Which is of great advantage when starting out rank beginners.

Now, until BASIC can toggle a GPIO pin on a Raspberry Pi 3 at 50MHz or calculate the first million digit Finonacci number in 13 seconds on my PC I see no reason to look at it.
Toggling a GPIO on the RPi from BASIC at high speed has been done many times over. The limit is not usually the language, it is the Hardware.

The Finonacci number is something I do not even think you could do on a much more powerfull system with the best optimizing compiler in any programming language, that is unreasonable.
People don't use basic because it went out of fashion for teaching and in the recent up surge in computing again in UK schools then scratch at the start and python later on are now the recommend tools. Some use Visual Studio if they want as well and whichever basic/c/.. they wish to use there.
Because they are what people may use when they are in jobs.
As is BASIC (for some closed source stuff you will be surprised), not allowed to say anything more specific, though there are companies that prefer modern BASIC and make closed source products that are used by millions of customers.

Ok I can see C, as it is used quite heavily commercially. Though it seems that Python is more of a hobbiest language than proffesional.
I don't think it is so dramatic. There are just often better languages to chose from so there is no need to stick to Basics.
While you can make the list of Basic basic features very long I somehow don't find anything that is better than with other languages.
No language is really better than most in any way. That is part of the point.

FYI, the BASIC on the C64 was an example of the wrong way around it, and not a good example of even the BASIC versions of that time. I do not know AMOS, on Amiga I used originally AmigaBASIC, then a few compilers compatible with AmigaBASIC with some extensions.

Yes it is a language that originally targeted beginners, and is still good at that, my primary point.

Though for those that wish to continue to use it, it has grown up to a full rich structured language, that can be applied for major projects.

That does not say that people should stick with it, just that for beginners it should be more readilly available if they wish to try it, and not be put down by those that remember a BASIC that no longer exists.

I have attempted to make most of these same points in favor of the C programming language, though it seems that people do not see it as easy, even though it is easier than Python for those students here that are taking part in a program to see what language works best for a begginner language. The instructers are carefull of teaching method so that the teaching method does not stand in the way of the language, trying to see what language really does work best.

So far it seems that young students do best with BASIC, with C being a close second, Pascal after that, then Java, after that is Scratch, further down the list is Python. Knowing this information (as I helped push the project into exestence a few years ago) is part of the many reasons that I mention it. And why I attempted to word the opening of this thread to actually have a positive descussion.
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: 4598
Joined: Wed Feb 04, 2015 6:38 pm

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 4:56 pm

DavidS wrote:
Tue Nov 20, 2018 4:36 pm
The Fibonacci number is something I do not even think you could do on a much more powerfull system with the best optimizing compiler in any programming language, that is unreasonable.
It can be done!

Code: Select all

$ time ./fibo | wc -c
1000001

real	0m0.196s
user	0m0.192s
sys	0m0.000s
The extra 1 is the final newline.
That was in C, on a six year old Intel PC.

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 5:07 pm

DavidS wrote:
Tue Nov 20, 2018 1:38 pm
BASIC is a good usable language, that is discouraged ...

it seems as if the RPi Foundation discourages the use of BASIC, in preference to languages that have a higher barrier of entry to new programmers, and in some cases are more limited.
I do not believe the Foundation discourages Basic beyond choosing to recommend other than Basic. I see no discouragement of using Basic just as I do not see discouragement of using Go, Java, Javascript, Lua, Pascal, Perl, Ruby or any other language.

But in more general terms there is a pervasive discouragement of using Basic.

That's something which has always interested me as someone who has long been a fan of Basic; TurboBasic, PowerBasic, VB3 through VB6, VB.Net ( though not so much a fan there ), RealBasic (Xojo), FreeBasic, and even BBC Basic. It's been the language I have most used, and I have used it for most things from utilities to compilers. Sometimes just to prove that "it can't be done, nor as easily, with Basic" is utterly false, prejudice or simply ignorance.

There was at least one huge thread on the forum from before the Pi was ever released which covered the debate on the appropriateness, or not, of Basic, AFAICR -

viewtopic.php?t=1705

I think there's one thing telling in all such discussion; "Basic" or "BASIC". I think that often reveals a significant detail of the perspectives people hold; "Basic" as a modern programming language or "BASIC" with all the baggage and limitations from what it originally was, complete with the the unfortunately lingering "Beginner's" label which people choose to drag out when they wish to criticise, demonise or ridicule it. "It's for kids, not serious competent professionals" has haunted Basic for years.

Most of the objection to Basic is merely ignorance, prejudice, by rote, or as a seized opportunity to hate upon something. It has found itself at the bottom of the pile. Basic and proponents of it considered 'fair game' by most. Usually for no good reason, and often those who do criticise have never actually used a modern Basic.

That reflects other pervasive social attitudes so good luck trying to convince those who have decided it's the worst possible language in the world that it isn't. No matter what one's preferred programming language; 'everyone agrees' it's better than Basic.

So, for all my love of Basic; why have I now moved to using Python ?

Not because it's a better language, simply because it's a language which, to me, is 'pretty much the same as Basic', and it is multi-platform, and, setting aside the Python 2 and Python 3 issues, has a universally standardised specification.

I would have kept with using Basic, would have preferred to, but the reality is that if one wants to write code once, use it anywhere, Basic isn't the right choice for that. Basics usually aren't even compatible with each other. Choose any variant and you're already walking yourself into a corner.

I wouldn't discourage people from using Basic because of what Basic is, but I would discourage people from using Basic because of the limitations choosing that imposes. I would recommend using a language like Python or Javascript ( maybe C though I personally detest using it myself ) which is far more widely supported across the platforms one may come to use.

Had there been some multi-platform Basic which had seen widespread adoption I would have likely gone with that. But there wasn't and isn't.

And why did I choose Python over anything else ?

Because I wanted to join in with the Pi journey and Python had been embraced by the Foundation and that seemed the best option for me of what was available at the time, looked to have the least steep learning curve, and the closest to Basic of the choices on offer. I guess it also helped that the white space indentation didn't faze me having already used programming languages which used the same.

The bottom line was that if I wanted to join in the fun, share with others, to educate or even show off, maximise my usefulness and returns, I would have to adopt something which could be shared and be useful to a wide audience. Basic does not fit that bill.

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 5:11 pm

For an example, an excerpt from a project that I am currently working on to be used.

It would be hard to find a language in which this code can be implemented more eloquently than it is in C:

Code: Select all

//*******************************************************************
//We are going to select the next task in queue, based on priority.
//The Round Robin algorithm is long gone, replaced by a binary place
//  change algorithm that assures static priorities and 100% of tasks
//  get there time.
//When counting in binary it is for certain that only one bit will
//  transition from a 0 to a 1 value, and each higher bit takes
//  twice as long between switching.  This is a good priority
//  scheduling method (val ^ (val+1) & val) gives the one bit that
//  switched.
//*******************************************************************
long NextTask(void)
{
  //We count until we swith a bit to one that corisponds with a queue
  //  having at least one runable task.
  int SwTo, LpEnd, bit;

  LpEnd = 0;

  while (!LpEnd)
  {
    //Get just the bit that changes for next count.
    SwTo = CurPri ^ ((CurPri + 1) & 0xFF) & (CurPri + 1);
    //Determine the bit position (would be easier in asm).
    for (bit = 7; !((1 << bit) & SwTo); bit--);

    //Increase the priority count, for the next pass, and wrap around
    //  at 255 to keep it in 8 bits.
    //A priority counter changing to zero does not have any bits that
    //  changed to 1, therefor skip the value 255 (as that would wrap to 0).
    CurPri = (CurPri < 0xFE) ? (CurPri+1) & 0xFF : 0;


    //If there is a runnable thread in that priority switch to it,
    //  this does not start the task running, it just sets the task
    //  to run next time we return to user mode.
    if (TskRunCnt[bit])
    {
      TaskSwitch(TskQueue[CurTsk[bit]].next);
      LpEnd = 1;
    }

  }

  //Yes we actually return, so that the OS can do other usefull work,
  //  or just to give the now active task time to run.
  return 0;
}
NOTE: this source also on my site.

And yet other languages are seen as a better option for beginners. It could actually be done this well in a modern BASIC, though that is only part of the point.

Or what about something like a program that uses the GUI:

Code: Select all

#include "MWimp.h"

//Set buffers for system calls.
long TBlock[255], WData[255], *WDataTop;
long THandle;        //Task Handle.
long WindowH[2];     //Window Handles.
long BarIconH;       //Icon handle for IconBar Icon.
long Quit = 0;       //Quit flag.

//Setup the IconBar Icon block.
CIconBlock BarIcon = {-1,0,0,68,68,0x3002,{"!t00wimp"}};

//Create an empty menu.
NewMenu("Wimp Tut 0",Menu0,2)


//**************************************************************************
// Copy string t into string s, no bounds checking at all.
//**************************************************************************
char *strcpy(char *s, char *t){
  for(int cnt = 0; (s[cnt] = t[cnt]); cnt++);
  return s;
}


//**************************************************************************
//Handle a Mouse Click event.
//**************************************************************************
void MClick(void){
  if (TBlock[3] == -2){     //If in Icon bar icon:
      switch (TBlock[2]){
        case 1: break;      //Adjust click do nothing.
          //Menu Click, open the default menu.
        case 2: Wimp_CreateMenu(&Menu0,(TBlock[0] - 64),188);break;
          //Select Click open the main window, or refresh.
        case 4: TBlock[0] = WindowH[0];
                Wimp_GetWindowState(TBlock);
                Wimp_OpenWindow(TBlock); break;
    }
  } else if (TBlock[3] == WindowH[0]){  //If in the main window:
      switch (TBlock[2]){
          //Menu Click, open main menu.
        case 2: Wimp_CreateMenu(&Menu0,(TBlock[0] - 64), TBlock[1]); break;
      }
  }
}


//**************************************************************************
//Handle a menu selection.
//**************************************************************************
void SelMenu(void){
  switch (*TBlock){
      //Item 0 is Information box.   We open the info window.
    case 0: TBlock[0] = WindowH[1];
            Wimp_GetWindowState(TBlock);
            Wimp_OpenWindow(TBlock); break;
      //Item 1 is quit, so we set to quit.
    case 1: Quit=0x0f; break;
   }

}


//**************************************************************************
// Handle Wimp events, and poll (cooperative multitasking).
//**************************************************************************
void PollLp(void)}
  while (!Quit){ //Loop while quit flag is 0.
  long r = Wimp_Poll(0x2301,TBlock,(long *)0); //Poll and get the return.
    switch(r){
     case 2: Wimp_OpenWindow(TBlock); break;  //Refresh event.
     case 3: Wimp_CloseWindow(TBlock); break; //Close Event.
     case 6: MClick(); break;                 //Mouse Click.
     case 9: SelMenu();                       // Menu Selection.
       break;
     case 17:
     case 18:                                 //Message.
      if (TBlock[4] == 0) Quit = 0x0f;        //Only handle quit messages.
      break;
    }
  }
}


//**************************************************************************
//Clean up before quiting.
//**************************************************************************
void CleanUp(void){
  Wimp_CloseDown(THandle,0x4b534154);
  return;
}


//**************************************************************************
int main(void){
  //Initialize ourselves as a Wimp Task.
  THandle = Wimp_Initialise(310,0x4B534154,"Wimp 0",(long *)0);

  //Set the IconBar Icon on the IconBar.
  BarIconH = Wimp_CreateIcon(0,&BarIcon);

  //Load  the main window definition from the template resource.
  Wimp_OpenTemplate("<T00Wimp$Dir>.Templates");
  long *toff;
  if (!(toff=Wimp_LoadTemplate(TBlock,WData,WData+64,"main\0"))) {
    CleanUp(); return 0;
  }
  WindowH[0] = Wimp_CreateWindow(TBlock);

  //Load the Info window definition from the template resource.
  if (!Wimp_LoadTemplate(TBlock,toff,WData+256,"info\0")) {
    CleanUp(); return 0;
  }
  WindowH[1] = Wimp_CreateWindow(TBlock);
  Wimp_CloseTemplate();

  //Setup the menu entries.
  Menu0.i[0].f = 0;
  Menu0.i[0].sub = WindowH[1];
  Menu0.i[0].icf = 0x07000021;
  Menu0.i[1].f = 0x80;
  Menu0.i[1].sub = -1;
  Menu0.i[1].icf = 0x07000021;
  strcpy(Menu0.i[0].name, "Info...\0");
  strcpy(Menu0.i[1].name,"Quit\0");

  //We are mostly idle for now.
  PollLp();

  CleanUp();
  return 0;
}
That seems to make a good case for how simple C is. People have already seen many examples of the same in BASIC and Assembly language (many posted by me).

So many feel that C is a poor option for beginners. The water on BASIC seems. to be an interesting mix. Yet the study project seems to be proving these to be the two easiest to teach modern languages to very young students with no prior experience with programming.
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

Andyroo
Posts: 4141
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 5:11 pm

DavidS wrote:
Tue Nov 20, 2018 2:11 pm
@AndyRoo:
It apears that you did not read my initial post.
...
You are again thinking about ancient BASIC.
Actually I did - I pointed it my notes where ancient history as I was around when BASIC died and the reasons I added where why I saw BASIC fall out of use in both my own teams and suppliers :lol:

Computing is driven by the 'next best thing' even now.

I would also add:

It became associated with home computers
With the rise of the Sinclair and Amstrad machines in the UK, BASIC was quickly associated with home machines where you typed in code from magazines or loaded from tape. I remember folk using the Commodore PET series questioning the BASIC inbuilt as not being suitable for large programs and one supplier (still on the go as a company) moving to COBOL to combat against CP/M systems written in the 'mainframe' language of the day :o :roll:

Remember part of general educations aim is to teach usable (and therefor marketable) skills again to the new generation of coders. Have a look at https://usersnap.com/blog/programming-languages-2018/ or https://www.codingdojo.com/blog/7-most- ... s-of-2018/ etc. to see what the market uses. The Foundations strategy does not state any specific language and who knows - a learning resource may come out in BASIC or C in the future.

Don't get me wrong - I've used at least 10 high level languages and a fair number of low level ones (inc hand assembly and hex code entry) and BASIC was around my 3rd or 4th - the new compilers are great but the marketplace does not see that. If I want to earn a living as a coder I would not choose BASIC.
Need Pi spray - these things are breeding in my house...

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 5:15 pm

hippy wrote:
Tue Nov 20, 2018 5:07 pm
That's something which has always interested me as someone who has long been a fan of Basic; TurboBasic, PowerBasic, VB3 through VB6, VB.Net ( though not so much a fan there ), RealBasic (Xojo), FreeBasic, and even BBC Basic.
DavidS mentioned several more types of Basic. Just how many are there?

There are two Python's which is a huge problem IMO.

There is only one C. Sure its evolved over the years C89, C99, etc as the ISO standards are revised and the language evolves. But it is only one language.

Andyroo
Posts: 4141
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 5:18 pm

One thing I love about this thread is comparisons of 'benchmark' tests of one language vs another :lol:

Having written a cross compiler and worked on a couple of others, the user language makes little difference if the interpreter or compiler kicks out waffly or poor machine code. I've first saw COBOL run both like a snail and a greyhound on a 6502 machine and it was all down to the assembler routines that came out of the compile stage. For most businesses a few seconds here and there make very little difference. I would rather have a sensible error trap rather than some obscure text that saves me milliseconds - and BASIC was always good for that.
Need Pi spray - these things are breeding in my house...

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

Re: Why Avoid BASIC on RPi?

Tue Nov 20, 2018 5:26 pm

DavidS,
Though I am speaking of structured programming as taught in university.
You assume I was not. I was. Or you can read it for yourself in the original publications. For example:
https://dl.acm.org/citation.cfm?id=3656 ... dl=ACM#CIT
https://dl.acm.org/citation.cfm?id=1243 ... =GUIDE#CIT
Toggling a GPIO on the RPi from BASIC at high speed has been done many times over. The limit is not usually the language, it is the Hardware.
That is good. My challenge then is: Show an example, in the BASIC of your choice, of toggling a GPIO pin on a Raspi 3 at 50MHz. My example in C is here: viewtopic.php?f=63&t=200793&start=25#p1252388
The Finonacci number is something I do not even think you could do on a much more powerfull system with the best optimizing compiler in any programming language, that is unreasonable.
Prepare to be amazed. This Python program computes the first Fibonacci number with one million digits, fibo(4784969), in about 8 seconds on my PC:

Code: Select all

import math
import timeit


fibs = {0:0, 1:1, 2:1}

def fibo(n):
    if n in fibs:
        return fibs[n]

    k = (n + 1) // 2
    fk = fibo(k)
    fk1 = fibo(k - 1)
    if n & 1:
        result = fk ** 2 + fk1 ** 2
    else:
        result = (2 * fk1 + fk) * fk
    fibs[n] = result
    return result


run_time = timeit.timeit('fibo(4784969)', setup="from __main__ import fibo", number=10)


print(fibo(4784969))
print('Run time = {}'.format(run_time))
Or this in Javascript in about 12 seconds:

Code: Select all

function isEven(n) {
  return (n & 1) === 0;
}

let memo = [BigInt(0), BigInt(1), BigInt(1)]

function fibo (n) {
  if (memo[n]) {
    return memo[n];
  }
  let k = (n / 2) | 0;
  if (isEven(n)) {
      return memo[n] = fibo(k) * ((fibo(k + 1) * 2n) - fibo(k));
  }
  return memo[n] = fibo(k) ** 2n + fibo(k + 1) ** 2n;
}

function timeIt (f, k) {
  t = new Date()
  let res = f(k)
  dur = new Date() - t
  console.log(res)
  console.log(dur + "ms")
}

timeIt(fibo, 4784969)
For timing on Pi see thread here: viewtopic.php?f=32&t=225927&start=25#p1388181

My challenge then is: Show code that computes fibo(4784969) in the BASIC of your choice and report it's run time.
I have attempted to make most of these same points in favor of the C programming language, though it seems that people do not see it as easy, even though it is easier than Python for those students here that are taking part in a program to see what language works best for a begginner language. The instructers are carefull of teaching method so that the teaching method does not stand in the way of the language, trying to see what language really does work best.
That is interesting. Where is here? I'd like to read their methods and results.

Return to “Off topic discussion”