10 ms·
KV Storage, the Web's First Built-In Module
- techntoke 8y agoMight as well build an OS in the web browser at this point and then you can have an OS within your OS. A sandbox within a sandbox. Next step is getting three levels deep.
- Izkata 8y agoIsn't that the idea behind Chromebooks?
- techntoke 8y agoSomething like that. I never understood why you can't just run graphics accelerated Android apps on Linux using native tools. Linux already has most, if not all, of the sandboxing/permissions components needed for apps. Wish apps were just distributed via containers.
- snaky 8y agoOr the opposite. There are more and more hardware that support Android but not Linux. That's why Termux and other solutions to run Linux on Android are so popular.
- techntoke 8y agoI assure you that there is much more hardware supported by the Linux kernel, than what has been added by Android. Termux doesn't run the majority of the Internet, and very few developers use Termux-based distributions for development.
- paxys 8y agoWe are already there today. There is very little to distinguish a modern web browser from an OS.
- 7952 8y agoYou just have to look in chrome://gpu for evidence of this. So much effort to deal with hardware differences to give a uniform experience. Isn't that exactly what an OS is for.
- solarkraft 8y agoAnd then there are (dying, because Chrome) JavaScript libraries to abstract away differences between browsers.
- vore 8y agoA step on the perhaps unintended path to first-class library installation into browsers, rather than relying on CDN caching for shared code? Will deploying on the web might look like deploying to the desktop, just one step abstracted? :-)
- breakingcups 8y agoI for one am looking forward to DLL Hell 2.0
- dessant 8y agoThe KV Storage API appears to be almost identical to the extension Storage API in Firefox, which is a joy to use. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/local#Methods https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/Web...
- nicoburns 8y agoOhhh, it's key-value like localstorage, but it allows you to store abitrary objects, not just strings. That would actually be really nice. JSON parsing can definitely become a bottleneck when getting stuff out of localstorage.
- fxfan 8y agoEither its so good that its worthy of being standardized or its not and google is flexing its monopoly muscle and trying to kill competition. Many here hate Microsoft, some probably copy others not knowing what's to hate but the minority that knows the 1990s knows what was so bad, and if they still use anything google then shame be upon them
- klodolph 8y agoIn the 90s you would be right, these days web standards don’t get standardized without having implementations first.
- _puk 8y agoTell that to WebSQL.. All vendors implemented (essentially) the same API, then the W3C subsequently abandoned it due to lack of independent implementations [0]. 0: en.wikipedia.org/wiki/Web_SQL_Database
- comex 8y agoAs far as I can tell, only two browser engines ever implemented WebSQL: Safari and Chrome's WebKit (which hadn't yet been forked into Blink), and Opera's Presto (which hadn't yet been abandoned in favor of Chromium). Firefox never implemented it, and neither did IE (Edge hadn't been announced yet), so it certainly wasn't implemented by "all vendors". And both implementations were just thin wrappers around the same library, SQLite, so the W3C was correct in saying there were no actual independent implementations.
- coldtea 8y ago>And both implementations were just thin wrappers around the same library, SQLite, so the W3C was correct in saying there were no actual independent implementations. Why should there be?
- developit 8y agoNot a great example, since "independent" is the important bit there: browsers just shipped sqlite, and you can't have a spec that says "just ship sqlite".
- networkimprov 8y agoThe bigger story here appears to be a "Javascript Standard Library" which is summarized [1] without any list of proposed modules/packages... A key-value store isn't quite the first module that leaps to mind for such a toolkit :-) EDIT: found a collection of module proposals! [2] [1] https://github.com/tc39/proposal-javascript-standard-library https://github.com/tc39/proposal-javascript-standard-library [2] https://github.com/tc39/proposal-javascript-standard-library/issues/16 https://github.com/tc39/proposal-javascript-standard-library...
- Nimelrian 8y agoI recommend reading through this issue [1]. It's amazing how much the JS community is firing against a bigger standard library, just because stuff like lodash exists and everyone can make their own packages anyways. [1] https://github.com/tc39/proposal-javascript-standard-library/issues/19 https://github.com/tc39/proposal-javascript-standard-library...
- sametmax 8y agoYeah, why get an uniform experience when you can have a different hard time in each new code base ? Why have basic features defined such as namespace, hashing, basic data structures manipulation, and uuid when you can have the unpleasure of rewritting it everytime ? Why avoid making your users download primitives they have a 100 copies of on their machines in all those dll and so ? It's not like those are solved problems in all other languages that don't have an accidental monopoly on the Web.
- bryanrasmussen 8y agosomewhat cynical/defeatist: Because those languages came along at a time previous to the web era and were often ruled by a single entity but in the web era XKCD standards rules https://xkcd.com/927/ https://xkcd.com/927/
- simias 8y agoAs a (mostly) C dev this is like bizarro world to me but I've noticed on HN and elsewhere that JS devs are very quick to move from one framework to an other, declaring a library dead if it hasn't received a significant update in mere months. I'm sure that there are plenty of JS devs out there who have fundamentally changed the way they code several times over the past few years. With this mindset I can understand that there might be some reluctance to consider a standard library that would be "set in stone" and shape the language basically forever (and potentially create a burden of legacy feature that needs to be maintained, C++ style).
- aboutruby 8y agoThe proposal doesn't seem to take into account the versioning of the included modules. > import { Date } from "std:Date"; > import { Date } from "std:Date+2.1.6-alpha.1"; Which version is the first line going to include? Latest? First? importmap for backward compatibility / polyfills is very neat though. I would love to see lowdash/underscore included as a standard library.
- philipwalton 8y agoThis is not different from existing web APIs, which are also not versioned.
- nathan_long 8y ago...and this has always been a unique pain point of development in the browser.
- paxys 8y agoI assume whatever is shipped with the browser version it is running on.
- nikeee 8y agoDoes versioning imports imply that the browser has to ship with all versions of a stdlib Module?
- nathan_long 8y agoIt could instead imply "if the browser didn't ship with a version that satisfies my requirements, use the polyfill"
- LoSboccacc 8y agoif they want these libraries to ever be used as default they need to have a stable api, so it needs versioning and the ability to link to specific version or versions in a bracket and the backport of security fixes across releases within a reasonable timeframe why would anyone develop toward a library that doesn't provide those basic guarantees? there's also no guarantee that your web app gets deployed to an up to date browser, so it's either you can specify which api level your app wants or we're all back to specify which browser version an app runs onto.
- reitanqild 8y agoHaven't seen anything from neither WhatWG nor W3C. Is Google out on another solo raid? Extra bad because the headline make it sound like a standard. Or am I missing something?
- philipwalton 8y agoThere are links to all the standards work in the article. All of the APIs mentioned are going through the standards process.
- networkimprov 8y agoThis is from TC39, the committee of ECMA that publishes Javascript standards.
- coke12 8y agoThis is a Javascript module, not a web standard. It goes through TC39
- domenicd 8y agoNot quite! Like built-in globals, built-in modules are a shared workspace between all standards bodies. In this case, KV storage is a web standard, for a built-in module that will be a web feature. This is similar to how IndexedDB is a web standard for a built-in global.
- domenicd 8y agoAt the W3C TPAC 2018 meeting, the spec editors for the IndexedDB spec agreed that after incubation (in the WICG, which is another less-formal standards group), KV storage should "graduate" by being incorporated into the W3C IndexedDB spec itself. (Indeed, they were enthusiastic about the possibility.)
- opportune 8y agoSo if Google loses its case against Oracle and the court finds that APIs can be patented, other browsers may not be able to offer the same functionality as any of Chrome's built-in modules under the same APIs. So could this be an attempt for Google to kill all the other browsers? Create a feature that will lock in developers and make most modern web apps less usable in other browsers
- executivetech 8y agoYea seems like Google is trying to hedge one monopoly (android) with another monopoly (browser) Win or lose, Google gonna benefit from both.
- fyfy18 8y agoDoes anyone know how import maps work in terms of scope? Does it affect all javascript on the page, just those from the same domain, or something else?
- philipwalton 8y agohttps://github.com/WICG/import-maps#scoping-examples https://github.com/WICG/import-maps#scoping-examples
- _pmf_ 8y agoI first thought it would be the response to Cloudflare's Workers KV (which I find an interesting concept).
- tybit 8y agoSame. They’ll probably end up being a nice pairing, fallback to cloudflare workers KV when the local one is empty/stale.
- gardaani 8y agoThe more APIs browsers have, the more expensive it is for browser vendors to implement and maintain them. Opera and Edge already gave up. W3C and TC39 are constantly publishing new APIs and features. They are pushing the Web towards a single implementation (Chromium). It will become too expensive to have separate implementations.
- jacobr 8y agobuilt-in modules will actually make it cheaper to create a new browser because modules can be easily polyfilled. A new browser will not have to implement kv-storage itself, either it can let the user polyfill it or quite easily copy another browsers implementation.
- callahad 8y agoKind of like when Google decided to ship a partial Shadow DOM polyfill to production that just so happened to make YouTube load 5x slower in browsers that weren't Chrome. https://twitter.com/cpeterso/status/1021626510296285185 https://twitter.com/cpeterso/status/1021626510296285185 Polyfills aren't a panacea, and we shouldn't blindly excuse anti-competitive behavior or attempts to monopolize the direction of an otherwise open platform that we all share and depend on.
- Secretmapper 8y agoIt is a bit funny though. Our problem used to be "OMG there are so many browsers with their own little gotchas, and they don't follow the spec" Now the problem is "Oh no we're converging to a single implementation, we need to diversify it!" I don't know which is better but it is kind of funny to note.
- akiselev 8y agoWe've actually gone full circle twice now, with a little mobius strip thrown in for good measure. 1. Early IE and netscape era: OMG there are so many browsers 2. IE6 dominance: Oh no we're converging to a single implementation... [and they don't follow the spec] 3. Rise of Firefox and Chrome: "OMG there are so many browsers 4. Chrome dominance: Oh no we're converging to a single implementation... [and they dominate the spec]
- callahad 8y agoI'm still in awe of the arrogance of calling this "the Web's first built-in module" and promoting it to developers when it's a non-standard, Chrome-specific feature backed by a spec written entirely by a single Googler without overt evidence of outside collaboration. Between this and last week's "Skype for Web," are we collectively done with the pretense that the Web is anything other than what Google dictates?
- setquk 8y agoIndeed. At this point, a Gopher revival is looking pretty enticing to serve content, not lock in, vendor wars or piles of straw stuck together with poo.
- developit 8y agoMost specs have a small number of authors (1-3) and a much wider group of people who have influenced the spec. This is as true for Import Maps and kv-storage as any other. FWIW I think "the web's first built-in module" is a reference to the name of the spec, which is called "built-in modules", not a claim to originality.
- callahad 8y agoHi! Thank you for your work on the polyfill. There is a healthy inter-vendor discussion in the spec's GH issues, and I believe there is absolutely technical merit to this specific proposal. That's all great and above-board. I'm mainly and strongly objecting to this degree of external promotion for a Stage 1 proposal, along with positioning it, fait accompli, as part of "the Web."
- writepub 8y agoMozilla has a storied history of roadblocking Google on principle. This outburst has all the hallmarks of an ideological objection, rather than technical, another in Mozilla's longstanding crusade against Google. If the proposal is a net benefit to developers and users, maybe energy is better spent in including this in Firefox, versus demonizing the semantics of a blog post from the competition. For the curious, below is a non-exhaustive list of promising tech clearly beneficial to developers and users, killed by Mozilla, on principle rather than technical merit: 1. WebSql - A web port of SqLite - arguably the world's second most used (and loved) tech. Instead, we have IndexedDb, which is such a damn hassle that a million wrappers exist to deal with it's shortcomings and complexity, including the tech presented in this blog post. 2. Nacl/PNacl - A precursor to WebAssembly which already had threads, SIMD, permissions, security ... figured out. By design, most Nacl code will run faster than webassembly, as Nacl's sandbox only excluded certain processor instructions deemed a security threat to it's sand-boxing model 3. HTML5 Storage: A file-system like storage for the browser! Killed by Mozilla...
- chr1 8y agoI couldn't find anything on how would bundled code or a simple script be able to access std: modules. Does anyone know the answer to this question?
- domenicd 8y agohttps://developers.google.com/web/updates/2019/03/kv-storage#what_about_browsers_that_dont_support_modules_at_all https://developers.google.com/web/updates/2019/03/kv-storage... , and especially the demo , show how you can use tooling for this use case.
- chr1 8y agoMy question is a bit different: how to load the native std:kv-storage from a webpack bundle. It seems the only options are to either load the whole bundle as a module, or use async import like: eval('import("std:kv-storage")').
- domenicd 8y agoAh, yeah, unlike bundling tools like Rollup, webpack doesn't have the ability to output modern JavaScript module scripts, only classic scripts. The article links to a feature request on webpack to support this: https://github.com/webpack/webpack/issues/8896 https://github.com/webpack/webpack/issues/8896 In the meantime, there are lots of workarounds, such as e.g. creating a script to bridge from built-in modules (which webpack doesn't support) to globals (which webpack does support). E.g. `import { storage } from 'std:kv-storage'; window.kvStorageStorage = storage;` then use `kvStorageStorage` in your webpack code.
- z3t4 8y agoWhen trying to port my web app into a Chrome app I had to rewrite all localStorage to be async because the Chrome app localStorage was async ... After a few weeks I gave up as there was too much work to make it into a Chrome app, but I kept the storage async in the web app. It seems that CPU memory is the new RAM and RAM is the new HDD, so it makes sense to make everything that access RAM async ... But then when everyone use async abstractions like "futures" it becomes a net negative in performance.
- markstos 8y agoWill the second module be jQuery??
- nivenhuh 8y agoIs there “import x as y” syntax?