I was mostly targeting the ability to write some simple games that combine graphics, some peripheral input, and sound. Mostly a toy though, but who knows: the future is unchartered :)
Indeed. The difficulty in manipulating graphics is what most puzzles me these days. We have these amazing graphics cards and screens, but all we can do is output text by default in most languages, and drawing anything requires large libraries or SDKs.
That blows my mind as well. You'd think I'd be able to write some pretty cool games using just PowerShell on Windows calling out to native graphics functions.
It is possible to access windows API functions from Powershell, but it's not particularly simple. I think you can define a method that calls an API function? Alternatively you can go via C#. In theory you could access the DirectX primitives that way.
DX is a pretty low level API though. Unreal and Unity exist for a reason.
Drawing modern graphics is not done by blitting pixels onto a framebuffer, which is the model most BASICs use. In fact, doing pixel-perfect 2D rendering on GPU is still hard and an area of active research.
Part of why we need huge libraries to put graphics on the screen is because those amazing graphics cards have comparatively large and complicated interfaces.
Having a bitmap in normal system memory that we can write to the window or screen is easy though and should be more widely supported. Once you've got that you can write pixels, lines, rectangles, mandlebrots etc very easily and building up to a GUI toolkit is also quite easy and fun. This mechanism is fast enough for pretty much everything other than games on modern hardware.
I consider GPU acceleration a form of premature optimization - it adds complexity unnecessarily in many cases.
It's all client-side, unless you use the cloud service to fetch the tiny programs that are shared, like this one: https://repl.endbasic.dev/?run=jmmv/bounce.bas -- and those requests are cheap and infrequent right now.
The current wasm file that's downloaded is just about 1MB!
Do you have any plans on adding hashtables/dictionaries of any sort to the language? It seems to be above the cutting-off point for some other retro basics I've seen, like QB64. Perhaps it's too complicated to add, but they feel kinda like part of the bedrock of "scripty" languages these days, so it's something I'd definitely add if I was making a BASIC myself, but I understand that different folks take different tacks on stuff like this.
C doesn't have that either. Most commonly people just do a linear search. If you have a bigger array you can either use a library or roll your own almost-hash table-kinda-thing. It's not that complicated to roll your own because you already know your specific type of input. Implementing something that works for "any" type of input is harder.
I wrote some (what would now be called "CRUD") applications back in the 80s in BASIC and later in C, and the answer is arrays and linear searches. 80s BASIC wasn't able to store more than, say, 100-500 user records, so linear searching was fine, even in an interpreted language.
If you wanted to get really fancy you might have used something like JETSAM which gave you a single key-value db in a file.
This looks really neat. I played around with it a bit and it's very intuitive to use.
If I could make a single request, it would be to be able to have white background. As someone with heavy astigmatism, using the site as is is very difficult, and I can only look at the screen for a few seconds at a time without my vision getting blurry.
I know I can use the color command to change it in the repl, but the editor still uses black background.
Thanks for the suggestion. I've never liked keeping some of these settings hardcoded and wanted to provide some kind of configuration file to tune them. Knowing that there is an important usability issue around them helps prioritize.
Because at the onset of the project, I favored implementing structured programming constructs (if, while, for) and ended up with an AST evaluator for the execution engine, which makes it hard to retrofit GOTOs in it.
Some form of jumping or function calls is the main feature that will drive the next release.
BASIC languages seem to be having a bit of a renaissance year. There have been about (that I know of) 2 or 3 new BASIC languages introduced just this year alone.
I absolutely love the idea of a modern web based BASIC as I can work on the road from anywhere!
I've added a room for this to my BASIC oriented discord, hopefully this doesn't seem spammy it's the only one around on the subject of BASIC in general, as far as I'm aware: https://discord.gg/HQaDgJvbbJ
Not only they were quite productive as dynamic languages, they also had optional typical and AOT compilation, besides the rich libraries for start coding right away.
One thing that many might be unaware is that the original Dartmouth BASIC was actually JIT based, the pure interpreted versions only came to be due to fitting it into 8 bit home computers.
My concern with attempting to learn BASIC is that at least the big ones aren't garbage collected (freebasic, qb64).
In the first place (not growing up using BASIC) I don't understand how BASIC got so big as a programming language for beginners (even kids) without a GC.
Or maybe my searches just haven't turned up the right implementation or something.
I have the same issue with (Free)Pascal but I'm less surprised there because it's not like (apparently, since like I said this wasn't me) everyone as a kid learned to game program with Pascal the same way they did with BASIC.
Why would garbage collection be an issue? All the best BASIC variants either do have GC, or they have manual methods of dealing with garbage, which as the programmer you can always automate.
Because it actually had a lightweight GC for strings and arrays.
8 bit home micros lacked more complex data structures.
And when they migrated to 16 bits, and grew structures, usually you couldn't do indirection with pointers/references, only have a single level of array of structures. For anything more complex you had to use indexes.
Pointers were only use for low level coding, changing specific memory locations.
Then by the time of VB and Real Basic, proper GC was already widespread among modern BASIC dialects.
I tried to move the cursor and then print at that location through the command line. How do you separate two commands on the same line to do this in the repl?
Yeah, there are no line numbers (although 0.3 had them!) nor GOTO. I think this is the main thing I'll add in the upcoming 0.10 because it's what everyone asks for :)
I spent 20+ years in my day job programming in BASIC on OpenVMS without using line numbers or GOTO's. Yet the first thing I did here was fall back to my childhood Sinclair/BBC BASIC of trying 10 PRINT "Hello" 20 GOTO 10
Software for the Agribusiness sector - mostly around the manufacture and selling of animal feed. So data entry, processing, interfacing, reporting. We had the legacy system which was a text terminal interface, as well as a newer browser based system that interfaced via webservices to the OpenVMS BASIC code. After 40 years it went end of life at the end of last year.
I'm not surprised that the system lasted that long! VMS is legendary.
I've looked through the documentation for OpenVMS BASIC and it does seem like it was a nice platform.
The entire VMS system appears to be quite a comfy environment to have worked in. (DCL, help system, documentation, standard libraries, multiple languages (Pascal, C, BASIC))
The console is hand-crafted and implemented as an HTML or SDL canvas to support rendering text and graphics at the same time. I haven't implemented text selection nor copy/paste on top of that yet (and it isn't in my list of priorities right now because, well, you didn't have a mouse in the old BASIC interpreters anyway ;) ).
Oh really? That must have been too advanced for when I played with it back in the day :) I'm looking at the CPC6128 manual right now and cannot find "shadow" in it though; what are the right keywords to find this?
But you did have light pens, and functions like PEN() and the ON PEN statement to work with them. When PCs came around, those were generally appropriated to work with mice.
It has no line numbers, fine. But I couldn't figure out how to enter a program since it doesn't present an editor. All my commands were executed in immediate mode.
I probably would have spent a little more time with it if it had been obvious how to enter a program without poring through documentation.
I did load the DEMO program, maybe it was in there, but I missed it.
This is how I learned to code. I cannot imagine throwing a kid in front of a Javascript browser console or modern IDE and say figure it out. This is so awesome -- with the low-res graphics, too! If my kids learn to code, this is how my kids will learn to code.
This is what's coming next. I've so far been carried away building the environment around the tiny language, but it's time to start making the language usable -- and user supplied functions are the very next work item to complete.
Not yet. I'm tempted to add custom functions first for which the AST evaluator should be sufficient. And anyway, even though not as retro, named functions are better than a mess of numbered GOSUBS... Which means that if I even get to GOTO/GOSUB, I may try to do it in a hacky way.
Although, to be honest, in the spirit of making this a true "retro-computer", the idea of compiling the code into a custom bytecode is incredibly tempting. It'd be super fun to build, and also... that'd enable a DISASM command of some kind to dump arbitrary memory, as well as PEEK/POKE! Tons of work though.
You know your project better than I do but unless there's something I don't understand going on, it really shouldn't be that hard.
You can also keep both backends around and just build a basic VM evaluator and start compiling simple expressions at a time to the VM version. I don't want to give you suggestions if you already know all that but also happy to chat if you are looking for a good plan. :D
Ok ok, it's probably not thaaaat hard technically, but it's a fair amount of work :) I haven't looked into it at all yet. Once I start doing so, I will probably reach out to you. Need a few days off before taking this on though as publishing a new release is always exhausting.
That’s a very interesting idea! But note that EndBASIC runs on the desktop just fine compiled to native code; no WASM involved. And it will not become an Electron app :P
In the mature versions of BASIC, SUB was for routines that didn't return any value and FUNCTION was for returning a value.
I'd 100% skip the line numbers and GOTO/GOSUB and build those two things. I grew up PDP BASIC and then VAX BASIC and the procedural aspect is what made it a great platform to write code. the line number/GOTO stuff is great for nostalgia, but a dead end for good coding practices.
This is a great idea. I grew up with AppleBASIC, which had line numbers, but after decades coding with many other languages, there’s no reason to use line numbers. And if the purpose of this repl is to teach, then teaching line number programming in 2022 is pointless.
Unfortunately it then requires an editor, otherwise how do you overwrite/change a line?
To me the main use of line numbers is that they allow you to have a seemless combination of an immediate environment and a line-oriented program editor.
With modern UI, there's pretty much no reason to do that, of course; with a retro style UI, there might be some marginal use.
(Also, supporting line numbers and line-oriented GOTO/GOSUB means you can directly use any of the libraries or classic code in that style; unwinding GOSUB/RETURN into named subs is trivial enough if it is otherwise clean, but unwinding GOTO-heavy code without having a working starting point isn't pleasant.)
Agreed. I'm not familiar with PDP or VAX Basic, but I did grow up on GFA Basic with its PROCEDURE and FUNCTION. Both could be called by just using their name without a GOSUB.
PROCEDURE printfoo(bar%)
PRINT "foo: " + bar%
RETURN
FUNCTION double(number%)
RETURN number% * 2
ENDFUNC
' Prints "foo: 8"
printfoo(double(4))
Microsoft Professional Development System 7.1 and later Visual Basic for DOS 1.0 had similar language syntax. I had put together a DOSBox VM with PDs installed awhile back. Still have it if you're interested. I built software using PDS professionally back in 1990.
The better choice is to fire up MS DOS 3.1 on VirtualBox and download VB for DOS 1.0 and install it (7 floppy images). Takes a but, but it's a solid BASIC syntax and it's the successor to PDS 7.1. To get PDP or VAX BASIC running, you'd need to emulate a PDP with RSTS/E or VAX+VMS and BASIC is built in. There are Raspberry PI images for both.
Personally I think SUB ... END SUB and FUNCTION ... END FUNCTION are the clearest syntax.
Unusable might be a bit harsh, but I have to say that when I wrote my own BASIC interpreter last year I deliberately concentrated on the line-numbers and facilities of the ZX Spectrum I remembered:
Well, it absolutely needs GOTO/GOSUB/RTS and so on. But it would be better off leaving line numbers behind. They don't add anything to the language, they were just a limitation of the editors on those small machines.
I first programmed using basica on an IBM dual 5.25 diskette PC but have not been able to find it or an emulator. I did graphics programming with it using commands like line (0,0)-(100,200). I've never been able to find a version if basic that had that graphics capability. I loaded it from Dos typing 'basica'. Anyways, great language to learn on.
Nice exercise developing an embeddable BASIC interpreter in Rust.
I've experimented with teaching 11-year old school children Python in a single session.
To obtain the immediacy effect that the original poster mentioed (which reportedly were liked by his kids), I use Turtle graphics module inspired by logo (import turtle - see also https://vegibit.com/how-to-move-the-python-turtle/ ).
Here's what you can do in a single two-hour session:
1. First I explained the children how points can be addressed using x and y coordinates (Cartesian coordinate system - which they hadn't had in maths classes at the time). "Each dot has two numbers that indicate where it lives, like house numbers."
2. Then I gave them the task of drawing a house only using straight lines (no curves permitted).
3. Next I asked them to convert the lines that made up their house into Python code based on forward(), right() etc. commands inspired by LOGO (which was, after all, inspired by education work with children ast MIT).
4. Let them try out their program on a computer.
5. Tell them that if they liked this exercise, they should ask for a Rasberry PI from their parents as a Christmas present as an affordable way to get into programming (early).
> I've never been able to find a version if basic that had that graphics capability.
If you are looking for a retro BASIC, then BBC BASIC had line and filled triangle drawing built in (or it was in the system ROM and BASIC had hooks for it). There was an extension (IIRC separately purchased for the Model A & B, built into the BBC Master) that added rectangles, circles, and ellipses.
BBC Basic was the best of the 8-bit offerings for learning on as it supported named procedures and functions, and a few other structural features (some BASIC implementations at the time didn't even have ELSE with their IF statements). There were significant limitations, but it was massively ahead of the GOTO/GOSUB (which it also had of course) that were your only option in BASIC interpreters on other home micros. It also supported variable names of reasonable length (40 characters IIRC, you could actually use more but any after 40 were silently ignored and you didn't want really long variable names anyway as they would take too much program space to store) where some other BASICs limited you to just a couple of characters. It even had a built-in multi-stage assembler for when you wanted a bit more oomph than interpreted BASIC could offer.
[caveat: one or two of the above features may not have been present in the very original version, though I think they were all in BASIC II that appeared in 1982]
Thanks for the info! I think you're right, must have been basic ll. Every once in a while I follow the rabbit hole trying to find that original (or similar) basic I learned on.
BASICA (IBM PC-DOS) and GWBASIC (Microsoft MS-DOS) were functionally identical. MS-DOS was just the version of PC-DOS that Microsoft released for non-IBM hardware. Not sure why the basic command was renamed.
"Built entirely in Rust with a minimalist modular design. Open source. Embed the interpreter into your own programs for just 700KB"
Back when QuickBASIC was a thing, 700KB was an enormous amount of memory. The early IBM PCs (which included a BASIC interpreter in ROM) maxed out at 640KB!
The original BIOSs were for a 8bit/16bit archs. I'm guessing this was measured on a modern arch, and the result would be smaller on a smaller pointer size. I wonder what the size would be if complied for avr.
I know, I know. And the Amstrad I had with Locomotive Basic only had 128k of RAM and (as I read now) 48kb of ROM -- yet it fit the whole language in there, which was more complete than what EndBASIC currently offers. But things have changed, and I still think that 700kb nowadays is reasonably small all other things considered.
Though I much prefer a unix CLI nowadays (like bash or zsh) and would choose something like Ruby over BASIC in all cases. I felt MS-DOS and QBASIC held me back by not being opensource (thus not allowing me to dig deeper).
Making that demo was tough but pretty rewarding in the end! I ended up featuring it in the About page of the site because it’s a great intro to what EndBASIC is supposed to be :D
ok. Basic. When did you parents learn to read?
I have been programming in BASIC since 1970.
I programmed it through primary school, middle school, jr high school, and high school, and took it in college. Almost all on a HP2000. (five different machines).
122 comments
[ 3.0 ms ] story [ 202 ms ] threadDX is a pretty low level API though. Unreal and Unity exist for a reason.
That's a choice. The hardware still supports it. It is still possible (and fast-ish and simple) to do graphics by blitting pixels.
I consider GPU acceleration a form of premature optimization - it adds complexity unnecessarily in many cases.
Here's my library for doing that on Windows and X11. https://github.com/abainbridge/deadfrog-lib
The current wasm file that's downloaded is just about 1MB!
Alternatively, we would buy a library from companies selling developer tools.
If you wanted to get really fancy you might have used something like JETSAM which gave you a single key-value db in a file.
If I could make a single request, it would be to be able to have white background. As someone with heavy astigmatism, using the site as is is very difficult, and I can only look at the screen for a few seconds at a time without my vision getting blurry.
I know I can use the color command to change it in the repl, but the editor still uses black background.
I've filed https://github.com/endbasic/endbasic/issues/181 to track.
20 GOTO 10
Some form of jumping or function calls is the main feature that will drive the next release.
I just edited the bouncing ball example and set "n = 200*200"
https://github.com/endbasic/endbasic/blob/ac3eb5622a6db0beb4...
I've thought about adding other ways of specifying colors, like COLOR "#aabbcc". Would that be useful/interesting?
I absolutely love the idea of a modern web based BASIC as I can work on the road from anywhere!
I've added a room for this to my BASIC oriented discord, hopefully this doesn't seem spammy it's the only one around on the subject of BASIC in general, as far as I'm aware: https://discord.gg/HQaDgJvbbJ
Not only they were quite productive as dynamic languages, they also had optional typical and AOT compilation, besides the rich libraries for start coding right away.
One thing that many might be unaware is that the original Dartmouth BASIC was actually JIT based, the pure interpreted versions only came to be due to fitting it into 8 bit home computers.
In the first place (not growing up using BASIC) I don't understand how BASIC got so big as a programming language for beginners (even kids) without a GC.
Or maybe my searches just haven't turned up the right implementation or something.
I have the same issue with (Free)Pascal but I'm less surprised there because it's not like (apparently, since like I said this wasn't me) everyone as a kid learned to game program with Pascal the same way they did with BASIC.
8 bit home micros lacked more complex data structures.
And when they migrated to 16 bits, and grew structures, usually you couldn't do indirection with pointers/references, only have a single level of array of structures. For anything more complex you had to use indexes.
Pointers were only use for low level coding, changing specific memory locations.
Then by the time of VB and Real Basic, proper GC was already widespread among modern BASIC dialects.
http://syn9.thehideoutgames.com/
LOCATE 5, 5: PRINT "Hi"
should do the trick.
'10 ? "hello, world"'
it got angry. That violates all my expectations of a BASIC :)
Also, is there a good reason the REPL won't let me select, copy and paste text?
https://www.endbasic.dev/docs.html#lang-goto
10 print "hello"
has GOT to be the leader.
https://support.hpe.com/hpesc/public/docDisplay?docId=emr_na...
Yes indeed. The docs for VMS are great. Really cool environment.
On an unrelated note, have you seen this video yet?
https://news.ycombinator.com/item?id=31701231
I'm not surprised that the system lasted that long! VMS is legendary.
I've looked through the documentation for OpenVMS BASIC and it does seem like it was a nice platform.
The entire VMS system appears to be quite a comfy environment to have worked in. (DCL, help system, documentation, standard libraries, multiple languages (Pascal, C, BASIC))
10 PRINT "BOOBS" 20 GOTO 10
in all the department stores where I grew up...
The BBC Micro had a very similar mechanism.
I probably would have spent a little more time with it if it had been obvious how to enter a program without poring through documentation.
I did load the DEMO program, maybe it was in there, but I missed it.
Although, to be honest, in the spirit of making this a true "retro-computer", the idea of compiling the code into a custom bytecode is incredibly tempting. It'd be super fun to build, and also... that'd enable a DISASM command of some kind to dump arbitrary memory, as well as PEEK/POKE! Tons of work though.
You know your project better than I do but unless there's something I don't understand going on, it really shouldn't be that hard.
You can also keep both backends around and just build a basic VM evaluator and start compiling simple expressions at a time to the VM version. I don't want to give you suggestions if you already know all that but also happy to chat if you are looking for a good plan. :D
I'd 100% skip the line numbers and GOTO/GOSUB and build those two things. I grew up PDP BASIC and then VAX BASIC and the procedural aspect is what made it a great platform to write code. the line number/GOTO stuff is great for nostalgia, but a dead end for good coding practices.
Unfortunately it then requires an editor, otherwise how do you overwrite/change a line?
With modern UI, there's pretty much no reason to do that, of course; with a retro style UI, there might be some marginal use.
(Also, supporting line numbers and line-oriented GOTO/GOSUB means you can directly use any of the libraries or classic code in that style; unwinding GOSUB/RETURN into named subs is trivial enough if it is otherwise clean, but unwinding GOTO-heavy code without having a working starting point isn't pleasant.)
Personally I think SUB ... END SUB and FUNCTION ... END FUNCTION are the clearest syntax.
https://github.com/skx/gobasic
Being standalone it doesn't have the graphic support or the interactivity, but it was still a fun project to work upon.
He did not support '10 PRINT "HELLO"'
He did not implement BASIC.
GFX_LINE 100, 100, 200, 200
GFX_RECTF 300, 300, 400, 500
I've experimented with teaching 11-year old school children Python in a single session.
To obtain the immediacy effect that the original poster mentioed (which reportedly were liked by his kids), I use Turtle graphics module inspired by logo (import turtle - see also https://vegibit.com/how-to-move-the-python-turtle/ ).
Here's what you can do in a single two-hour session:
1. First I explained the children how points can be addressed using x and y coordinates (Cartesian coordinate system - which they hadn't had in maths classes at the time). "Each dot has two numbers that indicate where it lives, like house numbers."
2. Then I gave them the task of drawing a house only using straight lines (no curves permitted).
3. Next I asked them to convert the lines that made up their house into Python code based on forward(), right() etc. commands inspired by LOGO (which was, after all, inspired by education work with children ast MIT).
4. Let them try out their program on a computer.
5. Tell them that if they liked this exercise, they should ask for a Rasberry PI from their parents as a Christmas present as an affordable way to get into programming (early).
https://el.media.mit.edu/logo-foundation/resources/software_...
If you are looking for a retro BASIC, then BBC BASIC had line and filled triangle drawing built in (or it was in the system ROM and BASIC had hooks for it). There was an extension (IIRC separately purchased for the Model A & B, built into the BBC Master) that added rectangles, circles, and ellipses.
BBC Basic was the best of the 8-bit offerings for learning on as it supported named procedures and functions, and a few other structural features (some BASIC implementations at the time didn't even have ELSE with their IF statements). There were significant limitations, but it was massively ahead of the GOTO/GOSUB (which it also had of course) that were your only option in BASIC interpreters on other home micros. It also supported variable names of reasonable length (40 characters IIRC, you could actually use more but any after 40 were silently ignored and you didn't want really long variable names anyway as they would take too much program space to store) where some other BASICs limited you to just a couple of characters. It even had a built-in multi-stage assembler for when you wanted a bit more oomph than interpreted BASIC could offer.
[caveat: one or two of the above features may not have been present in the very original version, though I think they were all in BASIC II that appeared in 1982]
https://www.pcjs.org/machines/pcx86/ibm/5170/cga/
When the machine loads up, switch the disk to PC DOS 3.30 (Disk 2), type BASICA and you're in.
https://robhagemans.github.io/pcbasic/
https://robhagemans.github.io/pcbasic/
Back when QuickBASIC was a thing, 700KB was an enormous amount of memory. The early IBM PCs (which included a BASIC interpreter in ROM) maxed out at 640KB!
Though I much prefer a unix CLI nowadays (like bash or zsh) and would choose something like Ruby over BASIC in all cases. I felt MS-DOS and QBASIC held me back by not being opensource (thus not allowing me to dig deeper).
[0] https://media.handmade-seattle.com/endbasic/
Is there a set of test programs for basic?