
How Steve Wozniak Wrote BASIC for the Original Apple From Scratch - mr_tyzic
http://gizmodo.com/how-steve-wozniak-wrote-basic-for-the-original-apple-fr-1570573636/all
======
k1w1
The update that describes why 4KB of RAM was necessary was interesting to me.
In 1998 I wrote a Java Virtual Machine in assembly language for a PIC-like
microcontroller that only had 4k of ROM (actually it was 4k instructions, but
they were 12-bit words giving 6kB). I managed to get all of the important
features of the language to fit, including exception handling and an
interactive debugger. However by the end, each time I wanted to add a new
instruction to my code I had to find something else to optimize first so it
would still fit in 4k.

By the end I convinced myself that 4k was the minimum possible code size for
implementing a JVM.

The JVM was used in the Parallax Javelin Stamp - a Java version of the BASIC
Stamp
([http://en.wikipedia.org/wiki/BASIC_Stamp](http://en.wikipedia.org/wiki/BASIC_Stamp)).

As an aside, the SX microcontroller only had 256 bytes (yes bytes!) of RAM
internally so I used an external 32kB SRAM for the Java heap and stack. The
256 bytes of internal RAM held the internal state of the interpreter and
memory manager.

~~~
seanmcdirmid
Around the same time, I wrote a JVM for the PalmPilot [1]. I think it had to
fit into 128K of ram with an additional 256K of memory for data (like the
class libraries). I was able to fit the entire JDK 1.0.2 runtime into it by
transforming the byte code.

But 4K...wow!

[1]
[http://lampwww.epfl.ch/~mcdirmid/papers/ghost.pdf](http://lampwww.epfl.ch/~mcdirmid/papers/ghost.pdf)

~~~
radio4fan
Yep, 4k is pretty wow indeed.

My first computer was a Sinclair ZX81, which only had 1K or RAM, but there was
8K of ROM, and the BASIC interpreter was pretty, um basic.

~~~
analog31
The hardware was interesting too. It bit-banged the video display circuit,
leaving only the re-trace interval for general purpose computation, including
running BASIC programs. Yet the result was an extremely simple and inexpensive
design.

Every early microcomputer had to come up with a solution to the video display
problem. As I understand it, the Apple II had a bus architecture that
interleaved the clock timing of the video circuit and the CPU, sharing a
single bus. The Commodore computers had custom video graphics chips. And so
forth.

------
matthewmcg
"In 1967 or 1968, as a senior in high school, our electronics teacher ...
arranged for me to go to a company in Sunnyvale (Sylvania) to program a
computer because I already knew all the electronics in class at school. Mr.
McCollum did this for students with electronics abilities every year, finding
local companies with engineers and projects that would let high school
students come and and get some experience."

It's amazing that his high school had electronics classes and vocational
externships. Is that something that was common at the time or just another
amazing aspect of Silicon Valley?

~~~
area51org
I grew up in a small-to-mid-sized town in California's central valley, east of
the Bay Area and SV. We had an electronics class, and as a freshman, I took
it.

If you needed parts for a homework assignment, the only store that had them
was Radio Shack (yes, they actually sold lots of electronic parts back then).
So one day, I meandered into The Shack to get a resistor I needed. Lo and
behold, there was a new manager, a guy named Tony. This guy was _much_
friendlier than the previous manager had been. That other manager just tried
to get us in and out, apparently presuming we wanted to shoplift or something.

This new guy? Happy to show me the new TRS-80, and though my parents wouldn't
pay for one, he scarcely complained as I went back to use it every day for
more than a year. I taught myself how to code on that machine, and so I have
that freshman electronics class to thank, in part, for my career.

~~~
troyk
Similar background, only got hooked on the commodore BBS scene... I'd ride my
bmx bike holding a box of floppies to a friends to hack on, with the warm
smell of manure rising up through the air. (Turlock)

~~~
Roboprog
Cool. My first programming experience was as a high school senior going to the
CSU, Stanislaus (Turlock) computer lab to play on the Apple II's, and later on
the C-64 in that lab. It was my job to be the "lab assistant" for about 6
months before starting school there. (put paper in the printers, make sure
equipment stays in the room, show people where the "on" buttons are)

Yeah, a ride down Monte Vista Ave was a pretty "pastoral" experience.

Going from toying with analog electronics to getting to use an actual computer
was pretty exciting, at least for somebody in a rural area who could not
afford such toys otherwise. Putting simple graphics into the Apple was a
stroke of genius and made it quite an experience to play with.

------
npongratz
" _The other 'bible' was a book "101 Games in BASIC." I was a fan of computer
games and knew that as soon as I had a computer of my own I would want to type
in all these games to play._"

I don't know for sure, but I think Mr. Wozniak is referring to the book edited
by David H. Ahl, _BASIC Computer Games_ :

[http://atariarchives.org/basicgames/](http://atariarchives.org/basicgames/)

Notes on the page mention the book was "[a]lso published as 101 BASIC Computer
Games".

This book happened to be a great influence on me. Reading it in grade school
gave me a small taste of what fun programming can be. I especially liked how
some of the programs showed how simple rules can result in emergent and
unexpected behavior. Not to mention how easy and fun it was to change the
source (sometimes by accident... SYNTAX ERROR anyone?) and seeing what would
happen.

Today, I have the distinct privilege to do effectively the same (different
platforms, of course :)), and now it even pays the bills.

~~~
mncolinlee
This was how I learned to program BASIC at six years old.

Of course, I also figured out I could get my TRS-80 Model 1 to make sounds of
various pitches by tuning an FM radio to its CPU and running loops with
varying delays. I added sound to a pinball game this way back then.

------
etfb
Woz is, for me, the ISO standard geek, the distillation of all that I aspire
to. Somewhere in Paris is a vault, and in that vault is a platinum-iridium
Steve Wozniak, against which all of us are judged and found wanting.

------
kbs
If you're interested in the actual details of the implementation of the syntax
table, I had a great exchange on the 6502.org forum a couple of years back.

[http://forum.6502.org/viewtopic.php?p=17736](http://forum.6502.org/viewtopic.php?p=17736)

There is a (relatively easier to understand) stack-based expression evaluator,
with hooks to allow for operator precedence. The interesting part is the
scanner, which converts each line of BASIC into the tokens used by the
evaluator. This is the bit that has the "syntax table diagram".

You may also find this article by Woz on the Apple][ from the '77 BYTE
magazine a pretty interesting read.

[http://www.downloads.reactivemicro.com/Public/Users/Grant_St...](http://www.downloads.reactivemicro.com/Public/Users/Grant_Stockley/Apple2WozSystemDescription.pdf)

------
tn13
In India I studied in a school that had only one electric bulb per class and a
second hand MS-DOS machine donated by a politician. The school and teachers
were glad to let me use it and I am eternally thankful to them for the same.
It changed me totally.

We also had awesome electronics equipment lying around which we could use. I
used IC-555 when I was in 8th grade to program a flashing LED and I can not
explain the joy of doing it in words.

~~~
noisy_boy
Our school had no computers. I first saw computers in my University in a air-
conditioned room and we were not allowed to go inside. We had a Fortran-77
module (elective) which I took in the hopes of getting a chance to use the
computers. However, it turned out that we were supposed to write our code on
paper and the teacher would evaluate them by reading them, not compiling them!
So the end result was me scoring very well in the exam by writing code on
paper, the teacher evaluating it by reading it. Sigh.

~~~
tn13
That is how C programming was taught in my engineering college and so was Java
and even HTML.

There would be a short note table tag or a 10 mark question on what is the
difference between Interfaces and Inheritance in Java.

------
listic
I programmed in Forth some time ago and I wonder why didn't Wozniak implement
Forth on his first computer. Surely, it would be easier to do and run faster
than BASIC. That BASIC was a naive interpreter, it couldn't help being slow,
except for the primitives that Woz coded in machine language, I'm sure they
were fast.

Was it already clear for Wozniak in 1975 that Forth looks weird and people
won't get it?

~~~
zhemao
Wozniak was all about bringing computers into wider use. At the time, BASIC
was considered the "easy" language to learn. So easy that kids could do it.

~~~
listic
I thought Logo was, too, and Logo is based on Forth, but I checked Wikipedia
article and Forth is not mentioned. Also, don't know about the popularity of
Logo back in the day, but I thought it enjoyed some.

------
csense
I feel like gaming has always been an important application for driving
hardware innovation.

It's interesting that this article shows that goes at least all the way back
to Woz's home-built computer that turned into the first Apple.

~~~
projectileboy
Games aren't given nearly the credit they deserve for driving the PC
revolution. My house was one of a very few in our neighborhood that had an
Apple II in the house (this was 1980), which cost $2000 in 1980 dollars. For
that kind of money, people _said_ the reason they bought the computer was for
<x>, but the _real_ reason was almost always for the games.

~~~
austinz
Not to mention the consumer-grade GPU market that preceded GPGPU and a lot of
the modern scientific uses for commodity/commodity-like hardware.

------
subdane
"But I had in the back of my head that I could be a star, that I could get a
little fame in the hobby world, like Bill Gates, if I created the first BASIC
for the 6502." Big things start small!

~~~
ProAm
Baby steps are fine as long as you keep moving your feet.

------
Someone
_" I kept about 50 chronological folders of papers throughout all my BASIC
design work. Each one was labelled GAME BASIC. So you can see where my head
was coming from."_

I'm not sure whether that 'kept' means they are gone, with that " _can_ see" a
sentence later, but if they exist, somebody should write a book or a paper on
them.

------
beachstartup
this is a serious question.

does anyone know if woz lifted weights or participated in any other kind of
serious athletics when he was younger? he's always very fit and muscular in
early pictures and as many athletes do, he's gained some weight in later
years.

i only ask because some contemporary biopic films/representations have
portrayed him as out of shape in his early years and that's clearly bullshit.

~~~
abecedarius
I suspect what's going on is that he was chubby by early-70s standards, and so
contemporary representations start with chubby-by-2010s standards and blow
that up for effect. (I've wondered about this too.)

------
dpweb
I remember a quote by Woz I think it was with the hardware however, about
being forced to design everything more completely before even starting to
build it. There's got to be a lesson in that somewhere.

~~~
krishna2
A few days of coding could save you a few hours of designing. :)

------
read
_Judging by my own feelings, I assumed that..._

 _At least then I was sure that my computer could possible do the important
things that high priced computers do, but I wasn 't sure._

 _I sniffed the wind and knew..._

 _I never saw my name in print so I didn 't get that 'Bill Gates' fame, but I
was known in my club._

 _Every club meeting I 'd have a few more commands that worked fully._

 _Had I not cared about BASIC, I probably would have just built another
switches and lights computer with minimal static memory and been done with
it._

~~~
read
Emotional decision. Uncertainty. Gut feeling as compass. Mild recognition to
ability. Incremental progress. Emotional tie.

These might be the ingredients for innovation.

HN penalizes them without reflection.

------
DodgyEggplant
"When you code by hand (couldn't afford a time-share account) it's hard to
make changes in the middle structure of things that have to be at fixed
addresses."

------
afs35mm
Woz wrote BASIC from scratch and I'm having trouble with call and apply...

------
marcosscriven
Wozniak is the closest I get to idolising. There's just something about the
combination his extreme talent, humbleness, and humanity.

------
moron4hire
People always ask me, "what was it like to be homeschooled" and I never have
an answer for them. It was all I knew. What was it like to go to public
school? But this. This is what it was like. My sister and I did things, made
things, whatever we wanted. We went places and interacted with adults and
worked on real projects. Nothing as impressive as this, but lots of things far
more impressive than our peers.

But that wasn't "being homeschooled", that was having our parents. I've
learned that most of our homeschooled peers didn't do anything like we did. It
was kind of a weird revelation to grow up in this group of supposed-academic-
over-achievers, often feel like the dumb one because I hadn't read all of the
books they did (which I now realize was because I had a much more balanced up
bringing that included sports and other studies), and then be the only two (my
sister and I) to make something out of our lives.

Religious zealotry will do that to people. And they were zealous in both
homeschooling and Christianity. I'm now somewhat surprised one or two of them
haven't committed suicide yet. I know one has tried, but his zealotry makes
him refuse to get help. His father, being the local physician in our small
town, apparently doesn't believe depression is a real thing. And yet half or
more of his 11 kids are textbook cases.

It makes me sick. But again, that's not homeschooling, that's having certain
parents. One's parents are, naturally, the biggest influence on their lives.

------
VikingCoder
I believe I know exactly how he did it - the Richard Feynman Problem Solving
Algorithm:

    
    
      * Write down the problem.
      * Think very hard.
      * Write down the solution.

------
raverbashing
"Wow, so, you mean people can develop software without using TDD and an OO
language?!"

Edit: yes, this is why I have much more respect for Wozniak than for Uncle Bob
or other consultants

~~~
softbuilder
Ordinarily I'd vote this down for snark not contributing to the conversation,
but I actually do this the underlying thought here is worthy and contributes
to the conversation.

There is a core aspect of hacking/making/doing that Woz demonstrated well and
aren't represented by many modern thought leaders in the industry.

~~~
bmm6o
> _Ordinarily I 'd vote this down for snark not contributing to the
> conversation [...]_

You're right, it doesn't contribute to the conversation.

> _I actually do this the underlying thought here is worthy and contributes to
> the conversation_

Unless someone actually takes the "underlying thought" and expresses it as
more than 12 words of snark, there's nothing to discuss.

