SQLite3 officially supports WebAssembly!

Original link: https://chai2010.cn/post/2022/sqlite3-wasm/

The official wasm project for SQLite is finally here! This means that WebAssembly is
The SQLite community has fully entered the industrial application stage!

1. WASM
what is

WebAssembly, aka WASM, is a standard that defines a low-level programming language suitable for
(A) as a target for cross-compiling with many other languages, and (B) running through a virtual machine in the browser. It was designed with JavaScript in mind
Scripting, which provides a way to compile C code (amongst others) to WASM and script it via JavaScript, though
There’s also a huge programming model difference between JavaScript and C, but it’s for different languages ​​and JS
The interaction brings the standard bridge.

According to Ending
The Law : “Everything that can be implemented in WebAssembly will be implemented in WebAssembly”. SQLite official support
WASM just proves and reinforces the validity of the law again. In fact, there are a lot of SQLite built on LLVM or Emscripten online a long time ago
Libraries, which can eventually be wrapped as JS libraries.

Further reading: WASM as
The 4th standard of the W3C, has made great progress in different fields. For example, Docker releases integrated WebAssembly
The first technical preview of . At the same time, a large number of programming languages ​​have begun to support the WASM platform (for a complete list, please refer to https://wasmlang.org/
), domestic Go+, concave language, KCL configuration language, etc. all regard the support for WASM as a higher priority. More information about WASM can be found in “Introduction to the WebAssembly Standard”.

2. SQLite official support
WebAssembly

https://sqlite.org/wasm/doc/ckout/index.md

In fact, as early as September 2022, Google’s Chrome development team announced
SQLite development team collaborated and developed a WebAssembly version of SQLite as an alternative Web SQL database
API. WebAssembly originated from the efforts of the SQLite development team.

3. Experience SQLite in the browser

open url
https://sqlite.org/fiddle/

4.
Project specific goals

According to the official website, there are mainly 4
goals:

  • Bind a low-level sqlite3 API that is as close to native as possible in terms of usage
    API.
  • Higher level object-oriented style API, similar to sql.js and node.js
    style implementation.
  • Worker-based API to support multi-threaded environments to make it easier to use SQLite
    Function.
  • Promises based on Worker API
    A wrapper that completely hides the complexity of cross-thread communication from the user

In short, while providing the underlying API
At the same time, it provides simple and easy-to-use APIs for object-oriented, multi-threading and other links.

This article is reprinted from: https://chai2010.cn/post/2022/sqlite3-wasm/
This site is for inclusion only, and the copyright belongs to the original author.