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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 10:41 pm

ScriptBasic,
Do you feel suggesting BASIC to a beginner looking to understand how programming works would be counter productive and a waste of time?
I think it would be as good an introduction as it ever was.
If you started off learning programming in BASIC, is it now a regret?
I was first introduced to programming, using BASIC in 1973. At the time I was awestruck by it. I considered myself lucky to even get time on a computer, at a time when most people had never even seen one.

But it was only a very small part of what we had going on at the time. We were expected to get familiar with "structured programming" which our BASIC did not enforce. We were expected to be able to use assembler. Then there was all the numerical analysis and statistics that was part of the CS course. Then there was all the pure maths and physics I had going on in other courses.

Do I regret starting with BASIC? No. But it was only a matter of months before I realized I needed something more.

But let's turn the question around: When introducing young kids to programming today what advantage does using BASIC have over many other languages that are also very easy to start with yet capable of taking them much further?

Anecdote:

When I showed my 11 or 12 year old son Python years ago he was not impressed, looking at it as if, "so, it's a calculator"

So I showed him how it could do arithmetic on huge integers. At that he spent an hour exploring the limits and trying to break it. After which he announced "This is cool, I have to tell my teacher about this"

I'm not a Python fan but for sure it can me used to introduce programming from the most simple things, in a very simple way.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 10:59 pm

But let's turn the question around: When introducing young kids to programming today what advantage does using BASIC have over many other languages that are also very easy to start with yet capable of taking them much further?
That's the problem. You relate the word BASIC as limited functionality. I have shown time and time again where I run circles around Python in less code that is easier to follow.

Show me a Python GUi example that does what I have shown with IUP.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 10:59 pm

ScriptBasic,
This is the first time I have had to deal with precision outside the hardware's native limitations.
What?

You never programmed an 8 or 16 bit processor?

Heck, even 32 bit hardware is not enough for many common tasks.

You never wasted your time tweaking your code to zoom in to more and more detail of the Mandlebrot set?

You never dealt with cryptographic algorithms?
I'm sure someone will chime in and give us a practical use of generating million digit integers.
Perhaps not many. I can't think of one.

I have to reiterate that the fact this challenge is about a million digit Fibonacci number is not the point. That is just an algorithm to show how people write code in whatever language they prefer, it's just code, it could have been anything.

But the Fibonacci is a concise and simple thing to specify as a coding challenge.
My approach to features not native to language is add the feature as a C extention and be done with it. That is what the open source movement is based on. Not having to recreate the wheel with every project.
Sound fine to me.

If you have a tricky thing to do in BASIC, do it in C.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 11:09 pm

I love it when some Windows nerd bad mouths Linux but spends most of his/her day using it via a browser.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 11:18 pm

ScriptBasic,
That's the problem. You relate the word BASIC as limited functionality.
When I say "BASIC" I mean BASIC.

Certainly there are a myriad of other totally different languages that happen to have "BASIC" in their name. Can't keep up with them all.
I have shown time and time again where I run circles around Python in less code that is easier to follow.
Hmm.. where is your fibo(4784969) in ScriptBasic again?
Show me a Python GUi example that does what I have shown with IUP.
OK. You got me there. I don't do GUIs much. Most programmers don't. When I want a GUI now a days I do it with Javascript in the browser, nice and simple.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 11:21 pm

You never programmed an 8 or 16 bit processor?
I worked on systems where BASIC and the OS were one and we ran 12 user terminals in a total of 256KB of system memory.

Please reread my comment. I said I didn't have to emulate prcission outside the hardware's limitations.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 11:28 pm

Hmm.. where is your fibo(4784969) in ScriptBasic again?
It was two statements at under 2 sec on the RPi 3 B. Did you miss it? It was based on GMP.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 11:33 pm

I know. That is great and all. But it is not what the fibo challenge calls for. The idea is to show how one writes algorithms in ones language of choice. Anyone can make a call to a function that is written in some other language.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 11:36 pm

GMP is written in C (with a tiny bit of assembler).
Last edited by jahboater on Sat May 04, 2019 11:38 pm, edited 1 time in total.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 11:37 pm

That wasn't your question. You asked to see a fibo of a million digits in SB.

A code challenge that is biased towards languages with emulated unlimited integers lengh is a waste of my time.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 12:08 am

When I want a GUI now a days I do it with Javascript in the browser, nice and simple.
Okay. Show me the JavaScipt code to emulate my desktop app in a browser. Curious to see your JavaScript socket code and event processing done in a browser without the need for a server connection.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 12:13 am

ScriptBasic,

When I asked for the fibo(4784969) in ScriptBasic I was referring to the ongoing fibo(4784969) challenge that has been the main topic of this thread since page one. It has been repeatedly stated here that using libraries external to the language standard does not qualify.

Now, you have caused a problem with that challenge rule. As the creator of ScriptBasic you get to define it's standard. As such you can define a fibo function as a standard part of the language. Then a one line fibo(4784969) in ScriptBasic would qualify.

But... As that fibo function was not part of the ScriptBasic standard before you tackled the challenge that implies your real entry is all the code you have added to ScriptBasic to get the job done. Then I can't work out of I would put your entry under the BASIC category or the C category. And if C, then you are using GMP, which disqualifies it!
A code challenge that is biased towards languages with emulated unlimited integers lengh is a waste of my time.
Quite likely it's a waste of time for all of us.

Some people spend hours on crossword puzzles, or Soduku, or countless other useless activities.

Around here we waste our time fiddling with a useless programming puzzle in many programming languages.

By the way, what do you mean by "emulated unlimited integers"? The results people have posted have been correct. They look as much like real integers as any I have seen.

And to reiterate, yet again, the challenge is not about fibo or big integers as such, that is just a vehicle to show how code is written in the language, it's just regular code.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 12:21 am

I demonstrated how I approached the challenge of a million digit Fibonacci. That is all I'm willing to offer. I'm not in my 30s with seemingly unlimited time left on this earth. I use my time wisely with the hope what I do share has benefit to others.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 12:33 am

ScriptBasic,
Okay. Show me the JavaScipt code to emulate my desktop app in a browser.
Can you link me to that desktop app so I can see what you are asking exactly?
I'm not in my 30s with seemingly unlimited time left on this earth. I use my time wisely with the hope what I do share has benefit to others.
That is good to hear.

I am more than double 30. I strive to do what is fun with my limited time left on this Earth. Amazingly others sometimes find it useful as well. I think a lot of useful stuff has passed through this thread for example.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 12:40 am

Can you link me to that desktop app so I can see what you are asking exactly?
Other programming languages - ScriptBasic - last post.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 12:50 am

Cool.

But why not just point a browser at dict.org ?

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 12:58 am

The demo is my ScriptBasic 'Hello World' for the IUP binnding.
But why not just point a browser at dict.org ?
Why not use GMP for Fibonacci?

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 1:36 am

What ScriptBasic lacks in unlimited integer length, it makes up for with extending integer precision with reals with no need for additional coding or type declaring. ScriptBasic also treats numeric strings as numbers when used in an expression.

These are features that have benefit to the projects I do.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 1:45 am

Heater wrote:
Sat May 04, 2019 10:09 pm
But here is the dilemma for the fibo(4784969) challenge. What you have presented is a shell script that runs maxima which calls a ready made fibo function. Is that cheating because the entry does not actually show code that implements a fibo algorithm? Is it acceptable because the challenge never actually said show the algorithm, only write the program and don't use non-standard libraries?
The standard way in Unix to run interpreted languages as commands is using #! at the beginning of a text file. I couldn't get that to work with maxima so I did the next best thing with a shell script. In the past #! used to be interpreted by the shell and not the kernel anyway.

I find it amusing that Macsyma was developed by the same research university which brought us Scratch. Have times changed that much?

Since we are on the royal road to Fibonacci, here is a similar code written in the Mathematica programming language, which is available under license on the Raspberry Pi at no additional charge. Simply use apt-get wolfram-engine or possibly wolframscript if you don't want the full GUI.

The program

Code: Select all

#!/usr/bin/wolframscript
Print[Fibonacci[4784969]]
produces the output

Code: Select all

$ time ./mmafibo >mmafibo.txt

real    0m25.302s
user    0m0.450s
sys     0m0.870s
$ head -c32 mmafibo.txt; echo
10727395641800477229364813596225
$ tail -c32 mmafibo.txt
4856539211500699706378405156269
on the Raspberry Pi Zero. Note with the Pi Zero you need to be careful not to automatically install Java 9 with wolfram-engine as it doesn't support the ARMv6 instruction set.

The results are interesting as 98% of the time is apparently spent loading the program and only 2% actually computing.

The wolframscript binary is only 3.9M but it likely spends additional time loading libraries as it executes. Even so, the total run time puts Mathematica in second place on the list

Code: Select all

                   BUILD TIME    RUN TIME     TOTAL
macfibo               0.000       11.140     11.140
mmafibo               0.000       25.302     25.302
serial                7.459       24.195     31.654
fibonacci             5.060       80.946     86.006
fibo_karatserial     56.154       40.090     96.244
integervol           17.886       87.556    105.442
visual               14.146      164.411    177.557
classic              10.851      217.004    227.855
Since Mathematica is included free of charge, why use anything else on the Raspberry Pi?
Last edited by ejolson on Sun May 05, 2019 5:15 am, edited 4 times in total.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 2:15 am

Why Avoid Fibonacci on the RPi?

timrowledge
Posts: 1259
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 3:37 am

Heater wrote:
Sat May 04, 2019 10:03 am
Tim,

A while back you questioned my use of the term "headless" when I described wanting to use Smalltalk/Squeak with a screen. Which does sound self contrary.
It certainly did.
Heater wrote:
Sat May 04, 2019 10:03 am
What I had in mind was a headless Linux system which one communes with over SSH say. No X Windows or display required to use the OS.

But, this system would happen to have a display attached for use by an application. Full screen into the frame buffer and hopefully supporting gl. Perhaps just a small screen. This would be a GUI for that application only. Perhaps a control interface for some machine with touch control or a few real buttons.
OK, I think I get the picture.

In principle (as in "I have done it but not for quite some time") you can run Squeak on a unix boxen with the display set to /dev/fb. The code for that (at the vm level) is at https://github.com/OpenSmalltalk/opensm ... play-fbdev and as you'll see it hasn't been updated in a long while. That may mean it has never needed any changes (there are parts of the RISC OS vm that have worked perfectly without change since I wrote them in the 1900's) or it may mean some tweaks wil lbe required. At the Smalltalk level, nothing should be noticed - it will just see a display window that happens to match the size of the screen.

For open GL, I can't offer much technical advice other than to note that there is someting called the 'B3DAcceleratorPlugin' which provides connections to GL, or Dirext3D etc as appropriate. I *don't* think it currently works on Raspbian but I haven't done anything to test that in a couple of years, and I have no idea at all if it would work with /dev/fb - we're into areas of unix I choose to steer clear of.

For touchscreens, it would depend very heavily on what exactly said touchscreen provides as input events. People have done touchscreen based Smalltalk systems but none ofthem have 'stuck' because none of the touch systems have really stuck - except iOS & Android, and both of those have carefully put up obstacles that still get in the way. Android by being, well, Android; iOS by having some really annoying restrictions on development systems that we so nearly got exemptions from but Steve died before completely fixing it for us. As a result there isn't any real touch based support provided by default. It may or may not actually impact what you need.

All I can really say is that I have personally done work on not-terribly-dissimilar systems four times over the years (Active Book, Interval MediaPad, DEC Itsy, HP internal "Carly's Handbag" project) and they all produced quite nice machines that then got killed by money grubbing bastards with no morals.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

timrowledge
Posts: 1259
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 3:44 am

ejolson wrote:
Sat May 04, 2019 5:51 pm
The question today is whether SoftBank will cancel ARM and whether RISC-V will ever run Smalltalk.
No idea about SoftBank but as soon as there are actually usable, accessible RISC-V machines it will be possible to run Smalltalk on them. To the best of my knowledge, 68020, ARM, PowerPC, Alpha, Itanium & HP-7000 had Smalltalks before most of the world even knew of their existence
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

timrowledge
Posts: 1259
Joined: Mon Oct 29, 2012 8:12 pm
Location: Vancouver Island
Contact: Website

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 3:50 am

ScriptBasic wrote:
Sun May 05, 2019 1:36 am
What ScriptBasic lacks in unlimited integer length, it makes up for with extending integer precision with reals with no need for additional coding or type declaring.
Floats do not extend integer precision. They extend the *range*. Doubles can extend the precision a little, as well as the range. Useful systems can maintain integer exactness to any practical level (you will run out of memory on most machines, eventually) or shift to float/double/etc when wished. *Really* useful systems can use fractions to maintain sub-integer precision too. *Really, really* useful systems can make use of complex numbers and tensors etc. *Really, really, really* useful systems could explain tensors and spinors - but I'm not sure there are any systems *that* good.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 4:55 am

timrowledge wrote:
Sun May 05, 2019 3:50 am
Useful systems can maintain integer exactness to any practical level (you will run out of memory on most machines, eventually) or shift to float/double/etc when wished. *Really* useful systems can use fractions to maintain sub-integer precision too. *Really, really* useful systems can make use of complex numbers and tensors etc. *Really, really, really* useful systems could explain tensors and spinors - but I'm not sure there are any systems *that* good.
I don't know about really useful, but for large Fibonacci numbers it would be possible to compute F(n) using the algebraic field Q(sqrt 5). Given the blog linked to in this post, one wonders whether Macsyma actually does that and computes directly with

F(n)=(phi^n-(-phi)^(-n))/sqrt 5

instead of using the doubling formulas that have been so popular in this thread.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 8:06 am

ScriptBasic,
Why not use GMP for Fibonacci?
Touche!

DavidS could answer that. He suggested the rule. Everyone seemed to agree. For reasons explained here many times.
What ScriptBasic lacks in unlimited integer length, it makes up for with extending integer precision with reals...
If I understand your explanation of how it works it actually silently looses precision when swapping from integers to floats behind the scenes.

Return to “Off topic discussion”