Have you all read Douglas Hofstadter’s beautiful Gödel, Escher, Bach: An Eternal Golden Braid? You should go get your copy. If you don’t have one yet, you can take one home for your very self here. I’ll wait. The internet always waits.
Ok! Remember the terrific inter-chapter dialogues between the Tortoise and Achilles? Remember the one about pushing and popping, meta-Genies, and the Majotaur, “Little Harmonic Labyrinth”? Page 103 in the 20th Anniversary edition. Hofstadter was something of a computer scientist (while being rather disinterested in programming itself), so it’s no surprise that the mathematics of this dialogue (and indeed of the entirety of the delightfully dense GEB) read like a computational theory problem wrapped up in a Lewis Carroll witticism (whom Hofstadter adores and references frequently in the book).
I’m getting lost in the book, as I so often do : ) but my point here, other than urging you to GO! GO! READ THIS BOOK! IT’S HARD AND THAT’S OK! is that javascript’s class inheritance reminds me just a bit of this airy idea of pushing and popping from world to world. Each class is its own world, and pushing from that class is another class that can only come from the initial one.
function Feline = (name, type) { this.name = name; this.type = type; };
Now let’s add a method to this class:
Feline.prototype.infoPrint = function() { for (var i in Feline) { console.log(Feline.i); } };
And now, let’s make a new thing altogether. Notice the third attribute:
function DSH = (name, type) { this.name = name; this.type = type; this.color = color;
And now! Since we know that Domestic Short Haired cats are a kind of Feline
, let’s make it so officially, and actually CREATE an animal out of this!!
DSH.prototype = new Feline(); var morris = new DSH("Morris", "ornery", "buff and white");
Also notice that only objects created from constructor DSH
will have the attribute color
, but the regular Feline
class will not. DSH
is a push down from Feline
, and divining objects from the constructor DSH
will only give us specific DSHs, which have all the characteristics of Feline
as well (though I believe those are specially mutable even after you’ve defined them, but more on that later, when I understand better too [which I am pretty sure can be strung into the metaphor of popping, perhaps?!] : ))!
So, go ye, and read of Gödel, Escher, Bach: An Eternal Golden Braid and tell me what beautiful mathematic or programmatic relation he makes you think of, and, likely, consider in a whole new way!
Last thing: once, on the train (a multi-day, cross-country trip), I had that book in my hand, waiting to get a morning coffee so I could sit and read it (I’ve still only read up to page ~130), and a gal came up to me and said “I read that book thirty years ago, and I’ve been reading it ever since.” Still the finest commendation for a book that I’ve ever heard.
This makes me wonder if the terms pushing and popping as they are used in your description are originally from this book, from computers, or elsewhere? I use push and pop all the time in batch files to push to a new directory, and then pop back to the old one; makes it super easy for me to have a batch file go to a new folder, run some programs, then come back to the original folder.
A bit offtopic, but what development environments do you use? I currently use Visual Studio 2012 Professional, Sublime Text 2, and MarkdownPad, for coding, scripting, and wiki writing respectively.
Oh of course, pushing and popping at the terminal! I should get used to doing that – I know HOW, but rarely use that functionality. I bet it would really zip through a lot of my workflows. I don’t know where it was first used. Maybe someone else can weigh in?
DEVELOPMENT ENVIRONMENT, EH?? I’m not terribly happy with my development environment. When I was on Ubuntu, I used the basic bash terminal for all my command line needs, nano for quick edits, and sublimetext for lengthier ones. I was medium happy with that – sublimetext’s aggressive suggestions are irritating, but nano is indeed too nano a scale for any real level of development aside from a quick peek.
Still using basic bash terminal on the macintosh I’m using along with nano, but I haven’t installed sublime, and the fabulous Python-specific IDEs that include a terminal, git source control, and lots of other really nice features all feel too heavy. I think I’m just going to learn vim, after all, because I want it to be very light AND really tough. Maybe after I finish this course.
I did check out VisualStudio at OSCON last week, and while I was NOT impressed with Microsoft’s whole presence there (more on that in person), I was very impressed with VS as a really robust IDE.