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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 7:33 pm

Heater wrote:
Fri Apr 12, 2019 7:16 pm
jahboater,

It's true that when selecting a language fro a task there is actually a lot more than just the actual language syntax and semantics to weigh up.

Is it any kind of standard?
Does it have a large use base?
Is there good documentation, tutorial, books etc available for it?
Are there multiple vendors for compilers/interpreters?
Does it perform well?
Does it fit in the space available?
And so on, and so on.

Certainly having a wide range of good quality libraries and modules available ranks high on the list of desirable features.

But this thread has been about writing code (and reading it), in the language, syntax and semantics.
That is one tangent it went off in for a long time, it is not what was asked at the starts.
It then went of on a script basic tangent.and then MD5 was asked, no limits on what could be used.
I used what was *built in* to Python 3.5.? and whatever is on my mobile phone.
So in my mind, a standard library if you must.
You might want it go back and re-read what was actually asked.

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 7:35 pm

ScriptBasic,
Nice job with the JavaSript MD5!
I have to own up. I did not write that MD5. Just found it on the net somewhere, cleaned up the formatting a bit and made the test cases work.

Old school JS programmers think it's efficient to put lot's of code into one line, 2000 chars wide in this case!

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 7:50 pm

bensimmo,
You might want it go back and re-read what was actually asked.
I have done so. A few times already.

The main question is still "Why Avoid BASIC on RPi?". Although the last paragraph gives away DavidS' real question.

"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."

Clearly what DavidS is really asking is "Why does the RPi Foundation not encourage BASIC, why do the promote those other languages?"

It's not "Why avoid...?", it's "Why do they avoid...?"

A question that I think has been answered well enough many times here.

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 8:02 pm

Which if i remember correctly, was also shortly after Eben had not avoided basic, by doing a blog and talks on writing for BBC basic.
https://www.raspberrypi.org/blog/learn- ... with-eben/

Why not move to a more complicated programming setup that would aid teaching and science by discovering the world around them.
Not just some number crunch.

Used by many people for all sorts of things.
So a simple datalogger logger program for all the sensors on the RPi SenseHAT and a colourful rainbow on the LED.

Then look at the differences.

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 8:48 pm

bensimmo wrote:
Fri Apr 12, 2019 8:02 pm
Which if i remember correctly, was also shortly after Eben had not avoided basic, by doing a blog and talks on writing for BBC basic.
https://www.raspberrypi.org/blog/learn- ... with-eben/

Why not move to a more complicated programming setup that would aid teaching and science by discovering the world around them.
Not just some number crunch.

Used by many people for all sorts of things.
So a simple datalogger logger program for all the sensors on the RPi SenseHAT and a colourful rainbow on the LED.

Then look at the differences.
Earlier in this thread I suggested that the next point of comparison concerning why to avoid Basic should be the construction of a graphical networked version of the classic Star Trader game.

Unfortunately, designing client-server applications with mouse interfaces, even with the promise of having a tournament to play the game afterwards, didn't seem rewarding enough for anyone to begin. Maybe because that challenge was too much like designing a shopping cart for a website. It should also be noted that courses on algorithms form a core part of most computer science curricula while game design and web programming are special topics.

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:01 pm

ejolson wrote:
Fri Apr 12, 2019 8:48 pm
bensimmo wrote:
Fri Apr 12, 2019 8:02 pm
Which if i remember correctly, was also shortly after Eben had not avoided basic, by doing a blog and talks on writing for BBC basic.
https://www.raspberrypi.org/blog/learn- ... with-eben/

Why not move to a more complicated programming setup that would aid teaching and science by discovering the world around them.
Not just some number crunch.

Used by many people for all sorts of things.
So a simple datalogger logger program for all the sensors on the RPi SenseHAT and a colourful rainbow on the LED.

Then look at the differences.
Earlier in this thread I suggested that the next point of comparison concerning why to avoid Basic should be the construction of a graphical networked version of the classic Star Trader game.

Unfortunately, designing client-server applications with mouse interfaces, even with the promise of having a tournament to play the game afterwards, didn't seem rewarding enough for anyone to begin. Maybe because that challenge was too much like designing a shopping cart for a website. It should also be noted that courses on algorithms form a core part of most computer science curricula while game design and web programming are special topics.
Probably because it's a computer science curricula and not a web or game design curricula.
There is nothing wrong with algorithms, the basics are taught in senior school and even on primary school even if they don't know it.
It's part of computing.
But it doesn't really show off a language and why or why not to use it.
In C some smart people wrote a compiler to take take the efforts you gave it and make it work really well.
Hats of the the people that can use both together to improve their algorithm.

That's (at a higher level) like knowing the intricacies of Python and which and where you locals are used and to use import math, install and import numpy or just use plain python code.

I'm sure Basic has its own intricacies to make its algorithm coding better (as seen between while and for in ScriptBasic).

But that is language specific programming ?

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:03 pm

jahboater wrote:
Fri Apr 12, 2019 7:31 pm
The success of C, at least initially, was the deliberate choice to have a simple language combined with a powerful run time library. That was compared to languages like PL/1 and Algol68 that had everything built into the language syntax. The simplicity of C meant that it was cheap and easy to write and port compilers for it. That helped its spread of course and the difficulty of writing compilers for the other languages mentioned helped their demise.
In my opinion, the success of C was due to

. Dennis Ritchie's C compiler generated code for the PDP-11 that was efficient enough to replace the existing assembler routines.

. The C code was easier to read and write from a programmer's point of view compared to assembler.

All further developments about machine independence, implementation and portability would never have been a concern if the performance was bad or the language difficult to understand.
Last edited by ejolson on Sat Apr 13, 2019 2:14 am, edited 3 times in total.

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:03 pm

ScriptBasic MD5

Code: Select all

IMPORT t.bas

m = t::MD5("My Name is John")
FOR i = 1 TO LEN(m)
 PRINT HEX(ASC(MID(m, i, 1)))
NEXT
PRINT
[email protected]:~/sbrpi/examples $ time scriba md5.sb
877E569DB07520884C36DF5183375780

real 0m0.019s
user 0m0.010s
sys 0m0.009s
[email protected]:~/sbrpi/examples $

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:12 pm

ScriptBasic wrote:
Fri Apr 12, 2019 9:03 pm
ScriptBasic MD5

Code: Select all

IMPORT t.bas
What is the significance of "t" ?

Code: Select all

m = t::MD5("My Name is John")
FOR i = 1 TO LEN(m)
 PRINT HEX(ASC(MID(m, i, 1)))
NEXT
PRINT
Ugly code to print out the result....
Python solutions are much cleaner

Code: Select all

import hashlib
hash = hashlib.md5()
hash.update(b"My Name is John")
print(hash.hexdigest())
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
ScriptBasic
Posts: 579
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:17 pm

What is the significance of "t" ?
t.bas is the include file for the C (t)ools extension module.

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:19 pm

bensimmo wrote:
Fri Apr 12, 2019 7:24 pm
ejolson wrote:
Fri Apr 12, 2019 7:01 pm
In particular, even though an MD5 subroutine library already exists, it will take more than a script kiddie to develop and code the algorithms of the future.
At which point they would have to move out of Python or Avoid Basic and to something else where you have to do the harder work.
One might also wonder why bother to learn Python or Basic in the first place if every new algorithm has to be coded in a different language anyway.

Since non-professional programmers do not have the time to fill their toolboxes with multiple domain-specific programming languages, it might be better for beginners to start with a general-purpose language that is suitable for more than simply scripting subroutines together.
Last edited by ejolson on Sat Apr 13, 2019 2:11 am, edited 2 times in total.

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:21 pm

ScriptBasic wrote:
Fri Apr 12, 2019 9:17 pm
What is the significance of "t" ?
t.bas is the include file for the C (t)ools extension module.
Then call it tools.bas not some meaningless single letter name.

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

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:34 pm

Heater wrote:
Fri Apr 12, 2019 1:05 pm
Only 140 lines of code [for JavaScript] vs 371 for the ScriptBasic above.
The x86 assembler version of MD5 on Rosetta Code results in the following comparison:

Code: Select all

$ wc md5.*
  370   832  6451 md5.bas
  140  1238  6181 md5.js
  267   848  5515 md5.x86
  777  2918 18147 total
It is interesting that JavaScript has the fewest lines, Basic the fewest words and x86 assembly the fewest bytes. What remains to be seen is

. Which version has the fewest bugs?

. How fast the x86 version runs on the Pi under QEMU?

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:42 pm

FYI:

The difference between IMPORT and INCLUDE is IMPORT will only include the code once where INCLUDE will include it unconditionally.

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:45 pm

ScriptBasic,
The difference between IMPORT and INCLUDE is IMPORT will only include the code once where INCLUDE will include it unconditionLy.
In which language are you talking about there?

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

Re: Why Avoid BASIC on RPi?

Fri Apr 12, 2019 9:57 pm

ScriptBasic

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

Re: Why Avoid BASIC on RPi?

Sat Apr 13, 2019 7:13 am

ejolson wrote:
Wed Apr 10, 2019 2:33 am
Heater wrote:
Tue Apr 09, 2019 6:24 pm
Amazing. 1000 BASIC dialects listed here and the one True BASIC is not included: https://www.truebasic.com/
It would appear that True Basic runs only on the one true operating system: Microsoft Windows.

Coming soon to a forum thread right here: Fortran Man and The Fibonacci Code--a cartoon written by neither Lee Schneider, Todd Voros nor Dan Brown.
Fortran Man and the Fibonacci Code
Draft version (dialogue only).

B. Where are all these rabbits coming from? Look! There were 2 then 3 then 5 now 8...
F. Don't worry. As soon as I finish compiling I'll start an execution.
B. But F-man. The rabbits are cute. Please reset that execute bit.
F. I'm afraid it's necessary, Billy. Karatsuba will conquer and divide their multiplication.
B. Wait. I've got an idea. I'll use an interpreter to find out what those rabbits want?
F. Okay. But be careful.
N. Billy goes into interactive mode to interpret when suddenly...
B. F-man! Help! They are using Cassini's identity and doubling. It will take a million digits. I think my stack is about to overflow.
F. I told you! Quick! Remove the recursive declarations from your subroutines.
B. I can't F-man, my functions are recursive by default.
F. Then I'll switch your version to EMCA-55 minimal line-numbered mode and goto the end.
N: Moments later...
B. What? Wait! Who am I? What happened? Is it I, or is it not I?
F. You are Basic and I am Fortran.
B. But your code looks all wobbly. Things should begin in column 7 and where are the common blocks?
F. Don't worry Billy. These days I'm structured, object oriented and even allow coarrays.
B. But Dartmouth is...
F. Not since 1972. You are just disoriented Billy. I switched you to an incompatible version because Fibonacci was overflowing your stack.
B. Er. My favourite Fibonacci is The Last Supper.
F. Imagine that! Speaking of supper, do you like rabbit?
B. Sure, as long as there is Raspberry Pi for dessert.
Last edited by ejolson on Sat Apr 13, 2019 3:38 pm, edited 2 times in total.

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

Re: Why Avoid BASIC on RPi?

Sat Apr 13, 2019 8:00 am

My RPi 3 B+ arrives today Do you think I would be wasting my time exploring a 64 bit OS with ScriptBasic compiled for 64 bit for the RPi?

I only discovered recently that Raspbian was a 32 bit OS. Personally I feel Raspbian will go 64 bit with the introduction of the RPi 4.

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

Re: Why Avoid BASIC on RPi?

Sat Apr 13, 2019 8:08 am

ScriptBasic wrote:
Sat Apr 13, 2019 8:00 am
Do you think I would be wasting my time exploring a 64 bit OS with ScriptBasic compiled for 64 bit for the RPi?
No - as you know, with the Pi you may just swap SD cards in and out to try different OS's with no risk.
This one is popular, it is what I use:-
https://github.com/sakaki-/gentoo-on-rpi3-64bit
ScriptBasic wrote:
Sat Apr 13, 2019 8:00 am
Personally I feel Raspbian will go 64 bit with the introduction of the RPi 4.
Possibly, but if you write portable code you will not notice the difference!

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

Re: Why Avoid BASIC on RPi?

Sat Apr 13, 2019 8:29 am

I'm hearing that if ScriptBasic were on the scene sooner, it would have been easier to get folks to use it. As it is, I'm late to the party and users already high on other languages.

That said, I feel my time would best spent getting a decent GPIO extension module built for SciptBasic on the RPi. My thoughts at this time is using the pigpio C library as it's base.

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

Re: Why Avoid BASIC on RPi?

Sat Apr 13, 2019 9:00 am

I'm curious why JavaScript isn't more popular on the RPi than Python? Is there some special relationship the Raspberry Pi foundation has with Python that everything seems based on it?

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

Re: Why Avoid BASIC on RPi?

Sat Apr 13, 2019 9:32 am

Special?
The Pi in RaspberryPi is for Python.

Mainly as the choice of language that school children would be using.
It is/(was and even more so) the go to beginners text only language.

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

Re: Why Avoid BASIC on RPi?

Sat Apr 13, 2019 9:49 am

ScriptBasic,
I'm curious why JavaScript isn't more popular on the RPi than Python?
I'm curious as well.

It's not just Pi world. Javascript is universally derided by "real programmers". Despite the fact that it is a very elegant and capable language. Simple enough for the most rank beginners to start with but sophisticated enough to keep the experienced happy. JS has always had advanced languages features like, first class functions, lambda's, closures, that other mainstream languages are only recently acquiring.

With the event driven model of JS it is very suitable for many of the kinds of projects that people do on a Pi where they need to juggle lots of external inputs, GPIO, network, serial, timers, etc. All of this is much harder to do in Python or languages that require threads. This recent post is an example of the mess people get into when trying to use Python to do this kind of thing: "Python recursion error" - viewtopic.php?f=32&t=238083

I suspect a big part of the reason for this is that it's only relatively recently that JS became available for stand alone applications (not in the browser) with the arrival of node.js. Before that Python had already gained a huge following.

Now, all the world and his dog is jumping on Python. I find it very disturbing.

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

Re: Why Avoid BASIC on RPi?

Sat Apr 13, 2019 9:52 am

RPi = Raspberry Python Interpeter

Who would of guessed?

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

Re: Why Avoid BASIC on RPi?

Sat Apr 13, 2019 9:53 am

ScriptBasic,
I feel my time would best spent getting a decent GPIO extension module built for SciptBasic on the RPi.
Oh yes. To gain any traction in the Pi world a language system needs to have support for GPIO, SPI, I2C, serial ports, etc, easily available and easy to use. Preferably out of the box.

That is way more important than 64 bit support which most people don't have and don't need.

Return to “Off topic discussion”