Classic Computer Magazine Archive COMPUTE! ISSUE 59 / APRIL 1985 / PAGE 10


The Editors and Readers of COMPUTE!


Using High-Level Languages
What will LISP, Pascal, Forth, or BASIC do for me that machine language can't?

W. R. Waddell, Jr.
High-level languages like BASIC are designed for the programmer's convenience, not the computer's. Machine language is the only true computer language. BASIC, LISP, Pascal, Forth, COBOL, FORTRAN, PL/1, Logo, PILOT, and other languages are for most people easier and faster to program in than machine language. In machine language, you are required to give all the details, building a program from extremely simple commands. If you're writing some text on the screen, you have to store each character into screen memory or print each character with your computer's operating system. In BASIC, though, you just use PRINT, a command of considerable flexibility. It's easier to type PRINT "HELLO" than to code in machine language:

        LDX #0
        CPX #5
        BNE LOOP

    When the computer extends the convenience of easier programming, though, it has to work harder, taking care of details that you would have to specify yourself in machine language. The machine language example prints as fast as is possible. The BASIC interpreter, however, has to think about PRINT for a while-should it print a number, a variable, a string, or the result of a calculation embedded in PRINT? Should it TAB over? PRINT also has to convert numbers and variables from their internal representation into a sequence of digits.
    The tradeoff is primarily speed. It can be much easier to write a complex program in a high-level language. This saves the programmer time. But although the machine language program may take longer to write and debug, it runs at the fastest speed possible.
    However, sometimes machine language is actually the easiest language to use when you are programming at the level of the machine, such as writing 1000 spaces to clear the screen.
    Your choice of a language should be tied directly to the kind of program you'll write. You can write a checkbook-balancing program in BASIC, a fractal generator in Logo, a general ledger in COBOL, experiment with artificial intelligence in LISP, or write a word processor in Forth or machine language. Keep in mind that different languages offer varying compromises between speed of execution and ease of use. Some languages require large amounts of memory and disk space.
    Also be aware that many languages are tied to particular programming philosophies. There are many camps of programmers who have evolved their own ways of solving computer problems. The particular way one group of people programs is a kind of dogma, and the language used is either built especially around this dogma or fits into the philosophy. For example, although Pascal does not rigidly enforce structure, it does encourage readable listings and the use of modules to build programs a piece at a time.
    BASIC is fine for those who wouldn't dream of writing a flowchart; why not just sit down and start writing your program at the keyboard? And machine language provides the ultimate flexibility-your source code can use meaningful labels and plenty of remarks, you can design your own custom control structures and variable types, and the code produced is still fast and efficient.