How Steve Wozniak Wrote BASIC for the Original Apple From Scratch
gizmodo.com
gizmodo.com
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).
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.
But 4K...wow!
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.
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.
https://github.com/k1w1/javelin-stamp/blob/master/asm/javeli...
Reading back over the assembly code gives me fond memories - but I am glad I don't spend my nights debugging my code with an oscilloscope and flashing LEDs anymore. It is a bit more productive coding in Ruby!
The JVM had some limitations to fit into 4k: no floating point, 16-bit integers and no dynamic linking. There was a PC program that took the Java class files, statically linked them and translated the bytecode to a more compressed form for download to the chip.
What do you think about Dalvik's register based VM ?
Have you looked http://www.jopdesign.com/ ?
Are you doing anything hardware related these days ?
These days I am about as far from embedded systems as you can get. I write Ruby on Rails code for aha.io. There is a lot of satisfaction in seeing the perfect waveform on your oscilloscope when the assembly code finally works - but these days I think there is much more satisfaction in being able to crank out a complex algorithm with some elegant Ruby and have it being used by customers before going home for dinner.
The stack and heap are both stored in an external 32kB SRAM. The stack is accessed simply by pushing and popping using the JVMPush and JVMPop routines around line 4553. The CPU is 8-bit, bit the JVM is 16-bit, so everything takes two operations to write both bytes. You can see the stack frame format at line 48.
Java objects and arrays are allocated on another stack that acts as the heap. Objects are allocate only - they are never freed. This isn't as big a deal as you might think since in embedded applications the code tends to just repeat the same operations over and over so you write your code to reuse the same instances instead of allocating new objects (which is slow anyway).
_do_new on line 2044 allocates a new object. Arrays are allocated at line 1991 in _l_j_newarray.
The nice thing about the JVM (at least version 1 which this implements) is that there are not many variations on operations - and if you statically link you can reduce some of the variations to common cases too.
I'd actually love an annotation for Python that ran it under the null-collector. Lots of times in short run or steady state programs one doesn't generate any garbage and the constant GC or ref count over head could done away with.
Did you look @ the Bob language? It was the spiritual seed for Java by David Betz http://www.xlisp.org/
https://www.google.com/search?tbm=pts&hl=en&q=dr+dobbs+betz
I really like http://www.amazon.com/Threaded-Interpretive-Languages-Design...
and
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?
There is nothing that unusual about that now except with tech companies or any other company that is the current "belle of the ball" or super large and well known.
The idea is to learn and gain experience not to get some buzz because you have achieved some popular culture dream of working for the same place that millions of others would like to. Sure we'd all like to work at those places. That's the problem.
If you pick any company that is generally off the public radar (and not being fawned over in the press with a celebrity CEO) it is quite possible to send a postal letter to the CEO and have a fair shot of getting a summer job. Or even an email but my feeling is a letter would get more attention and seem more genuine.
Not all the value lies in the usual suspects that have more applicants than they can handle.
A corollary to this goes with low paid jobs. Our offices used to be located near a Walmart. Yet not one time in 9 years to anyone ever come through the door looking for an office or admin or warehouse job. Yet everyday people showed up at the Walmart and got a much lower paying job and (from our pov) much worse working conditions. It's important to put effort in, be creative, and not do what everyone else is doing.
Until I graduated from college it was hard to get anyone to take me seriously or even respond. I think the barriers to enter the tech job market with no experience or degree is so much higher today.
When I was in grades 7-9 it was mandatory, then elective after that. We didn't flash chips back then (in the late 90's) but I bet they do now.
We mostly did hands on of making circuit boards (acid etch), and soldering all the components together for simple little circuits. I only stayed in electronics until grade 10, but I know they made some pretty cool stuff in grade 11 and 12.
I went on to Study Software Engineering with a minor in Digital Electronics.
In my 5th and final year, I took an electronics class called "Digital Electric Design" which actually turned out to be my only hands-on Electronics course at University. All the EE people were shocked to see me there, as I'd not been in all the same hands-on EE type classes as them for the prior 4 years. (I think we only had Maths in common)
They were more that a little shocked I knew how to use a soldering iron, acid etch bath, multimeter, had the resistor charts memorized etc. etc. Apparently, they'd spend the preceding 4 years learning that at Universtiy which I had learned in high school. (The Australians had learned it in High School too, but my university was majority international students)
They do? None of those I know (high school 2000 - 2005) in Perth did electronics. We had the usual woodworking/metalworking/art/photography electives, plus drama & music, but no electronics. We also had extremely sub-par computing classes, with no option for a T.E.E level (i.e. contributes to your University entrance score) computing class whatsoever.
The consequence was "more" available to students and teachers.
So we had the tools in the tenth grade to design a part in autocad in drafting class, take it over to the machine shop and have a CNC machine mill a mold that could then be pushed over to have parts injection molded.
All that is gone now due to cuts in funding.
And for fun we actually had a class to teach people how to be a logger.
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.
Gratuitous photo share (not my photo) - https://www.flickr.com/photos/xythian/4223283103/
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.
Nonetheless I got permission to sign up for Electronics. I discovered that the course was mainly going to revolve around TV repair, and the teacher even told me that I'd be bored. So I dropped it and learned that one of the math teachers had started a course in BASIC! It's not an understatement that the course changed my life.
In the 1980s in Palo Alto, my high school AP Computer Science teacher asked parents to come in and give guest lectures in the last few weeks of class. Donald Knuth's daughter was in my class so he came and talked about TeX. Another kid's parent was a VP at a bank; he talked about secure transaction processing for ATMs. My dad (a researcher in robotics and AI) talked about expert systems.
It was okay. :-)
I started with electricity concepts and basic circuits in the 7th grade and 8th grade. Sadly had to take mechanic in the 9th as electronic classes were full.
On my last three years (10-12 grade), I switched high school to became a computer technician. We had classes about data structures, programming languages, basic compiler design concepts, DB, network and graphics programming.
It made my first CS years a walk in the park.
Understanding how these work is one thing, and that used to be enough to be worth employing. Today, you have to have a passion for using that knowledge to solve problems.
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/
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.
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.
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...
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.
There would be a short note table tag or a 10 mark question on what is the difference between Interfaces and Inheritance in Java.
Was it already clear for Wozniak in 1975 that Forth looks weird and people won't get it?
I checked the above link to confirm my recollection, but while Forth had been around for a while it wasn't really public until the 70s (versus BASIC). I suspect he wouldn't have even heard of it, or at least not realized its potential, in 1975.
Since he had an HP calculator, yes
> "The key to games was BASIC. Bill Gates was unknown except in the electronics hobby world. Everyone in our club knew that he'd written BASIC for the Intel microprocessor. I sniffed the wind and knew that the key to making my computer good (popular) was to include a high-level language and that it had to be BASIC. Engineers programming in FORTRAN were not going to be what would start a home computer revolution."
And actually implementing a basic interpreter isn't all that complex. The loop is simple:
Read a line.
If the line starts with an integer, you're adding a line to your program; otherwise you need to interpret then execute.
Read the first word. In some BASICs, this is the first string of characters that matches one of the keywords; in others, it's all the alphanumerics up to a non-alphanumeric.
(In effect) dispatch to the appropriate interpretation routine based on which keyword you just read in. For example, PRINT goes to the argument handler for PRINT, LET goes to the argument handler for LET, and so on.
Then you just have a bunch of routines (read one variable name, read an expression and interpret it as a number, read a destination line number, etc) and different keywords use them in different ways.
It's pretty simple, really. Way easier than writing a full LALR parser.
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.
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.
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.
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.
These might be the ingredients for innovation.
HN penalizes them without reflection.
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.
* Write down the problem.
* Think very hard.
* Write down the solution.Edit: yes, this is why I have much more respect for Wozniak than for Uncle Bob or other consultants
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.
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.