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

Re: BASIC - more harmful than useful?

Sat Jan 07, 2012 3:11 pm

Chromatix said:


I think that it is possible to invent a language which is as simple to start with as BASIC - not requiring any boilerplate just to get words or simple graphics on the screen - but which has more advanced features, waiting only for the need to use them.

The important thing is to ensure that the advanced features never get in the way of learning the simple ones - they are not stumbled across by accident, nor required in boilerplate form to access the simple features.


I agree it's best to create an "R-Pi Basic" which keeps to the spirit of the Basic heritage but delivers what is needed for the R-Pi environment, both for newcomers and more advanced programmers.

"Option Explicit On/Off" is one way to determine whether variables need to be pre-defined or not ( though may be better as an IDE or command line switch ) and no reason we cannot have options for any number of things; to warn newbies that where they are straying 'there may be dragons' and so on or limit capabilities available, while providing everything the more advanced programmer could need.

Defining a specific "R-Pi Basic" would allow us to create a language which suits both camps so I'd be in favour of it. I've developed ( but not completed ) compilers which support Basic, Pascal and C-style programming in one language allowing the user to pick and choose ( even mix! ) the flavour they like. There are also downsides to that but there are plenty of options available.

The most frustrating thing I find when moving between languages is remembering that things are different in each, hex constants are prefixed with 0x, &h, $, h'..' or are 0...h, equality tests are <> and = or != and ==, arrays are ( ) or [ ], and I've always felt it would be good for a language to support as many options as possible within its design. Designing a new language provides the option to allow that.

No matter what is done, perhaps the first thing to do is to define what that language should be. Of course that's not necessarily going to be an easy task, and like every new language is reinventing the wheel.

User avatar
riffraff
Posts: 307
Joined: Tue Sep 27, 2011 3:17 am
Location: Newnan, Georgia, US

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 1:17 am


hippy said:

Chromatix said:

I think that it is possible to invent a language which is as simple to start with as BASIC - not requiring any boilerplate just to get words or simple graphics on the screen - but which has more advanced features, waiting only for the need to use them.

The important thing is to ensure that the advanced features never get in the way of learning the simple ones - they are not stumbled across by accident, nor required in boilerplate form to access the simple features.

I agree it's best to create an "R-Pi Basic" which keeps to the spirit of the Basic heritage but delivers what is needed for the R-Pi environment, both for newcomers and more advanced programmers...


Start with Dartmouth set, add extensions for GUI and maybe, to get everyone in the mood, add some branching/control structures that resemble those peculiar to ARM family ML code?




User avatar
riffraff
Posts: 307
Joined: Tue Sep 27, 2011 3:17 am
Location: Newnan, Georgia, US

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 1:51 am

If you're think of this as an IDE, You might want to start from the from the very beginning with the concept of declarations in a "Variables" page/tab. I'm thinking along the lines of Scratch, but with a UI with definable levels of complexity.

The IDE is the tutorial environment. As you progress through each tutorial level, new "Tools" are added to your "Tool Box" and as necessary, the U/I is upgraded with new panels or tabs to access the required Tool-related features.

User avatar
Chromatix
Posts: 430
Joined: Mon Jan 02, 2012 7:00 pm
Location: Helsinki

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 6:05 am

I think providing "more than one way to do it" too extensively will just end up with Perl.  I've seen quotes by highly competent and experienced programmers that if they stop using Perl continuously for more than a few weeks at a time, they *forget* how to use it and have to learn again.  That's not even including the line-noise that obfuscated Perl looks like.

By contrast, I think that making things as conceptually simple and straightforward as practical will be more helpful.  Everything else is just syntax, whch is relatively easy to relearn when moving to a new language.
The key to knowledge is not to rely on people to teach you it.

User avatar
riffraff
Posts: 307
Joined: Tue Sep 27, 2011 3:17 am
Location: Newnan, Georgia, US

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 10:06 am

Chromatix said:


I think providing "more than one way to do it" too extensively will just end up with Perl...

...By contrast, I think that making things as conceptually simple and straightforward as practical will be more helpful.  Everything else is just syntax, whch is relatively easy to relearn when moving to a new language.


Most of the gripes I've seen here about BASIC come from a fundamental misunderstanding of what BASIC on early machines was, at least on the Microsoft ROM based interpreters.

You were actually swimming around in the machine executable code. Line numbers were integral to the function of the interpreter.  Commands and functions were stored in the workspace "tokenized" form as a 2-byte number. Lines were terminated with a null. It was actually preferable to have several statements on a single line.

All of that crap is gone. It isn't necessary to squish all of that together to get it all to fit in 4-16K of memory.

If you start from scratch, you can create and environment that encourages the creation of clean, readable and hopefully elegant code.

I've been pondering Scratch, VB and some of the earlier code editors I've used and daydreaming of the ultimate IDE/learning environment. Please excuse my musings:

Would like to see a "Helper" and Editor that encourages producing well ordered, spaced, indented and commented code consistent with good Pascal or C source - very much like VB. The only thing you would be borrowing is BASIC syntax... except, of course, GOTO. If you permit user defined functions and named procedures that makes GOTO superfluous.

Would like to see a tab for a "data dictionary" of declared variables

Also a tab for included libraries.

Parenthetical expressions shaded and some kind of bracketing on left margin for loops and conditional structures.

Procedure and function calls are links. Clicking on one would bring up manual page (or source code for UDF's) in a window.

Clicking on a variable name would take you to that item in the "data dictionary" in the declarations tab.

Clicking on an undeclared parameter would again take you to the manual page for the procedure/function and the explanation of the particular parameter.

Keep the comments out of the workspace, put them in a hovering thought-bubble out of the way so the user stays focused on the source. User could view or print final product with commentary included.


User avatar
Chromatix
Posts: 430
Joined: Mon Jan 02, 2012 7:00 pm
Location: Helsinki

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 11:31 am

There are some good ideas in there - some of which I had already filed away for further consideration.  A decent code editor is something that many experienced programmers would love to have, never mind beginners, especially if it came *without* a bloated and intrusive IDE wrapped around it.

I'm not yet sure whether GOTO is a good thing to leave out or not.  If you read certain bodies of code written by highly competent people - like, say, the Linux kernel - you actually see a lot of gotos being used, usually as a way of handling exceptions cleanly.  Of course if you drop line numbers, you have to use labels instead as targets for the goto.

Perhaps a good exception mechanism could replace GOTO in a language that enforces structured programming - we certainly need something to replace ON ERROR anyway.

The counter-argument might be that having GOTO available is valuable for simplification in the early days, and to demonstrate why over-using it is a bad idea later on.  It is also equivalent to the most common type of branch in assembly, and is therefore an important concept for low-level programming.

Meanwhile I'm making gradual progress with my ideas.  I've got a type system that I'm reasonably happy with, so I can start thinking about syntax, operators and other features.
The key to knowledge is not to rely on people to teach you it.

spock
Posts: 208
Joined: Sun Oct 02, 2011 10:33 am

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 11:33 am


I think that it is possible to invent a language which is as simple to start with as BASIC – not requiring any boilerplate just to get words or simple graphics on the screen – but which has more advanced features, waiting only for the need to use them.



i don't think a new language is needed for that. the teacher simply could hide the boilerplate in some helper library.

for example in python:

from rpi_helper import *

draw(100, 100)


wah, that ugly first line!!! i haven't tried it but i am sure there are ways to include it by default.

Would like to see a "Helper" and Editor that encourages producing well ordered, spaced, indented and commented code consistent with good Pascal or C source it's funny how editors always should encourage well indented code but how indentation in python is seen as a huge disadvantage.

User avatar
Chromatix
Posts: 430
Joined: Mon Jan 02, 2012 7:00 pm
Location: Helsinki

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 11:35 am

There is one more thing I need to comment on from the above.  A lot of those ideas refer to "clicking on" something.

I think it is important to accommodate users without a mouse, only a keyboard.  The Model A will require a USB hub to attach more than a keyboard, in particular.
The key to knowledge is not to rely on people to teach you it.

roelfrenkema
Posts: 105
Joined: Sat Jan 07, 2012 5:17 pm

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 12:13 pm

I agree console based start best start. No mice please just the cool white characters on a black background. The beauty of simplicity and minimalism. You start your programming live by trail and error and we dont need any mice to obscure things

roelfrenkema
Posts: 105
Joined: Sat Jan 07, 2012 5:17 pm

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 12:17 pm

BTW no code editors either. Just a pain text editor.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 1:49 pm

Chromatix said:


There are some good ideas in there – some of which I had already filed away for further consideration.


Most of them are about environment, not language.


A decent code editor is something that many experienced programmers would love to have


Writing a decent text editor with code awareness is no minor task.  It"s significantly harder than writing a new language, and that"s not easy.  I would strongly suggest staying away from that particular challenge for the moment.  And anyway, there's already a hatful-and-a-half of decent text / code editors out there already.

Anyway, onto the meat of things.  It seems that even the BASIC fans are coming around to the idea that BASIC simply isn"t good enough as it stands, and could bear some improvement.

riFFraFF said:


Most of the gripes I"ve seen here about BASIC come from a fundamental misunderstanding of what BASIC on early machines was, at least on the Microsoft ROM based interpreters.


Not mine.  My gripes are particularly about the expressibility (well, to be more exact, the lack thereof) of BASIC.  Nothing to do with the tokenising, interpretation, or even syntax of the language, but about what it allows you to do.  Surmounting the brick wall that BASIC puts in the programmer"s path means moving away from classic "Dartmouth" BASIC and into something else entirely.  That"s fair enough, but it puts you on a long and slippery slope of language tweaking.  It"s hellishly hard to do right, especially when "right" is defined by "producing a language for teaching".

Before going any further, and as an absolute minimum, you need to read, and totally understand, Sussmann & Abelson"s "Structure and Interpretation of Computer Programs".  You need to understand what needs to be part of a language, and what can be built onto a language with extensions written in the language / linking to external libraries.

You probably want to be intimately acquainted with Papert"s work, the stuff that came out of the Xerox AI labs, Bertrand Meyer"s stuff, and to be able to read and contribute on Lambda the Ultimate.  Of course, once you"ve got to that stage, you may find yourself wondering what, exactly, you originally thought was so great about BASIC in the first place.

Did I suggest it was easier to write a language than an editor?  I lied.  In a mechanical sense, it may be, but in a conceptual sense, it's way, way, harder to write a consistent, useful, language.

If you decide to go for it, for initial implementation, I'd suggest implementing your pseudo-BASIC as a DSL on top of Scheme or Common Lisp.

Oh, and don"t throw GOTO away just yet.  It may be "considered harmful", but it can be particularly useful – it was put into BASIC for a reason.  I"d throw away GOSUB instead.

Simon

User avatar
ukscone
Forum Moderator
Forum Moderator
Posts: 4155
Joined: Fri Jul 29, 2011 2:51 pm
Contact: Website

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 7:41 pm

Just to annoy people and because I am waiting for the wife to get ready (it's been 3 cups of coffee and 90 minutes so far) so we can go out to get new cellphones I decided to build tinybc (tiny basic for curses) for the raspi

it works quite well inside scratchbox2 & qemu and is built static so it should be ok on any armv6 linux setup.

http://russelldavis.org/Raspbe.....yPi/tinybc


richcole
Posts: 21
Joined: Sat Dec 10, 2011 11:54 pm

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 9:00 pm

You could write a lisp interpreter in basic and then your done.

User avatar
riffraff
Posts: 307
Joined: Tue Sep 27, 2011 3:17 am
Location: Newnan, Georgia, US

Re: BASIC - more harmful than useful?

Sun Jan 08, 2012 10:20 pm

@ Chromatix

Yes you are correct - go away, GOSUB, if not GOTO. 3:00 am musings are more like the insane ramblings of the inebriated and every thought seems golden at that hour.  They all look quite silly and obvious in the light of common day. You're forgiveness for my foolishness is humbly requested.

Yes, you are correct, most of my thoughts have been about environment. I've been thinking about how I learned, what I found helpful, how I might teach my young niece (if I thought she was inclined to learn) and how you can possibly keep a youngster's attention outside of the classroom setting.  It's much harder to do that now. When we were younger and playing with programs, we were creating something new. Now the reaction is "and why am I doing this when I can download it from cNet!!!?".

I've always felt that the greater part of learning comes in that alone time at home. The up-side is that there are ( hopefully =/ ) fewer distractions and you're not bound by course directives or pushed for time. The down-side is that you have fewer information resources outside of the classroom.  That's when the tools come in handy.  Code aware editors are useful when you're studying existing code and online documentation allows you to stay focused on the flow of the program.

It's been many, many moons since I've used a stand-alone code-aware editor, and that only for Clipper. If I recall correctly, you had to select a configuration file in the settings of the editor I'd chosen to customize it for the target language. Developing an editor for even one flavor is a black art, I'm sure.

What I'm thinking of is less an editor and more of a generator. Forgive me, I was immediately smitten with Scratch and found myself wondering if something similar could be created that is less toy and more tool - something that starts out with manipulable objects and produces usable code. That step may be entirely unnecessary as I may be underestimating the power of young minds to grasp a new language.

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

Re: BASIC - more harmful than useful?

Mon Jan 09, 2012 12:49 pm

tufty said:

It seems that even the BASIC fans are coming around to the idea that BASIC simply isn"t good enough as it stands, and could bear some improvement.
In the sense of K&R C being superseded and C++ being a development upon C and other languages' evolution then it can be seen in that way.

Every language can likely be said to have some deficiency or disadvantage whether in capabilities and means of doing things, in ease of use or learning curve and approachability and there's none that is perfect for all things and all men of all capabilities or we'd likely already have one language which rules them all and we'd not be having the debate.

I don't think anyone's saying Basic isn't good enough per se but it would be fanciful to say it could never be improved upon, made better or more useful in some respect. Every new language undoubtedly seeks to improve upon other languages which exist, and languages evolve to improve themselves. I don't see that Basic should be expected to be any different.

Wooloomooloo
Posts: 92
Joined: Fri Nov 25, 2011 10:52 am

Re: BASIC - more harmful than useful?

Mon Jan 09, 2012 1:40 pm

*sigh* Ok, I'll bite. What exactly is wrong with GOSUB, and how is one supposed to write programs without using subroutines/procedures/functions/whatever-you-prefer-to-call-them...?

User avatar
Chromatix
Posts: 430
Joined: Mon Jan 02, 2012 7:00 pm
Location: Helsinki

Re: BASIC - more harmful than useful?

Mon Jan 09, 2012 3:21 pm

GOSUB relies on global variables, because it does not take parameters or return results.  That's *really* bad - even assembly does not really work that way.

Structured programming (including DEF PROC/FN in BBC BASIC) uses parameters and (optional) returning of results.  This eliminates the need to us global variables for this purpose, except when a large amount of shared state needs to be modified (and even then it is better to pass it in by reference).

Hopefully that clarifies the point.
The key to knowledge is not to rely on people to teach you it.

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: BASIC - more harmful than useful?

Mon Jan 09, 2012 8:01 pm

Chromatix said:


GOSUB relies on global variables, because it does not take parameters or return results.  That's *really* bad - even assembly does not really work that way.


Actually, I would say that assembler / machine languages for most popular architectures do exactly that.  ARM's Branch and Link instruction just jumps to the subroutine while setting the Link Register (R14) to the return address.  Arguments and results are passed via global resources like general-purpose registers and the stack.  IBM 360/370 and PowerPC do essentially the same thing.  IMO, it's only architectures with stack-like register files like SPARC, AMD 29000 [sic], and CRISP that really model C or Pascal function calls, and they've had limited success.

pvgb
Posts: 51
Joined: Sat Oct 15, 2011 9:53 pm

Re: BASIC - more harmful than useful?

Mon Jan 09, 2012 11:42 pm

I suddenly wondered which dialect of Basic we are talking about - Dartmouth Basic ?

( Did gosub as I remember, but also had matrix operations built in )

Somebody has compiled a list of Basic (derived languages) and popped it onto

http://en.wikipedia.org/wiki/L.....C_dialects

A quick browse indicated that there were Basics with Object Oriented features (!) pointers, recursion, multitasking  ...

Somebody must like it !

2+8  <  number of versions of Basic !

( Maybe 2^8 is nearer ! )

Narishma
Posts: 151
Joined: Wed Nov 23, 2011 1:29 pm

Re: BASIC - more harmful than useful?

Tue Jan 10, 2012 1:01 am

pvgb said:


I suddenly wondered which dialect of Basic we are talking about - Dartmouth Basic ?

( Did gosub as I remember, but also had matrix operations built in )

Somebody has compiled a list of Basic (derived languages) and popped it onto

http://en.wikipedia.org/wiki/L.....C_dialects

A quick browse indicated that there were Basics with Object Oriented features (!) pointers, recursion, multitasking  ...

Somebody must like it !

2+8  <  number of versions of Basic !

( Maybe 2^8 is nearer ! )


I think that's the problem with this thread. Some people are talking about old BASICs like the ones found on early 8bit computers while others are talking about modern versions with optional line numbers, procedures, objects and whatnot which are really not that different from Java, Python or C#.

Bakul Shah
Posts: 321
Joined: Sun Sep 25, 2011 1:25 am

Re: BASIC - more harmful than useful?

Tue Jan 10, 2012 1:01 am

John Beetem said:


Chromatix said:


GOSUB relies on global variables, because it does not take parameters or return results.  That's *really* bad - even assembly does not really work that way.


Actually, I would say that assembler / machine languages for most popular architectures do exactly that.  ARM's Branch and Link instruction just jumps to the subroutine while setting the Link Register (R14) to the return address.  Arguments and results are passed via global resources like general-purpose registers and the stack.  IBM 360/370 and PowerPC do essentially the same thing.  IMO, it's only architectures with stack-like register files like SPARC, AMD 29000 [sic], and CRISP that really model C or Pascal function calls, and they've had limited success.


All HLLs use a "calling convention" (basically specifying how args are passed, results are returned, which registers can be used as temporaries and so forth) to ensure that at the *language level* arguments and results are local (and not in global) and functions are reentrant. And this calling conventions is chosen to allow efficient use of resources. Thus typically the first few args and the result are in registers. Only if you call another function would you push your incoming arguments on the stack. You can call assembly language function from your HLL (or vice versa) *as long as* the assembly lang function follows the same convention.

Even on the amd29k! It did provide a register stack but you would only use it as such if you are *not* a `leaf' procedure (that is, you won't call another function). If you are a leaf, there is no point in wasting time in setting up / tearing down the local frame (which required 4 instructions). The return value was in a global register (though the return *address* was in the register stack).

This "reentrancy" feature of a subroutine (as they used to call in the old days) has to be at the language level & GOSUB doesn't have it. Now we take it for granted that any function f can call itself from within its body (or a function it calls) but in the old days there were passionate arguments about the "overhead" of subroutines! Not unlike the arguments for/against BASIC : )

User avatar
Chromatix
Posts: 430
Joined: Mon Jan 02, 2012 7:00 pm
Location: Helsinki

Re: BASIC - more harmful than useful?

Tue Jan 10, 2012 6:08 am

I would characterise registers and stack differently from global memory.  They are used in a local context, and one of those uses is to pass parameters to/from functions.

In the same way, the existence of local variable scopes and parameter passing in true functions cannot be adequately emulated with GOSUB.  Okay, you can set up an array for that specific purpose and a stack pointer into it, but you're reinventing the wheel and it's error-prone.

The PROC and FN features in BBC BASIC are not perfect either - new variables are not local by default - but they are lightyears ahead of GOSUB.  I don't even remember where I last saw a BBC BASIC program using GOSUB.  That's why GOSUB can be dropped without losing any functionality.
The key to knowledge is not to rely on people to teach you it.

Wooloomooloo
Posts: 92
Joined: Fri Nov 25, 2011 10:52 am

Re: BASIC - more harmful than useful?

Tue Jan 10, 2012 9:16 am

Chromatix said:


GOSUB relies on global variables, because it does not take parameters or return results.  That's *really* bad - even assembly does not really work that way.

Structured programming (including DEF PROC/FN in BBC BASIC) uses parameters and (optional) returning of results.  This eliminates the need to us global variables for this purpose, except when a large amount of shared state needs to be modified (and even then it is better to pass it in by reference).


Ah, ok, I see now what the point was about. Thanks.

wardy
Posts: 3
Joined: Tue Jan 10, 2012 8:43 am

Re: BASIC - more harmful than useful?

Tue Jan 10, 2012 9:34 am

The problem with the perception of "basic" is its name.

Sure the early versions were very basic. There are however versions currently available far more capable, far more powerful and far more useful. Some (such as RealStudio) cross compile between Mac, Linux and Windows, Others are apparently useful for gaming code (not tried them, just looked at the forums).

I happen to use RealStudio. Its fast, efficient to code in, fully OOP compliant and when I really can't squeeze out the performance I want, I can switch to C++ and build a plugin which RealStudio uses.

I also program in C++ and Objective-C. Each language has its place. I personally prefer to be open to idea's and possibilities rather than dismiss "a" language based upon its name and my experiences back in the 80's, when there are actually hundreds of variants, some of which are very powerful.

User avatar
riffraff
Posts: 307
Joined: Tue Sep 27, 2011 3:17 am
Location: Newnan, Georgia, US

Re: BASIC - more harmful than useful?

Tue Jan 10, 2012 10:10 am

Forgive me for my ramblings about IDE's. I was almost tempted to cross over to the dark side. Reading one of Liz's posted links reminded me:

http://www.fastcocreate.com/16.....tion-story

esp. the line:


It had to do, they thought, with the rise of hand-holding operating systems that had turned computers into magical black boxes.





And all that from me, the guy who shocked his English Comp instructor on the eve of the Mac's release by writing a final paper predicting the end of computer literacy with the introduction of PARC technology. I seem to be recalling how I learned VBA and not how I learned to program.

One of the aims I was stabbing at was encouraging thorough commentary and portability of code. The best project our Clipper SIG ever embarked on was creating a code library of everyone's favorite functions and procedures. Though we couldn't always use the code unaltered, we were all at different levels of proficiency and benefited greatly from studying each others work.

I could see that being of great benefit to students if you can arrive at a common language that can be carried through several forms. Hopefully something that doesn't stray too far afield from what graduates will see in the workplace. But remember they have access to internet forums with world wide reach, something us old dogs didn't. It will be interesting to see how quickly student's catch on when they're able to share concepts.

http://www.fastcocreate.com/16.....tion-story

Return to “Staffroom, classroom and projects”