• 1 Post
  • 3 Comments
Joined 1 year ago
cake
Cake day: June 16th, 2023

help-circle
  • These are similar but distinct concepts. Most languages have a concept of (lexical) scope, which is how variables are resolved to their values. For instance,

    var a = 10;
    function foo() { return a; }
    

    Here, a is in the global scope and it’s referenced by the closure foo. Any changes made to a (so long as it isn’t shadowed) will also appear in the a that can be seen inside foo.

    JS is also what’s called a prototype-based language, so it has an additional more exotic concept called the “prototype chain”. This is how it implements something approximating OOP inheritance - essentially, if I request obj.x, JS will first check if obj has the x property, and if it doesn’t find it, it follows the __proto__ (note: nonstandard) value to get the prototype of that object and checks there. If that prototype doesn’t have x, the process continues until it reaches the end of the chain.

    The JS global object (also called window in the browser - which has a reference to itself called window) is part of lexical scoping, but not the prototype chain. The global object is the end of the scope chain, but the end of the prototype chain is Object.getPrototypeOf(Object.prototype) == null (note: we need to get the prototype of Object.prototype because Object is the constructor function, not the prototype)

    Window is the constructor of the window object, Object.getPrototypeOf(window) == Window.prototype and window.constructor == Window. It’s a weird quirk of Javascript, “classes” are actually the constructor, and when we prototype a new object it prototypes that function’s prototype property.


  • If I was God Emperor for any sort of content algorithm, I’d want to try a decentralized “simulated annealing” of feature vectors based on up/down votes, subscriptions, etc. That lets you create linear combinations (eg on Wikipedia the vector for King - Man might be close to Royalty) and share them around on different platforms. This makes The AlgorithmTM a lot more transparent and user-driven, since you can feasibly program on a per-user basis all sorts of policies for how their own preference vector updates, or they could have layers of linearly combined vectors for base style, mood, binging, etc.

    What I like about this is it doesn’t presume some kind of inherent value - it implies a philosophy that everything is equally valid/valuable to someone, and people just have different preferences for what they prefer. If it’s something utterly vile that everyone downvotes into oblivion, that’ll naturally sink into the recesses of feature-space that occupy the opposite of whatever “all humans” value. It’s also dead simple to implement, you just need an update policy (N-dimensional modular incrementing?) and a way to search a database by a given metric (cosine distance is the new hotness with AI, but back when I first thought of this I used hamming distance).