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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 6:32 pm

ScriptBasic,

Thanks for the Julia fractal demo. You might just have spun me off into wasting countless hours playing with fractal code in Julia. When we discovered fractals back in the day the software teams productivity hit zero for a month as we all competed to produce the best mandlebrot/julia demo on the new fangled 386 PC's we had.

I do understand your reluctance to spend time on something that is essentially useless.
Memory in C++ is a leaky abstraction .

User avatar
John_Spikowski
Posts: 1396
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 6:48 pm

I do understand your reluctance to spend time on something that is essentially useless.
Thank You.

It makes being ban 3 times worth the effort.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 7:54 pm

Heater wrote:
Sun May 05, 2019 5:47 pm
I'm taking a liking to Julia.
But.. but... Julia is implemented in C! I thought that was a Bad Thing? :o
Actually, rather like Squeak Smalltalk, it's C and occasional assembler low-level stuff to get it started, a dynamic translator and self-written libraries.
Making Smalltalk on ARM since 1986; making your Scratch better since 2012

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 8:06 pm

Heater wrote:
Sun May 05, 2019 5:58 pm
One can always statically define arrays or whatever of the size(s) one needs up front and manage things ones self. Like one might do in ALGOL or C (if not using malloc) or BASIC etc. That's what we used to do in the old days.
And what I spent yesterday doing when I was creating 64-bit maths routines for an 8-bit microcontroller which only runs a Basic-style interpreter which only supports 16-bit integers for the user. Those 64-bit numbers are of course all four word arrays of 16-bit integers.

That was a fun and enjoyable adventure back into figuring out how to do 64-bit multiplication, division, modulo and printing numbers in decimal from first principles.

I was hoping to have moved on to implement a floating point library from scratch but, alas, it was not to be.

Who needs to avoid Basic when that POS* which is Firefox can have its add-on system, every extension, theme, language packs, and everything one has come to rely upon, completely borked by a Mozilla certification screw-up ?

That took away over 8 hours of my life, getting it to usable state, tabs disabled and it ad-blocking again. Still, it was a good reminder of how unbelievably unsafe and almost unusable much of the internet is without ad-blocking and the like these days.

* Piece Of Software, obviously.

User avatar
John_Spikowski
Posts: 1396
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 8:20 pm

How that even got out the door without testing is beyond me. A lesson I hope they remember. All the effort put in to out do Chrome was lost due to carelessness and stupidity.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 8:38 pm

I take the Firefox temporary problem as a cautionary tale: it could happen to anyone, and the Mozilla engineers came up with quite an elegant temporary fix using an unexpected back-channel. I was up and running again in minutes. It's still my favourite browser.*

OKAY, SO … yet another solution to the fibo(4784969) challenge — this time in PARI/GP, a GPL computer algebra system that calculates an exact 1,000,000-digit solution in under 10 seconds on a Raspberry Pi 3B+. It uses the equation
Fibonacci(n) = φⁿ / √5
to get the answer. Despite outputting in a slightly different format, it agrees with all the other working solutions:

Code: Select all

/*
	fibo.gp - calculated big float Fibonacci(n) in PARI/GP
		    -- https://pari.math.u-bordeaux.fr/ --
		  with a million digits of precision
	scruss - 2019-05

	To run (with 128 MB of stack):

		gp -s $((128*1024**2)) -q fibo.gp

	To install on a Debian system:

		sudo apt install pari-gp
		(this seems to install all of TeXLive too, sorry)

	*** NB: Output is seemingly (?) always in scientific notation
		and includes header on setting precision

	    Also, we're avoiding gp's fibonacci(n) function as it
	    	uses gmp.

	Timing (Raspberry Pi 3B+):

time gp -s $((128*1024**2)) -q fibo.gp |tail -1 | head -c 33 ; time gp -s $((128*1024**2)) -q fibo.gp |tail -1 | tail -c 40

1.0727395641800477229364813596225
real	0m9.845s
user	0m9.723s
sys	0m0.119s
4856539211500699706378405156269 E999999

real	0m9.844s
user	0m9.729s
sys	0m0.110s
	
*/


\p 1000000			/* set precision to 1,000,000 digits */
phi = (1 + sqrt(5)) / 2		/* Golden Ratio */
fibo(n) = (phi^n) / sqrt(5)
print(fibo(4784969))
quit
I've submitted a PR in the github repo.

*: disclosure: I've been close-ish to some of the dev team here. They've hosted events for me at no cost, and fed me for free several times.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 8:54 pm

Thank you scruss,

I pulled it, now I'm going to have to try it...

Good to see a different approach to the problem for a change.
Memory in C++ is a leaky abstraction .

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 8:58 pm

Can you show how to use gp2c to make your solution an actual stand alone executable?
Memory in C++ is a leaky abstraction .

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 9:06 pm

timrowledge,
But.. but... Julia is implemented in C! I thought that was a Bad Thing?
I think we may be misunderstanding each other Tim.

I don't think I ever said that it was a bad thing that a high level language be implemented in C. After all, my beloved Javascript is written in C++, there are many other examples.

What did rub me up the wrong way is the constant claims of Smalltalk folks that all other languages are terrible, how things can be much smaller, simpler, better in Smalltalk etc, only to find that Squeak Smalltalk itself depends on C. Not to mention the gigantic infrastructure of Linux under that, written in C.

All seemed somewhat hypocritical.

Maybe that is not what you intended to convey but that is how it came over to me. Sorry if I read to much into what you wrote.

Now, on a different tack, a while back I was suggesting that there are probably great ideas behind Smalltalk but that it did not find popularity and wide adoption because it's syntax was alien to high school kids that had learned some algebra and general programmers who were used to the C inspired syntax as found in Java, Javascript, Lua, etc.

The Julia folks seem to have gained traction because they wanted a much higher level than C but they did not want to totally blow away the comfort of the C style syntax.

My immediate experience is that their plan works. In a matter of minutes I had Julia installed, that big fibo working and could tweak around with the code, pretty much without having to struggle with the manual to find out how the syntax worked.

Contrast to the Squeak big fibo which took days to sort out.

On a totally different tack I was just listening to Alan Kay telling, in 1990, how "computers will be really valuable when we can loose them". It struck me that one the design requirements of Raspberry Pi was exactly that it be cheap enough that it would not be an issue if lost and/or broken by kids as they learn with it. It has taken a long time for Kay's vision to come to fruition.

Alan Kay interview: https://www.youtube.com/watch?v=275FQ9koAw8
Memory in C++ is a leaky abstraction .

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 9:10 pm

scruss wrote:
Sun May 05, 2019 2:03 pm
I didn't know there was a Mono VB compiler for Linux. The source input format barely looks like any BASIC I remember - since when did we wrap stuff we needed to run in a main function?

Is there a proper IDE for this? The strength of BASIC for me is its approachability: though I may have grown out of doing this somewhat*, in a BASIC system I should be able to type

Code: Select all

PRINT "ALAN IS A WALLY!"
and see the result immediately somewhere.
Alas, in order to please Edsger, Visual Basic has modules which contain subroutines and functions. Your single line of code must now be written

Code: Select all

module alan

sub main()
    console.writeline("ALAN IS A WALLY!")
end sub

end module
and run as

Code: Select all

$ vbnc alan.bas
Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.0.1 - tarball)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.

Assembly 'alan, Version=0.0, Culture=neutral, PublicKeyToken=null' saved successfully to '/XXXXXX/alan.exe'.
Compilation successful
Compilation took 00:00:11.6051860
$ mono alan.exe
ALAN IS A WALLY!
The Visual Studio IDE for Linux may allow you to compile and run the code with the press of a single function key. Alternatively, you can use the bash command history.

I've updated the Pi Zero Fibonacci timing table with runs for Julia and the Basic Calculator. The results are now

Code: Select all

                   BUILD TIME    RUN TIME     TOTAL
macfibo               0.000       11.140     11.140
julfibo               0.000       14.844     14.844
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
bcfibo                0.000      263.715    263.715
with meanings as follows:
  • macfibo -- Using the built-in fib function in Macsyma/Maxima version 5.38.1 from the Raspbian repository.
  • julfibo -- Using the built-in big-number support of Julia 0.6.0 from the Raspbian repository with a simple recursive implementation of the doubling formula.
  • mmafibo -- Using the built-in Fibonacci function in Wolfram Language 11.3.0 downloaded from the Raspbian respository licensed for use on the Raspberry Pi at no charge.
  • serial -- C code using Karatsuba multipication and vectorizable loops with arrays of 64-bit signed integers for big-number addition, subtraction and multiplication compiled with GCC version 6.3.0 from Raspbian.
  • fibonacci -- C code using Karatsuba multiplication and a somewhat inferior version of the doubling formulas compiled with GCC version 6.3.0 from Raspbian.
  • fibo_karatserial -- C++ code illustrating operator overloading with Karatsuba multiplication compiled with G++ version 6.3.0 from Raspbian.
  • integervol -- Classical line-numbered Basic implementing Karatsuba multiplication with gosub and goto compiled using arrays of 32-bit integer variables with FreeBasic version 1.06.0 modified to label variables used across setjmp longjmp sequences as volatile.
  • visual -- Visual Basic code implementing Karatsuba multiplication with arrays of 32-bit signed integer variables and a fairly optimal version of the doubling formula compiled with the open-source Visual Basic.Net Compiler version 0.0.0.5943 in Mono 4.0.1 from Raspbian.
  • classic -- Classical line-numbered Basic capable of running on the original MITS/Altair version of Extended Basic written by Microsoft. Compiled with FreeBasic version 1.06.0 to implement big-number arithmetic and the Karatsuba algorithm using arrays of double-precision floating-point variables.
  • bcfibo -- Version using the built-in big-number arithmetic of the GNU BC Basic Calculator version 1.06.95 from the Raspbian repositories.

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 9:21 pm

ScriptBasic wrote:
Sun May 05, 2019 8:20 pm
How that even got out the door without testing is beyond me.
More a case of insisting on having total ownership and then taking their eye of the ball, failing to ensure everything would keep on working. They aren't the first to have done that, but most people only forget to renew a domain registration, generally screw themselves, their companies, and reputations, not tens of millions of customers around the globe.

We have to be grateful it was 'only a browser', not our nuclear defences, critical infrastructure, or autonomous cars. It really should be a wake-up call. The irony is that something intended to keep us safe and happy ruined so many people's day.

The problem was that once the "Firefox has decided to disable everything you rely upon" pop-up arrived on-screen there was little anyone could do about things. Official advice is confusing and not clear, and reality doesn't seem to match what they are saying. Add-on installation links are failing "cannot be downloaded; check your internet connection". Links which go through the add-on site report "corrupted". I only got things working by disabling all security options and checks, directly downloading from vendor sites.

Amusingly, Classic Theme Restorer which Firefox has been claiming "isn't compatible" for years, was and is, working just fine for me.

And, given when it hit me, late last evening, when I first found there had been an issue, it seems that it might have been the fix roll-out which ruined things for me.

It's really not surprising people turn off automatic updates, won't upgrade, choose to live with what they have and the risks in doing that, rather than risk potentially worse problems in the future.

With their leanings towards forced upgrades it seems an inevitability that Microsoft will one day accidentally roll-out an upgrade which 'bricks everything'.

I put all blame at the door of Mozilla. If they hadn't decided to disable things, hadn't arrogantly decided that would be best for users, had merely warned of a detected issue, left it to users to decide what to do, far less damage would have been done, and they'd be seeing a lot less deserved backlash.

But why avoid closed source when open source can screw you over ?

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 9:26 pm

scruss wrote:
Sun May 05, 2019 2:03 pm
I didn't know there was a Mono VB compiler for Linux.
It's years old, but unfortunately has a bug with winforms which severely limits its use for a lot of VB programmers. Last time I looked that was bizarrely sitting in a fixed" and "won't fix" limbo.

viewtopic.php?t=100516

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

Re: Why Avoid BASIC on RPi?

Sun May 05, 2019 10:19 pm

As I said above, use the language appropriate for the job. If that is basic, use basic.

And as someone who started with basic, and has been a racing driver, and is now a moderator, I've had enough of the continual reports I keep getting on this thread. So, I'm closing it. Please take you language wars to a different forum.
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."

Return to “Off topic discussion”