Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: QBasic 4.5 on Android (github.com/ianatha)
234 points by thatha7777 on Nov 9, 2023 | hide | past | favorite | 92 comments
My father, who hung up his coding hat in the '80s, recently entered the golden years of retirement.

One day, he mused about the simplicity and educational value of BASIC and wondered if there was a way to share its charm using today's technology.

Specifically, he was looking for an Android application that could run BASIC so he could "teach programming while drinking coffee with [his] friends".

Thus, BabaBASIC was born—a hat tip to 'Babá', the Greek term for "dad", and a reminder of who sparked this journey.

The first iteration of this was made over a 10-hour all-nighter using existing open-source libraries.

I ended up forking the BASIC-like implementation to make it more byte-for-byte compatible with QBasic 4.5, which is what my father used back in the 90s to teach me programming.

This is the first thing I have ever made of which he approves.




I love this so much. I got my start on QBasic and made hundreds of games between 12 and 19 years old. I eventually left it behind, but always had a fond spot in my heart for it.

Last year, when I was going to rebuild my personal website, someone on Twitter challenged me: “Build it in QBasic, you coward”. I was like “haha…wait, can I?”

And I did! It runs on QB64 on a DigitalOcean droplet.

Here’s the source:

https://github.com/jamonholmgren/jamon.dev

Check app.bas for the QBasic code.

I may eventually release a CLI and library that lets people spin up a QB64 website in little time.


Ha, I once created a web framework in classic ASP that was inspired by QBasic - you’d use pure HTML templates but in handlers you’d write LOCATE statements using XPath selectors instead of screen coordinates, followed by PRINT statements to actually fill in the content of an element. Never tried to actually write it in QBasic itself though. Nice work!


Thank you!

XPATH in LOCATE stmts sounds like asking a disco dancer to moonwalk -- out of its era, but oddly fascinating to watch


It honestly wasn’t a bad approach in practice, many years later there was a similar library called Enlive in Clojure which I genuinely enjoyed. Forces you to use nice semantic IDs and classes for everything. I suppose if you wanted the real BASIC experience you’d actually just PEEK and POKE with character offsets into the templates or something ungodly like that.


This is awesome! Kudos!

I wish there was some kind of "computing archeology" discipline


The folks who built this stuff are still alive. Historian would be a better fit, and we can archive the actual first-hand accounts if we don't waste the chance.


I was confused for a few seconds. This is to help others. The user didn't build their website, they built the web server, a more difficult task.

I was expecting a classic CGI gateway approach with some templating support and maybe a data source (not necessarily sql but perhaps INI).

Instead it's an HTTP server


You could serve your qbasic website from an old Android phone in a drawer my dude.


Not with BabaBASIC (for now?). No networking support whatsoever :P


Fairly certain jamon can wire in some io, let me nerd snipe in peace plz


My apologies. BabaBASIC is here to make any Android-related anachronistic dream come true (˃̣̣̥ w ˂̣̣̥).


I think I have a general idea on how to implement basic TCP/IP sockets while staying true to QBasic 4.5's spirit (i.e. not introducing functions like _OpenConnection/_ConnectionAddress etc.)

The "API" I have in mind would look something like

```

OPEN "TCP:\127.0.0.1\80\LISTEN" FOR INPUT AS #1 INPUT #1, CONN$ IF CONN$ <> "" REM CONN$ contains something like "TCP:\127.0.0.1\80\REMOTE_HOST\REMOTE_PORT" OPEN CONN$ AS #2

  REM ... respond to request
  PRINT #2, "200 OK"
  CLOSE #2
END IF

```


Don't tempt me.


Ugh, jamon51, I think we slashdotted your website


This is nice, I'd like to know the changes you made.

I started a discussion on GitHub, I think the killer feature of QBasic and even more so QuickBasic was the help and reference.

Even the ASCII table was fun to look at and go grab characters, you could imagine something analogous for Unicode.

Similarly for all the stuff in there working out modern equivilents.

The annoying stuff was how much hassle it was to do extra things like handle the mouse pointer via assembly, it would be good if this has extensions for touch etc all documented.


Ah, and I almost forgot, in re the changes:

the commit log is the definitive (and painstakingly accurate) log of changes: https://github.com/ianatha/bababasic/commits/main

To clarify my slightly obtuse original post, I started this by using PuffinBASIC, but I ended up forking it because there were a few things implemented differently than my reference QuickBASIC 4.5 installation (running on DOSBox):

* label syntax / case-insensitive labels * forward function declarations * flexible array indexing (i.e. in QBasic your arrays could start at 0, or at 1, and it somehow figured it out, and it still had bound checks) -- haven't implemented this yet * various functions (VAL, INKEY$, SLEEP)

Lastly, and more importantly, PuffinBASIC required Java AWT support (which made it necessitate a desktop), but I have refactored BabaBASIC to abstract the HCI portions (audio/video/keyboard).

Another interesting technical point is that the "Run View", which displays a terminal through which you interact with your script is also a (very small) fork of Termux.

(I needed something to efficiently draw a text buffer while handling all the VT100-related functionality.)


QB64 has taken on the mantel of modern reimplementation, its worth seeing if there are any extensions from there that are worth implementing.


> the killer feature ... was the help and reference

So much this. The help in QBasic is how I learned to program at ten years old in a pre-internet world.

A couple years later my friend was trying to push me to learn C and I was sorely disappointed that there was no help, at all.


I'm actively working on some kind of "live docs" feature for BabaBASIC.

Though ... I have to wonder (and I'm only half-joking) -- should it just be a ChatGPT integration that can answer questions?


No, plain old docs


'twas just a joke


Definitely not ChatGPT, even if you put in a thing that any code it ran would be tested somehow for correctness.


>I think the killer feature of QBasic and even more so QuickBasic was the help and reference

without any internet access in the 90s, I taught myself QBasic largely out of that help reference in order to write little games and simulations. it really was something fantastic.


100%. Heck I coded up a system that printed footage marks along the side of industrial coated material using qbasic interfacing to an industrial printer via the joystick port on a 386! No internet so I used the help system constantly. Eventually the company kept a pile of 386's stacked as spares because the system ran too fast on a 486.


I had the same experience as a kid. Probably built over a hundred QBasic-powered games with no internet to help me.

I missed it, so last year when I rebuilt my website I built it in QBasic:

jamon.dev


Ohhhh yes, you're absolutely right.

Frankly, this is my first Android/mobile application, so I'm still trying to wrap my head around the limited screen space and whatnot.

I'd be awesome to get some syntax hints, or some form of better autocompletion (it only recognizes some basic statements/lang-delcared functions right now).

I'll follow up on GitHub -- thank you for contributing the discussion there, this is very exciting!


Awesome! QBasic was my first programming language, long obsolete by the time I discovered it but I had no idea. Had a lot of fun. Fond memories of browsing Pete's QB site.

My favorite programs from those days are both games. Mysterious Song[0], a JRPG, and Monospace[1], a horizontally scrolling shmup.

[0] http://www.petesqbsite.com/sections/zines/qbgamer/issue1/re_...

[1] http://www.petesqbsite.com/reviews/action/mono.html


That's an awesome resource! Thank you for sharing. Hopefully BabaBASIC will be able to run any of these games at some point of time.

My first explorations as a child were more around math/algorithms/graphic functions. Not sure why I was never particularly drawn to games as a child ¯\_(ツ)_/¯.


qbasic news, petesqbsite, among other good places. Good memories, thanks :D


Mid 90s qbasic was how I learned to program!

My friend and I extended the nibbles / snake game ... I wonder if I can get it to run on your qbasic implementation:

https://github.com/ronyeh/nibbles


This is cool :)

I'll also give it a try, and if it works as-is on QBasic 4.5, I'll try to live up to my promise and make BabaBASIC more compatible with QBasic 4.5 :).


> I couldn't find anything that I felt comfortable recommending to him, so I pulled an all-nighter and made this.

All-nighters for an employer are one thing, but I have fond memories of exploration and discovery in computing while burning the midnight oil. There is something about programming that just excites the mind in a way that causes time to fly.

I hope your dad enjoys his new BASIC app! Really cool of you.


> My father, who hung up his coding hat in the '80s, recently entered the golden years of retirement.

Totally off topic but what I would give for (a) my father being the kind of father I want to maintain contact with and (b) to share a common interest with me, someone that I could talk to about tech. You're a lucky person!


I learned with but hated QB, GW-B and MSX-B. Why? Because I could not make an "fast" executable (.exe) and the compilers those days (on those platforms) we're al costly and impossible for me to come by as a kid.

Man you should have seen my eyes light up when someone should me a full opensource, Linux, computer boot up! I CAN STUDY/MODIFY EVERYTHING! Muahuahaha.

It was a good learning tool, but not as good as LOGO (with the Turtle), of which I later made a clone (KTurtle, part of nearly all Linux distros).

https://apps.kde.org/nl/kturtle/


When I was a kid and found out that QBasic couldn't make an exe, I pirated QuickBasic which could do it just fine.


I am still so very confused by all the xBASICs, and I wonder if that was a big part of its decline...

I hope some mid-level Microsoft marketing manager is enjoying his retirement knowing we're still discussing this decades later.

Fun fact: for a while, Greek public schools taught a language that was called "LANGUAGE", and it was some BASIC-variant written in Greek. It came with it's own IDE called "The Interpreter for LANGUAGE" [1].

10 ΑΡΧΗ_ΕΠΑΝΑΛΗΨΗΣ 20 ΓΡΑΨΕ "HELLO WORLD" 30 ΜΕΧΡΙΣ_ΟΤΟΥ 0

[1]: https://alkisg.mysch.gr/


the decline of basic is the story of .NET and c#. MS stopped meaningful support for it and went all in on .NET.


And for good reasons. F# and C# are superior to Visual Basic -- for a language perspective -- in every way. Also dotnetcore is MIT licensed!


I do not disagree. The problem was the visual basic ecosystem was basically abandoned. I personally did not use it and thought it kinda of janky. But thousands of people for some reason really connected to it and could make interesting things. MS threw out all of that goodwill and forced Visual Studio 2002 which was utter junk compared to visual studio 6 and not really fixed until 2010. Yeah now c# is better. But at first it was a real head scratcher and the IDE made it seem terrible.


I knew it existed, but by the time I had access to warez CDs and found a QuickBasic version I also knew about the open source movement and GCC. :)


So cool! When I was at GitLab I modified a CI runner to execute the script section of the CI YAML in VICE, a Commodore BASIC emulator. No particular reason and it wasn't useful for anything, but it was pretty fun. https://gitlab.com/jyavorska/c64exec


Game of Life but no Gorillas?


C'mon, that's clearly over the top within the context of an all-nighter for a gift for my father :P


I kid. But QBasic Gorillas was the first time I ever edited code. When the the banana takes out half a city block the pressure really amps up.


Yeah, but... Can it gorillas.bas?


2nd time this comes up -- I'll have to reconsider my project priorities!


Worth noting that you can also run the original qbasic in dosbox.

That's handy if you want to run old qbasic code, since typically that code expects to be able to poke hardware registers to do anything beyond what the built in bits of basic can do (for example, adding mouse support or playing sounds beyond beeps).


Yep, me and my son are currently daily users of QB1.1 in DOSBox. Works nicely, but you might need trial and error to figure out the [Break] key when you're on a laptop.

Haven't tested, but QB1.1 or 4.5 should also work with vDosPlus [1]. The original vDos apparently has issues with keyboard input in QB, but, arguably [2], this has been fixed in vDosPlus.

There's also that bootable USB stick with FreeDOS or SvarDOS or smth on bare metal + native QBasic within it. I imagine this would actually make a really nice, responsive and distraction free environment for a child. DOS could also boot straight into QBasic via autoexec.bat, or present some fancy personalized menu.bat for the child, which is, yknow, cool. Or... it sure used to be in 1995. :)

As a non-native English speaker, I must also say that QBasic's simple syntax is incredibly good for teaching programming to children. Not too many footguns with weird (#$ymb0ls{}) either. It really is a great teaching language, even in 2023.

1: http://www.vdosplus.org/

2: List of additional features as compared to original vDos: "Keyboard IRQ1/INT9 handling for running programs such as MS-DOS EDIT, QBASIC, Visual Basic and XyWrite": http://individual.utoronto.ca/wengier/vDosPlus/featurelist.h...


Thank you! I use DOSBox to run QuickBASIC 4.5 on my Mac to check my implementation :)

Unfortunately, Magic Dosbox for Android doesn't seem to work very well with QB45.exe...

Aside from linking with assembler, what QuickBASIC 4.5 funcs give you the ability to interface with the hardware directly in the fashion you're describing?


'peek' and 'poke' were the commands for messing about with low level stuff if I remember correctly.

With those two you could do anything.


Ah, yes, you're 100% right.

Writing a full-on IBM PC/DOS emulator is beyond the scope of this project -- the project's goal is my dad's request to "show off programming while drinking coffee" :P.


There were also IN and OUT commands. Used by programs to directly set the palette on VGA, among other things (entering tweaked VGA modes, etc)


This is fantastic. What happens if you peek/poke a random memory address though? ;)

I grew up on QB 4.5 and was one of the few kids on the block to have access to Microsoft PDS 7.1 which added some crazy (for BASIC) features like inlining assembly.

Also, recently watched Stranger Things and was super pleased to see Sean Aston uses BASIC to brute force an access code. Fingers crossed for a basic revival.

https://specularrealms.com/2021/04/21/strangest-things


The PEEK/POKE syntax isn't even supported -- you'd get a syntax error.


I made a super cheesy version of BASIC you can run in a browser. It just does a search and replace from BASIC to JavaScript.

https://gabrielsroka.github.io/webpages/BASIC.html

Src

https://github.com/gabrielsroka/gabrielsroka.github.io/blob/...


You could also use B4A (https://www.b4x.com/b4a.html), which compiles BASIC into Java bytecode and has an interface builder -- as well as versions available for iOS, Arduino, and desktop Java. Only the iOS one requires a payment, the others are 100% free.

The IDE runs on Windows. The whole thing was developed by one guy who is very active answering questions and providing lots of sample code.


I learned programming on QBASIC in the 90's, aged 11 or so. My brother and I had dabbled with GW-BASIC, which a more knowledgeable friend used to draw cool-looking rainbows and whatnot on the screen. That same friend taught me the "IF... THEN..." construct and a new world opened up to me. QBASIC's built-in help manual was a key resource in getting up-to-speed.


For everyone who wanted a QuickBASIC 4.5-like documentation feature, there's an early version now on the testing channel: https://play.google.com/apps/testing/io.atha.quickbasic


Cool stuff! Growing up in the 80s, my first programming language was BASIC on a Commodore 64.

This came in handy when I did a commercial apprenticeship in the early 90s, as there was QBasic on the PCs we had and it was a great tool to kill time when there was nothing interesting to do. So I’ll always have some fond memories of QBasic.


What a wonderful and heartwarming story! Until that last sentence… I’m so sorry. At the risk of sounding too personal, I imagine many of us here can relate to that with someone in our family.

Coming from someone of a similar age who also started with QBASIC, I hope your dad realizes soon what a talented kid he has.


Thank you for your kind words. I think this app pushed him over the edge.

¯\_(ツ)_/¯


My first game was a version of Space Zap by Midway on a Timex Sinclair 1000 in Sinclair Basic. Recreated in on a Commodore 64 and then in QBasic on an early IBM at work. I still use the Model M keyboard from the IBM to this day.


Looks interesting :)

My first introduction to programming was BASIC on some 8-bit home computer. Sometimes I wonder what had happened if I had started with Pascal or Scheme instead.

I think a lot of developers own their carrier to BASIC being so accessible.


Same here. I wrote a lot of code in my life but barely remember any of it. I do remember writing a 'madlibs' program as a kid and showing my family and being so proud. 100% the reason I'm doing what I do today is because of that day.


My analogue is writing a thing that could draw numbers and print them (I think it was just using the PRINT SCREEN button?), but it would make every line squiggly to emulate my (very bad) handwriting.

I think my goal was to make it write my homework, so that it would still look like my very bad handwriting, but more legible?

Family didn't care, but a classmate was very impressed :P


Thank you!

I've never thought of owing my career to BASIC being so accessible, but you're right, and it's a very beautiful thought.

I also wrote my first lines of code on QBasic 4.5 -- though my big teenage-years programming love was Turbo Pascal.


Awesome! A blast from the past!

Feature request: could you make SOUND and/or PLAY work? :-)


Absolutely! Thank you for brining this up! Tracking it as https://github.com/ianatha/bababasic/issues/77


I'm a huge fan. I used to volunteer on allexperts.com to help people with QBasic stuff, before the dawn of stackoverflow and other probably more searchable places.

This is wonderful, and i'll have to check it out!


wow-- it's been very impressive and heartwarming to learn today that so many folks have fond QBasic memories and it evokes such a sense of community.


I think it's because QBasic was, among many things, a bit of a bridging language.

- Basic had existed even before displays and keyboards were popular, so many software developers from that era could appreciate it.

- Microsoft included QBasic 1.1 for free with some of their operating systems.

- All things considered, it was fairly compatible (depending on what the code did) with GWBasic and even basic/basica from old IBM terminals.

- The language was also easy to understand which made it ideal for education

Probably among other points, this brought a pretty large and diverse group of people who loved programming together.


Does it supports graphics?


No, not at the moment, it only supports the default "text mode" (VT100). Graphics modes are my next milestone.


Nice, to be honest I never lived during the QBasic days, but one of the channels where I got inspired into programming as young(Bisqwit) commonly used QBasic to showcase their creations in live coding.

My favorite one from him: https://www.youtube.com/watch?v=VL0oGct1S4Q


>This is the first thing I have ever made of which he approves.

So no grandkids yet?


Grandpa is obviously paying you to inject this here. Hi grandpa!


Very cool! Check out this software and games archive: http://qbasic.de/


Never would've found this myself -- appreciate it


This isn't as much about the project itself, but I just wanted to say that it sounds like you have a very special relationship with your dad. Cherish it!


Considering this is the first thing I have made in decades that he liked/didn't say anything negative about it... it's all very special.


For this reason I put bwbasic in https://www.exaequos.com


I learned on BASIC for the Tandy 102

Then moved to QuickBASIC for the Mac

Then TurboPascal

Then C (via C++, taught by a FORTRAN programmer)

BASIC will always hold a sweet spot in my heart :)


Very similar journey :)

Some form of BASIC on an XT8086 -- maybe QuickBASIC? Can't be sure. I remember getting my hands on a ISO-B5-sized burgundy booklet with printed source code annotated with "REM" comments.

Then Turbo Pascal. Then Delphi. Then X86 ASM (influenced by some dude I met at a programming competition).

Then Dr. Scheme for years on end.

<3 BASIC.


QB45, those were the days :D


I continued to use qb45.exe for years to write utilities for dos/windows because it would produce an exe with no external dependencies.


i've been searching for an appropriately nostalgic, yet 8-bit, soundtrack to go along with this feeling. suggestions welcome


Great post, congrats on the release.


Thank you!


Impressive project! I remember a friend showed how to render some "demo" style graphics (not a fractal, I believe it was some kind of line-based art) on our pentium. First time I thought the PCs might be the bane of the Amiga (we had an Amiga 2000).

On the subject of Android - is it just me, or are there no good, FOSS, off-line capable repls for Android? Ideally I'd want ruby - but anything in the python/js/lisp vein that feels like a repl and is FOSS would be of interest?



> This is the first thing I have ever made of which he approves.

So sad. People from this kind of upbringings are usually very good at "intrinsic motivation".


Thought so too . . .until earlier today when I noticed how chipper all the upvotes are making me.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: