HNHacker News
TopNewBestAskShowJobs

jeffmcmahan

388 karma · joined August 1, 2016

[ my public key: https://keybase.io/jeffmcmahan; my proof: https://keybase.io/jeffmcmahan/sigs/LkRxkjFGiURCcGAZhebTYaCjrrZ6HbydIvnH9FJA2HE ]
submissionscomments
jeffmcmahan··on Design Doc: Use JavaScript instead of TypeScript for internal Deno Code
That's true. But with TS I have to declare types, import typings, maintain a build process to run the TS compiler, and so on. Moreover, static typing comes with added tediousness, and I personally feel that it's not worth the freight.
jeffmcmahan··on Design Doc: Use JavaScript instead of TypeScript for internal Deno Code
I'm not OP, but in my case, no. I don't. I write a roughly ES7, and if you're on an ancient phone/PC, oh well. I really don't care. Not because people using those devices don't matter, but because I am writing code for a company in which I have a say in what hardware/software is provided to employees. I don't have to support IE. That's true of a lot of developers, for whom Babel is a waste of time.
jeffmcmahan··on Design Doc: Use JavaScript instead of TypeScript for internal Deno Code
Amen. I don't transpile to JS anymore. If the client is IE (no updates for 7 years?) and doesn't feel like installing FF, Chrome, Edge, or whatever, then it is what it is.

Modern static ESModule JS is quite good. I have several projects north of 30KSLOC written in modern JS. I'm not living in "undefined hell" because I use named-export ESModules, I check types all over, and I write quality tests. A little discipline goes a long way.

jeffmcmahan··on Times New Roman alternatives: You can do better (2013)
I join you in hating Arial for its ugliness. It is one thing to be a copy of another font (Helvetica); it is quite another to be a bad copy.
jeffmcmahan··on Times New Roman alternatives: You can do better (2013)
Yes, they are more different that I initially thought.
jeffmcmahan··on Times New Roman alternatives: You can do better (2013)
I stand corrected. Let me rather say that Plantin shares a lot more with (say) Bembo than it does with Times, and I don't see why either would be a times "alternative".
jeffmcmahan··on Widely disseminated hydroxychlroquine study retracted by authors
FWIW, that never occurs.

EDIT: Although it is currently being mentioned on the front pages of NYT, WaPo, and WSJ.

jeffmcmahan··on Times New Roman alternatives: You can do better (2013)
First, as a type nerd, I don't agree that Times is a bad font or that it signals "apathy." When I see nice kerning, judicious leading and tracking in a book design or webpage using a Times font - particularly LaTeX documents using TeX Gyre Termes - I'm generally very pleased.

Second, Plantin is not a "Times alternative," it is a variation on Bembo. Bembo is the opposite of Times ... it is e x p a n s i v e. It's like suggesting black as an alternative to white.

Third, I think the best alternative is actually NYT Imperial.

jeffmcmahan··on Frameworkless Movement
I have a simple reconcile function (that I wrote, in umpteen variations) diff the previous and upcoming view state (not the DOM state) for each list item, and if there are changes or new items, the changes are made. If not, DOM nodes are not touched.

FWIW, it is actually nice to take hold of the details. In many situations you realize that you can alter the way things work to achieve cool effects or performance gains or whatever. Things you don't imagine or explore when React is just going to do whatever it does on your behalf.

jeffmcmahan··on Frameworkless Movement
In JS, frameworks have helped us to work out which bits of "magic" we really value, and over the past 5-7 years especially, that has informed the evolution of the language. And now, most of what we'd want is built into the platform (raucous applause). I build pretty much everything - from simple to very complex - with arrow function closures and direct DOM manip, and it works beautifully. I occasionally use lit-html if I really need to to make quick progress. But otherwise, it's the raw DOM API with one simple, functional pattern...
jeffmcmahan··on Bullshit Ability as an Honest Signal of Intelligence
GA Cohen wrote "Deeper into Bullshit" as a sort-of reply to Frankfurt, which drew attention to what I find the more interesting kind of bullshit, namely pseudo-academic and/or pseudo-technical bullshit. This, Cohen sensitively observes, is always found to have the property of "unclarifiability" - which is just exactly on the money. Very much worth the read. Frankfurt published a reply to it, as well, as I recall.

http://www.professorsapp.com/cohen--further-into-bullshi.pdf

jeffmcmahan··on Open UI
Thank you for your work on lit-html. I use it daily. What a great tool.
jeffmcmahan··on This Artwork Does Not Exist
The results are indistinguishable from real modern art. That is to say, this AI is really bad at producing art.
jeffmcmahan··on The neuroinvasive potential of SARS-CoV2
Hmm. Based on what I read, particles smaller than 0.3 microns have a widely "wandering" path of travel through the mask fibers on account of Brownian motion. My understanding was that 0.3 micron particles are the size that the N95 mask is least effective at blocking. Smaller particles are blocked more effectively, not less, until you get down to a scale so small that you pretty well exclude live biological material.

Not my original source, but discusses the same thing: https://multimedia.3m.com/mws/media/376179O/nanotechnology-a...

This is to say, 95% filtration is the worst the mask will perform, with particles of any size, as it relates to coronavirus.

jeffmcmahan··on Lisping at JPL (2002)
Well, and the corollary, that's why your typical engineer doesn't get it - and anyone who really insists on it is just a lunatic; adopting it would be a nightmare to the average workaday developer who just wants to have the compiler tell him/her what to do...
jeffmcmahan··on Software Disenchantment (2018)
To answer your technical question: You can approach it one of two ways (I've done both). The first you hinted at. You can keep the last state object handy for the next incoming update and compare (e.g.) stateA.className against stateB.className, which is extremely fast. But you have an extra object in memory for every single node, which is a consideration. You can also just use the node itself and compare state.className to node.className. Turns out this is ~90-100% as fast ~95% of the time, and sips memory.

If you're thinking, "wait, compare it to the DOM node? That will be slow!" - notice that we're not querying the DOM. We're checking a property on an object to which we have a reference in hand. I can run comparisons against node.className (and other properties) millions of times per second. Recall that my component update functions return an object of roughly the form:

{ node, className: 'foo', childNodes: [...], ... }

That first property is the DOM node reference, so there's no difficulty in running the updates this way. Things are slower when dealing with props that need to be handled via getAttribute() and setAttribute(), but those cases are <10%, and can be optimized away by caching the comparison value to avoid getAttribute(). There are complications with numerical values which get rounded by the DOM and fool your code into doing DOM updates that don't need to happen, but it's all handle-able.

Here's quick gist: https://gist.github.com/jeffmcmahan/8d10c579df82d32b13e2f449...

jeffmcmahan··on Software Disenchantment (2018)
>>> it sounds like you are describing exactly tree diffing

The object returned by the function expresses a tiny subset of the properties of a DOM node. Often just {className, childNodes: [...]}. Only those explicit attributes are checked for update or otherwise dealt with by my code. My code has no idea that a DOM node has a thousand properties. By contrast, a ReactComponent is more complex from a JS POV than a native DOM node.

In other words, if my code returns: {className: 'foo'} at time t0, and then returns {} at time t1, the className in the DOM will be 'foo' at t0 and at t1. That is not at all how exhaustive tree diffs work, and not at all how react works.

With 5,000 nodes, you might have 8K-15K property comparisons. Per-render CPU load thus grows linearly and slowly with each new node. I can re-render a thousand nodes in 2-5 milliseconds with no framework churn or build steps or any of that. But more importantly, we have the ability to step into "straight-to-canvas" mode (or whatever else) without rupturing any abstractions and without awkward hacks.

This is unidirectional data flow plus component-based design/organization while letting the DOM handle the DOM: no fake elements, no fake events -- nothing but utterly fast strict primitive value comparisons on shallow object properties.

EDIT: Earlier I said that a node changes if and only if its state description changed; that is not strictly true. "if and only if" should just be "only if".

jeffmcmahan··on We’re approaching the limits of computer power – we need new programmers
It's pretty weird to me to try to picture Microsoft's monopoly as a better situation than the current one?
jeffmcmahan··on Software Disenchantment (2018)
Well yeah. But I've seen it done; the attitude being "this is fine, React is fast, it works on my Mac..."
jeffmcmahan··on Software Disenchantment (2018)
No one's going back to the messy spaghetti-generating "just-jQuery" pattern of yore.

I devised a way of using plain closures to create DOM nodes and express how the nodes and their descendants should change when the model changes. So a component is a function that creates a node and returns a function not unlike a ReactComponent#render() method:

props => newNodeState

When called, that function returns an object describing the new state of the node. Roughly:

{ node, className: 'foo', childNodes: [ childComponent(props) ] }

So, it's organized exactly like a react app. A simple reconciliation function (~100 lines) applies a state description to the topmost node and then iterates recursively through childNodes. A DOM node is touched if and only if its previous state object differs from its current state object - no fancy tree diffing. And we don't have to fake events or any of that; everything is just the native platform.

I implemented an in-browser code editor this way. Syntax highlighting, bracket matching, soft wrap, sophisticated selection, copy/cut/paste, basic linting, code hints, all of it... It edits huge files with no hint of delay as you type, select, &c. It was a thorough test of the approach.

Also, when we animate something, we can hook right in to the way reconciliation works and pass control of the update to the component itself, to execute its own transition states and then pass control back to the reconcile function... This has made some really beautiful things possible. Fine grained control over everything - timing, order, &c. - but only when you want it.

Sorry for the wall of text.

jeffmcmahan··on Software Disenchantment (2018)
I completely agree, here. React has replaced the DOM, and it's pretty fast, pretty efficient when you understand its limitations... but when you start rendering to the canvas or creating SVG animation from within react code, everything is utterly destroyed. Performance is 1/1000 of what the platform provides. I have completely stopped using frameworks in my day-to-day, and moved my company to a simple pattern for updatable, optionally stateful DOM elements. Definitely some headaches, some verbosity, and so forth. But zero tool chain and much better performance, and the performance will improve, month-by-month, forever.
jeffmcmahan··on Merry Christmas HN
Peace be with you all.
jeffmcmahan··on How to Build Good Software
I agree completely. Dependencies solve problems but not for free - bugs, security issues, versioning headaches, performance problems, compatibility gotchas, churn, &c. I live by the following:

(1) If a problem can be exhaustively specified in a formally well-defined way (mathematical logic), it will be wise to adopt a mature implementation - if it exists.

(2) If a problem can't be so specified, all implementations will be incomplete and will contain trade-offs. I have to address these problems myself to ensure that limits and trade-offs suit as well as possible what the business needs. If I can.

So, (1) says I shouldn't parse my own JSON. (2) says I should avoid the vast majority of what shows up in other people's dependency trees.

jeffmcmahan··on Goodbye, EdgeHTML
I switched months ago. No regrets, as a full time js/web developer, the dev tools are good enough. Not better than Chrome, but good enough. You can do the right thing.
jeffmcmahan··on The Insect Apocalypse Is Here
They're evidently capable of doing advanced mathematics and of producing microprocessors among many other things, so whatever we think about them managing the globe, their intellectual equipment goes well beyond "small group interactions".
jeffmcmahan··on The Insect Apocalypse Is Here
So what you're saying is, "in an ecological sense" you're fine with it if my children die of starvation? Well good for you.
jeffmcmahan··on Bruno Latour, the Post-Truth Philosopher, Mounts a Defense of Science
> [Latour's] early work, it was true, had done more than that of any other living thinker to unsettle the traditional understanding of how we acquire knowledge of what’s real.

I'm sorry, but no. Anglosphere philosophers (= the mainstream, like it or not) do not, in general, take social constructionism at all seriously. I'd predict that there is not one tenured philosopher of science at a top-50 department who'd regard Latour as an influential contributor to epistemology or philosophy of science.

For some reason, journalists who write about philosophy are universally ignorant of the fact that academic philosophy took a hard analytic turn a century ago, and that the continent has contributed very little since - France least of all.

jeffmcmahan··on Walt: JavaScript-like syntax for WebAssembly
This looks great. I've been looking for a project like this for a while - a simple language in which I can write hot code and compile it straight to web assembly for use in existing node and web projects.

However, I wonder whether Walt is markedly faster than JIT-compiled javascript? Have you benchmarked the performance gain?

jeffmcmahan··on U.S. government sides with Apple and Amazon, effectively denying Bloombergreport
Right, that was a bizarre connection to make.
jeffmcmahan··on Why Are Enterprises So Slow?
"If it doesn’t go well he’s out of a job and his boss might go to prison"

Yeah, I don't think that happens much.

← PreviousPage 2 of 4Next →