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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 4:49 pm

ScriptBasic wrote:
Sat May 04, 2019 3:58 pm
gcc is my default C compiler on all platforms ScriptBasic runs on. I love the macro / pre-processor ability.
You should be able to use the macro processor independently. It was deliberately designed like that so that any language could benefit from the pre-processor. The command is "cpp"

cpp myfile.sb

There are others which are probably better, for example "m4"
see "man m4" for details.

User avatar
ScriptBasic
Posts: 946
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 5:07 pm

Peter Verhas (ScriptBasic author) used macros extensively to access the pointer based object API. I extended the concept with C BASIC which is pre-processor #define's that substitute abriviated C syntax to look like BASIC. Most of the extension modules I wrote for ScriptBasic are done using C BASIC.

User avatar
ScriptBasic
Posts: 946
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 5:21 pm

I would like to ask a simple question that may answer the title of this thread.

Do you feel suggesting BASIC to a beginner looking to understand how programming works would be counter productive and a waste of time?

If you started off learning programming in BASIC, is it now a regret?

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 5:51 pm

Heater wrote:
Sat May 04, 2019 3:19 pm
Wow, according to a post here: http://www.thinbasic.com/community/arch ... 12736.html PowerBasic consists of 400,000 lines of assembler code.
Think how different the world would be if the last hacker, instead of writing gcc and all those Unix-like utilities, had instead written a 36-bit PDP-10 emulator in Smalltalk and preserved the assembler legacy of the Incompatible Timesharing System.

If DEC hadn't cancelled the PDP-10 and Compaq hadn't cancelled DEC and HP hadn't cancelled Compaq...but that's all history and speculation. The question today is whether SoftBank will cancel ARM and whether RISC-V will ever run Smalltalk. This brings us back to the question of emulating the PDP-10 running ITS so that large Fibonacci numbers can be computed using the original version of Macsyma.

Fortunately, Macsyma is available on the Pi for trademark reasons as the open-source programming language called Maxima. The code for computing your and my favourite Fibonacci number looks like

Code: Select all

#/bin/sh
maxima --very-quiet <<EOF
print(fib(4784969))$
EOF
When running on a Pi Zero the output is

Code: Select all

$ time ./macfibo >macfibo.txt

real    0m11.140s
user    0m9.130s
sys     0m1.570s
$ head -c32 macfibo.txt; echo
10727395641800477229364813596225
The updated timing table on the Pi Zero now looks like

Code: Select all

                   BUILD TIME    RUN TIME     TOTAL
macfibo               0.000       11.140     11.140
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
which puts Maxima at the top.
Last edited by ejolson on Sat May 04, 2019 6:32 pm, edited 2 times in total.

User avatar
ScriptBasic
Posts: 946
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 6:04 pm

Code: Select all

#/bin/sh
maxima --very-quiet <<EOF
print(fib(4784969))$
EOF
That sure looks like a call to GMP fib().

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 6:07 pm

ScriptBasic wrote:
Sat May 04, 2019 6:04 pm

Code: Select all

#/bin/sh
maxima --very-quiet <<EOF
print(fib(4784969))$
EOF
That sure looks like a call to GMP fib().
Macsyma/Maxima was written between 1962 and 1982. The first release of GNU GMP was in 1991.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 6:15 pm

ScriptBasic wrote:
Sat May 04, 2019 5:21 pm
Do you feel suggesting BASIC to a beginner looking to understand how programming works would be counter productive and a waste of time?
For me; no.

When people are starting out they need simple things which aren't complicated or difficult to get their head around or to get to grips with, which allows enough to be done to do what they want at the level they're at, to keep and encourage their interest and enthusiasm. Basic, even original BASIC, serves that purpose well.

In fact I would say going the other way is far more counter productive when people haven't yet gained enough of an understanding for why things are done some way. Trying to force them into something when they can't see the purpose of that, aren't yet capable of understanding the why, makes things far too complex and difficult to be interested in.

If one can hook people they can be led onwards. If one scares them off they are usually gone for good.

There's a reason there was a huge leap in programming participation when Microsoft introduced Visual Basic and the horrendous nightmare that was C message loops could be left behind.

People had gone from BASIC on home computers, thrown in the towel with Windows programming in C, but flooded back when they were given a Basic they could get to grips with and understand. It's sometimes easy to forget how barren the programming arena had become before VB came along.
ScriptBasic wrote:
Sat May 04, 2019 5:21 pm
If you started off learning programming in BASIC, is it now a regret?
I did and it's not a regret.

An interesting question might be how many people started with some kind of Basic and how many started with something else ?

One would probably have to analyse that by age and/or generation seeing as there often wasn't a lot of choice, that favoured teaching languages come and go.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 6:37 pm

ejolson wrote:
Sat May 04, 2019 6:07 pm
ScriptBasic wrote:
Sat May 04, 2019 6:04 pm
That sure looks like a call to GMP fib().
Macsyma/Maxima was written between 1962 and 1982. The first release of GNU GMP was in 1991.
That doesn't mean they couldn't have introduced some GMP functions at any time since 1991.

Anyway, if its allowed then 38 milliseconds for the C call should also be allowed, bringing C to the top by a large margin :)
Last edited by jahboater on Sat May 04, 2019 6:39 pm, edited 1 time in total.

User avatar
ScriptBasic
Posts: 946
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 6:38 pm

Great response hippy!

It may be the first post on topic. :D

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 6:47 pm

The main teaching language for my CS course at uni (late 70's) was Pascal.
Pascal was specifically designed by Niklaus Wirth as a teaching language.
While I wouldn't use it now, it did its job very well, encouraging elegant structured programming that simply wasn't possible with the commonly used languages of the day (Fortran IV, Dartmouth? Basic, Cobol etc), you had to use the superb Algol68 or similar, that wasn't so widely used.
As BASIC has improved over the years, I'm sure its fine now.
But which of its myriad versions?

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 6:52 pm

ejolson wrote:
Sat May 04, 2019 4:08 am
hippy wrote:
Sat May 04, 2019 3:58 am
Here's a simple, self-contained and complete, extension, for Python 2 and 3 though I've not tried building it, created from a single "int add(int a, int b) Add two numbers together" line in a definition file. It doesn't follow all the recommended standards but, meh, it works for me -
Did you make those comment boxes out of asterisks and hyphens or is that something the editor does automatically?
Everything you see there is exactly as created by a Python program I wrote, all automatically generated 'as is' from a definition file which had a single definition line in it. No post-editing.

I know the comment boxing isn't to everyone's taste but I find it useful when one has a huge file with lots of methods in there.

Code: Select all

def Head(f,c,s="",*extra):
  def Any(lst):
    if len(lst) > 0:
      return True
    return False
  if c == "-":
    WriteLine(f, "// ." + "-"*73 + "." )
    WriteLine(f, "// |  " + Pad(s,71) + "|" )
    if Any(extra):
      WriteLine(f, "// |" + "-"*73 + "|" )
      for s in extra:
        WriteLine(f, "// |  " + Pad(s,71) + "|" )
    WriteLine(f, "// `" + "-"*73 + "'" )
  else:
    WriteLine(f, "// " + c*75 )
    WriteLine(f, "// " + c + SPACE*73 + c )
    WriteLine(f, "// " + c + "  " + Pad(s,71) + c )
    if Any(extra):
      WriteLine(f, "// " + c*75 )
      WriteLine(f, "// " + c + SPACE*73 + c )
      for s in extra:
        WriteLine(f, "// " + c + "  " + Pad(s,71) + c )
    WriteLine(f, "// " + c + SPACE*73 + c )
    WriteLine(f, "// " + c*75  )
  WriteLine(f)

Code: Select all

Head(f,"*",product)
Head(f,"-","Determine Python version being used")
Head(f,"-",t.lower()+" = "+FixArgs(funnam)+"("+FixArgs(args)+")",docstr) 

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 6:55 pm

What about

Code: Select all

/*
 * Hello world.
 */
 
 or 
 
 /**************************************\
 *   Hello world                        *
 \**************************************/
Which are more common and only use the single old style of comments.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 7:00 pm

jahboater wrote:
Sat May 04, 2019 6:37 pm
ejolson wrote:
Sat May 04, 2019 6:07 pm
ScriptBasic wrote:
Sat May 04, 2019 6:04 pm
That sure looks like a call to GMP fib().
Macsyma/Maxima was written between 1962 and 1982. The first release of GNU GMP was in 1991.
That doesn't mean they couldn't have introduced some GMP functions at any time since 1991.

Anyway, if its allowed then 38 milliseconds for the C call should also be allowed, bringing C to the top by a large margin :)
That GMP could be used behind the scenes is why it's interesting to run the original ITS version of Macsyma on an emulated PDP-10.

In the present case, my guess is the Fibonacci doubling formula are written in LISP and in turn leverage the built-in big-number capabilities of that language. One would have to look at the source to be certain what's going on. In particular, the LISP interpreter used on the Raspberry Pi to run Maxima might have build dependencies on GMP.

Is 38 milliseconds the time for GMP on the Pi Zero?

User avatar
ScriptBasic
Posts: 946
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 7:04 pm

Richard's BBC BASIC would be a good language to use for those looking for a general understand of program flow and an introduction to graphics programming.

ScriptBasic is more of a Lego engine using open source libraries to extend it.

The BASIC to use depends on what your goals are.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 7:06 pm

ejolson wrote:
Sat May 04, 2019 7:00 pm
Is 38 milliseconds the time for GMP on the Pi Zero?
Oh no. It will be slower than that on a Zero. At a (grossly) wild guess, around 1/2 sec.
My Pi Zero is currently trying to compile approx 54 million lines of C code, so I'll leave the poor little thing alone for a bit until it completes.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 7:13 pm

Heater wrote:
Sat May 04, 2019 2:53 pm
Having never heard of PowerBasic I did a quick google...

Luckily it has a new owner. Who is happy to take $100 a pop off the remaining helpless, dependent users. Despite not having progressed the project in 8 years !
TurboBasic and then PowerBasic were both brilliant, 'best in show', well worth the money. It's what I left behind as I moved to developing code for Pi's.

Why avoid basic when one can criticise what one's never heard of, let alone used ?

User avatar
ScriptBasic
Posts: 946
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 7:22 pm

TurboBasic was my first PC BASIC coming from a Business BASIC world. (BASIC IV, REXON, BBx, ProvideX, ...)

I facilitate the https://OxygenBasic.org project run by Charles Pegge. (UK developer) It's a 32/ 64 bit JIT BASIC compiler written in itself and very flexable. Down side it's Windows only.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 8:50 pm

jahboater wrote:
Sat May 04, 2019 6:55 pm
What about /* ... */Which are more common and only use the single old style of comments.
I really dislike those, actually detest them. There's something I find very unaesthetic about those and the various arrangements people come up with to do boxing. None of them have ever rocked my boat though your second example is one of the better version IMO. I never liked Pascal's {* ... *} either, if I've remembered that right.

I'm just more happier and content with single-line comments. And that probably is my Basic heritage shining through. Though I hate "REM" even more so.

Mind you there's nothing worse than switching between programming languages and having to remember which of ; ' # // -- it should be,and I bet there's more variants as well. Smalltalk/Squeak would drive me nuts with its double-quote text strings as comments.

Not that I'm saying multi-line or block comments, or within line comments, don't have their place - I wish Python had both for when they would be useful. Nor that others shouldn't use them. They're just not my cup o' char.

User avatar
ScriptBasic
Posts: 946
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 9:17 pm

Code: Select all

'"""

Not that I'm saying multi-line or block comments, or within line comments,
don't have their place - I wish Python had both for when they would be useful.
Nor that others shouldn't use them. They're just not my cup o' char.

"""

PRINT "Done.\n"
$ scriba multi-rem.sb
Done.
$

Also useful for remarking a large chuck of code you haven't finished while testing other routines.
Last edited by ScriptBasic on Sat May 04, 2019 9:49 pm, edited 1 time in total.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 9:27 pm

hippy,
Why avoid basic when one can criticise what one's never heard of, let alone used ?
You will notice that I did not criticize TurboBasic/PowerBasic as languages or language systems as such.

I did point out the potential problems of using such closed source systems. Whichever or whatever they are. In response to jalih's question. Which others have shown to be correct in this case.

If TuboBasic/PowerBasic was anything like TurboPascal then it was pretty ground breaking at the time. If it really is 400,000 lines of assembler then it is nothing short of an astounding piece of work.

User avatar
ScriptBasic
Posts: 946
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 9:55 pm

PowerBasic had its day but left the room a shambles.

Thanks hippy for giving ScriptBasic a try. You are one of the few compiler fans that gave an interpreter a chance to meet your needs.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 10:09 pm

ejolson,

I consider myself very lucky to have seen a PDP-10 in the metal, running the first video game Spacewar! At the Computer History Museum in Mountain View. Presented by the Spacewar author himself Steve Russell. Whom I was lucky enough to talk to.

Today I find Steve Russel's alma marta was Dartmouth College, birthplace of BASIC. But he was known for implementing Lisp and inventing the "continuation".

On the downside he mentored Bill Gates and Paul Allen. Presumably they were not smart enough for all the serious Lisp stuff and ended up building BASIC instead.

Anyway, maxima, what a treat. A blast from the past. Runs on my PC just fine:

Code: Select all

$ cat fibo.sh
#/bin/sh
maxima --very-quiet <<EOF
print(fib(4784969))$
EOF

$ time ./fibo.sh | head -c 32
10727395641800477229364813596225Inappropriate ioctl for device

real    0m1.031s
user    0m0.234s
sys     0m0.656s
$ time ./fibo.sh | tail  -c 32
856539211500699706378405156269

real    0m2.910s
user    0m0.828s
sys     0m1.938s
$
Except, as you see, it complains about piping to "head", like some others we have seen.

I have no idea about maxima, but judging by this page: https://andrejv.wordpress.com/2010/02/1 ... i-numbers/ it might well use more funky techniques to get fibos than we know. Never mind GMP.

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?

I'm leaning toward the latter and am about to check it into the challenge repository.

User avatar
ScriptBasic
Posts: 946
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:17 pm

This is the first time I have had to deal with precision outside the hardware's native limitations. I'm sure someone will chime in and give us a practical use of generating million digit integers.

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.
Last edited by ScriptBasic on Sat May 04, 2019 10:28 pm, edited 1 time in total.

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

Re: Why Avoid BASIC on RPi?

Sat May 04, 2019 10:24 pm

ScriptBasic wrote:
Sat May 04, 2019 9:17 pm
'"""
Maybe not what was intended but it sent me off to search on triple-double-quoted strings in Python and it seems they can be used likewise. And, brilliantly, can be used to comment out entire function bodies without needing a 'pass' adding. I guess because it becomes a docstring there and is elsewhere something which does something, even if it is a waste of doing it.

So I've learned something new. Not only new but very useful. So many thanks for that.

User avatar
ScriptBasic
Posts: 946
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:33 pm

I forgot to mention that was one of the features Peter borrowed from Python. The SciptBasic MODULE syntax is from Perl.

Return to “Off topic discussion”