33

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?

2

2 Answers 2

27

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

I would put Time-Shared BASIC as the first, but that's just an educated guess due to HP Time-Shared BASIC being not only extremely influential to later implementations (*1), but also 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.

[Maury Markowitz checked the TSB manuals and it does not show up, so it must be later.]

It was that introduction of interactive interpreters that led 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 ...", but to ask the interpreter about something. Think of it as "Tell me ..." or "What is ...", as in "what is 2+2", or "What is (the content of variable) A".

This usage became possible the moment BASIC was no longer a compiled 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 are based on simply printing the result of an expression, so use of PRINT as interactive command (*3) came quite naturally. Except that 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 character may even avoid typing the space.

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


*1 - Most notable with microcomputer 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 to interpreters, but in ye-goode-olde-time(tm) of compiled 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 directly executable. With compilers such as Dartmouth BASIC, only editing was interactive. Heck, even INPUT was only added two years later with the Third Edition in 1966.

10
  • 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.
    – dave
    Commented Apr 18, 2022 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
    Commented Apr 19, 2022 at 13:15
  • @masterX244 Thx.
    – Raffzahn
    Commented Apr 19, 2022 at 17:55
  • Looking in the 1975 version of the HP BASIC manual, I do not see the ? as a short form for PRINT noted: bitsavers.org/pdf/hp/2000TSB/22687-90001_AccessBasic9-75.pdf I looked in the V4 Dartmouth, HP, Wang, SUPER BASIC and BASIC-PLUS manuals and none of them list it. Commented Aug 12, 2023 at 18:09
  • 2
    Well I only checked due to a question on another forum, and I too expected it to be HP. Since MS is essentially BASIC-PLUS I checked that, and then SUPER BASIC from Tymshare. Neither had it. It may indeed be an MS invention, but I'm still looking. Commented Aug 13, 2023 at 1:31
2

I checked some HP TSB manuals from 1969 to 1976 and found no mention of "?" for PRINT. HP TSB was my first experience with programming BASIC and I never used "?" for PRINT back then. I went from HP TSB, to VAX BASIC, to Sinclair BASIC, to Hitachi Level-3 BASIC (Microsoft), and only the latter had "?" for PRINT, as far as I can remember. Answers in the BASIC Programming group suggest "?" for PRINT was introduced in Microsoft Level-2 BASIC, while Microsoft Level-1 BASIC had the "P" abbreviation for PRINT.

2
  • Sinclair BASIC obviously had no need for an abbreviation, given that commands were pre-tokenised (i.e. PRINT is always a single keystroke in command context, including the space). Commented Aug 15, 2023 at 7:26
  • 1
    And who said MS never came up with anything original? Commented Aug 15, 2023 at 13:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .