On Programmer Archaeology
Brit Butler
2012-08-06
(use arrow keys or PgUp/PgDown to move slides)
Brit Butler
2012-08-06
(use arrow keys or PgUp/PgDown to move slides)
"Tools are only worthwhile in the service of ideas."
At 50 lines/page, Storyville is 185k or *10* 370-page books.
No one knows how to solve it. Especially me.
Though historically we've tried a number of things ...
-- Alan Perlis, Epigrams on Programming
Another example: @bigthingist used mark+sweep GC algos to manage retail fashion site.
In many ways, this is equivalent to knowing and having an interest in CS...but the lens of archaeology is more fun. :)
Why didn't old tech win if it was so great?
Alan Kay - Programming and Scaling talk, Dr. Dobbs interview, etc
"...But nowadays people are reinventing the flat tire."
A broken record. Crank or genius? Why keep saying it?
Lisp and Smalltalk failed for a reason, presumably.
Alright, proof is in the pudding. What's he building?
5 year project funded by the NSF.
First thought: What a pretentious jerk!
Second thought: Well...what are their results?
An entire OS+Office Suite in 20,000 lines of code. W.T.F.
Even if it isn't backwards compatible with /anything/ ... ... HOW?!?
OMETA - Technology from the 60s!!!
[extended with Inheritance and PEGs]
Parsing as a weapon: Compiler as parser series in lieu of IR.
See appendices of 2007 STEPS report for further examples.
[Like OMETA->JS in 75 lines and Prolog->JS in 100 lines.]
'We should burn all libraries and allow to remain only that which everyone knows by heart' - Hugo Ball
Interview question: 'Write as much of jQuery as possible in 45 minutes from scratch.'
The antithesis of using past solutions.
Tests define 'satisfactory code'. By using them, we are less trapped in the past.
My Open Source Talk makes it clear how this would help promote competition and diversity.
MustacheJS has a specs repo in JSON.
... but it's not quite clear how to apply this to the 6502.
And it wasn't my goal to. :)
Let's emulate one.....with Lisp!
* - All SLOC figures courtesy of sloccount.
Still fairly unique to Lisp culturally...because metaprogramming and source transformation is usually INSANE AND FROUGHT WITH DANGER.
Non-paren alternatives in Dynamic and Static langs exist: Template Haskell, Camlp4, Dylan, Factor, Io
Thus far, no parens == no culture of metaprogramming.
Fear not, I will explain macro usage carefully.
It's basically a VM, duh. Simulate hardware and run a program inside the simulated hardware.
Portability thinking seems to be: Write it in C. After all, C compilers are ported everywhere.
I stayed with interpretation for simplicity's sake. Crawl, then walk. For a great overview, see this paper.
None of this "Declare a variable" nonsense.
6502 has 13 addressing modes. No instruction supports every mode. Indirect mode only used by one instruction.
Some opcodes use address, some use byte at address.
The following code has been rated GH-MA*
* - [Github Mature]
Remember when I said I'll Explain?
Which method goes with this byte in the array?
Wound up doing dispatch via opcodes just like a switch/case interpreter...
But using Lisp's EQL-specialized methods! \o/
Once you have an opcodes array full of metadata, disassembly is *trivial*.
Assembly is more involved even though I was lazy and didn't write a proper parser, just regexes. Still not so bad.
2-pass assembler. First sets labels, second resolves uses.
Supports labels, constants, comments. Here's a small example.
Decimal mode - Dodged that bullet. Not in the NES! ;)
Sadly, no language can make decimal mode pretty.
Status bits - Sort of ad-hoc and messy. No defaults for you!
Relative addressing - Oh God, Oh God.
Truthfully, CPU emulation isn't so bad. Whole systems are what's complicated.
Emulation as a Service!
Maybe build crazy dev tools on top a la Frodo Redpill.
No promises! ;)
Biologists vs Logicians
Late-bound metaprogramming vs Static verification
Civilization advances by extending the number of important operations which we can perform without thinking about them.
- Alfred North Whitehead
We are living now, not in the delicious intoxication induced by the early successes of science, but in a rather grisly morning-after, [where we have]... improved the means for achieving deteriorated ends.
- Aldous Huxley
There must be a middle place between abstraction and childishness where one can talk seriously about serious things.
Czeslaw Milosz, Second Space