After three months of early-morning hacking, I’m pleased to announce that EndBASIC 0.10 is now available—right on time for some holiday-time experimentation!

This release marks a huge milestone because it makes the language usable for real-world development.

You see, when I started this project over two years ago, I wrote a rudimentary interpreter for something that resembled BASIC and then launched EndBASIC 0.1. Since then, I have been piling onto those insufficient foundations by adding flashy features such as a web interface, a cloud file sharing service, and a hybrid text/graphics console. These features have been well-received in every demo I’ve given but… the feedback that always came back was the same: “Give me some sort of functions or subroutines!”, or “This is no BASIC without GOTO!”.

And these criticisms were right. Trying to write any sort of non-trivial program in EndBASIC was a daunting and frustrating experience. I had tried to simplify coding to the foundations of structured programming, but without a way to perform unstructured jumps (aka go-tos) or define custom functions… it was impossible to factor out common code, which is a need for the vast majority of programs that exceed a screenful of text. There were also usability deficits such as the lack of line numbers in error messages, which made it incredibly difficult to debug any failing program.

The situation had to change, and change it has in EndBASIC 0.10.

A blog on operating systems, programming languages, testing, build systems, my own software projects and even personal productivity. Specifics include FreeBSD, Linux, Rust, Bazel and EndBASIC.

0 subscribers

Follow @jmmv on Mastodon Follow @jmmv on Twitter RSS feed

Main changes

EndBASIC 0.10 is a humongous release that comes with improvements across the board. Most changes have focused on the core language, but they also spread to the standard library and the user interface. To summarize, these are the main changes in this release:

  • Support for GOTO and GOSUB. Implementing these required dropping the previous AST-based evaluator and replacing it with a bytecode-based executor (with an associated compiler). You can read more about this change in “From AST to bytecode execution in EndBASIC”.

  • Error catching and handling via ON ERROR. This was also made possible by the new bytecode executor mentioned earlier.

  • Precise line and column numbers in every error message. This required a massive overhaul of how the AST is represented to carry these details in every node. Modifying the AST was relatively easy… but adjusting all existing tests to validate this new information was extremely laborious.

  • Interop of numeric types. Being strict about numeric types was nice in theory—just as it is a very welcome pedantic feature in Rust—but the lack of automatic conversions between integers and doubles was… quite annoying. As a consequence, this release brings transparent promotion of integers to doubles and automatic rounding of doubles to integers. This works now but I feel it’s a hack due to all of the special-casing that has taken place. A more advanced bytecode will probably make this better in the future.

  • Revamped interactive help system. Previous versions provided a HELP command that exposed documentation for all high-level types, but failed to provide documentation about the language itself (other than for a simplified cheat-sheet that grew too cryptic and long). This release has fixed this by extending HELP to provide language-specific documentation.

  • New control flow structures. These include suppport for DO loops (with all of their variants, which include infinite loops as well as WHILE and UNTIL clauses before or after the loop), SELECT CASE, and one-line IFs. SELECT CASE is probably the hardest structure that exists right now due to the oddities in its grammar and the many cases to consider.

  • Addition of bitwise operators. These are a nice-to-have, and because these are now available, the language now supports specifying integer literals in binary, octal, decimal and hexadecimal bases.

  • Rename of EXIT to END to terminate programs. This seems like a triviality, but it’s worth mentioning because it was quite difficult to retrofit it into the parser due to how END is sometimes a statement on its own and other times it is combined with other keywords (e.g. END IF or END SELECT). Stay tuned for an upcoming post that will deep dive into the parsing oddities of this language.

  • Lots of small tweaks here and there. These include fixes to the editor, minor changes to the grammar, command renames, addition of exponents and square roots, addition of various new string functions, and addition of a way to query the screen size to let games programs adjust to different viewports.

Quite a few changes, huh? :)

How can I enjoy this?

Here are the usual links to get you started:

Please let me know if you have any questions, feedback, or encounter any issues. There are tons more things I wanted to continue tweaking and fixing before publishing 0.10, but I had to force myself to get it out of the door already. There will always be a next release to fix stuff.

With that, I’ll leave you with a demo to display some holiday greetings, all written in EndBASIC and leveraging the new features in this release 😊

… and if you have made it this far, you can also: