HNHacker News
TopNewBestAskShowJobs

nolanl

1,091 karma · joined August 13, 2013

[ my public key: https://keybase.io/nolanlawson; my proof: https://keybase.io/nolanlawson/sigs/5Udxhb8X1E57tmNkoMyOonOIeiVfEpGPlwm9amgvHMQ ]
submissionscomments
nolanl··on Ask HN: Why don't more open-source projects monetize?
Maybe it's more accurate to say that, when you're on Patreon, part of your job suddenly becomes a "hustle"? E.g. in Evan's case I get the feeling that without a constant stream of conference appearances and blog posts it would be harder to drive Patreon donations.
nolanl··on Scrolling on the web: A primer
(Author of the post and Microsoft Edge team member here.)

This is actually an active area of discussion for browser vendors, and we're all experimenting with "interventions" that are designed to benefit users at the expense of web developers. Our most recent efforts can be browsed at https://github.com/wicg/interventions , and you can see things in there like "passive-by-default" event listeners, timer throttling for background tabs and cross-origin iframes, requiring user intent for vibration, etc.

Not all of these efforts have been popular with web developers, and some of them may even need to be rolled back. But browser vendors are indeed trying to address this problem! :) You'll note that Chrome, Firefox, Edge, and WebKit representatives are all involved in this effort.

nolanl··on Scrolling on the web: A primer
(Author of the post here.) It may depend on your OS or your Firefox version! :) I spoke with some Firefox folks after publishing this piece, and it turns out they've fixed some things in Firefox 52, notably for touch-enabled Windows laptops.
nolanl··on Anthony Burgess at 100: unearthly powers
As a teenager I came across the eclectic medley of Anthony Burgess novels in my school's library, and fell in love. They're all so vastly different and weird and yet they made for great reading:

- The Wanting Seed: sci-fi about an overpopulated planet, full of dry humor

- The End of the World News: a musical about Trotsky's final days in Mexico, mixed with Freud and an Earth-destroying comet. Supremely weird but entertaining

- Tremor of Intent: Ian Fleming-style spy novel

He also wrote books on linguistics and was a composer. (Not sure about his compositions, but I have a degree in linguistics and found "A Mouthful of Air" to be solid.) Really underrated writer.

nolanl··on JavaScript in Parallel: Web Workers and SharedArrayBuffer
(I'm the author of the article you cite.)

For the record, Chrome has been working on improving their postMessage performance as of M57 [1], so my benchmark should probably be re-run.

Assuming they end up in the same ballpark as Safari and Edge, the only browser for which stringification would still make sense is Firefox. (And maybe they have improved in the past year too. :))

But a lot of the conclusions from that article came from the fact that non-stringified postMessage perf was so bad in Chrome, which especially impacted performance on Android devices.

[1]: https://twitter.com/cramforce/status/824273332258209792

nolanl··on PouchDB, the JavaScript Database That Syncs
In principle yes any CouchDB/PouchDB database can sync with one another because they all share the same protocol, but OTOH I've seen very few examples of apps that offer users a simple "export to your own CouchDB/PouchDB" feature.
nolanl··on PouchDB, the JavaScript Database That Syncs
(PouchDB contributor here.) Just a quick note that slow replication is one of the things that is largely fixed in CouchDB 2.0 thanks to the new _bulk_get API (https://issues.apache.org/jira/browse/COUCHDB-2310) and is set to get even better in CouchDB 3.0 once it has HTTP 2.

As for your app feeling sluggish, my hunch is that you're seeing this in a Chromium or Gecko browser (e.g. Android WebView) in which cases IndexedDB does quite a lot of heavy operations on the UI thread (http://nolanlawson.com/2015/09/29/indexeddb-websql-localstor...), which can be mitigated by moving it to a Web Worker (as Pokedex.org does) or a Service Worker (as HospitalRun.io does).

nolanl··on PouchDB, the JavaScript Database That Syncs
(PouchDB contributor here.)

There are actually several layers of "cache" inside of a browser, including the traditional HTTP cache (which is global) as well as the site storage, which includes stuff like IndexedDB, WebSQL, LocalStorage, AppCache, and window.caches (all of which is per origin).

This site storage _can_ be cleared by the browser (it's "temporary" per the spec), but in practice it isn't very frequently cleared unless the machine is running low on space. E.g. Chrome only does it if a site exceeds 20% of total per-origin browser storage (https://developer.chrome.com/apps/offline_storage) whereas Edge is extremely conservative with clearing IDB because it's considered user data (e.g. email drafts in Outlook). In any case, when the browser does clear this storage, it clears everything at once for that origin, so the user essentially has the experience of visiting the site for the first time. This is why it's a good practice to periodically sync your PouchDB data to CouchDB because it can be lost in rare cases.

Also there is a new Storage spec that allows site authors to designate certain buckets of per-origin storage to be persistent, but this typically requires a user permission and isn't widely supported yet: https://storage.spec.whatwg.org/

nolanl··on PouchDB, the JavaScript Database That Syncs
Yup, exactly. We use JSON.parse inside of a try/catch and then fall back to vuvuzela (https://github.com/nolanlawson/vuvuzela) which is a non-recursive JSON parser in cases of stack overflows (here's the code: https://github.com/pouchdb/pouchdb/blob/62be5fed959bbdf91758...).

Unfortunately the only way to resolve this without vuvuzela would have been to change the structure of the stored documents which would have required a large migration, so I'm glad to hear that the vuvuzela solution was the right way to go.

nolanl··on Realm Mobile Platform – Realtime Sync Plus Fully Open Source Database
(I also work on PouchDB.)

For "conflict-free sync," according to the docs, this appears to be last-write-wins along with a special case for deletes: https://realm.io/docs/realm-object-server/#conflict-resoluti... . (Incidentally Couch/Pouch also has a special case for deletes, but it does the opposite behavior by default – deletions lose to updates.)

There's also some language in here about how "insertions in lists are ordered by time;" I'd be curious to know how they coordinate clock times across nodes. Ditto for "last update wins" – important to know how "last" is determined.

In general, I tend to be skeptical of systems that hinge on last-write-wins, but LWW is definitely a model that works in a lot of cases where you're not too concerned about the possibility of losing data, and it's also a simpler mental model for the app developer.

nolanl··on Realm Mobile Platform – Realtime Sync Plus Fully Open Source Database
Thanks, I'm that person. :) I tried to write it as a "missing manual" for Couch/Pouch, and had a lot of fun in the process! It needs some updates for newer stuff, though: pouchdb-find, custom builds, Chrome DevTools storage UI improvements, etc.
nolanl··on Top-level await in JavaScript is a footgun
Sounds like I misunderstood. Thanks for the correction!
nolanl··on Top-level await in JavaScript is a footgun
It's not so much about blocking as it is about delaying the module waterfall. E.g. a module that did `await new Promise(_ => setTimeout(_, 5000))` at the top would prevent any of its dependents from being loaded for 5 seconds.
nolanl··on The cost of small modules
(rollupify author here.) It works if you configure Rollup to use a plugin like https://github.com/rollup/rollup-plugin-node-resolve, and it works best if the third-party packages also expose jsnext:main or the new "module" field in package.json.

Overall though there are still lots of edge cases that aren't well-covered without plugins (such as globals like process.nextTick etc.). Some details here: https://github.com/rollup/rollup/issues/552

nolanl··on The cost of small modules
Oh yeah and also - "modules" !== "packages." ;) Not sure many folks are really counting the number of _modules_ in their code as well as packages.
nolanl··on The cost of small modules
As I say in the post, I'm not sure it's safe to say "I have _n_ number of modules, therefore my overhead is the same as the '_n_ modules' benchmark." For runtime perf it's about the total number of require()s; the "_n_ modules" benchmark is more reflective of the bundle size cost.

E.g. consider the m.reddit.com example - 1050 modules, yet an order of magnitude slower than the "1000 modules" example. I might need to follow up with more benchmarks to reduce the confusion. ^_^;;

nolanl··on My condolences, you’re now the maintainer of a popular open source project
Some advice I would give to open-source maintainers, based on my own experience and also advice I've received from veterans:

- take breaks. go AWOL for 2 weeks. it clears the mind

- ask the user to provide a test case to reproduce. if they cannot, close the issue after a month or so

- mark issues as "needs test case" or "has test case"

- use email instead of GitHub notifications. mark as read, labels, folders, etc. are all invaluable

- if some user is abusive, cut them out immediately (e.g. ban them from the GitHub org)

- do a little bit every day so you don't become overwhelmed

- set up automated tests that run for every PR. projects without tests are impossible to maintain.

Good luck!

nolanl··on On Joining Microsoft Edge and Moving to Seattle
Yay, thanks for your comment! :) I look forward to proving you wrong. wags bushy tail, bats bright eyes
nolanl··on Introducing PouchDB custom builds
(Author here.) Actually it's fairly easy to swap out npm for another package manager. Under the hood, npm is just CouchDB, meaning you can replicate from npm by simply clicking the "replicate" button in CouchDB's Futon UI. There are also plenty of npm-like alternative implementations, such as Sinopia, local-npm, Nexus, etc. You can also just `npm pack`, host the tarball, and `npm install` from the tarball.

For better or worse, npm is the package manager for JavaScript – it won. We definitely need to be vigilant to make sure npm (the company) doesn't add proprietary features that lock us in to their service, but that's another reason the PouchDB team didn't choose scoped packages – it doesn't play very nicely with the rest of the npm-esque ecosystem, due to not being part of the main CouchDB changes feed (as well as other issues). Although, I'm told by npm folks that many of those issues with scoped packages have been fixed, and they're working on fixing the remaining ones.

nolanl··on I switched to Android after 7 years of iOS
(I'm the author of Pokedex.org.)

Unfortunately it's a limitation of the Android platform; you can't add arbitrary launch activities at runtime. So the Chrome team is unable to fix this AFAIK.

However, you could imagine a future release of Android that sports a custom homescreen app that just includes Chrome progressive webapps in the main app drawer. Or someone might be able to write a third-party homescreen app already that does that. (Not sure if Chrome exports that data though TBH.)

Also, FWIW, the "add to homescreen" is really just icing on the cake - even without it, PWAs save data locally and are launchable offline. If you remove Pokedex.org from your homescreen, you'll notice you can still navigate to https://pokedex.org while in airplane mode, and Chrome still reports some 6MB of Pokémon data as being stored on your device. (It remains to be seen whether this is a bug or a feature... but we'll see how many PWAs abuse it.)

nolanl··on Apple starts rejecting apps that use UIWebBrowserView
Let's say you have one big contenteditable, so there's only one field, and it's pointless to have "previous," "next", and "done" buttons. Or just any situation where you don't think the user needs to be able to switch left and right and can tap instead. Or situations where you want to make your own UI instead of using the default Safari UI.
nolanl··on Apple starts rejecting apps that use UIWebBrowserView
In case anyone is wondering, this plugin hides the "accessibility bar," i.e. the keyboard bar that appears when you tap on a form element in iOS: https://nolanwlawson.files.wordpress.com/2016/03/accessibili...

The accessibility bar is really annoying for hybrid app developers, because it's often not needed, and just takes up valuable screen real estate. As one of my coworkers put it, it has no purpose other than to announce, "Hi! I'm a WebView!"

nolanl··on The Website Obesity Crisis
You're exactly right; ES6 modules can solve this. Rollup (an ES6 bundler) has tree shaking [1] and also smaller bundle sizes in general [2].

[1]: http://rollupjs.org/ [2]: https://github.com/nolanlawson/rollup-comparison

nolanl··on The App-ocalypse: can Web standards make mobile apps obsolete?
I'm quoted at length in the article, so I feel obliged to respond. Overall I think it's good, but it misses some nuances.

First off, there's a small contradiction about offline storage. The author says that users prefer web apps because they take up little-to-no space, but that the web needs to catch up in terms of storage capability. You can't have it both ways - if websites become more offline-heavy, then users will need to get accustomed to managing their available space (as they already do with native apps). This is an as-yet unsolved UX problem for the web.

Also, based on the comments in this thread, I think many people don't realize how far the web has come in terms of offline storage. Today you can build a mobile site that stores MBs of data, launches from the home screen, and works even in airplane mode. (On Android anyway. iOS is another story.)

I built a small site to demonstrate: http://www.pocketjavascript.com/blog/2015/11/23/introducing-.... On an Android phone, Pokedex.org is basically indistinguishable from a native app, at least once you add it to the home screen. In Chrome, tap the green lock and you can see exactly how much space it takes up (around 6MB). Feel free to put your phone in airplane mode and refresh the page - it will still work.

Second off, there's a lot of speculation in the post about Apple's motives, and why they might be throttling back on the web platform relative to Google, Mozilla, and Microsoft. I'm guilty of this myself in "Safari is the new IE," but nowadays I try to have a more nuanced take.

AFAICT, Apple seems to have many small teams with many different motivations, as does Google. Within Google, you'll even find teams that actively undermine other teams - e.g. what the Chrome team is doing with Progressive Web Apps is a direct threat to Android apps. (I'm even surprised to see one team occasionally trash-talking the other on Twitter.) So talking about "Google's motives" or "Apple's motives" as if they're each one big monolithic entity is a little simplistic.

My favorite theory about Apple and the web comes from this article (http://blog.html5test.com/2015/07/safari-and-ie/), which argues that the WebKit team is just too small since the Blink split, which is why they've been having trouble keeping up. No grand conspiracy theory required - just that the team is a little under-financed. Also, Safari is still rocking it in terms of performance and battery life, so it's not like they're asleep at the wheel.

I think the web still has a chance to catch up with native (for a lot of use cases anyway, not all of them), but it will require a change in how we build websites. In the same way that XMLHttpRequest was around for years before web devs "discovered" Ajax, I think offline storage and various mobile APIs might lay dormant for awhile before suddenly everybody is taking advantage of them. As web developers, the ball is in our court.

nolanl··on Pokedex.org: a progressive webapp for Pokémon fans
Author here - thanks a lot! :) I think many of the emerging performance bottlenecks in webdev are on the client rather than the server, so there's definitely a lot more research that needs to be done here. In particular, I feel like the whole "web worker" angle has been seriously overlooked, even though the tech is ~5 years old.
nolanl··on Pokedex.org: a progressive webapp for Pokémon fans
Hm, that might be due to the autoloop <video>s I have in there (which are great for illustrating the animations, but may be a bit indulgent). Which browser are you on?
nolanl··on Pokedex.org: a progressive webapp for Pokémon fans
Thanks! I totally failed to notice that, but I've filed an issue now: https://github.com/nolanlawson/pokedex.org/issues/9
nolanl··on Pokedex.org: a progressive webapp for Pokémon fans
Thanks! I'm glad there are some true Pokémaniacs out there keeping me honest. ;) In my defense, though, I put this site together in my spare time over the course of the past few weeks, and the data source I used (PokéAPI) is missing some crucial data that I still need to patch (e.g. the Gen VI species, the catch rates). But the point of the site is mostly to demonstrate what you can do with web tech, not to be the end-all be-all best Pokémon resource ever.

I'd like it to be, though! :) Hence why I open-sourced it, and why I'm encouraging anyone with the inclination to help improve it: https://github.com/nolanlawson/pokedex.org

nolanl··on Pokedex.org: a progressive webapp for Pokémon fans
Author here. I'm no stranger to this situation; I wrote a native Android Pokédex app awhile ago that got DMCA'd: http://nolanlawson.com/2011/05/26/on-pokedroids-removal/

Last time I talked with the legal team of The Pokémon Company (subsidiary of Nintendo that owns the IP), I was informed that, while they allow web sites like Bulbapedia and Serebii, it gets hairier with native apps (e.g. because you implicitly assert ownership over the IP when you publish on the Play Store). This happened almost 5 years ago, though, and nowadays there are lots of Pokémon apps on the Play Store (https://play.google.com/store/search?q=pokedex&c=apps), so I can only assume that they've softened their views.

That said, it's their IP, and they're free to wield the DMCA hammer as they see fit. For me, though, the point of Pokedex.org is to show what you can do with 2015-era web tech, and that, on Android at least, the web has already (mostly) caught up with native. I mean, this app is arguably superior than my old Froyo-era native app, and it's all HTML/CSS/JS! So hopefully someone will be inspired by it to build a similar, offline-capable webapp. That was reason enough for me to build it.

nolanl··on Pokedex.org: a progressive webapp for Pokémon fans
Author here. You hit the nail on the head. :)
← PreviousPage 2 of 4Next →