Jump to content

Recommended Posts

I teach a small group of children the programming language Scratch and ScratchJr. While it is easy, cute, and simple, I don't quite like it. I want to be able to teach the kids more about the computer architecture in general. The 6502 is a perfect choice for that IMHO. I can teach everything there is to know using an Apple ][, C64, or X16, but that means using BASIC.

Question: Should I teach C64 BASIC, X16 BASIC (similar but better "hardware"), or GW-BASIC (A very solid BASIC using the awesome PC-BASIC emulator)?

What are the pros and cons and what are your thoughts? Maybe even ditch BASIC altogether? Is it a waste of time to teach an "obsolete" language?

  • Like 3

Share this post


Link to post
Share on other sites

I had similar thoughts recently. A C64/C128/X16 seems to be a good platform for teaching beginners, since BASIC is easy, and the device offers almost no distractions from that. Switch it on - you have BASIC. No knowledge required up to this point and you are ready to start. I like that a lot. I think BASIC is well suited for teaching the basic concepts (ba-dum-tss), and later you can move on to other languages on other platforms.
There is, of course, the matter of acquiring the hardware...

Share this post


Link to post
Share on other sites

Not at all a waste of time. It's important to teach CONCEPTS, not languages. Learning BASIC is about teaching kids how stuff works. I keep seeing programmers leaving college being unable and unwilling to look beyond the language they've been taught. That's the main reason for this JavaScript everywhere madness. So I'm all for teaching BASIC, but making it clear that this is a first stepping stone.

Thanks for teaching the young! We need more people like you.

  • Like 2

Share this post


Link to post
Share on other sites
3 minutes ago, Fnord42 said:

There is, of course, the matter of acquiring the hardware...

Getting actual C64s for kids is not feasible. What kind of monitor are you going to plug them in? I'm absolutely in love with my Colo(u)r Maximite 2. It's the perfect modern BASIC machine.

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

I would use actually anything then C64 for BASIC. The reason is, that they run out of ROM space and did not imlement a lot of basic things. So you have to use Peek and Poke with weird numbers and you will never get to it - actually very painful. 

You cannot even plot a point or draw a line on the screen.

To be honest everyone had a 6502 based computer (C64 for the most part) in the 80s, but C64 Basic was never good. Also the C64 architecture esp. the video modes are so weird, if you come from any other computer you will think that the developers were insane. Yes it had hardware sprite support, but the pure basic (not the language) design of the video memory was a nightmare. Drawing a line on the C64 is absolutely painful, as the memory is organized in a very weird structure. It does not simply count up the lines one by one etc.

So X16 IS a big improvement in BASIC dialect as the developers have implemented a lot of those missing functionality. That will help to avoid all Peeks and Pokes (hopefully).

Look at Amstrad CPC Basic. The computer is very simple as well and even simpler in certain aspects. It has a great and full featured BASIC implementation that let you program anything you like without the need for Peeks and Pokes. The only time you need Peek and Poke is if you want to embed Machine routines in your BASIC code and want to poke that to memory and then run the routine. 

Also I would go with emulation. No reason to buy real hardware for learning to Programm BASIC. Hardware makes a lot of sense if you want to teach how computers work and BASIC is just your vehicle for easy access. Then the X16 is my clear recommendation. It has a much simpler architecture compared to the C64 (the bank switching alone on the C64 is a nightmare and much easier to understand on the X16). 

Just my personal thoughts.

Edited by SerErris
  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

I'm teaching my 9-year-old daughter python, and it's going pretty well. Like BASIC, it has the benefit of an interactive shell, but is a better introduction to actual modern programming. At the end of the day, she has learned an actually useful language, and it wouldn't be as difficult to move on to other languages. And she can do it on pretty much any platform, so not tied to any hardware or OS.

That being said, she sees what I'm doing with the X16 and she's really curious about 65C02 assembly. Can't wait till she's ready to dive into that!

Edited by SlithyMatt
  • Like 4

Share this post


Link to post
Share on other sites
6 minutes ago, Fnord42 said:

There is, of course, the matter of acquiring the hardware...

Well... I'd think the students would run VICE emulator on their PC or run "Hand BASIC - CBM Flavor" on iOS iPad. As last resort, spend $35 on the amazing C64mini.

Wouldn't the X16 emulator be better since it has better "hardware"?

Share this post


Link to post
Share on other sites
1 minute ago, geek504 said:

Well... I'd think the students would run VICE emulator on their PC or run "Hand BASIC - CBM Flavor" on iOS iPad. As last resort, spend $35 on the amazing C64mini.

Wouldn't the X16 emulator be better since it has better "hardware"?

Yes .. X16 is much better, cause BASIC is much better on X16 than on C64. As I wrote .. it is really painful and ugly on C64. Not enough space in ROM for C64 BASIC 2.0. The C128 hat much better and the C+4 even better, however the C+4 is a completely different machine and the C128 requires to run in 128 mode to see the new BASIC. In 64 mode you are back to square one as it is 100% compatible with a C64 in that mode.

  • Like 1

Share this post


Link to post
Share on other sites
8 minutes ago, SerErris said:

I would use actually anything then C64 for BASIC. The reason is, that they run out of ROM space and did not imlement a lot of basic things. So you have to use Peek and Poke with weird numbers and you will never get to it - actually very painful. 

You cannot even plot a point or draw a line on the screen.

To be honest everyone had a 6502 based computer (C64 for the most part) in the 80s, but C64 Basic was never good. Also the C64 architecture esp. the video modes are so weird, if you come from any other computer you will think that the developers were insane.

[snip]

You said what I felt exactly. I always thought the Applesoft BASIC was better than C64 BASIC because doing graphics was easy: HGR, HPLOT, HCOLOR, etc. and kids NEED graphics!

GW-BASIC is also pretty straightforward to use graphics and is very mature with lots of books available, BUT that's the "problem"... just BASIC and not too much hardware (emulation of course).

X16 BASIC would allow me to teach BASIC, then 6502 Assembly, then talk about memory map, zero page, stack, soft switches, ROM, etc.

Then the real Commander X16 will allow me to teach about the expansion slots and hardware hacking akin to the Raspberry Pi and Arduino.

The plus being the child/teen can learn A LOT with an 8-bit machine without getting LOST with 64-bit wide registers, 16GB+ RAM memory space, complex OS APIs, etc.

Learning 8-bit assembly within 64K memory space allows for efficient coding, something that's been lost today! Who remembers Michael Abrash's extremely tight x86 assembly code?

  • Like 2

Share this post


Link to post
Share on other sites
Posted (edited)
1 hour ago, SlithyMatt said:

I'm teaching my 9-year-old daughter python, and it's going pretty well. Like BASIC, it has the benefit of an interactive shell, but is a better introduction to actual modern programming. At the end of the day, she has learned an actually useful language, and it wouldn't be as difficult to move on to other languages. And she can do it on pretty much any platform, so not tied to any hardware or OS.

That being said, she sees what I'm doing with the X16 and she's really curious about 65C02 assembly. Can't wait till she's ready to dive into that!

You're a brave father! I only taught Python to my teenage son because he wanted to write games. Now he's learning C# with Unity. I'd think Python has a lot happening under the hood which may confuse a curious child... "Daddy, what does IMPORT TIME, IMPORT MATH, IMPORT OS, etc. do?" While it can be explained, it adds a whole new dimension to her learning. Having all the BASIC software and functions in ROM gives a certain comfort. Anything missing, just write it yourself! This LIBRARY making process will then help explain the IMPORT statements 🙂

I'd love to watch you teach her LAMBDA functions... 🙂

Edited by geek504
  • Like 1

Share this post


Link to post
Share on other sites

6502 is also very bare bones ... you cannot even add x to a. I grew up on a Z80 and never understood why people loved the 6502. It is most likely a nostalgia thing, as the C64 were everywhere and people had access to a 6502 . Z80 was much more in UK and in Germany present and still compared to Commodore a fraction of the Market. However looking from today’s perspective the Z80 was much easier to program for real things. For learning assembler in general the 6502 is pretty good as it has only very few commands to learn. The addressing modes then makes it difficult to understand. Esp Indexing has some serious limitations that you need to work around and that no one would put in any CPU anymore those days.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, SerErris said:

6502 is also very bare bones ... you cannot even add x to a. I grew up on a Z80 and never understood why people loved the 6502. It is most likely a nostalgia thing, as the C64 were everywhere and people had access to a 6502 . Z80 was much more in UK and in Germany present and still compared to Commodore a fraction of the Market. However looking from today’s perspective the Z80 was much easier to program for real things. For learning assembler in general the 6502 is pretty good as it has only very few commands to learn. The addressing modes then makes it difficult to understand. Esp Indexing has some serious limitations that you need to work around and that no one would put in any CPU anymore those days.

One of the differences between the Z80 and the 6502, it sounds like, is that the 6502 effectively only had the accumulator. For additional general-purpose registers, most folks looked to ZP memory, which could be accessed more quickly than the rest of memory. The X and Y registers are not intended to be general-purpose, they are index registers. There's just enough power in the opcodes to blur that distinction a little, though, so I can understand the confusion.

  • Like 2

Share this post


Link to post
Share on other sites
54 minutes ago, StephenHorn said:

The X and Y registers are not intended to be general-purpose, they are index registers. There's just enough power in the opcodes to blur that distinction a little, though, so I can understand the confusion.

Yeah, especially with LDX, STX, LDY, and STY. You'd normally use the accumulator when doing memory transfers (i.e. with LDA & STA'ing), but you can indeed do the same with the X and Y, just with less addressing modes.

For example, the standard 6502 has increment/decrement instructions that can only be performed on index registers or directly on memory contents (i.e. RMW), but not the accumulator. If I want to do a "dest=src+1", then I'd use an LDX/INX/STX triplet. Changing the X's to Y's will work just fine as well. However, changing them to A's won't work (needs ADC with relevant CLC/SEC), but thankfully, the 65C02 in the CX16 added INA and DEA, so I can be able to use the accumulator for this operation.

Share this post


Link to post
Share on other sites
32 minutes ago, StinkerB06 said:

the 65C02 in the CX16 added INA and DEA, so I can be able to use the accumulator for this operation

Those opcodes are not listed in the reference I've been using (http://www.obelisk.me.uk/65C02/reference.html), nor any other 65C02 references I've found, including the datasheet for the WDC 65C02S. Also, they are not implemented in the emulator.

Share this post


Link to post
Share on other sites
8 minutes ago, StephenHorn said:

Those opcodes are not listed in the reference I've been using (http://www.obelisk.me.uk/65C02/reference.html), nor any other 65C02 references I've found, including the datasheet for the WDC 65C02S. Also, they are not implemented in the emulator.

INA and DEA are alternative mnemonics for "INC A" and "DEC A", to be consistent with the X and Y equivalents.

Share this post


Link to post
Share on other sites

Do any assemblers use INA or DEA? I've never seen that mnemonic before. For ca65 you just use implicit INC and DEC, as long as you are specifying a 65C02 target.

Share this post


Link to post
Share on other sites

From Wikipedia:

INC and DEC with no parameters now increment or decrement the accumulator. This was an odd oversight in the original instruction set, which only included INX/DEX,INY/DEY and INC addr/DEC addr. Some assemblers use the alternate forms INA/DEA or INC A/DEC A.

Share this post


Link to post
Share on other sites
On 8/28/2020 at 9:49 PM, SerErris said:

6502 is also very bare bones ... you cannot even add x to a. I grew up on a Z80 and never understood why people loved the 6502.

It was an actually reduced instruction set processor before the instruction set got expanded ... so without the dogma.

When you are used to the Z80, your reaction is "how can I do as much as possible in the registers" because with four clock cycles to each memory cycle, going out memory is expensive.With the 6502, your reaction is "how can I do as much as possible in zero page, because you save 20% to 25% of your clock cycles on a Read-Modify-Write.

But the most complex instruction only takes six clock cycles, so a 6502 programmer looks at a z80 instruction set and sees instructions that take 15 or 23 clock cycles and asks, " wait a minute, is that a typo?"

And some of the oversights in the 6502 are fixed in the 65C02 ... the fastest generally practical direct threaded Forth "NextOp" in the NMOS 6502 is self modifying in the zero page:

DoNext: INC IPV+1 : INC IPV+1 : BEQ +

IPV: JMP (COLD)

+ INC IPV+2 : BRA IPV ; = 20clock cycles including JMP DoNext, 29 on pages crossing

... and it requires aligned addresses, which is a pain. Meanwhile a faster 65C02 DoNext is:

DoNext: INX : INX : JMP (COLD,X) ; 13 cycles, including JMP NextOp at end of primitives.

... with updating the instruction pointer deferred until calling high level calls or executing branches.

 

  • Like 2

Share this post


Link to post
Share on other sites

Yep, that might be a thing and the approach is different. However the Z80 had so much other thing (other than the memory access issue) like 16bit index registers and other stuff. The concept of pages in memory was also completely new to me, as the Z80, did not know any pages. 

But anyhow .. the beauty of the 6502 is that it is very easy to learn. On the other hand it is at the same time very difficult to master. You need to be either very bright, or read a lot of stuff that is not officially documented, but hidden everywhere (like in this thread now 🙂 ). 

Thanks @BruceMcF for the knowledge sharing .. appreciate it.

  • Like 4

Share this post


Link to post
Share on other sites

I really think that the 6502 is not harder to master if it's your first processor, rather it's harder to master if it's your second or later. The peculiarities are not on their own hard to master, what is hard to overcome are habits of thought assuming more orthogonal operations.

"I want to do a post-indexed indirect, which index register is that again?" is a question of someone who has originally learned programming on a chip with multiple registers able to do a set of indirect addressed operations. Someone who learns the 65C02 at the outset thinks, "I want to do an (a),Y" and which register it is that can do it is not a question. Indeed, since I learned 6502 programming by the seat of my pants, I've had to unlearn some bad habits to get xForth working reliably ... like trying to use BMI and BPL after a CMP operation for an unsigned comparison instead of using BCC and BCS.

The Z80 is DEFINITELY kinder to high level languages. A main reason I would like a CP/M box of a Z80 and it's own RAM, calling a support program in the CX16 for it's I/O, are all of the old classic languages available in CP/M ... not only multiple Forth's and both interpreted and compiled Basic's, but also bytecode & Turbo Pascal, Aztec, BDS, and Mix C, and the original self-hosting Small C, Microsoft Fortran and Cobol, Nevada Fortran and Cobol, Modula2, APL, Ada, etc.

A CP/M box is a 1970's and 1980's "living programming history in a can".

  • Like 1

Share this post


Link to post
Share on other sites
On 8/28/2020 at 1:11 AM, geek504 said:

I teach a small group of children the programming language Scratch and ScratchJr. While it is easy, cute, and simple, I don't quite like it. I want to be able to teach the kids more about the computer architecture in general. The 6502 is a perfect choice for that IMHO. I can teach everything there is to know using an Apple ][, C64, or X16, but that means using BASIC.

Question: Should I teach C64 BASIC, X16 BASIC (similar but better "hardware"), or GW-BASIC (A very solid BASIC using the awesome PC-BASIC emulator)?

What are the pros and cons and what are your thoughts? Maybe even ditch BASIC altogether? Is it a waste of time to teach an "obsolete" language?

IMHO, a good first "text" oriented programming language after Scratch is Logo.

  • Like 1

Share this post


Link to post
Share on other sites

I programmed in LOGO on the C64 is was pretty enjoyable!  (it wasn't only turtle graphics but also string manipulation and pattern matching if I recall correctly)!

HOWTO Square;     repeat 4 ;  fd 100 rt 90  ;    end        Or something 🙂

  • Like 1

Share this post


Link to post
Share on other sites

I don't think BASIC is such a great idea to teach kids. It lacks a lot of features which makes languages easier to understand and use today, it's very verbose for a language, its reliance on goto statements instead of proper loops encourages spaghetti code, it's not object oriented while everything in the modern day is object oriented and it's not very modern so even if you can teach the basics with BASIC, it's obsolete knowledge. Don't get me wrong, I enjoy programming in BASIC, maybe not as much as someone from the Commodore 64 era, but I do and I'll tell you that it seems to me that a lot of the positive opinions about the language are linked more to nostalgia than facts. I'm not saying BASIC is hard to learn or use. What I'm saying is that it has been outclassed; there are several other choices which are much better suited for new beginners and there are even technologies such as Scratch which have been created with kids in mind.

In some way, this discussion has reminded me of the old days when I first got into programming. I naively wanted to learn C++ because I wanted to make games on my Dreamcast (yes, you heard correctly, I'm much younger than a lot of you here) and people kept saying the first step to learning computer programming was C, then C++. But the truth is, Java, C#, Python and Javascript are much more beginner friendly and have actual uses in the modern world. I've struggled to learn C/C++ for a long time, but when I first learned Java, things fell into place much more easily. Then I used what I had learned to master other languages much more easily and now I can use pretty much any language I want, because I learned the basics from an easy language and made my way up lower level languages such as C++, C and even assembly.

  • Like 1

Share this post


Link to post
Share on other sites

To be fair, the Editor Basic will supposedly have nomal programming structures and normal Labels, and not require GOTO or line numbers. It it will be TRANSLATED into line numbers and GOTOs, but that can be entirely behind the scenes, just like in Forth I write FOR >R COUNT R> CPUT NEXT and it compiles the equivalent of:

L1: !word TOR,

CMOVE1: !word TOR,COUNT,RFROM,CPUT

L3: !word DONXT,CMOVE1

Edited by BruceMcF
  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, Doigt said:

it's not object oriented

That's a good thing (most of the time). It doesn't really matter if it's "object oriented" or "structural". Objects tend to become bloatware and structures need some discipline to maintain properly. And Java, excuse my french, is a pain in the ass: Bloated, slow, depends on a huge runtime (needs a paid licence for companies) and permanent patch-management ...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use