BASIC 2? Why not get BASIC 7?

Chat about anything CX16 related that doesn't fit elsewhere
rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

BASIC 2? Why not get BASIC 7?

Post by rje »



4 hours ago, Scott Robison said:




I may be in the minority, but Commodore BASIC v2 is responsible for getting me started!



PET BASIC 4.0 was responsible for getting me started, which is more or less BASIC 2 (we didn't use the disk commands so much).

 

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

BASIC 2? Why not get BASIC 7?

Post by BruceMcF »



9 hours ago, Scott Robison said:




I may be in the minority, but Commodore BASIC v2 is responsible for getting me started! Sure, there are a lot of things missing WRT modern languages, but I firmly believe that learning any language is a useful exercise to get one to begin thinking in a programmer mindset. And the more languages you learn, the better off you are because you being to contemplate programming in the abstract (input, output, variables, conditionals, control structures) instead of the concrete (INPUT, PRINT, A$, IF X=Y THEN ...).



I know there are plenty of people who believe "avoid these toy languages because you'll learn bad habits" or other similar arguments. For learning the basics (pun not intended but apropos) of how to write a program to tell a computer what to do, BASIC is great.



Not every language must lead directly to a six figure income.



Then of course there is assembly / machine language. Talk about a language without modern first class features like functions! ?



Indeed, one advantage of Basic is that is it NOT a "watered down version of a popular modern language", so people who start learning to program on Basic know that they don't know how to program in Java or Python or R or C++ or uhhhh ... Clojure. If the language WAS an aggressively watered down version of a more popular modern language, there would indeed be some people who would be, "yeah, I know how this works" when they set down in front of a real version of those languages, and would set about using all of the bad habits for those languages that they learned because it was how you had to do it in a version of the language stripped down to be able to run on an 8bit processor with, for a base set-up, 558K of RAM.

If the CX16 picks up a niche in education in addition to its core niches, it will be because of the "an entire system you can understand completely" nature of it, not because it's a great sandbox for learning to program Python or R or C++ or Clojure. For that kind of sandbox, a Raspberry Pi will always beat it, hands down.

And of course the biggest language by job listings citations is SQL, so before worrying about a Small-Python, the first target on that track would be a CX16-SQL database manager. ?

iljitsch
Posts: 25
Joined: Thu May 27, 2021 4:38 pm

BASIC 2? Why not get BASIC 7?

Post by iljitsch »


The problem with BASIC is that it is an evolutionary dead end as programming languages go. And BASIC v2 is not even very far down that dead end, it's extremely limited and forces the use of very poor programming habits.

Now, in the interest of shipping the product as well as having some compatibility with the most popular computer ever, it's not a bad idea to go for a slightly extended BASIC v2 now.

But if the Commander X16 is going to be an educational tool in addition to something those of us of a certain age can use to relive our youth, then something better than BASIC (v2) is warranted.

I've seen Forth being suggested. I liked it back in the day, but the RPN is weird and it's also extremely far from the programming main stream.

I barely know Python myself, but when I started looking at it I was struck at how friendly it comes across doing away with the annoying syntax of C-based languages. And except for any time a GOTO appears, it's actually pretty straightforward to convert BASIC to Python. The main issues are that function definitions must come at the beginning of the program and you must explicitly declare global variables. But these are not issues when writing something from scratch.

Even many statements and functions are the same between Python and BASIC, and the missing ones can be added in Python with just a few lines of code.

So the main issue with Python on an 8-bit system is that the language is just too big and too complex. But by simply omitting any features that go beyond what BASIC can do, it should be shoehornable into a system like the X16.

This means that you will be unlikely to run existing Python code on the X16, but the other way around (X16 program on a real Python system) should work as long as you don't use any of the X16's hardware features.

And although I'd say if you want to learn Python, just learn the real thing, it's definitely helpful for people who learn to program on the X16 to be able to take those skills to more modern systems rather than have to start from scratch.

Scott Robison
Posts: 952
Joined: Fri Mar 19, 2021 9:06 pm

BASIC 2? Why not get BASIC 7?

Post by Scott Robison »



27 minutes ago, iljitsch said:




The problem with BASIC is that it is an evolutionary dead end as programming languages go. And BASIC v2 is not even very far down that dead end, it's extremely limited and forces the use of very poor programming habits.



The single best (as in most valuable to me) programming class in college (the first time I tried in the 1980s) was a FORTRAN 77 class. I did not have many of the modern niceties. Sure, it had subroutines and functions, but it didn't have many typical control structures. But the reason it was a great class was not because FORTRAN 77 was a great language (though there are things written 50 or more years ago still being maintained because Fortran is great at what it does). It was a great class because the instructor taught it not as a FORTRAN 77 class, he taught it as a learning to program class. So he actually took the time to show "you should use a WHILE loop in this case; FORTRAN 77 doesn't have a while loop, so you would write it as an IF condition with a GOTO to exit the loop, and a GOTO at the bottom to return to the top.

In my experience of managing and interviewing engineers over the years, there are far too many who are completely lost when they don't have their tool box. They don't know how to adapt. They don't know how to craft a tool that isn't already in their toolbox when needed.

One common question we would ask engineers, just to weed out ones that couldn't cut it, was to write in pseudocode a routine to reverse the characters in a string. We were in a C# shop at this point, and I was shocked at how many BSCS grads could not do it without resorting to a standard library function. The point wasn't that we expected them to write a bunch of string reverse code from scratch. Clearly the standard library would be the best way to accomplish this in production code in most cases. But there are many algorithms / decisions for business logic that will not be in the standard library, and if they can't reverse the characters in a string without a "strrev" function or similar, we knew they were't going to be a good fit for our organization. Note: Just because they *could* write up a strrev didn't mean they *would* be a good fit, but it was a good first step.

So I disagree fundamentally that BASIC is a dead-end language if what you are trying to do is learn logic and program structure. There are ways to write BASIC in a "pretty" way to ensure that it is "structured" even if it must use GOTO. The problem with GOTO isn't that it exists, the problem is that it isn't used well.

Now, I'm not advocating that everyone should be forced to write in BASIC v2 before moving on to other languages, but it could be taught in a way that allows BASIC programmers to adapt to other languages, once they understand that the BASIC incantation for "PRINT" is knowns as "PRINTLN" in Java or "printf" in C "std::cout" in C++. Yes, the syntax is different, but they ultimately do the same things. That's what I think a good programmer / engineer does. They know there are a bunch of types of screwdrivers and wrenches and pliers and other tools. Some are better suited for certain tasks, but in a pinch, you can adapt and use a less capable tool when you must. BASIC is that limited toolbox that can help you learn about the "basics" of tools that you will encounter as an engineer.

In like fashion, 6502 ML isn't a dead end either any more than x86-16 is a dead end in a world of x86-32 or x86-64. They all allow one to learn how CPUs work at a low level and that knowledge can be translated to other platforms.

Circling back to the interview of programmers who are lost when their library doesn't provide the exact tool they need: That doesn't make them bad. There are jobs for people who know how to do particular tasks, and they are good and necessary jobs. I would not be a good fit for a webdev position given my specialty which made me stand out to my employer and which results in regular contacts from recruiters trying to hire me away. A webdev would not be a good match for what I do. Specialization can be a good thing, but so can generalization. It's allowed me to work a number of different industries and with multiple programming languages. Could I do webdev? Probably. I just am not interested in it, so I'm glad there are others who are, and I'm glad my skills are not shared by as many which increases my value in projects that require high performance on custom platforms.

iljitsch
Posts: 25
Joined: Thu May 27, 2021 4:38 pm

BASIC 2? Why not get BASIC 7?

Post by iljitsch »


Dead end as in: it has no living descendants. (At least not as far as I know / recognize.) Obviously you can learn programming in BASIC, as I did myself many moons ago. But structure in BASIC is write-only: perhaps you used GOTOs the most structured way possible. But someone reading the code won't be able to tell. (This is actually also true for imperative constructs like FOR loops, where declarative would be better, but let's not get carried away.)

The structure thing is actually not the worst problem. That can be fixed by extending IF / THEN to IF / THEN / ELSE / ENDIF.

A much more nefarious issue is that you can't use functions like you can in other languages. In BASIC you can define a function, but  but that's in the mathematical sense of the word: you can only use it to calculate something.

With proper functions, people could for instance write their own graphics routines and others could improve those, with no need to lobby the X16 development team for specific additions to BASIC. Having the community extend the language in an organic fashion would be pretty cool.

Actually in my opinion, for someone who knows they want to learn how to program and will commit to the time required up front, I'd recommend C. Although not easy, it's small enough that you can learn the whole thing reasonably quickly and because it's low level in many ways, you learn a whole bunch of computer architecture in the process. But it's still high level enough to get reasonable things done in a reasonable amount of time. And even if you then never program in C again, you're in a good position to learn a good number of other languages.

If you want quick and cool results on something modern, I'd say Javascript along with HTML and CSS. And just like back in the day on an 8-bit home computer, you're not going to understand much of what you're doing for some time, let alone what a lot of other people's code does, but you can do a lot by copying other people's code and tinkering with it.

It's surprising how tinkering with web stuff is the closest thing I've experienced the past decades to experimenting with programming on my C128 back in the day. For instance, I wrote some Javascript to make my Hue lights do things that the apps that are available won't do, which was extremely satisfying.

Oh, by the way:

A$="ABCDE":B$="":FORI=LEN(A$)TO1STEP-1:B$=B$+MID$(A$,I,1):NEXT:PRINTB$

Life was so much simpler before Unicode. ?

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

BASIC 2? Why not get BASIC 7?

Post by BruceMcF »


The thing about the friendliness of Python is it HAS that friendliness because of burning cycles to create it. Assuming that a computer has the cycles to burn on resolving ambiguities based on what is being operated on is a lot more tenuous in an 8bit system. C was originally created in the days of teletypes to access mini computers, so has a syntax that is less tolerant of ambiguity. 

iljitsch
Posts: 25
Joined: Thu May 27, 2021 4:38 pm

BASIC 2? Why not get BASIC 7?

Post by iljitsch »


What kind of ambiguity do you have in mind?

Again: I'm not advocating for anything resembling the full Python that exists today. That is possibly even too much for an Amiga, and famously a non-goal of Python is to be fast. They handsomely non-reach that goal.

After programming in C, PHP and Javascript for a long time the lack of { } and ; in Python was a revelation. Creating structure through indentation is a bit weird, but probably the best/easiest way to do it.

Obviously "real" functions would be quite different from BASIC, and replacing GOSUB subroutines with functions is a bit annoying as the latter usually go at the end but Python functions need to go at the beginning. Other than that, the differences between BASIC and Python are actually relatively small. I could easily see Python be tokenized like Commodore BASIC, although of course there would have to be a system to create new tokens for new functions.

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

BASIC 2? Why not get BASIC 7?

Post by BruceMcF »



1 hour ago, iljitsch said:




A much more nefarious issue is that you can't use functions like you can in other languages.



This has been false since the 80s for Microsoft Basic, and earlier than the 80s for some minicomputer Basics. Similar to that fact that Microsoft Basic has had DO UNTIL expr ... LOOP, DO WHILE expr ... LOOP, DO ... LOOP UNTIL expr, and DO ... LOOP WHILE expr since the 80s.

Simply stop saying "Basic can't ..." when you mean "CBM Basic can't" for the functions with local variables, or "CBM V2 Basic can't" for the DO LOOP and IF expr THEN ...:ELSE ... that the CBM V7 had. It often converts true claims into falsehoods.

 

iljitsch
Posts: 25
Joined: Thu May 27, 2021 4:38 pm

BASIC 2? Why not get BASIC 7?

Post by iljitsch »



1 hour ago, BruceMcF said:




Simply stop saying "Basic can't ..." when you mean "CBM Basic can't"



Well, how many things do you need to add to BASIC (and take away) before it's not really BASIC anymore?

We're talking about different flavors of Commodore BASIC here...

BruceMcF
Posts: 1336
Joined: Fri Jul 03, 2020 4:27 am

BASIC 2? Why not get BASIC 7?

Post by BruceMcF »



1 hour ago, iljitsch said:




Well, how many things do you need to add to BASIC (and take away) before it's not really BASIC anymore?



We're talking about different flavors of Commodore BASIC here...



On your first question, anything in QBasic is obviously "still Basic", and QBasic has full fledged functions and procedures with local variables. It ran on the original IBM PC, so it COULD well be implemented for the more powerful CX16. So I don't worry about the general philosophical question of how many things you need to add to Basic before it's not really Basic anymore.

As far as "we are talking about different flavors of Commodore Basic here", ... setting aside that when you go into "evolutionary dead ends" you are clearly NOT talking about ONLY different flavors of Commodore Basic, here, but talking about the Basic programming language more generally ...

... sometimes TTSIA ... it doesn't ask "Basic? Why not get Basic?", it asks "Basic 2? Why not get Basic 7?" Just talking about DIFFERENT flavors of Commodore Basic requires being more specific than "Basic".

And yet again, if something is a part of an argument about "why Basic should be abandoned", it bears making a distinction between "Basic 2 can't" and "Basic 2 doesn't". After all, a number of things that "Basic 2 doesn't" on the C64 are things that Basic 2 does on the CX16.

Post Reply