I really wish browsers hasn't decided against WebSQL and replaced it with IndexedDB.
The web as a platform thrives on multiple implementations, even going so far as to require it for new standards in many areas.
All implementations of WebSQL were basically a lightly wrapped SQLite, and that meant that a bug in SQLite was a bug in all browsers, and design decisions in SQLite would impact the entire web ecosystem, and that was consitered by many involved to be a bad tradeoff.
IndexedDB is much simpler to spec out, much simpler to build multiple implementations of, and much simpler to maintain and improve over time.
In a way it's punting the problem down to userland, but userland doesn't need to abide by the same rules and restrictions as a blessed standard does, so it makes sense to push more complexity down to that level.
400kb is a lot to pay, but it just goes to show how complex an SQL engine really is. Paying for that in the form of a JS bundle download is one thing, but having that complexity in every browser means a larger attack surface, larger maintenance surface, and at the end of the day still doesn't completely remove the need for things like AlaSQL.js (which may target a different implementation than WebSQL)
In any case, I would rather have the W3C, etc. just setting on a minimal SQLite version implementation as a baseline. Or, similar to JS spec now follow with the minimal active version in major browsers. MS IE/Edge was the main holdout, and they're going with Blink (Chrome) based builds now.
As to AlaSQL, I'm curious how it compares to an emscripten build of SQLite.
Creating two+ independent implementations before allowing the spec to be adopted may be too much work, but the same would be true of HTML5 or modern DOM specs to implement from scratch today. Fighting to ensure that there are multiple implementations of standards is a noble goal (incidentally, a fight we're in dire need of for HTML/DOM), but expecting these implementations to materialise fully formed for new standards is a severely limiting requirement.
Without that requirement, supporting WebSQL would be less work for browser makers and web developers alike. Who knows, competing implementations might even have followed down the line had the spec. been adopted.
Without that requirement, PNaCL would be the standard not WebAssembly, without that requirement ShadowDOM would be Chrome's version and not the version that most browsers are implementing now and which most people agree is better.
It's not just a philosophical goal, but one that has time and time again found issues with proposed standards and prevented them from being included.
It may keep some things out of the standards which should be in it, but it also keeps a LOT of mistakes out as well.
I agree with your above comment, and we can argue that working on a single web-engine might lead to less duplicated work for Front-End devs, and less bugs in the web overall.
Given that sqlite is the most widely deployed DB already, making it part of web browsers doesn't seem like a huge deal to me. https://www.sqlite.org/mostdeployed.html
What happens when the web wants to implement some special optimization or security addition but SQLite doesn't want or support being used that way? What happens when SQLite makes a breaking change in a future version that might make sense for them, but would break a large number of web apps?
Once something is in the web standards, it's VERY hard to drop support for it. SQLite might make sense now, but what about in a decade?
No matter how you slice it, WebSQL has the ability to become a massive maintence liability, one that all major browsers agreed was too significant to codify into a standard.
You can replace every mention of "SQLite" in your comment with Chrome (or Google) and suddenly you're agreeing with the comment instead of expressing your opinion against it. Chrome currently dominates web standards, and other browsers must keep up or risk losing even more market share to Chrome.
Many web standardization systems already require multiple implementations of a feature before it can become "standard", and by that nature some will have to implement it first. Chrome has Google behind it, and they have a lot of money and a good reason to spend it here (the better the web is as a platform, the better their company which is based on the web works).
But there are plenty of examples of where Chrome's "dominance" didn't allow them to just unilaterally push through APIs or platform changes. PNaCl failed and we got WebAssembly which is much better. The original version of ShadowDOM was shot down and it left Chrome behind other browsers when it came to the true implementation. HTML Imports were again something chrome implemented first and is currently being removed due to it ultimately not working out well and the platform as a whole moving in a different direction. Hell most of the WebComponents spec was changed or removed before it started getting in other browsers in a major way.
Sure, Chrome could just stop improvements altogether, but that seems like a poor solution. One thing I'd love to see from Google is for them to pull their (in)famous move of eating their own lunch. I'd love to see them pull a Servo and try to spend the time and money creating a new rendering engine from scratch to compete with their own Blink engine.
Edge and Opera have only a fraction of the Firefox, IE, and Safari usage, so I'm not entirely sure why you're phrasing things this way.
Agreed. It's not easier to use though - almost everyone ends up bundling 10s of KBs of code just to wrap around it and make it useful. That doesn't seem great to me.
Using bare IndexedDB sucks, but it's flexible enough to support a pretty wide range of needs. Using bare Fetch sucks in some cases (it's a hell of a lot easier than xmlhttprequest!), but most people create small wrappers in their applications to do things like add headers, auth information, and simplify JSON parsing and error handling. Using bare canvas APIs sucks, but with a small wrapper allows pretty powerful abstractions with very little code.
It has the unfortunate side effect of a lot of code written and shipped to users to simplify APIs and make common use cases easier, but if that downside allows the APIs to be as flexible and powerful as they are, then I'm personally all for it.
To supplement, see my 2015 comment in response to Lovefield: https://news.ycombinator.com/item?id=10197672
Now nearly 10 years later. The notion that a WebSQL-like library would be created on top of IndexedDB to replace the deprecated API has proven to be utterly groundless.
It's hopeless, how on earth will a bloated JS library compete with the beast that backs WebSQL? Sqlite, a native C application, just blows everything else out the water. Table joins, window functions? Can't even think the thought with anything built on IndexedDB.
Interestingly Chrome and Safari, the browsers that dominate the market, after all these years still ship with WebSQL. Perhaps there's still hope...
Uh, we came here to discuss AlaSQL.js which does implement a decent alternative to the WebSQL standard and does store to IndexedDB, when asked. It's probably a better alternative given its additions of JS functions and JSON operators.
In the footnotes you can even find a WebSQL shim that recreates the old WebSQL API on top of AlaSQL (though it recommends just using the AlaSQL API if you can).
I don't know what the benchmark characteristics of it are, as I haven't yet tried to use this library, but I doubt it is "hopeless".
On the other side, SQLite itself directly runs very well with Emscripten (sql.js), and I've heard Web Assembly builds are getting really good, if you do need the "performance" of "real" SQLite.
All of which seems to be further proof that SQLite is much better in "user land" than in the Browser's security footprint.
Well, it isn't at all if SQL is important to you (and corresponding performance gained through delegating to a native C application), or table joins, or efficient aggregation, or window functions etc.
> SQLite itself directly runs very well with Emscripten (sql.js)
Oh, yes, now try writing to disk -- you can't, it's in-memory only, not to mention huge (2MB). I'm sure mobile devices will love parsing that, battery life must be wonderful.
> All of which seems to be further proof that SQLite is much better in "user land"
No proof has been given, severe limitations have been, however. Security is an issue, I'll conceed that, but otherwise I'll stand by "The notion that a WebSQL-like library would be created on top of IndexedDB to replace the deprecated API has proven to be utterly groundless".
Maybe... I'll have to start experimenting again... when I first looked at it, IE was still too many people to ignore.
Heck, even if we just consider databases, the IndexedDB implementations in both Firefox and Chrome have had remote memory corruption bugs of the type that are often exploitable for remote code execution, although I don't know if anyone ever actually built such an exploit.
I still wish WebSQL just had broader support in general.
The blame lies entirely with Mozilla/Firefox: https://nolanlawson.com/2014/04/26/web-sql-database-in-memor...
SQLite is not a standard, and it would have been an IE6-level mistake to bake SQLite quirks and bugs into the web standard for the rest of time. (It doesn't matter that SQLite is open source, it's still a central source of failure that the web doesn't necessarily need in every browser for the rest of time.)
I came across https://nanosql.io/ also which I am leaning more towards. Not to the point yet to play with either yet but it seemed like nanosql had better documentation and also less issues opened on Github right now.
Kinda odd how when you look up things or think of things you see signs of them... Just wow'ed to see something I was looking at last night be #4 on the HN homepage... I know people talk about positivity and the law of attraction but starting to believe more and more in it where thoughts and focus becomes reality.
I'm not sure how the two compare...