Programming Windows: Microsoft Basic (Premium)

Today, Microsoft is most closely identified by its Redmond, Washington campus and the market dominance of Windows. But it started more humbly, in a strip mall office in a rundown part of Albuquerque, New Mexico and with its first home-grown version of the BASIC programming language.

I don’t want to get too bogged down in this pre-Windows ancient history. But the short version is that Bill Gates and Paul Allen founded Microsoft in 1975 specifically to sell BASIC for the first personal computer, called the MITS Altair 8800. Sold as a kit to enthusiasts—Gates and Allen had found out about it in Popular Electronics magazine in December 1974—the Altair was powered by an 8-bit 8080 processor. Gates and Allen knew it was powerful enough to run the BASIC programming language, and given their past successes building an emulator for the Intel 8008—the 8080’s predecessor—and various software development tools on a PDP-10 mainframe for their first company, called Traf-O-Data, they modified it for the newer chip and got to work.

Right. What’s BASIC?

BASIC had been created in 1964 by John G. Kemeny and Thomas E. Kurtz, two educators at Dartmouth College who wanted a programming language that was simple enough for non-engineers and scientists to use. After considering Fortran and ALGOL, Kemeny started work on his own simplified language, which he called BASIC, an acronym for Beginner’s All-purpose Symbolic Instruction Code. It was based on Fortran, and it featured line numbers with one command per line.

Though it went on to legitimatize the Altair, BASIC was seen as a “toy language” by computer scientists. Most early implementations took the form of an interpreter, a software program that evaluated BASIC source code and then spit out the results, instead of a compiler. That is, a BASIC interpreter didn’t compile and link source code into a native, standalone application like C.

But that suited Gates and Allen just fine, as BASIC would fit better in the memory- and resource-constrained early computers than would more powerful and complex languages: Their Altair BASIC would require only 6 KB of RAM and it even included its own I/O system and line editor in addition to the interpreter. (That said, an entry-level Altair could be built with just 256 bytes of RAM.) BASIC was also easy to use, and in a world in which there was literally no software, being able to create your own applications was life-changing. For early personal computer makers, it was a requirement.

That’s the why of both Microsoft, as a company, and of the early personal computer revolution. The firm’s subsequent successes were based entirely on the rapid expansion of the market, over time, to include many, many more personal computers. And to expanding Microsoft’s offerings to include more programming languages and environments and then eventually productivity applications as well.

But before any of that could happen, Gates and Allen had to win the MITS contract.

Altair BASIC was written entirely by Bill Gates. He based it on the feature set from DEC BASIC-PLUS, which included a compiler and ran on the RSTS/E time-sharing operating system on that firm’s PDP-11 minicomputers. This wasn’t theft: The syntax and structure of BASIC-PLUS, like other BASICs of the day, was itself based on the Dartmouth original, but it also included numerous improvements of its own and was considered by Gates to be the best version of BASIC then available.

These days are steeped in industry lore. But long story short, Gates and Allen won the MITS contract and incorporated Micro-Soft (for microcomputer software) with Gates as CEO. Aside from seeing the potential of the Altair and then seizing the opportunity, the smartest thing the two did was to see past the Altair: The BASIC they wrote for that machine could be easily ported to other 8080-based personal computers that would come later and sold and resold to new customers.

The original version of Microsoft BASIC

MITS sold Altair BASIC for $500 if you purchased the required memory upgrades or for $75 if purchased with the Altair 8800. It was followed up by more powerful versions that supported 8 KB or 12 KB of RAM, and a stripped down version for 4K Altairs. They hired a contractor to help, but Gates hand-optimized every line of code to make sure it was as small and fast as possible. And Allen was also working on an assembler and program editor for MITS and the Altair.

And though Gates got caught up early on in voicing his concerns about software piracy and the impact it was having on him and his company, Microsoft got paid every time MITS sold BASIC: It received $30 to $60 per sale depending on the version, plus $10 for every Altair hardware upgrade past 8 KB. Given the success of the Altair and its BASIC, Gates quickly dropped out of Harvard. He would be rich within a few years, but that future success wasn’t hard to see coming. Microsoft earned just $16,000 in 1975, but it was earning that much per month by mid-1976. (Less nobly, Gates structured the Microsoft partnership with Allen 60/40 in his favor because Allen was, at the time, also receiving a salary from MITS for his assembler work.)

The rest, as we say, is history. Microsoft BASIC appeared on virtually every personal computer sold in the late 1970s and early 1980s, often rebranded for the machine’s maker. It was ported to different chipsets, enhanced with new features, and accompanied by a growing selection of other Microsoft programming languages. Ace developer Gordon Letwin—later, the lead architect of OS/2—was hired and immediately set out to create Microsoft’s first BASIC compiler.

And then IBM came calling.

Seeing the success of the then-nascent personal computing industry, IBM wanted in. So, in 1980 it created a skunkworks project to create the first IBM Personal Computer (PC) within a year. To do so, it had to use an open architecture consisting of widely available hardware components, including an Intel x86 processor. And it needed to shop around for all the software that businesses and end users would expect in that day: An operating system and some programming languages, including BASIC.

(Fun aside: IBM briefly considered licensing the Atari 800 and marketing that as the first IBM PC, and Atari had agreed to the plan. The idea reached the highest levels of the company before IBM chairman Frank Cary shot it down, wondering how it was that the world’s biggest maker of computers couldn’t build a computer of its own.)

IBM needed software, so it reached out to Microsoft. Which, by then, had moved to the Seattle suburb of Redmond, Washington. And they quickly reached a deal by which Microsoft would a BASIC interpreter and compiler for the PC, plus versions of COBOL, FORTRAN, and Pascal.

These days, too, are steeped in industry lore.

And cutting to the chase again, let’s just say that Gates originally pointed IBM to Digital Research for its OS—CP/M-86—and that, when that deal never happened, Gates simply told IBM that Microsoft would supply its own OS. So, Microsoft licensed and then later purchased a CP/M-86 clone called QDOS for next to nothing (a grand total of $75,000 over time), renamed it to 86-DOS and then MS-DOS, and licensed it to IBM. Which marketed the product as PC-DOS.

(I know. There’s a lot more to this story. But I’m trying to stick to the parts pertinent to BASIC.)

What established Microsoft has the company we know today, and what cemented Bill Gates’ reputation as a master business tactician, was making the agreement with IBM non-exclusive on its part. That is, IBM couldn’t sell Microsoft’s software for the IBM PC to third parties. But Microsoft could. And that meant that Microsoft could and would eventually sell MS-DOS and Microsoft BASIC to other firms that made PC clones.

Our hero, Bill Gates.

This forward thinking immediately paid off, as the IBM PC was such a huge success—it outsold the Apple II line in its first year in the market—that it was copied and cloned by many third parties, creating the PC market that dominated personal computing for the next 25 years. And all those clones would need MS-DOS, BASIC, and other Microsoft software. (Microsoft was, at the time, also expanding into productivity software for end users.) Over the next several years, Microsoft’s OS and BASIC would spread to millions and millions of PCs.

Because of the importance of the IBM contract, Gates personally oversaw the development of BASIC for the new computer. “Outside of maintaining the relationship [with IBM],” Bill Gates’ main involvement with the IBM machine was with his first love, BASIC—refining the specs, coding and reviewing, teaching [developer] Neil Konzen the ‘right’ way to put the IBM logo on the screen, getting pissed off when a self-described ‘random little grit’ like Konzen came up with a better algorithm for a graphics routine,” the book Gates says of this time.

(Fun aside: Konzen and Gates co-wrote the game DONKEY.BAS that shipped with PC-DOS on the IBM PC.)

The IBM PC shipped with five ROM chips; one was for the BIOS and four were for BASIC because shipping BASIC in ROM helped lower the royalty that IBM owed Microsoft. (Future IBM PC models would likewise include BASIC in ROM through the end of the decade.) There were four discrete BASIC versions originally, each on its own ROM: Cassette BASIC, Disk BASIC, Advanced BASIC (BASICA), and Cartridge BASIC.

Because of the IBM PC’s ROM-based system, none of these BASIC versions would run on the PC clones that soon appeared, so Microsoft had to create separate versions of both MS-DOS and BASIC for each clone maker. To get past this redundancy, it adapted BASICA, the most impressive version made for IBM, into a self-contained BASIC interpreter called GW-BASIC (for “gee whiz”) that it could include with the versions of MS-DOS it sold to clone makers starting in 1983; Microsoft wouldn’t create a cross-compatible version of MS-DOS that worked on all PCs and could be sold at retail until it shipped MS-DOS 3.2 in 1986. Microsoft also created a BASIC compiler called BASCOM, which it sold at retail.

BASIC was “a cash machine” for Microsoft, Gates notes. Indeed, the first version of GW-BASIC was so popular that a contract to bring it to Hitachi PCs was the firm’s first single-product million-dollar deal.

GW-BASIC also evolved over time to support EGA graphics, joysticks, and even light pens, and certain machine-specific features on a case-by-case basis; the version of GW-BASIC for the Tandy 1000 supported 3 sound channels, for example. It was full speed ahead for Microsoft and BASIC.

And then Borland happened.

Key to this Danish firm’s early success was a sophisticated software development package called Turbo Pascal that provided a compiler and integrated development environment (IDE) for a language that was, in every conceivable way, superior to BASIC. It was created by Anders Hejlsberg, who will factor into our story in a much bigger way later, since he was hired by Microsoft in 1996 and went on to create J++, C#, and TypeScript, and played a major role in the development of .NET and the .NET Framework. But in 1983, Anders and Borland were busy embarrassing Microsoft and its toy language with Turbo Pascal.

And not just because it was technically superior in every way. Turbo Pascal was cheap: It sold for just $49.95 at a time when competing products cost several hundred dollars. It was so cheap, in fact, that IBM refused to sell it. Turbo Pascal made IBM’s version of Pascal (which was supplied by Microsoft) look antiquated.

“Turbo Pascal sold for one-sixth the price of Microsoft’s Pascal compiler,” Gates explains. “Programmers had never seen anything like it … the program simply marched in and stole the Pascal market right out from under Microsoft’s nose.”

This could not stand.

Microsoft made some short-term moves to counter Turbo Pascal; it offered Turbo Pascal users a $40 rebate for “trading up” to Microsoft Pascal, for example, a product that then sold for $300. But this didn’t move the needle at all, and Borland CEO Philippe Kahn laughed off the effort, claiming that “this is the way that Bill Gates says that Turbo Pascal is a decent product.”

So, Microsoft retrenched. And after polling its developer customers for what they wanted in a “ideal programming environment,” it fought back at Turbo Pascal by using a strategy that it would later employ against Java with .NET: Duplicate what the competitor got right but support multiple languages. The result was a family of “Quick”-branded developer products, each with a Turbo Pascal-like IDE and windowing and graphics commands. The most popular was QuickBasic, but Microsoft fielded QuickPascal and QuickC products as well. (In response, Borland started shipping a Turbo C in 1987.) Each was priced at just $99.

(Fun aside. QuickBasic was codenamed PK for “Philippe Killer”)

In a nod to Microsoft’s past, in which it had created emulators for new chipsets on mainframes and minicomputers, the firm’s BASIC products didn’t generate native executable files. Instead, they compiled to pseudocode, or p-code, that was then translated to native code at runtime. In the old days, this allowed Microsoft to more easily port BASIC between different chipsets like the Intel x86, the MOS 6502, and the Motorola 6800. All it needed to do was adapt its runtime library for each platform. But this system persisted into the PC era with GW-BASIC and QBasic/QuickBasic. The result was slightly slower performance but smaller program file sizes.

To address the performance issues, Microsoft adapted QuickBasic to precompile code as it was entered by the programmer. This had the helpful side-effect of providing syntax error-checking in real time and ensuring that when compilation was required, the program was essentially error-free (at least from a syntax perspective). An immediate mode window was added to QuickBasic 4.0 so that programmers could execute blocks of code without leaving the environment.

QBasic and QuickBasic also brought then-modern programming techniques to the venerable language. In addition to dropping the all-caps BASIC name, Microsoft adapted the language itself so line numbers, a staple of BASIC from the beginning, were no longer required. So that hello, world code we saw in Programming Windows: Hello, Microsoft Basic (Premium) could actually be expressed like so in QBasic or QuickBasic:

PRINT "Hello, QBasic!"
END

Microsoft also added structured programming capabilities in the form of subroutines, which are blocks of code that can be called by name and, optionally, return a result (subroutines that returned a result were called functions.) For example, the QBasic version of the hello, world could be written with two modules, one the main module and one a subroutine:

CALL sayhello
END

SUB sayhello
    PRINT "Hello, QBasic!"
END SUB

It was simple and sophisticated. And it seemed that BASIC could be successfully adapted for the modern age.

And then Windows happened.

As we’ve discussed, Windows was wonderful for users, thanks to its event-driven graphical interface and multitasking capabilities. But it also presented new challenges, both to developers and to Microsoft, the platform’s maker. The Windows API that the firm created in the mid-1980s was complicated and obtuse, and hard for developers to learn and use. It pretty much required that they used the C programming language, and they had to initially write applications in MS-DOS, and then tediously switch back and forth into Windows to test their creations as they went.

The lack of usable developer tools was holding back Windows as much as any other technical issues it had. Worse, for the generation of enthusiasts and budding developers who had grown up learning BASIC—and almost certainly did so with a Microsoft variant of that language—it wasn’t possible in Windows’ first five years to write Windows applications in their favorite language.

“What we really need is a Windows/[OS/2 Presentation Manager] fourth-generation language—something that is a simplified Windows application generator,” my old pal Mark Minasi noted in the March 1989 issue of Byte Magazine. “Too many people roll their eyes when I suggest that they port their applications to Windows/PM. ‘Do you know how difficult that is?’ they respond. As I’ve said before, Windows/PM programming is very different from what most programmers are used to. Not bad different, just different different. A language designed from scratch for Windows would be of help here, something simpler than the usual PM code—C programs consisting largely of strung-together Windows procedure calls. Some attempts have been made to produce such a language for Windows, but thus far I haven’t seen anything compelling.”

That language and application generator would arrive a bit over a year later, in 1991, just as the popularity of Windows exploded. It was called Visual Basic. And it would change everything.

More soon.

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Thurrott