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

Re: ScriptBasic

Wed May 15, 2019 11:17 am

RichardRussell,

I'd say the is pretty impressive. Well done!

TIOBE is great and all but over there on Github no variety of BASIC shows up as a language anyone uses at all!

https://www.benfrederickson.com/ranking ... hub-users/
https://githut.info/
https://octoverse.github.com/2017/

Meanwhile...

How about a structured GOTO?

When creating logic designs one often needs to implement state machines. These are crudely handled in Verilog and VHDL.

I was just now wanting to add a state machine to my RISC V core for FPGA. I was about to do it with a state variable and a bunch of condional statements in Scala. I'm using the SpinalHDL Scala library for this design. Spinal generates Verilog and VHDL from Scala source, integrates test benches with Verilator and generally makes designing logic a much nicer experience.

Then I discovered, of course, that SpinalHDL has a state machine class to make writing state machines nicer. Sucha state machine in Scala/SpinalHDL looks like this:

Code: Select all

  val fsm = new StateMachine{
    val stateA = new State with EntryPoint
    val stateB = new State
    val stateC = new State

    val counter = Reg(UInt(8 bits)) init (0)
    io.result := False

    stateA
      .whenIsActive (goto(stateB))

    stateB
      .onEntry(counter := 0)
      .whenIsActive {
        counter := counter + 1
        when(counter === 4) {
          goto(stateC)
        }
      }
      .onExit(io.result := True)

    stateC
      .whenIsActive (goto(stateA))
  }
Wow! Check that out. It's uses "goto" to get from one state to the next. For the first time in decades I can use "goto" without feeling dirty.

Of course this is not your Grandfather's goto. What you see there does not run like you might think. That counter never gets incremented when you run this code for example. Rather it's more a description of the behavior you want from your logic hardware. When you run it, it emits Verilog or VHDL that will do all that in an FPGA or other hardware.

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

Re: ScriptBasic

Wed May 15, 2019 12:40 pm

Heater wrote:
Wed May 15, 2019 11:17 am
TIOBE is great and all but over there on Github no variety of BASIC shows up as a language anyone uses at all!

https://www.benfrederickson.com/ranking ... hub-users/
https://githut.info/
https://octoverse.github.com/2017/
But using those as measures it seems no one uses C much either; 94% of github projects are anything but C.

That may be "fact" but it doesn't seem to me to be a very useful fact.
Heater wrote:
Wed May 15, 2019 11:17 am
How about a structured GOTO?
They would probably be implemented by way of function assignment, and are useful in the implementation of finite state machines as you note. In Python -

Code: Select all

def FSM():
  state = Idle
  while state != None:
    state = state()
Any language which supports function assignment could do things like that.

User avatar
RichardRussell
Posts: 419
Joined: Thu Jun 21, 2012 10:48 am

Re: ScriptBasic

Wed May 15, 2019 12:48 pm

Heater wrote:
Wed May 15, 2019 11:17 am
When creating logic designs one often needs to implement state machines. These are crudely handled in Verilog and VHDL.
If you think they are crude, my experience with HDLs stopped with ABEL! My most complex FPGA-based design (the BBC's Transform PAL Decoder) used a mixture of schematic capture and ABEL.

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

Re: ScriptBasic

Wed May 15, 2019 12:50 pm

bensimmo wrote:
Tue May 14, 2019 5:41 pm
You missed Small Basic, my son was very happy using that until he hit its limits.
That's a nice simple teaching interpreter with some good curriculum behind it. It's a shame it uses bits of .Net that can't easily be ported to Mono.

Confusingly, there's also SmallBASIC, a totally different QBasic-ish interpreter that's cross-platform.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

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

Re: ScriptBasic

Wed May 15, 2019 12:59 pm

RichardRussell,

ABEL, wow, a blast from the past. That was advanced stuff. I recall using PALASM for a few simple address decoder PALs back in the day.

Then nothing HDL wise until I took it into my head, last year or so, to get a DE0-nano board working that somebody gave me a while back. That led to Verilog, which led to wanting to build a RISC V, which led to SpinalHDL...

I would never have made any progress if I only had the Quartus IDE for design. That is a prime example of a loathsome, huge, complex, slow, ugly, dev environment with a crappy editor thrown in.

But I found Verilog was a breeze if you used the Icarus Verilog simulator for the development cycle. You can hack and test code almost as quickly as BASIC with that. Then SpinalHDL cranks that up another notch.
Last edited by Heater on Wed May 15, 2019 1:06 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: ScriptBasic

Wed May 15, 2019 1:00 pm

Any language which supports function assignment could do things like that.
I hope I'm not off topic here but ScriptBasic supports calling functions / subs by its function address.

Code: Select all

FUNCTION Indirect(arg)
   ' something
 END FUNCTION
 
 f =  ADDRESS(Indirect())
 ICALL(f, my_arg)
 

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

Re: ScriptBasic

Wed May 15, 2019 1:03 pm

jamesh wrote:
Tue May 14, 2019 4:16 pm
I occasionally read this thread to make sure you are all behaving, and this goto stuff/argument in the biggest load of nonsense I've read in ages.
After reading these BASIC threads I find myself yearning for the utter simplicity of C.

A goto is a goto (a single jmp instruction, no stack involved).

There is only one version of C, learn that and you are fine. Trying to keep up with all the 97 versions of BASIC and their individual syntax requires a brain the size of a planet, and the count grows daily.

Since none seems to be available, I am tempted to implement a exact replica of the original 1964 Dartmouth Basic as published by Kurtz. It would be interesting to see how simple and fast the implementation could be using a modern parser generator like Bison (the GNU version of yacc - yet another compiler compiler!).

Since this version of BASIC hasn't been extended over the years at the individual whims of each developer, it must be the one true version of BASIC.
Last edited by jahboater on Wed May 15, 2019 1:14 pm, edited 2 times in total.

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

Re: ScriptBasic

Wed May 15, 2019 1:10 pm

There is only one version of C
Only BASIC has more variations than C.

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

Re: ScriptBasic

Wed May 15, 2019 1:12 pm

ScriptBasic wrote:
Wed May 15, 2019 1:10 pm
There is only one version of C
Only BASIC has more variations than C.
Not sure I understood that.
There is only one C (as per the ISO C18 standard), any compiler not correctly supporting that is in error.
There are, it is true, "extensions", but they are always in addition to the standard.

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

Re: ScriptBasic

Wed May 15, 2019 1:27 pm

hippy,
But using those as measures it seems no one uses C much either; 94% of github projects are anything but C.
6% is good. I'd say that is ship shape. Use C/C++ to build the infrastructure where necessary. Use something more comfortable on top.
That may be "fact" but it doesn't seem to me to be a very useful fact.
Quite so. As useful as the TIOBE fact or the popularity of pop singers.
Any language which supports function assignment could do things like that.
Quite likely. To a lesser or greater degree of convenience. Don't forget that code I showed does not actually run though those states when you execute it. It generates Verilog code that implements the state machine in hardware eventually...

I've heard rumor of a couple of attempts at such HDL generators in Python. They don't seem to have come to much for some reason.

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

Re: ScriptBasic

Wed May 15, 2019 1:32 pm

ScriptBasic,
Only BASIC has more variations than C.
I thought we had been through this before.

There is only one C standard. Give or take a few revisions over many decades, all backwards compatible. A compiler that veers from the standard is buggy.
Last edited by Heater on Wed May 15, 2019 1:38 pm, edited 1 time in total.

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

Re: ScriptBasic

Wed May 15, 2019 1:33 pm

jahboater wrote:
Wed May 15, 2019 1:03 pm
There is only one version of C, learn that and you are fine.
Is it as simple as that though ?

In your link to Dennis Ritchie's history of C in another thread he notes there are many "descendants" of C; Concurrent C, Objective C, C*, C++, and we can add C# and others like Go and Rust, and probably more.

I don't see that as much different to there being multiple descendants of BASIC.

In comparing 'the one true' parent of one language with descendants of another, one would be comparing apples to oranges.

One could counter there is only one version of Dartmouth BASIC, learn that and you'll be fine; it won't be confusing at all.
jahboater wrote:
Wed May 15, 2019 1:03 pm
A goto is a goto (a single jmp instruction, no stack involved).
JMP @(sp++)

:P

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

Re: ScriptBasic

Wed May 15, 2019 1:47 pm

hippy,
Is it as simple as that though ?
Yes.

From your list, C++ has it's own standard and multiple vendors who support that standard.

That seem very different from the free for all chaos of BASIC land.

I have no idea about the others. Go and Rust (and D, Java, Javascript, Lua...) are excused as although the may borrow the look and feel of the C syntax to a greater or lesser extent they are very different languages and at least have the decency to not leech off the C name.

User avatar
RichardRussell
Posts: 419
Joined: Thu Jun 21, 2012 10:48 am

Re: ScriptBasic

Wed May 15, 2019 1:48 pm

ScriptBasic wrote:
Wed May 15, 2019 1:00 pm
I hope I'm not off topic here but ScriptBasic supports calling functions / subs by its function address.
BBC BASIC can also call a FN or PROC by address (it's one of my extensions). It's invaluable for tables of function pointers, dynamically-created functions etc.

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

Re: ScriptBasic

Wed May 15, 2019 1:51 pm

If you add REF to the mix you can do some pretty slick stuff on a matrix level. Arrays ++

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

Re: ScriptBasic

Wed May 15, 2019 1:56 pm

Heater wrote:
Wed May 15, 2019 1:32 pm
There is only one C standard. Give or take a few revisions over many decades, all backwards compatible. A compiler that veers from the standard is buggy.
Correct, but so what ?

There are C-like languages which have descended from that C language and there's no problem with that. There are Basic-like languages which have descended from Dartmouth BASIC and there's no problem with that either.

It doesn't matter that Dartmouth BASIC was never an official standard, that there is no official standard for anything claiming to be Dartmouth BASIC to comply to. Descendent languages don't have to comply with any official standard for the language they descend from anyway.

Descendant languages are not their parent language. I don't understand what's so difficult to grasp about that.

I don't understand why you would expect any BASIC-descended language to comply with some 'official BASIC standard' ( if such a thing existed ) when you wouldn't expect a C-descended language to comply with any 'official C standard'.

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

Re: ScriptBasic

Wed May 15, 2019 2:02 pm

hippy wrote:
Wed May 15, 2019 1:33 pm
In your link to Dennis Ritchie's history of C in another thread he notes there are many "descendants" of C; Concurrent C, Objective C, C*, C++, and we can add C# and others like Go and Rust, and probably more.

I don't see that as much different to there being multiple descendants of BASIC.
The descendent's of BASIC are all called BASIC. PowerBASIC, BBC BASIC, Script BASIC, QB BASIC etc, and all claim to be the new BASIC.

C is different. The descendants of C that Mr Ritchie mentioned last century have all gone, probably since the first ISO standard was ratified. Later languages like D, Go, Rust and even C# are not C and don't claim to be, even though they may have included concepts from C, just like C included concepts from Algol68, BCPL, PL/1 and B. Since then C has had nearly three decades of strong ISO standards that decent compilers all support. There is only one C.

C++ is the exception as it is (mostly) a superset of C.
I mentioned this before. from the C99 Rationale ...
Minimize incompatibilities with C++. The Committee recognizes the need for a clear and
defensible plan for addressing the compatibility issue with C++. The Committee endorses the
principle of maintaining the largest common subset clearly and from the outset. Such a principle
should satisfy the requirement to maximize overlap of the languages while maintaining a
distinction between them and allowing them to evolve separately.
The Committee is content to let C++ be the big and ambitious language. While some features of
C++ may well be embraced, it is not the Committee’s intention that C become C++.

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

Re: ScriptBasic

Wed May 15, 2019 2:15 pm

I feel there are three classes of BASIC.

1. Retro - Dartmouth like, line number centric, GOTO / GOSUB for structure

2. Traditional - QuickBasic like, function /:subs for structure.

3. Object BASIC - VB6 like, COM /:OLE automation, OOP

ScriptBasic can emulate / interface with all three.

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

Re: ScriptBasic

Wed May 15, 2019 2:19 pm

Hippy,
hippy wrote:
Wed May 15, 2019 1:56 pm
I don't understand why you would expect any BASIC-descended language to comply with some 'official BASIC standard' ( if such a thing existed ) when you wouldn't expect a C-descended language to comply with any 'official C standard'.
C descended languages are not C, just like C is not Algol 68.

Just read the long threads here on "Why avoid BASIC", Script BASIC, and BBC BASIC.
Can you keep track of the all the languages calling themselves BASIC ? I cant.
And I certainly cannot keep track of all the different semantics and syntax for each of myriad BASIC versions that keep randomly changing at the whim of the individual developer.

I write a program in strict standard conforming C, even a big one, and I expect it to compile and work with any respectable C compiler on any platform. If not (nowadays anyway) its my bug or my lack of understanding.
That's clearly not true of ???? BASIC.
Last edited by jahboater on Wed May 15, 2019 2:25 pm, edited 3 times in total.

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

Re: ScriptBasic

Wed May 15, 2019 2:23 pm

ScriptBasic is written in ANSI C. It has one source tree for all platforms. Runs on everything.
Last edited by ScriptBasic on Wed May 15, 2019 2:27 pm, edited 1 time in total.

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

Re: ScriptBasic

Wed May 15, 2019 2:23 pm

ScriptBasic wrote:
Wed May 15, 2019 2:23 pm
ScriptBasic is written ANSI C. It has one source tree for all platforms. Runs on everything.
I rest my case :)

BTW I am not complaining about any kind of basic, each to his own.

For me, I just prefer the simplicity of one standard language. I find all these BASIC's a little overwhelming.
Last edited by jahboater on Wed May 15, 2019 2:29 pm, edited 1 time in total.

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

Re: ScriptBasic

Wed May 15, 2019 2:26 pm

jahboater wrote:
Wed May 15, 2019 2:02 pm
The descendent's of BASIC are all called BASIC.
No they aren't. They give themselves unique names to distinguish themselves from "BASIC". Just as Objective C, C++ and C# do to distinguish themselves from "C".

In including the name of their parent languages they are merely acknowledging their heritage, recognising their parentage, not claiming to be identical to those parents.
jahboater wrote:
Wed May 15, 2019 2:02 pm
PowerBASIC, BBC BASIC, Script BASIC, QB BASIC etc, and all claim to be the new BASIC.
"new BASIC" != "BASIC"

They aren't claiming to be "BASIC" they are only claiming to be "descendants of BASIC".

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

Re: ScriptBasic

Wed May 15, 2019 2:34 pm

jahboater wrote:
Wed May 15, 2019 2:19 pm
I write a program in strict standard conforming C, even a big one, and I expect it to compile and work with any respectable C compiler on any platform. If not (nowadays anyway) its my bug or my lack of understanding.
That's clearly not true of ???? BASIC.
It is if you write in BASIC. But when you are writing a program in Visual Basic, QB Basic, Xojo, or any other basic-descended language you are writing in those languages, not "BASIC".

It's as wrong to call Visual Basic or Xojo "BASIC" as it is to call C++ or Go "C".

One wouldn't expect Visual Basic to compile Xojo program without error, or vice-versa, any more than you would expect Go to compiler a Rust program without error, or vice-versa. They are all their own unique languages, even if they may be descended from the same parent.
Last edited by hippy on Wed May 15, 2019 2:37 pm, edited 1 time in total.

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

Re: ScriptBasic

Wed May 15, 2019 2:36 pm

hippy wrote:
Tue May 14, 2019 5:20 pm
jamesh wrote:
Tue May 14, 2019 4:16 pm
So just don't write crap code, irrespective of whether the compiler/interpreter find it valid or not.
I would counter that this isn't really about writing code, more about what a compiler should do with crap code when a programmer writes that, when a programming language allows that to be done.

I would hope it's interesting to those who are into compiler writing or programming language design but can well understand why it won't be to anyone who isn't.

BTW: What colour paint have you got drying ? Do you know its Pantone number ?

:P :P
RAL5005.
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
ScriptBasic
Posts: 1006
Joined: Wed Apr 03, 2019 5:53 pm
Location: Anacortes, WA USA
Contact: Website Twitter

Re: ScriptBasic

Wed May 15, 2019 2:36 pm

With the C BASIC gcc pre-processor, I make C look like BASIC. All modern languages are a descendent of BASIC program flow including C.
Last edited by ScriptBasic on Wed May 15, 2019 2:43 pm, edited 2 times in total.

Return to “Other programming languages”