HitBasic, BASIC improved

Par pizzapower

Supporter (6)

Portrait de pizzapower

05-07-2020, 08:54

So this is the result of some months of programming during the quarantine. Inspired by projects like Basic Dignified and Inliner, I created my own BASIC transpiler (uh, BASIC-to-BASIC transpiler). The difference is that it is a dialect pretty close to Visual Basic. And just like Visual Basic, you can write code with long variable names, functions, subs (*), select case, do until/while loops and many more features. And it's written in Python! Cool Parn has been working with me remotely fleshing out the documentation as we digress about the idiosyncrasies of microsoft BASIC. Cool Cool

A more complete list of features can be seen in the docs folder. And the project is currently available in github.

(*) in the near future.

!login ou Inscrivez-vous pour poster

Par konamiman

Paragon (1083)

Portrait de konamiman

05-07-2020, 18:41

Nice project that reminds me of my old NestorPreTer: https://github.com/Konamiman/NestorPreTer. Back then I didn't know the term "transpiler" so I just called my thing "pre-interpreter" :)

Par Parn

Hero (603)

Portrait de Parn

05-07-2020, 22:00

Good to see you here!

NestorPreTer surely was in the back of my mind when I went and talked to @pizzapower about this. It's kind of hard to explain how this project came around, but both @pizzapower and me were thinking about something in these lines for some time before talking to each other. He isn't a regular here, but I've been trying to be present as much as I can. I didn't specifically think on NestorPreTer but I knew about it. @pizzapower, on the other side, was eager to try PEG at some personal, smaller project, and was also interested in making MSX programming easier.

Another, more recent inspiration was, from my side, @farique's MSX Basic Dignified. @pizzapower was also inspired by Giovanni Nunes' Inliner, which is another transpiler that aims to modernize MSX-BASIC a little.

At this moment many would ask what's the point of another BASIC-to-BASIC transpiler. Well, the short answer is, obviously, because it's fun! But there's also a long answer. I personally think it's a bit painful to program in MSX-BASIC nowadays. Not only because of limitations like line numbers and short variable names, but also because MSX-BASIC lacks more modern flow control and structures. Of course, these are my personal thoughts on the subject, but @pizzapower has his thoughts as well and although we agree on a lot of stuff we don't necessarily always agree and some things are more important to me than to him and vice versa.

For example, HitBasic aims to support things like Do Loop blocks (with While and Until checks both at the start and the end of the block), Select Case blocks, multiline If Then Else blocks and even Subs and Functions, including Functions that return more than one value. Also labels, some extended instructions and good practices like variable declaration and even scoping. Some of these are also provided by previous transpiler efforts, but the difference is that we try to adhere to Visual Basic conventions, so it looks familiar to anyone who already programmed in VB. It also has the advantage of not needing new syntax for stuff already supported by the language.

Also, it supports normal MSX-BASIC, kind of like QuickBASIC and QBASIC support most stuff written in GWBASIC. So if you prefer you can start with a normal MSX-BASIC program and convert it to HitBasic at your pace. The advantage is that HitBasic code is much more readable than MSX-BASIC.

Par pizzapower

Supporter (6)

Portrait de pizzapower

06-07-2020, 06:01

We wanted to leverage the knowledge of users familiar with Visual Basic, QuickBasic or QBasic to help them create programs in a more productive and relevant language. And because MSX-BASIC is relatively low level compared to most modern languages, it is simple to recreate lots of more modern BASIC features on top of MSX-BASIC code, albeit with some caveats. For instance, our implementation of function cannot be recursive, unless they are tail recursive. Tail recursive functions don't need a stack and for that they are often the target of compiler optimisations. MSX-BASIC doesn't have activation records, so it's not a matter of optimisation, but of simple capacity. After all, calling the function again from itself will erase all the previous scope variables of the last iteration if it is not tail recursive.

As it is now, HitBasic is a work in progress. Writing a parser is no trivial pursuit, since all the language's structures must be knew and accounted for if we want it to be really useful, but most of the groundwork is ready and it will be much easier now. Wink