From BASIC to Java: an introduction to Java for BASIC programmers (3)

(Continued from the Java for BASIC programmers introduction.)

Libraries and access to the operating system

In many early versions of BASIC, it was difficult if indeed possible to access many features of the operating system. A typical version had 50 or 100 "commands". But if there wasn't a command to do the thing you happened to want to do, it would be almost impossible to do it efficiently, or at best obscure. ZX Spectrum programmers will remember obscurities such as POKE 23652,255 to enable line scrolling. Some BASICs even required sending obscure character codes to the display system to do something as simple as clear the screen. Versions of BASIC typically didn't provide very sophisticated graphics commands, and coding such routines "by hand" in BASIC was too slow for many purposes such as games.

Later, more sophisticated versions of BASIC made things a little easier. For example, on the Acorn Archimedes and its successors, it was possible to use the SYS command to access most operating system facilities such as managing windows or sprites. But this still relied on access to a reference manual and the construction of buffers with obscure contents to specify simple things such as the colour of an icon or the size of a sprite.

Java and many modern programming languages come with a "platform" or set of libraries for doing many things such as handling images, windows, files, networking, audio, text manipulation etc. The object oriented model means that parts these libraries can often be extended if they don't quite behave as you want. And the fact that there are base libraries that do pretty much all the fundamental things means that it's possible to write "more or less anything".

On the next page, we look at the issue of program speed, and how Java is essentially a compiled language, while BASIC is essentially interpreted.

If you enjoy this Java programming article, please share with friends and colleagues. Follow the author on Twitter for the latest news and rants.

Editorial page content written by Neil Coffey. Copyright © Javamex UK 2021. All rights reserved.