Skip to content

Instantly share code, notes, and snippets.

View mheiber's full-sized avatar

Max Heiber mheiber

View GitHub Profile
@mheiber
mheiber / jsconf-asia-autobang-talk.md
Last active January 24, 2019 02:41
JSConf.Asia Autobang (JS->strict TS) Talk

Summary: I describe why and how we built "Autobang", a tool that automatically converts JS projects to strict TypeScript. This is an unusual solution to a problem that previously seemed intractable for large projects.

We built a tool to automatically convert a JS codebase to strict TypeScript with some interesting trade-offs. This is a hard and interesting problem I've never heard discussed

Why TypeScript

@mheiber
mheiber / ecs-notes.md
Last active June 26, 2020 10:09
Notes on Entity Component Systems

Entity Component Systems notes from someone who doesn't write games and didn't know what ECS was.

Why care?

Possible Maintainability Advantages of ECS Systems as Compared to OOP:

  • State shape is more explicit, so much more likely to make good sense as an app grows
  • ECS encourages much less plumbing for data flow between parts of an app, since systems can just read whatever they want.
    • For big stateful apps, OO seems to encourage an 8-to-1 ratio of data plumbing compared to biz logic
  • easier to safely share behavior
  • Supports state serialization for record/replay debugging
@mheiber
mheiber / bm.js
Last active October 5, 2018 13:34
closures
const main = () => {
const x = 2
const y = 3
;[1, 2, 3].forEach(v => {
console.log(v, y)
})
console.log(x, y)
}
@mheiber
mheiber / error cases for private names.md
Last active September 7, 2018 10:33
Error cases for private names

Three error cases for private name semantic errors:

  1. shadowing (the nested classes case). See also suggested error message.
  2. accessibility violation
  3. name not found

(1) and (2) are special cases of (3)

Confusing note on terminology: in the semantics, '#foo' is the description for a private name, what a Muggle would call a "spelling" and a philosophyer would call an "orthography." From a semantic point of view, the private name itself (#foo) is unforgeable and cannot be written down, even thought it's clear exactly where the private name node in the syntax is.

Rough algorithm for generating the most accurate error message for leftHandSide.#foo:

@mheiber
mheiber / private-names-in-nested-classes.js
Last active August 31, 2018 00:35
Private names in nested classes
class A {
#foo;
#bar;
method() {
class B {
#foo;
methodNested(a) {
a.#foo; // error: shadowed
a.#bar; // OK
}
:tnoremap <Esc> <C-\><C-n>
:tnoremap jj <C-\><C-n>
:tnoremap <C-w><C-w> <C-\><C-n><C-w><C-w>
:source ~/.vimrc
au TermOpen * setlocal nonumber norelativenumber
:nnoremap <leader>e <C-w><C-w>pa
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-commentary'
nnoremap <leader><space> :noh<return>
nnoremap <leader><leader> :b#<CR>
nnoremap <leader>S :source ~/.vimrc<CR>
nnoremap <leader>g :e ~/.vimrc<CR>
nnoremap <right> <C-w>10>
nnoremap <left> <C-w>10<
nnoremap <leader>1 :bp<Cr>
nnoremap <leader>2 :bp<Cr>
nnoremap <leader>] @:
@mheiber
mheiber / Differences between MobX Observables and Rx Observables.md
Last active February 10, 2018 03:32
Differences between MobX Observables and Rx Observables
MobX observable Rx Observable
common use case facilitating updating a UI when data changes composing frequently-updated data from multiple sources and/or implementing a lot of timing logic
better name is "sneaky KVO" "composable streams"
very similar to reactive data in Meteor and Vue Node streams if Node streams were always in object mode and had things like through2 and multipipe built in
implementation in JS requires
@mheiber
mheiber / Similarities between MobX Observables and Rx Observables.md
Last active February 10, 2018 02:31
Similarities between MobX Observables and Rx Observables
MobX observable Rx Observable
has to do with things changing yes yes
"reactive" yes yes