
The original source code of Microsoft GW-BASIC from 1983 - AlexeyBrin
https://devblogs.microsoft.com/commandline/microsoft-open-sources-gw-basic/
======
linguae
The funny thing about this announcement is that a week ago I just found my old
QBASIC textbook that I learned how to program with back in 1998. QBASIC was my
very first programming language; I was a nine year old kid who loved computers
and would read anything computer-related that was available, including my
mom's textbooks (she was returning to college at the time and took some
courses on computing and applications such as WordPerfect and Lotus 1-2-3) and
software manuals. When we finally got Internet access in 1998 via AOL, I used
the message boards to get resources on how to program. I was recommended to
learn QBASIC, and I was told that QBASIC could be found on the Windows 95
install CD. I remember initially learning QBASIC through some web tutorials.
My mom happened to have a friend who recently took a QBASIC programming
course; her friend gave my mom her QBASIC textbook, which my mom then gave to
me.

I'm now a researcher at an AI lab in Silicon Valley, and I just finished a
five-week stint as a section leader for Stanford's CS106A "Code in Place"
introductory Python course
([https://www.stanforddaily.com/2020/05/07/students-
instructor...](https://www.stanforddaily.com/2020/05/07/students-instructors-
share-thoughts-on-free-course-code-in-place/)). There's nothing like the joy
of programming for the very first time, the realization that you can create
something that works with code. Teaching those sections as well as finding my
QBASIC book has reminded me of the feelings that I have from when I started
learning how to program roughly 22 years ago. This release of GW-BASIC was
quite timely for me.

~~~
codebolt
My first attempt at coding was with a Java Programming For Dummies book around
the Java 1.1 era, using applets. That was a terrible choice for 12 year old
non-native english speaking me, and I never got too far.

Somehow I ended up trying QBASIC a couple of years later and programming
suddenly became a lot easier and fun. I especially loved that you could easily
switch to graphics mode and just start drawing pixels and lines to the screen,
it was like the perfect blank canvas to try out different ideas for a curious
young mind.

~~~
dTal
Alas, that easy graphics programming environment - so critical to my early
engagement with programming as well -is nowhere to be found. Even in the
Python ecosystem, nothing approaches the simplicity of "SCREEN 12" and
immediately being able to use POINT, LINE, CIRCLE etc.

~~~
int_19h
Python ecosystem is precisely the one that _does_ approach this level of
simplicity, because it has turtle graphics out of the box. Here's one complete
example from the docs:

    
    
       from turtle import *
       color('red', 'yellow')
       begin_fill()
       while True:
           forward(200)
           left(170)
           if abs(pos()) < 1:
               break
       end_fill()
       done()

------
cachestash
My first foray into BASIC was BBC BASIC. I was an 11 year old in the eighties
and attending comprehensive secondary school in the UK.

We had a school 'computer room' which hosted ten BBC Micros. The mathematics
teacher at the time ran an after school computer club and it was alleged that
the last 30 minutes were unstructured and some students had managed to get a
cassette tape copy of Elite (now Elite Dangerous) loaded onto some Micros.
This absolutely blew my mind and I had to get in there somehow. The problem
was I knew nothing about computers and I had no computer at home to practise
on (this was also not likely to change as I was part of a financially
stretched single parent family).

What I did manage to do however, was get a copy of Computer Weekly from WH
Smiths. This particular edition was running a monthly section on 'Programming
in Basic'. Now as said I had no computer, but I was not deterred into letting
that stop me, so I wrote my first program on some A4 paper. As with many first
time programmers, It was a text based adventure game with a multiple choice
engine:

You find yourself facing the dragon. Do you?

A, Fight the dragon B, Run away C, Use the magic potion the elf gave you. D,
Do nothing.

The program itself consisted of nothing more than print statements, capturing
user input and then conditionals leading to "goto line X" statements. Quite
soon this got hugely un-manageable and I realised this programming stuff was
not as easy as I thought. Somehow though, I summoned the confidence to take it
to the math teacher for his feedback and thought perhaps he might see some
promise in me sufficient to get me into the club. He leafed through a few
pages and said I could join. He later told me that he was more impressed that
someone would attempt such an effort, more than myself showing any sort of
genius.

Years later now, that snotty nosed inquisitive 11 year old is now a Principal
Engineer with a long career spent building many, many systems with many
engineers. I have always remained a software engineer , while colleagues have
drifted off into management. I will be honest, I am still as excited about
tech as I was when I was young upstart. I am also still all to willing to take
risks, fail and bite off more that I can chew. In reflection that sense of
false bravado is what has led to my career being as successful as it has been.
It's never been about how beautiful my code is or how well I understand the
deep idiomatic nature of whatever the new language is. It’s been my naive over
confident nature to always take on more than I can handle.

~~~
tomc1985
Is it really a good idea to be just as enthusiastic about tech now as you were
then? Few things are what they say they are any more. Everyone's clawing at
your personal data. With a few large exceptions, all the innovation goes to
things make both us and tech cost less to management, or manipulate our
attention, or track us because business types think theres gold in them thar
hills. Half-assed attempts at things like "agile" abound so that we can please
nosy managers. "Code as art" falls by the wayside as many of us are reduced to
stringing together various services for a living

Tech isn't fun anymore...

~~~
ddingus
Sure it is!

Go small. Embedded / retro / various micro controllers are a ton of fun, and
they have most of the feel we all experienced back then too. A decade ago, I
had a bunker. Unix, Linux, Windows, BSD, OS X, all piled into a basement
running pretty much everything. It was serious fun building it up, and then
when I got there?

These dark times took a lot of the fun out of it. So, I literally gave the
best away to a younger guy I could see drooling over the whole works and
ordered some micros. Back to my roots.

Assembly language was fun in the 80's. It's fun now. Hooking shit up to do
things? Yup. Even more fun now because there is so damn much just laying
around, and we can get almost anything delivered for a song too.

Back in the day, I actually got good at vacuum tubes. That is what was laying
around, and I was in poverty at the time. (Which actually was good for me
personally, no worries, no regrets, no harm done)

My point being:

Seeing and channeling that excitement will pay off for most who experience it.

Yeah, big brother networked computing is in a dark time. Oh well. It's a big
world of tech out there.

And, these days?

Hell, we are super good at electro mechanical. So, a young person can get a
look at that, learn to program, control things.

Then, head over to bio tech, which will soon be electro-bio-mechanical, among
other things, and likely experience a boom and sense of wonder at it all same
as we did.

I pretty much am against snuffing out those little sparks. Sometimes there is
only one. Sometimes they don't come back.

I would have hated to see my own snuffed out. At that time, I probably would
not realize the impact. But today I would, and do not want anyone with
inclination to self-learn, grow, do, build, experiment, teach, go into
business, to lose any of that inclination just because we see some bad times
right now.

------
tobinfricke
Wow, what a blast from the past. I learned to program with BASICA.EXE and GW-
BASIC as a kid in the late 80's.

I just noticed that microsoft has also released the source to MS-DOS 2.0:
[https://github.com/microsoft/MS-DOS](https://github.com/microsoft/MS-DOS)

I don't think I ever imagined that I'd be able to "look behind the curtain"
like this, let alone that Microsoft would come to embrace open source.

From there I moved on to Turbo Pascal 3.0, and then Borland Pascal 7.0 (which
I loved - super fast compiler and superb IDE - many examples and comprehensive
documentation - which were a must in the pre-Internet era), then Borland C.
And then Linux and gcc for the following two decades.

~~~
deepspace
Thirty years later, I still miss the Turbo Pascal / Borland Pascal, Borland
C(++) experience. Few, if any, 'modern' IDEs have yet reached the simplicity
and ease of that development environment.

~~~
cblum
I've been toying with Turbo Pascal 5.5 running on FreeDOS on an old laptop.
There's something really relaxing about it, compared to modern programming.

~~~
russh
Turbo Pascal 5.5 with objects was the pinnacle of my programming enjoyment.
Python 3 is catching up.

------
bajsejohannes
Has anyone got it compiling yet?

I've tried in DOSBOX, using this MASM from this (possibly sketchy?) site:
[http://www.mediafire.com/file/x13v7gqqmw1pom7/8086_Assembler...](http://www.mediafire.com/file/x13v7gqqmw1pom7/8086_Assembler%2528TechzClub_joyjophin%2529.zip/file)
. The output is as follows:

    
    
        Microsoft (R) Macro Assembler Version 5.00
        Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.
        
        Object filename [GWMAIN.OBJ]: Source listing  [NUL.LST]: Cross-reference [NUL.CRF]: End of file encountered on input file
        GWMAIN.ASM(3568): warning A4085: End of file, no END directive
        Open segments: CSEG
        OEM.H(55): warning A4016: Reserved word used as symbol: SHORT
        OEM.H(102): warning A4016: Reserved word used as symbol: LENGTH
        OEM.H(165): warning A4016: Reserved word used as symbol: LENGTH
        End of file encountered on input file
        GWMAIN.ASM(3568): warning A4085: End of file, no END directive
        
          51620 + 169980 Bytes symbol space free
        
              4 Warning Errors
              1 Severe  Errors
    

TASM (version 2.5) gives a similar error.

~~~
oso2k
Mentioned it in another reply, you'd probably want to start with the MASM and
LINK from the MS-DOS 2.0 release.

[https://github.com/microsoft/MS-
DOS/tree/master/v2.0/bin](https://github.com/microsoft/MS-
DOS/tree/master/v2.0/bin)

~~~
bajsejohannes
Unfortunately, I can't get MS-DOS 2.0 to run in DOSBOX ("Invalid COMMAND.COM")
and running MASM.EXE directly gives me some really interesting errors (looks
like it's reading uninitialized memory).

I think you're on to something here, though!

~~~
oso2k
Good job! I'm going to throw some cycles at this, this holiday weekend.

[https://github.com/lpsantil/GW-BASIC](https://github.com/lpsantil/GW-BASIC)

------
pan69

      --------- ---- -- ---- ----- --- ---- -----
      COPYRIGHT 1975 BY BILL GATES AND PAUL ALLEN
      --------- ---- -- ---- ----- --- ---- -----
      
      ORIGINALLY WRITTEN ON THE PDP-10 FROM
      FEBRUARY 9 TO  APRIL 9 1975
      
      BILL GATES WROTE A LOT OF STUFF.
      PAUL ALLEN WROTE A LOT OF OTHER STUFF AND FAST CODE.
      MONTE DAVIDOFF WROTE THE MATH PACKAGE (F4I.MAC).
    

I love comments like these. They also say that the GW refers to Bill Gates, as
in Gates William but I don't know the details on that.

[https://github.com/microsoft/GW-
BASIC/blob/master/GWMAIN.ASM](https://github.com/microsoft/GW-
BASIC/blob/master/GWMAIN.ASM)

Edit: Forgot to say, I was 3 years old when they wrote this code, wow! and I
learned programming with GW-BASIC in the late 80's.

~~~
kranner
The meaning of "GW" is controversial according to the Wikipedia entry for GW-
BASIC [1]:

> There are several theories on what the initials "GW" stand for. Greg
> Whitten, an early Microsoft employee who developed the standards in the
> company's BASIC compiler line, says Bill Gates picked the name GW-BASIC.
> Whitten refers to it as Gee-Whiz BASIC and is unsure if Gates named the
> program after him. The Microsoft User Manual from Microsoft Press also
> refers to it by this name.[citation needed] It may have also been nicknamed
> Gee-Whiz because of its numerous graphics commands. Other common theories as
> to the initials' origins include "Graphics and Windows", "Gates, William"
> (Microsoft's president at the time), or "Gates-Whitten" (the two main
> designers of the program).

[1] [https://en.wikipedia.org/wiki/GW-BASIC](https://en.wikipedia.org/wiki/GW-
BASIC)

~~~
kristopolous
Those are all too clean for 1983 Microsoft. I'm more likely to think it's some
cutting inside joke, maybe an IBM insult.

If they said it was say, something like George Wallace Basic, because they
segregated it from IBM basic and only put it on the clones as a "separate but
equal basic" I wouldn't think twice.

I can even imagine the meeting

"We can't say this is George Wallace basic, no".

"Fine, it's GW basic. Say it means gee wiz or some shit, just make something
up"

------
4cao
It's really enjoyable to look at the source. These days one I feel it's quite
rare to see assembly code not as an output from a tool like IDA Pro.

If I remember correctly, the size of a compiled GWBASIC.EXE file was about 80
kB.

What feels weird though is seeing all the files on GitHub last modified "38
years ago," which by the way, also includes the file CODE_OF_CONDUCT.md.

~~~
bitcrazed
You think there weren't codes of conduct back in 1983? ;)

~~~
4cao
Markdown itself is from 2004 but the .md extension/suffix wasn't used for it
until sometime later (not really sure where it appeared first).

~~~
tjalfi
MDCD[0], an open source DOS archiver, used the .MD extension in 1988.

[0]
[https://www.sac.sk/download/pack/mdcd10.zip](https://www.sac.sk/download/pack/mdcd10.zip)

------
perl4ever
I wasn't particularly aware of it, but it looks like the TRS-80 BASIC that
introduced me to programming was also probably developed by Microsoft, and I'm
pretty sure that AmigaBASIC was as well. I think I also used QuickBASIC on the
Mac a little, but what I particularly remember was a demo for it that visually
showed different sorting algorithms, that inspired me to do something similar
in Pascal.

~~~
pan69
Microsoft BASIC was all over the place in the late 70's and early 80's. Before
MS-DOS, Microsoft was basically a programming languages company (and they
still are today). They licensed their BASIC to many other companies, even
Apple.

[https://en.wikipedia.org/wiki/Microsoft_BASIC](https://en.wikipedia.org/wiki/Microsoft_BASIC)

~~~
C1sc0cat
And I think most if not all MSBASIC ports for early PC's had a memory leak if
you did not break out a FOR loop in the right way.

I am a bit rusty but this sows the problem:

10 L = 4720 FOR I =1 TO 1000 STEP 2

30 PRINT I%

35 IF I = l GOTO 6999

40 NEXT

6999 STOP

What you needed to do was set I to the end condition as part of the break out
of the loop.

There was also a lot of aggressive compression done to reduce program size PET
in particular munged every thing up putting as many statements on one line as
possible

~~~
Starwatcher2001
There was a bug in the TRS-80 basic (which was indeed Microsoft). It had an
"on x goto" command that allowed the program to move to different lines
depending on the value of a variable:

ON X GOTO 200,300,400,500 depending if x=1, x=2,x=3...

They'd obviously used the same parser for the standard "If a=1 then goto 200"
construct, which allowed an undocumented shortcut of "If a=1, 200" which a few
people noticed and started using. However, a later model fixed this, which
broke a number of programs.

~~~
C1sc0cat
ooh I never worked on TRS80's - so they had a version of the Arithmetic IF :-)

I could have Told BillG that was bad idea back when I was 19

~~~
ddingus

      x = x + (x < 5)
    

:D

No If needed.

Atari Basic would allow crazy things like:

    
    
      10 Goto ((x < 5)*100) + 50
    

Goes to either line 50 or 150, depending on the comparison result being 1, or
0)

Or...

    
    
      Goto (100*x)
    

Faster On goto with no checking, lol.

Bill Gates was not involved with the original Atari Basic. That could be
purchased on a cartridge for running MS Basic programs.

~~~
int_19h
Did Atari BASIC use 1 for TRUE? Most BASICs used -1 (i.e. all bits 1), because
this allowed the same operators to work for both bitwise and Boolean logic, in
the absence of a dedicated Boolean data type.

~~~
ddingus
[https://atariwiki.org/wiki/Wiki.jsp?page=Boolean%20Logic%20i...](https://atariwiki.org/wiki/Wiki.jsp?page=Boolean%20Logic%20in%20BASIC)

Yes, it used 0 and 1. And it did not contain bitwise ops. Those were quite the
surprise!

My first efforts were in Applesoft. Computers at school. Got an Atari machine
and programmed the crap out of it. Wrote my own assembler, a few games, etc...

Then I got an Apple and finding them in Applesoft was a nice surprise! Prior
to that, I thought they were an assembly only thing.

The trade off in the Atari basic was doing things mathematically was pretty
easy and it generally, but not always, was faster.

A few of us wrote fairly complex programs with basically no if statements.
Kind of a fun way to think about things back then.

I much prefer -1 and 0 and the bit ops, frankly. Internally, I remembered this
kind of thing as "really fucking true" as in every bit better signal, or it's
false!

~~~
int_19h
The problem with using bit ops as logical is that they don't short circuit.
Although it was unfortunately common even in languages that had proper
Booleans at the time - e.g. standard Pascal didn't have it, and Turbo Pascal
required a compiler directive/switch to enable it, which few even knew of. So
it feels worse in retrospect than it actually was back then.

On the other hand, one thing that BASIC still has to this day (in VBA) that no
other language I can think of does, is _bitwise_ equivalence (EQV) and
implication (IMP) operators. Furthermore, since VBA has a Boolean data type,
these operators are also available for Booleans; implication comes in handy
sometimes.

~~~
ddingus
Not sure what you mean by short circuit.

I had no idea about those VBA features. Will read about them.

Having the bit ops themselves is a very strong feature.

My simple assembler would definitely been faster and simpler with them.
Graphics, some math, all benefit. People would make little language extensions
or callable machine language routines to make the bit ops available.

In basics with bit ops, and the -1 as true:

X = 100 & (y = 5)

Atari

X = 100 * (y = 5)

Not doing the multiply seems like a net gain in a limited CPU too. That basic
did not really have types, like MS basic did. Pretty much floating point only.

Interestingly, basics that have the bit ops do not always allow the
expressions in a goto. Or, could just be my own memory, or lack of trying. Not
really needed.

In fact, outside of trying to optimize, or just explore the language, the only
case that made real sense was a sort of jump table making good use of line
numbers like one would do with memory addresses in assembly.

Say, branching directly on a checked or masked character value.

And the spiffy thing was making pseudo labels. Put line numbers into variables
and use them like labels.

Foo = 1000

Goto Foo

Overall though, it was a weird little basic. It nicely supported the machine,
and the device independent I/O system in the OS ROM, but was slow otherwise.

This guy has actually made an N: driver meaning Atari Basic programs written
long ago can operate across the Internet today.

Lol, cool old stuff.

[https://m.youtube.com/user/tschak909](https://m.youtube.com/user/tschak909)

~~~
int_19h
Short circuiting means not evaluating the right side if the left side is
sufficient - so e.g. in (Foo() OR Bar()), if Foo() returns true, it won't even
evaluate Bar().

Most modern languages are like that, but BASIC is an exception to this day -
even VB.NET still doesn't do short circuiting by default. You need to use
special operators, AndAlso/OrElse, to get it.

Computing the line number in a GOTO is definitely an extension - the original
Dartmouth BASIC never had anything like that. For jump tables and such, you
were supposed to use ON..GOTO.

~~~
ddingus
Makes perfect sense. Maybe nobody cares enough about Basic, or figures there
are a zillion better performing options? Seems like an optimization like that
would have been done at some point

Yeah, the computed goto is odd.

Back in the day, I used it and some conditional math to greatly shorten and
improve performance in some programs. My first machine was only 16k. Using the
graphics system in any meaningful way cost a lot in terms of program space.
So, every dirty trick, including poking new addresses into string variable
address pointers to overlap the graphics screen got done.

Absolutely terrible code though. I am sure if I saw some of that code today, I
would have a bugger of a time sorting it out.

------
downerending
Not sure whether it was exactly this version, but on an early job in the mid
80s, used a Microsoft BASIC compiler on a PC in a shared office. At least by
default, when compiling, it would ring the "bell" on every syntax error. And
by "ring", I mean _loudly_. BEEP BEEP BEEP BEEP BEEP BEEP BEEP. Which I
discovered sitting at the PC, surrounded by secretaries, who commenced
withering stares.

That's the first day I remember not liking Microsoft.

~~~
WorldMaker
Supposedly IBM's fault that the original PC speaker failed to think of
niceties like a mute button.

As late as the 486 era I remember how often it was reminded to people to just
disconnect the PC Speaker. I also recall there were also crazy case mods where
people would add a switch to their cases to add an on/off button.

~~~
downerending
Yeah, once I bought my first PC, I rapidly realized that just disconnecting
the speaker was the way to go.

That said, I totally blame Microsoft for thinking that ringing the bell was in
any way acceptable. Even if the PCs of the day had a soothing, quiet 'ding'
sound, emitting that for every compiler diagnostic was the height of
stupidity. As it was, I recall the original PC bell sound as more like gear
grinding, if your head was one of the gears.

~~~
WorldMaker
Once per compiler diagnostic isn't quite so bad as POSIX and macOS apps I know
that will ring the bell for every wrong _key stroke_. ;)

(Even if more POSIX terminals these days make the bell actually sound like a
bell or use a simple visual "nudge" instead and not the poor buzzsaw of an
early DAC wired to a cheap speaker because it was free parts just laying
around during the invention of the IBM PC, it's still amazing that terminals
ever had a bell signal, as annoying as it can be, much less that apps
intentionally used it or that it will forever be ambered into Unicode even.
Learning to type a bell was a rite of passage for DOS kids, maybe with pseudo-
terminals coming back into fashion it will be a thing kids learn again.)

------
ChuckMcM
I could not find the original macrotized version. As history tells it there
was a version of this code that was written in a bunch of macros that were
parsable by humans and they emitted assembly code for a wide variety of
machines and architectures (from the 8080 to the 80286).

When I wrote the BASIC interpreter that runs in your web browser (using Java)
I modelled it after GW-BASIC as this was the BASIC that had the most number of
test cases I could find.

Given that we've got DOSBox for running DOS in your browser this should be
portable to that sort of environment right? I know playing HAMMURABI and TREK
isn't very engaging to the cool kids these days but they were a big component
of the early microcomputer "revolution."

~~~
beambot
The article seems to confirm your recollection of a macrotized "master":

> Each of the assembly source files contains a header stating This translation
> created 10-Feb-83 by Version 4.3

> Since the Instruction Set Architecture (ISA) of the early processors used in
> home and personal computers weren’t spectacularly different from one
> another, Microsoft was able to generate a substantial amount of the code for
> a port from the sources of a master implementation. (Alas, sorry, we’re
> unable to open-source the ISA translator.)

------
LyalinDotCom
For more information on why this happened check out Richard's blog post:
[https://devblogs.microsoft.com/commandline/microsoft-open-
so...](https://devblogs.microsoft.com/commandline/microsoft-open-sources-gw-
basic/)

~~~
skissane
> (Alas, sorry, we’re unable to open-source the ISA translator.)

> Alas, we’re unable to provide sources for these ports and/or customizations.

I wonder why. (I guess it might involve code licensed from third parties, co-
developed and jointly owned with OEM vendors, or unclear provenance of IP.)

I wonder if it will ever change. I hope one day it does.

One of these days (probably long after I'm dead) the copyright will expire. I
hope the source code hasn't been lost by then. (Sadly, there's a decent chance
it will have been.)

~~~
WalterBright
Much of the source code from those days is simply lost.

------
throw_away
In 1988 or so, my dad bought us an 8088 IBM-PC for christmas. He used the gw-
basic manuals to code in this christmas scene on boot with a santa, a tree,
fireworks and even some christmas carol in chiptune in the background.

My dad was an autoworker. I've built foundational services and products now in
the homes of 100s of millions & to this day I'm still astounded by what my old
man pulled off.

------
the_af
Like others here, I see, I learned to program with GW-BASIC. Well, actually it
was with the clunky BASIC from my beloved C64, but I wrote my first actual
programs that did something with GW-BASIC, running on a trusty PC XT clone.

I also remember it had a graphics mode -- Hercules card, ambar monochrome
monitor -- which sort of resembled Logo's turtle. You gave directions to a
sort of pencil tip. I don't remember what the statement was called, but I
remember I used it to program games.

I owe a lot to GW-BASIC :)

------
RcouF1uZ4gsC
From a comment in the source

> ORIGINALLY WRITTEN ON THE PDP-10 FROM FEBRUARY 9 TO APRIL 9 1975

Wow! I did not realize that it was written so quickly. Two months that
literally changed the PC landscape forever.

~~~
bluedino
Well...remember it is 'just' a BASIC interpreter.

Woz wrote Apple integer BASIC in the evenings while working at HP in just a
few months. Guys were writing crazy stuff at the time. The original version of
DOS that Microsoft bought to license to IBM for the PC was written in 6 weeks.

~~~
Tehdasi
Expectations of complexity were much less in those days. Like, a programming
language that is limited to 40 character variable names would be considered
amateur hour, but back in the day it was prolly considered luxuriant. Also
given the memory constraints, it also limited the amount of complexity you
could put in your code.

~~~
vidarh
More than luxuriant. Commodore BASIC (effectively 6502 Microsoft BASIC under
license with tweaks) on the C64 only looked at the first _two_ characters of
variable names. It allowed them to be longer (don't remember how long), but
would ignore subsequent letters.

~~~
guenthert
This is getting off-track, but while the pitfalls of two relevant characters
out of potentially many are obvious and only excusable due to technical
limitation of the platform, insisting on more than 40 relevant characters is
likewise contraproductive. Who (which _human_ ) will readily distinguish two
character strings more than 40 characters in length sharing the first 40?

I feel often the need to remind programmers, that they don't write code for
the computer. The computer will make it obvious, whether it understands you or
not. You write for the poor sod tasked to maintain your code three years from
now, when you're at your next gig.

~~~
panzagl
Does namespacing count?
com.mycompany.class.classfactory.factory.initializer.StaticGlobal

Sure you can usually use import/aliasing to narrow it, but sometimes you just
need to grab some random global from somewhere.

------
ncmncm
Poked around a fair bit. Didn't find any hint what the GW is/was supposed to
stand for.

Micro-soft BASIC on Apple ][, as on other 8-bit targets, infamously did a
linear search from the beginning of the program to locate the target of a GOTO
or GOSUB statement, so that programs ran faster if frequently called
subroutines (what we now call functions) were close to the front. I wonder if
or when that behavior was ever corrected in GWBASIC. Also, did the NEXT
statement do it too?

~~~
tobinfricke
> Didn't find any hint what the GW is/was supposed to stand for.

Hah! This is the real mystery, isn't it? I noticed Wikipedia has a section on
the topic (without resolution): [https://en.wikipedia.org/wiki/GW-
BASIC#Name](https://en.wikipedia.org/wiki/GW-BASIC#Name)

------
nsxwolf
Looking at this source code I'm astonished by how many lines of code it is.
I've never written more than the most basic (ha) of assembly language programs
in my lifetime.

How does all this assemble into a 60k binary?!

Also, wasn't it true that Steve Wozniak was able to bootstrap the entire Apple
I BASIC in hexadecimal from his own memory? How can that be? I'm reeling.

~~~
Scuds
Each line gets translated down to a few bytes, maybe two to ten depending on
the opcode. The downside being that each line doesn't do a whole lot.

And I can imagine that this is an absolute ear pull to try to debug with the
tools they had. It's more akin to debugging embedded systems to the PCs we
have today.

------
bitpow
GWMAIN.ASM ( [https://github.com/microsoft/GW-
BASIC/blob/09ad7bc671c90f0ee...](https://github.com/microsoft/GW-
BASIC/blob/09ad7bc671c90f0eeff4cb7593121ad6f170d903/GWMAIN.ASM#L23) )

BILL GATES WROTE A LOT OF STUFF

------
rietta
That's awesome. I actually have GW Basic from my first computer available.
Copied from the old 5.25 inch floppy to a 3.5 inch floppy via a 486 and then
to a USB hard drive about 20 years ago into a folder i called "Diskette
Collection".

~~~
the_af
I lost a lot of valuable stuff, including my own first programs I wrote as a
kid, to aging diskettes and bit rot. And then threw the diskettes away. I wish
I had had your foresight...

------
dboreham
Hmm: " (Alas, sorry, we’re unable to open-source the ISA translator.)"

For...legal reasons? Or because they lost it?

------
pknerd
GWBasic was good resource to get into programming world during my teenage. Now
I want to teach coding to my 10 years old son. Will you still recommend
GWBASIC/Quick basic or Python or other languages for kids?

~~~
cachvico
Check out Scratch, from MIT.

[https://scratch.mit.edu/](https://scratch.mit.edu/)

~~~
ArnoVW
Scratch is great. If you want something like that but less open ended and more
directed (with exercices and training videos) try
[https://code.org/](https://code.org/)

It also helps they use known franchises like minecraft or angry birds =)

------
kristopolous
IBM had their own Basic, 4 of them really (collectively called IBM Basic) that
was a barrier for the clones[1] (eg, Compaq, Dell, etc) because they wouldn't
license it. (You probably used one of them, basica if you used the classic PC)

Microsoft made GW basic and smited IBM by putting it on the clones Except for
the IBM machines. They also intentionally made it slightly incompatible with
IBM's basic. Then they held the GW basic source hostage so IBM couldn't
resolve the inconsistencies, couldn't backwards engineer it because of the
licensing, and thus put them at a losing negotiating position since Microsoft
now called the shots because they controlled the software. (I wonder if this
slight is in the comments, let me go look, that'd be great[2])

Microsoft also held the DOS source code hostage and it was a huge stickling
point in the OS/2 and Windows work and was a significant reason Microsoft was
able to steal the show from IBM. IBM even sent over a bunch of engineers to
get DOS 2 to work because DOS 1.1 was a complete mess. But they didn't have
the rights to walk out the building with the source they wrote due to a
contract oversight.

Bill Gates was a true software Napoleon, it's really quite something.

Now they're releasing all of it. It's a strange coincidence to pick the three
they burned IBM with 35 years ago...

Maybe they're trying to shake off the old days, maybe they're putting a final
stick in IBMs eye, maybe it's genuinely unrelated, who knows.

Smacking around IBM is my preferred reading because the idea of doing one
final power play, against IBM for God sakes, 25 years after it became
unarguably 100% meaningless with the release of Windows 95, I personally find
hilarious.

\---

[1] The only source code left in the timeline we don't have is Phoenix, who
cleanroom cloned IBM's BIOS in 1983 (using a Chinese Wall) which allowed the
clones to really take off. But they've been pieced off and sold as a
fleamarket to HPE, Absolute, and Marlin, so who knows when we'll see that
source.

[2] I'm going to make the bold claim (after 10 minutes of poking) and say
either they removed the incriminating things or the claimed intentionality of
the incompatibility is now provably just a rumor (as in they lucked into it
through implementing an imperfect clone)

There's evidence for both I guess. For instance, GIOCOM.ASM has a reference:

COMPAQ=0 ;Include IBM 1.0/1.1 Bugs for compatibility

But this isn't cited anywhere else. It's just hanging. They have a bunch of
other vendor specific things like ZENITH, TSHIBA, they all have logic, this
one is absent any logic, it's just an orphan. Shrug...

I just tweeted @ BillG and asked him --- snowballs' chance he'll respond but
who knows.

~~~
hakfoo
I'm not sure that the ROM BASIC was a huge commercial factor much after 1983
or so.

It might have given IBM more leverage to say "not fully compatible" or
instigate IP lawsuits, but most clones seemed to be okay with a boot error of
"NO ROM BASIC - SYSTEM HALTED" instead of the IBM BASIC ROM.

They stopped updating the ROM version virtually immediately, and it never
supported discs. No PCs after the PCjr supported cassette tape natively. So
all it could be was a penalty box when the boot failed.

BASICA and GWBASIC seemed to be treated equivalently from the perspective of
mid-late 80s magazines with type-in listings of near commerical-grade for the
time software.

------
zozbot234
Great news, and hopefully this will be pulled into the FreeDOS devtools
distribution ASAP.

------
iforgotpassword
So this is the initial version that might still contain some bugs?

I forgot the details, but I remember that my XT clone had does MSDOS 2.11 and
whatever version of gwbasic came with that, and MUSIC.BAS would always play
the notes slightly out of sync with the visuals, and the prompt would return
before the last note played.

Some day I saw it running on a friends machine, and there everything looked
fine. I copied his gwbasic.exe and lo and behold, now it worked on my machine
too. The version numbers were also different, but I couldn't tell you either
one now.

------
jhoechtl
That's interesting:

    
    
        ; There is a problem with running the ASM86 sources for BASIC as they
        ; stand.  MSDOS puts a 100 hex byte control block at the beginning of the
        ; EXE file and sets up the ES register to point to it.  BASIC, however,
        ; expects this block to be at 0 in the code segment.
    

[https://github.com/microsoft/GW-
BASIC/blob/master/BIBOOT.ASM](https://github.com/microsoft/GW-
BASIC/blob/master/BIBOOT.ASM)

------
orionblastar
[https://sourceforge.net/projects/pcbasic/](https://sourceforge.net/projects/pcbasic/)

PC Basic emulates GWBasic on many platforms.

------
29athrowaway
The Altair BASIC from early Microsoft was an insane achievement. They created
it without having access to the Altair, and it worked at the first attempt...
using punched tape.

------
timonoko
"Sometimes I just look in mirror and spook myself". In 1983 I wrote modern
high-level language interpreter and compiler with backtracking and throw-
catches (clojures sortof) in MSDOS assembler and it is much shorter than this
GW-Basic. Admittedly I used macros like a madman on steroids.
[https://github.com/timonoko/nokolisp](https://github.com/timonoko/nokolisp)

------
bsharitt
My biggest take away here is that old MS-DOS has been made free software. I
had a Compaq Portable that I’m restoring, and I gave half a though to
combining my love of retro hardware with free software and running FreeDOS
even if it is a bit of a resource hog. But I think this machine(its the
original version of the Compaq Portable) came with DOS 2.something, so the now
open source DOS 2.0 might work without the performance hit of FreeDOS. Neat.

------
bexsella
This is great! But it makes me think that Microsoft need to add a BASIC
compiler as standard in all Windows distributions. They did that Small Basic
thing a while back, but it was too encumbered in .NET-isms, a kind of Visual
Basic .NET lite. It would be great if there was just a easy to understand
BASIC that you could hack away with that could produce interesting programs
without the .NET cruft or the barrier that is dealing with Windows APIs.

~~~
tobinfricke
It's too bad Microsoft QuickBASIC isn't a thing anymore. Who didn't love
GORILLAS.BAS?

~~~
bobochan
Yes! QuickBasic 4.5 was my jam! I used to churn out apps with that left and
right.

~~~
the_af
I loved QuickBasic 4.5! It could compile programs to .EXE files ;)

And from there, once you hit QuickBasic's limitations, it was a small step to
Turbo Pascal or Borland C!

~~~
0xabe
It’s about time MS open sourced QuickBasic or at the very least released it as
abandonware.

------
Starwatcher2001
In 1985, I was developing a simple serial network for barcode readers, to run
on the original IBM PC. It needed to run as a TSR (Terminate and Stay
Resident) assembler routine and use the 8250 UART chip, and the 8259
Programmable Interupt Controller.

At that point the only documentation we had access to was the IBM Technical
Reference Manual, which gave the schematics and BIOS listing, but little else.

I was very familiar with GW-BASIC and had written some BASIC code to use the
RS232 serial interface from it, so decided to reverse engineer GW-BASIC
itself, to work out how it was addressing those chips.

A month or two later, we came across Peter Norton's "Programmers Guide to the
IBM PC", which could have saved us weeks.

Exciting times.

------
peter_d_sherman
First of all, I'd like to thank Microsoft for open-sourcing this, as well as
early versions of MS-DOS; they are _important pieces of computer history_.

Now, a few software engineering observations (these are to my future self, not
to Microsoft):

1) This is extremely minor, but it would have been nice if the main file
(which I'm guessing is GWMAIN.ASM?) had been pointed to in the documentation.
Reason: We're not in a language that has a default main file by custom, i.e.,
C's 'main.c'. But again, extremely minor...

2) This code is great, I mean, absolutely great for someone to learn x86
programming IF they have the prerequisite understanding about how memory is
segmented in those early computers (including segment registers, etc.)...
Reason: Very few basic x86 instructions are used, relative to the entire x86
instruction set...

3) It seems that the assembler which was being used at the time had a
limitation of 6 characters per symbol. This kind of sucks a little bit for the
readability of those symbols (but note that the code makes up for this with
liberal commenting, which is great!), and of course, with a little bit of
effort, you can mentally parse what most of these mean.

4) I would have liked to see some kind of document (although, since it's 38
years "after-the-fact", after this program was being written, I certainly
don't expect one! <g>) which, at a high level, would describe the main data
structure being used to hold the lines of basic code (I'm guessing this would
be a linked list of sorts), in what source file that data structure lives, and
how it is evaluated when a BASIC program is run...

 _Basically, give me the high-level view of the system._

The code itself represents the low-level implementation details of that high-
level "as simple as possible but not simpler", view...

But again, those things are minor, relatively speaking, and they only amount
to "notes to self" in my future software engineering efforts...

Anyway, thanks again to Microsoft for this great important contribution to
computer history!!!

------
Brajeshwar
Perhaps stupid questions but how do they get the commit history to be from 38
years ago at [https://github.com/microsoft/GW-
BASIC](https://github.com/microsoft/GW-BASIC)

~~~
mrunkel
Probably a script with some version of:

git commit --amend --no-edit --date="Fri Nov 6 20:00:00 2015 -0600"

------
kerng
Visual Basic 6 next please! :)

~~~
xellisx
I did VB 3 when I was like 13. I think it makes more sense to me after doing
JS for so damned long now.

------
wegs
Awesome!

I'd love QBasic from a few years later.

I'd also love a nice, easy-to-run Ubuntu .deb for either.

~~~
Koshkin
Not a .deb, but still pretty damn easy to install:

[https://github.com/QB64Team/qb64/releases/download/v1.4/qb64...](https://github.com/QB64Team/qb64/releases/download/v1.4/qb64_1.4_lnx.tar.gz)

~~~
rzzzt
QB64 is pretty cool, they got the IDE experience right:
[https://www.qb64.org/portal/#about](https://www.qb64.org/portal/#about)

In their implementation, BASIC code is transpiled to C++ first, then compiled
and executed.

------
duskwuff
Oh, interesting. I wonder what implications this will have for the MS Basic
disassembly project:

[https://github.com/mist64/msbasic](https://github.com/mist64/msbasic)

~~~
ksaj
While it might initially feel like a downer, it would still be quite
educational on its own to go through the code comparing what they came up with
in the disassembly in light of the real deal being now published.

There would probably be a few "Ah Hah!" moments for code that stumped them,
and lessons to be learned on any particular errors they made.

~~~
skissane
They are different. That project is disassembling Microsoft BASIC for 6502.
What Microsoft has just open sourced is their BASIC for 8086. Two separate
codebases, although they have some commonalities. (As the MS blog post
mentions, they kept master source in some kind of abstract assembly which
could then be automatically translated into specific machine's assembly
language, but then I believe there were manual additions to the assembly code
after translation.)

~~~
andrewf
I wonder if the master source was that abstract, the original Microsoft BASIC
was for the 8080, and there were several 8080 -> 8086 source translators.
TRANS.COM shipped with 86-DOS before it became Microsoft MS-DOS.
[https://tech-insider.org/personal-
computers/research/acrobat...](https://tech-insider.org/personal-
computers/research/acrobat/8206-b.pdf)

------
tvmalsv
Very nice, that was my first language on a PC-compatible (Epson Equity I if
anyone remembers those, later upgraded it with a 20MB Seagate ST225!). Man,
those were the days... and get off my lawn! lol

------
roywashere
GW-BASIC was the first Basic I wrote substantial code in! I got a kids' book
with drawings and text explaing variables and such from my dad. I think I was
7 or 8. It was not long that I reached for the extensive and English-language
manual for GW-BASIC which came with the computer. Being a Dutch kid, this
allowed me to both learn some English AND some Basic.

Prior to that my dad had a Tandy TRS-80 model III but at that point I was 6 or
7 and my typing skills were holding me back from writing more than 3 or 4
lines of code.

------
Newtonip
My mom's IBM 8088 had GW-BASIC built into its BIOS. You could turn on the
computer and go straight into it without having any storage medium present.

~~~
russellbeattie
Interesting. Was that the original IBM PC? I thought it needed DOS for some
reason.

I've always thought that using BASIC as the default command line was really
weird... Like on an Apple II or TRS-80. You could type in a command to load
something from a disk or run a program, or type a line number to start
programming. How did that make sense to anyone?? To my 11yo self, it was
confusing and I've never changed my mind.

~~~
nsxwolf
Yes. The original PC and PC XT had BASIC in ROM just like all the other home
computers of the day. In its most bare bones configuration, you booted into
BASIC and used a cassette tape drive for your storage.

I don't know how common that setup was - probably not very. The most typical
stripped-down PCs were dual floppy (the hard drive was a premium), and booted
either MS-DOS or CP/M.

------
kerng
Some real cool things - this is computing history being preserved, like in one
of the files I saw this:

\--------- ---- -- ---- ----- --- ---- ----- COPYRIGHT 1975 BY BILL GATES AND
PAUL ALLEN \--------- ---- -- ---- ----- --- ---- -----

ORIGINALLY WRITTEN ON THE PDP-10 FROM FEBRUARY 9 TO APRIL 9 1975

BILL GATES WROTE A LOT OF STUFF. PAUL ALLEN WROTE A LOT OF OTHER STUFF AND
FAST CODE. MONTE DAVIDOFF WROTE THE MATH PACKAGE (F4I.MAC).

 _

------
staycoolboy
I really appreciate the nearly per-line commenting.

~~~
mrweasel
Sure, but opening a random file yields the comment:

.RADIX 8 ; To be safe

To be safe of what exactly?

~~~
peteri
Probably because the PDP & Intel 8080 were typically octal systems rather than
hex, the 8080 instruction set decoded nicely in octal (or at least the MOV A,H
instructions). By the time the 8086 arrived the micro-computer world had moved
to hex as it nice decode mapping was broken by the Z80 and the 6502/68xx
families didn't have that nice split.

So my guess this is to allow 12 octal to be 10 decimal as that would have been
the default in the inital code base.

~~~
guenthert
I thought the whole octal business stemmed from the time mainframes and minis
used 36b, 18b words respectively as 6bit (early mainframe character width) can
be conveniently represented as two digit octal. This changed when computers
went 16/32bit and started to use 8bit bytes (and ASCII encoding of
characters).

------
vijaybritto
I noticed an odd thing here. The repo is full of assembly code and nothing
else but the colored bars in github shows C++ and C !!

------
floppy123
Missing github feature: activity chart on the forks page to see easily who is
working on the code - not just collecting

------
JoeAltmaier
I remember when Bill Gates released his terrible BASIC for homebrew computers.
It was implemented in ROM (because nobody had enough RAM to hold something
like an interpreter). It was terrible, bug-ridden and unambitious. I recall
thinking at the time "I could do better than that!".

If only I had :)

------
qwerty456127
Please also open-source MS DOS 7.1 and QuickBasic 4.5. These are equally
nostalgic and slightly less useless.

------
pjmlp
Very nice commented code, it really looks like the best practices of some
Assembly books back then.

Also love the remark about high level languages and the choice to go with
Assembly, no kids, C wasn't always as fast as you have been sold on, specially
on home computers.

------
jpswade
Wow, Microsoft are really going full-in on open source. I think this means
Open Source has won?

~~~
anticensor
Wait until the Current Branch of Windows 10 becomes open source.

~~~
npongratz
I'd be content (happy, even!) with Windows 2000.

------
anta40
"Contains no build scripts, makefiles, or tools required to generate
executable binaries, nor does it contain any pre-built binaries / executables"

Considering the repository is 80's assembly code, I have no idea how to
rebuilt it.

------
rluoy
Is the original Turbo Pascal open sourced? I would have lots of interest in
reading it.

------
goatinaboat
_When developing on /for mainframes and minicomputers of the day, developers
were sometimes able to use higher-level languages_

ISTR hearing that MS had a VAX that they developed on then cross-compiled for
8086

------
ezconnect
My first programming language was AppleSoft Basic. My Aunt gave me a book,
they have Apple II at work, and I read it and learned it even though I dont
have an Apple II at that time or even a computer.

------
axaxs
very cool.

> When writing software for early PCs, every single byte and every single
> instruction mattered, so developers often wrote code entirely in assembly
> language simply to be able to physically fit their software into the
> available memory, and to be able to access the computer’s resources and
> internal workings.

This made me a bit sad. Imagine how fast things could be today if developers
still had this mindset. Of course I wouldn't advocate writing everything in
ASM, but the adage that computers are fast, write inefficient code...is
disappointing to say the least.

------
guenthert
I don't care about Microsoft's BASIC, in fact I don't care much about BASIC at
all. It was a poor choice 35 years ago, it's irrelevant today. Or nearly so.

However, I do find GPIB programming examples in what seems to be Rocky
Mountain BASIC (HP BASIC / HT BASIC) in the manuals of measurement devices
from the seventies to the early nineties. Analog electronics didn't evolve
nearly as quickly over the last forty years as digital, so some of those
instruments are still significant today (chiefly to hobbyists, but at least
the HP 3458A, introduced 1989, is still produced virtually unchanged and is
even today the top-end long scale-scale DMM).

I like to see a OSS implementation of that dialect (for Linux).

------
ddgflorida
I loved QBasic. Did Numerical Analysis homework in college with it and wrote a
clone in the late 90s that integrated with the web/CGI. It was my favorite
until Turbo Pascal came out.

------
moron4hire
When I first looked at this, the commit logs showed everything last updated 37
years ago, except the README , which was 37 minutes ago. I thought it was kind
of funny.

------
markbnj
I still have an original GW-BASIC quick reference pamphlet that came with a
compaq luggable from about that time, in case anyone wants to complete their
collection :).

------
johnnyAghands
The perspective and excitement this write up adds is super infectious. Kinda
really shows the organic change MS has had in the last 5 years -- at least to
me

------
password4321
I read through the GW-BASIC manual of commands from front to back, so I
couldn't do any graphics commands until I got to 'SCREEN'.

------
barking
There was a later also discontinued Basic from Microsoft that a lot of people
have been hoping would be open-sourced too.

------
jg42
Initial commit was 38 years ago. Heh.

------
shannifin
My first programming language, started self-learning it in the early 90s,
great intro language.

------
hartem_
Does anyone know what GW stands for? Is it just Gates William, or is there
more to it?

------
m4tthumphrey
I love that the "Initial commit" is timestamped to 1983 :)

------
tinus_hn
What do the letters GW stand for?

------
vs2
GW stood for Gee Wizz !!!

------
timonoko
"Contains no build scripts, makefiles, or tools required to generate
executable binaries, nor does it contain any pre-built binaries /
executables".

So what is the point of publishing this? All we learn that "Every Line Must
Have Comment" in Microsoft.

~~~
timonoko

        CLC ; Clear Carry

~~~
timonoko
One line of quoted assembly downvoted. Dang?

