Skip to content

Instantly share code, notes, and snippets.

@dfkaye

dfkaye/posts.md Secret

Last active May 18, 2024 00:33
Show Gist options
  • Select an option

  • Save dfkaye/01537c58e425ef3480f2844eb4a65580 to your computer and use it in GitHub Desktop.

Select an option

Save dfkaye/01537c58e425ef3480f2844eb4a65580 to your computer and use it in GitHub Desktop.
11 September 2021 - ideas for blog post or posts
  • JavaScript grouping operator, behavior modification proposal:
    • Current behavior:
      1. ().toString() and ().valueOf() result in SyntaxError: Unexpected token ')'
      2. (null).toString() and (null).valueOf() result in TypeError: Cannot read properties of null
      3. (undefined).toString(), (undefined).valueOf() result in TypeError: Cannot read properties of undefined
    • Proposed changes to stop throwing errors:
      1. ().toString() should return string "undefined"
      2. ().valueOf() should return value undefined
      3. (undefined).toString() should return string "undefined"
      4. (undefined).valueOf() should return value undefined
      5. (null).toString() should return string "null"
      6. (null).valueOf() should return value null.
    • Alternate proposal to stop throwing errors:
      1. (undefined || null || ).toString() should all return empty strings
      2. (undefined || null || ).valueOf() should all return empty objects without any own properties, as in Object.create(null).
  • Logic-less templates (rendering):
    1. run all logical checks on data first,
    2. pass a representation of the data (or an error) to a function that returns a populated template,
    3. run (new DOMParser).parseFromString(template, "text/html") on the template,
    4. update the DOM with parsed result (or show an error),
    5. Important: this is not the same as finding nodes in the DOM and updating each one. That is a separate thing.
  • Spec runner (formal methods) tricks:
    • Given a current system (under spec), and a new or modified system (under spec);
      1. Verify both current spec and new spec are correct,
      2. Verify there exists at least one optimal transition from current spec to the new or modified spec.
  • 3 Nov 2023: "is my library AI-friendly?"
    • on redesigning programming languages so that AI code assistants can better understand them
    • redesigning programming languages so that AI can understand them better so that everyone has to use AI or get left behind sounds suspiciously like elitist bigotry and communism.
    • privileging AI over live human beings to solve problems that human beings have only ends up privileging problems that AI has which will not lead to happier human beings.
    • there are two things that make people happy - understanding something and making decisions.
    • giving that away to AI or to startups is the same mistake as giving ownership to the state.
    • hectoring people as useless for not using your technology is how we end up with wars of religion and homelessness.
    • imagine someone saying they've changed their code base the better to match how copilot will guess the next word. imagine changing your professional behavior not because your profession demands it but so that AI assistants can understand it and then tell you how to change it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment