I was rummaging around my BackUp folder and found a bunch of old BASIC code. Most of it was in binary format saved several decades ago so it was not readable as text. QBasic can still be run on Windows systems but within DOSBox which takes time to set up. Luckily, there is a much better alternative in QB64 which unlike its predecessor can compile native binaries for Windows, Linux, and macOS.
Unlike traditional BASIC and QBasic code, QB64 gets compiled automatically into machine code – allowing exceptional performance, easy distribution, and the ability to link with external C and C++ programming libaries. Compatible with most QBasic 4.5 code, QB64 adds a number of extensions, such as OpenGL and other modern features, providing the perfect blend of classic and modern program development.
For many people, including me, BASIC was their first introduction to programming. I still remember a bulky blue book that came with my first computer, Comodore64.
My first program EVER was the basic Hello World. a QBasic version looks something like this:
1 SCREEN 12 #enter SCREEN 12 mode, 640x480 with 16 colors
5 COLOR INT(RND * 15) #randomly choose one of 16 colors (starts at 0)
10 PRINT “HELLO WORLD”; #Print Hello World but without end of line, remove ; for EOL
20 GOTO 5 # Go back to position 5 and repeat
BASIC, which was popular as a novice programming language in the 1980s and evolved into a professional tool in the 1990s, helped many people acquire a love for programming. For the majority of today's professional developers, these languages served as a core learning platform. Later evolutions of BASIC gave us QuickBasic and its free version that came with MS-DOS version 5 and on, the QBasic. I think that’s where the disconnect happened. Most people know QBasic as a slow, memory hog but its best features were in QuickBasic which could compile code to machine code, QBasic could not do that and was interpretive language making it unusable for any serious work. Later, its descendants in form of Visual Basic are still used in programing language for macros in all Microsoft products like Excel, Word, or Windows in general with Visual Basic Script. There is little left of BASIC in them except for the name.
One issue I noticed is that everything runs at a much faster rate which is not so strange as QBasic was made around the era of 286-486 CPUs so if we want to see what’s going on on the screen we need to slow the execution down by creating a delay with TIMER, DELAY or WAIT commands. I found that WAIT works best for graphical programs. Just add
WAIT &H3DA, 8
WAIT &H3DA, 8, 8
to your loop and it will wait for screen refresh before continuing.
To give it a test drive I’ve uploaded some old code to Github, you can find examples here. Load them in QB64 IDE, press F5 to compile, and run. For more tutorials, examples, games, demos, and more you can check out Pete’s QBasic page.
A modern equivalent would be Python which is a far more modern language than QBasic but the simplicity of QBasic for learning programming as a kid is unmatched.
In QB64 Report - S03E06 - Interview with Ryan Carter, from Florida, Ryan noted that
school in general should not be about learning facts. It's not about road facts. It's about learning how to think. And the, one of the fantastic things that QBasic in general does this is it teaches you a way of thinking. And that way of thinking works in pretty much every programming language. Yeah. The syntax may be different. The keywords would be different. If you're going to object orientated, I don't know what you're thinking, but that's completely different. But if you're in any kind of other functional language, the thought process is still the same.
Some may disagree but the ability to enter graphic mode and draw on the screen is something Python desperately lacks. There are ways to draw in Python but it’s cumbersome and it was not meant to do it by itself and relies on external libraries. The use of libraries increases the complexity of programming significantly if you are an 8-year-old kid. And at that age, ease of approach to a subject is more important than coding styles or trying to unravel abstract ideas.
Python is far more popular and has a huge community around it and is a good mid-point in learning with more impact on the real world (deployable apps, services) whereas QBasic can be looked at as a playground, a trike before leveling up to a bike.
After taking a second look, QB64 looks more like what VB Script should have been. The one feature I like the best is an availability of a proper mini UI editor.
Python has many graphical routines for creating User interfaces but they all are cumbersome to work with and don’t come with a “What You See Is What You Get” editor for creating Windows applications*. QB64 comes with a WYSIWYG IDE editor called InForm which brings it closer to everyday use as a quick and dirty language for automation for Windows.
If you want to program a Win32 application there are better choices, or for an additional dose of nostalgia, an open-source version of Delphi 7, Lazarus. Lazarus will be a topic for another post as I really like it, how its setup and the workflow are much more me than an all-in-one window like Visual Studio IDE. This is how IDE was designed and not a language preference.
QBasic’s time has passed for any complex task but as an intro for kids to learn to program, it’s perfect. Its syntax is similar enough to modern languages that the transition to more powerful and popular programming languages is easy and programing paradigms learned are also transferable forward.