4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

お題は不問!Qiita Engineer Festa 2023で記事投稿!

WASMのComponent-Modelへの期待

Last updated at Posted at 2023-06-14
1 / 13

Component-Modelで何ができるようになるか

Component-ModelとはWASM(WebAssembly)の現在策定中の新しい仕様。
このComponent-Modelでは抽象化された、静的解析可能で、機能安全で、言語にとらわれないインターフェースを定義することを目標としている。


主な用途

  • ネイティブプラグインの代替
  • サーバレスなプラットフォームでの低レイテンシで高速なインスタンス化ができるサンドボックス環境
  • 簡単に効率的にスクリプトを導入するサポートの提供
  • ライブラリをサンドボックス環境で安全に外部のunsafeなライブラリを実行する

経緯

このComponent-Modelはもともと二つの提案に分かれていました。

  • interface-types
    • 入出力の構造を定義してインターフェースを作りやすくする
  • module-linking
    • 他のwasmのモジュールに動的にリンクする

WIT

Component-Modelにおいてのインターフェースを記述する言語
まだ仕様策定中

default world sample-plugin {
    record plugin-config {
        name: string,
        version: string,
    }
    record response {
        content: string,
    }
    import get-config: func() -> plugin-config
    export gen-response: func(user: string) -> response
}

想定される活用先

これらのインターフェース定義がwit経由になると考えられる


Rust等の言語でフロントエンド

DOMを直接操作できるようになる。yewとかが高速化するはず


fass

witでインターフェースを定義したwasmを設定することになるはず
https://wasmer.io/wasmer-for-faas
https://github.com/cloudflare/workerd
https://deislabs.io/posts/introducing-spiderlightning-and-slight/


WAPM

IRB,RustPython,sqlite
Wasmのパッケージをimportなどして呼べるようになる。


Rustへの影響

wasmと親和性が高いRustにいろいろメリットがあると思われる


yewなどのRust製フロントエンドの高速化

Domが直接操作できるようになるので高速化、効率化する


wit-bindgen

  • ランタイム(ホスト)として
    • wasm-time wasmer
  • ゲスト
    • 対象のコンポーネントが実装されることをtrait定義で確認することができる

まとめ

Component-Modelでwasmの表現力が高まり、様々な用途で使いやすくなると思われる。

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?