27

In many dialects of BASIC, the PRINT statement can be abbreviated with a single question mark when entering programs or direct-mode commands. So instead of typing PRINT "HELLO, WORLD" you can save a few characters by typing ? "HELLO, WORLD".

I have two related questions:

  1. When and where did this convention originate? It seems to be used by all the microcomputer Microsoft-derived BASICs that I'm familiar with, but it's not mentioned in the 1976 manual for Apple's original BASIC, nor (unless I've overlooked it) is it mentioned in the ECMA-116 standard from 1986. Is the question mark PRINT then a Microsoft convention, or does it predate Microsoft's original BASIC interpreter?

  2. Why was the question mark in particular chosen, and not some other character that happened to be unused by the language? To me it would have been more logical to use ? for INPUT and something else—maybe !—for PRINT. Did whoever originally chose the question mark give any rationale for this decision?

3

1 Answer 1

23

When and where did this convention originate? [...] or does it predate Microsoft's original BASIC interpreter?

Most likely, as already HP's 1969 Time-Shared BASIC, for the HP 2000 minis, included it.

I would as well put Time-Shared BASIC as the first, but that's just an educated guess due HP Time-Shared BASIC being not only extremely influential to later implementations (*1), but as well being one of the first interpreter based BASIC, which is the important part here, as Dartmouth BASIC and all direct successors (Super Basic, etc.) were compilers

It was that introduction of interactive interpreters, that lead to the "invention" of the question mark command. Or better shortcut, as it's really all about less typing for interactive queries. Usability in program source is more of a side effect.

Why was the question mark in particular chosen, and not some other character that happened to be unused by the language? [...] Did whoever originally chose the question mark give any rationale for this decision?

It seems, at least to me, rather obvious. The meaning of "?" isn't really "Print me ...", but to ask the interpreter about something. Think of it as "Tell me ..." or "What is ...", like in "what is 2+2", or "What is (the content of variable) A".

A usage that became possible the moment BASIC was no longer a compiler language, but interpreted. This enabled two new and very convenient use cases for/with BASIC:

  • Using BASIC as a pocket ... well, desktop calculator to solve expressions
  • Stopping a BASIC program at arbitrary locations and inspecting state/content of variables (*2)

Both is based on simply printing the result of an expression, so use of PRINT as interactive command (*3) came quite natural. Except it's 5 characters plus a space. Not really what anyone would love to type over and over. Having a single stroke replacing five would be welcome and using a punctuation may even save typing the space.

So, what punctuation, available in 7 bit ASCII, would you choose to ask the computer for something?


*1 - Most notable with micro computer BASICs that followed HP's style of string handling by indexing, like Wozniak's Integer BASIC, Atari-BASIC or Sinclair-BASIC.

*2 - This may be surprising to young folks only accustomed with interpreters, but in ye-goode-olde-time(tm) of compiler BASIC one had to use a machine monitor to inspect memory once a program was STOPed. That is, if the environment allowed this at all :))

*3 - Interpreters also mark the point when BASIC instructions became direct executable. With compilers, like Dartmouth BASIC, only editing was interactive. Heck, even INPUT was only added two years later with the Third Edition in 1966

4
  • 1
    Futhermore, in DTSS on the original hardware, you edited in the (language-independent) front-end machine, and BASIC jobs were compiled and run on the mainframe. Apr 18 at 12:36
  • 1
    small fyi: you got a typo in footnote 1 where you wrote sting instead of string. Can't edit though due to the 6-char limit
    – masterX244
    Apr 19 at 13:15
  • @masterX244 Thx.
    – Raffzahn
    Apr 19 at 17:55
  • I'll tentatively accept this very informative answer. If anyone finds an example that predates Time-Shared BASIC, then I'd be willing to accept that answer instead.
    – Psychonaut
    May 2 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.