webassembly system interface (wasi) changes everything.. getting started tutorial using rust & wasm

  Рет қаралды 18,259

Chris Hay

Chris Hay

Күн бұрын

in this video we look at how using WASI (web assembly system interface), we can create more powerful webassembly applications that can interact with i/o such as the console and filesystems using WASI.
we create some rust cli apps and then build their equivalent webassembly cli apps in rust. we explore how to write to the console. write to files and access command line arguments. finally we look at how we can use runtimes to excute our cli apps or create native executables, as well as thinking about webassembly/wasi use cases.
code is on github
github.com/chrishayuk/chuk-wa...
00:00 - introduction
01:50 - creating a rust cli application with cargo new
03:20 - executing our rust cli application
03:45 - introducing WASI (Web Assembly System Interface)
04:25 - targeting our rust application for WASI
05:15 - building our wasi webassemby app
07:30 - introducing wasmtime (webassembly runtime)
07:50 - installing wasmtime
08:06 - executing our wasm with wasmtime runtime
09:07 - speeding up development with cargo wasi
10:15 - executing our wasi webassembly module with wasmer runtime
11:10 - creating a webassembly exe with wasmer
12:41 - comparing rust cli app sizes with wasmer cli apps
14:00 - webassembly and wasi use cases
15:15 - accessing command line arguments with wasi
19:20 - writing files using webassembly, wasi and rust
23:30 - filesystem sandboxes with wasi
24:30 - webassembly wasi use-cases vs native rust
26:00 - outro

Пікірлер: 48
@BinaryReader
@BinaryReader 2 жыл бұрын
These videos are incredible. Thank you for making them!! Such a rapid and pragmatic way to show these emerging developer technologies. I'm very keen on the WASI spec, sorta anticipate a time where the defacto deployment preference will be pushing WASM assemblies up to cloud providers, with the cloud providers able to trivially sandbox process IO behind WASI sys calls (and balance execution on shared hardware). Can totally see it being a slick alternative to current docker deployments. Ideally just need really optimized high level language runtimes to be running on WASM to make it practical for most devs (me specifically :P). Rust is nice, would prefer JS/TS or C#.
@chrishayuk
@chrishayuk 2 жыл бұрын
i have one in the pipe for assemblyscript and as-wasi (which is really typescript). If you check my WAPM video out, it'll give you most of what you need. and totally agree on the push wasm assemblies point.. i really do see wasm as the future universal binary
@shlomohassid5888
@shlomohassid5888 3 ай бұрын
Chris! You have great tutorials and content. This should be a 1.2m subscribers channel - Keep up the good work and PLZZZZZZ don't become like all those programming "influencers"... I like that your content has no "noises", no "extra hyping", clear and clean voice, and no fancy ridiculous editing.
@chrishayuk
@chrishayuk 3 ай бұрын
Very kind, tbh, I’ve experimented a lot, including background music etc, just doesn’t work, so i landed on this. I do all the editing myself hence why I keep it simple. lol. Thanks for the kind comments. I always try and keep things that one level deeper but hopefully just one level and no more
@karelhrkal8753
@karelhrkal8753 Жыл бұрын
Imagine video games mods being written in WASM instead of Lua.
@ishangrover1453
@ishangrover1453 6 ай бұрын
Quick & Nice explanation
@casualweekday-ytshadowbang2469
@casualweekday-ytshadowbang2469 Жыл бұрын
Best explanation I’ve watched so far on this topic. Great video!
@chrishayuk
@chrishayuk Жыл бұрын
Awesome, thank you!
@PaulEmsley
@PaulEmsley 2 жыл бұрын
Ctrl-E to go to end of line in the terminal. Use Crl-R for history-search-backwards. Thanks for the video - I will probably use wasi myself now.
@chrishayuk
@chrishayuk 2 жыл бұрын
Thanks for sharing
@codetothemoon
@codetothemoon 2 жыл бұрын
Great video Chris!
@chrishayuk
@chrishayuk 2 жыл бұрын
Thank you so much
@ay-pj8co
@ay-pj8co Жыл бұрын
TS is compiled to JS now just like C++ was compiled to C at first. I think just like C++ TS will not be compiled to its older subset. I can see TS being compiled to WASM to run natively on browsers in the future.
@jfk1337
@jfk1337 Жыл бұрын
I think something like this exsits, assemblyscript
@ay-pj8co
@ay-pj8co Жыл бұрын
@@jfk1337 yes but there are too many differences between assemblyscript and typescript for it to be considered a typescript to wasm compiler imo. Its more like a new but very similar language.
@1414tyty
@1414tyty Жыл бұрын
It seems like you could design an Operating System to bridge the wasi hardware gap. No linux, just "drivers" to coordinate with the system interface. Not sure if there's anything to gain from this, but seems really cool!
@1414tyty
@1414tyty Жыл бұрын
In this way, wasi would be your "OS" target. I wonder if the system interface is missing any important features to be a full fledge target?
@stinkytoe
@stinkytoe 2 жыл бұрын
It would be interesting if wasi (or something similar) became the next application deployment environment. Never mind Docker, this could also replace Java as the go-to cross-platform target. How far from a good, cross platform GUI widget library are we?
@chrishayuk
@chrishayuk 2 жыл бұрын
agree. i have high hopes for webassembly becoming the universal binary for gui stuff, i think blazor is where good ground is being made
@AlexanderSuraphel
@AlexanderSuraphel Жыл бұрын
I think Flutter is a great solution. It basically supports all the platforms you can think of and you can use wasm Dart package to run your wasm files if you want.
@AlexanderSuraphel
@AlexanderSuraphel Жыл бұрын
@@chrishayuk I think Flutter is a better GUI solution if you want to target Mobile and Linux too.
@itacirgabral8586
@itacirgabral8586 Жыл бұрын
fast fun
@chrishayuk
@chrishayuk Жыл бұрын
glad you liked
@user-qm6up7kz4n
@user-qm6up7kz4n Жыл бұрын
Is wasm64 not availiable yet? That means every usage of f64 wouldn't be valid?
@diligencehumility6971
@diligencehumility6971 Жыл бұрын
Been a C# dev for a decade+. Been looking into C and C++ for performance reasons, and thus also been looking into Rust, which seems to be replacing C/C++ completely (since it has same/better performance, guaranteed no memory leaks and null pointers, and is even compatible with C/C++ libs.) Now I am learning the greatness of a standardized system interface (across platforms) which WASI seems to bring. But I don't understand. Will everything be complied to Javascript as is the case for WASM?
@ongeri
@ongeri Жыл бұрын
Your last line is a bit wrong, things are not compiled to js in wasm, browsers have the ability to run wasm binaries directly and js is only needed to do some dom interactions
Жыл бұрын
I only need concurrency and http requests and I could start using this for everything.
@AlexEllwein
@AlexEllwein Жыл бұрын
Hmm, even with the sandboxing, you can still do harm to the underlying system. Imagine writing an infinitely big file. Or using up all CPU...
@alanhoff89
@alanhoff89 Жыл бұрын
That's why there are CPU and FS quotas
@gabekoleszar3604
@gabekoleszar3604 2 жыл бұрын
I liked the video but the music in the introduction was quite jarring, I don't think it fits your tone
@rumplstiltztinkerstein
@rumplstiltztinkerstein 2 жыл бұрын
a bit loud lol
@chrishayuk
@chrishayuk 2 жыл бұрын
yeah, still trying to optimize this, good feedback
@peppybocan
@peppybocan 2 жыл бұрын
An application which has access to filesystem, network and IO is inheritely not safe and breaks the encapsulation. I think WASI is going contrary to the spirit of WASM.
@evolutionx1
@evolutionx1 2 жыл бұрын
This would be solvable with a permissions system, like how we can already request access to camera and microphone for video calls.
@stickyfingies
@stickyfingies 2 жыл бұрын
@@evolutionx1 WASI feels redundant , we're basically re-implementing the operating system at this point lol
@stickyfingies
@stickyfingies 2 жыл бұрын
With obvious gains ofc to portability and cross-platform apps... but WASI feels like a very heavy abstraction to achieve that (from a performance perspective). Is that just me? Maybe I'm missing something about WASM.
@sohn7767
@sohn7767 2 жыл бұрын
@@stickyfingies Let’s take this perspective: Many languages compile to wasm and interoperate easily with wasm libraries. Plus it’s quite secure. Now it would be nice to salvage this power for applications outside your browser. Where? Imagine a wasm plug-in system for your text editor. People could write their plug-in in their language of choice, since wasm is a compilation target. No need to be locked to vimscript, lua, elisp, etc. Wasi makes this possible. Also, Write python apps without dependency hell? Hell yes. As for performance it’s “near native” so a little bit slower in exchange for portability. Areas where cutting edge performance is desired ofc you won’t use wasi. Another comparison: “Java: write once, run everywhere.” => Only true for the jvm ecosystem. Call Java outside of it or in the browser? Good luck. Despite this, Java has become popular. Wasm + wasi would be: “compile once, run everywhere” => Browser, on your operating system, inside of other languages…
@sohn7767
@sohn7767 2 жыл бұрын
@@hermes6910 not sure what you’re asking. If you’re asking why you why would write Java/python to build a wasm app, then yes it’s a weird idea. If you’re building a brand new app, you wouldn’t choose those technologies. But you can port already existing code to wasm and use it that way. And it’s only a little bit slower
@Mempler
@Mempler Жыл бұрын
Tune down that intro song, it literally blew off my phone's speaker
Getting Started with WebAssembly (WASM) with Rust Lang
33:10
Chris Hay
Рет қаралды 11 М.
Can You Draw The PERFECT Circle?
00:57
Stokes Twins
Рет қаралды 73 МЛН
ХОТЯ БЫ КИНОДА 2 - официальный фильм
1:35:34
ХОТЯ БЫ В КИНО
Рет қаралды 1,1 МЛН
Surprise Gifts #couplegoals
00:21
Jay & Sharon
Рет қаралды 33 МЛН
WASI: a New Kind of System Interface
37:12
InfoQ
Рет қаралды 18 М.
New Wasm Platform And Standard WASIX??
10:27
ThePrimeTime
Рет қаралды 35 М.
The Truth about Rust/WebAssembly Performance
29:47
Greg Johnston
Рет қаралды 167 М.
The WASI OS - Isolation with Communication, Wasm style - Dan Gohman, Fastly
28:29
A proper look at WebGPU for native games
34:58
Madrigal
Рет қаралды 41 М.
The World of WASI by Dan Gohman @ Wasm I/O 2023
44:24
WASM I/O
Рет қаралды 6 М.
Zig Is Bootstrapping With WASM, Why?
17:26
Zig SHOWTIME
Рет қаралды 9 М.
WebAssembly On The Server??? Why?
13:42
Code to the Moon
Рет қаралды 37 М.
rust runs on EVERYTHING (no operating system, just Rust)
18:10
Low Level Learning
Рет қаралды 341 М.
Я Создал Новый Айфон!
0:59
FLV
Рет қаралды 3,5 МЛН
The power button can never be pressed!!
0:57
Maker Y
Рет қаралды 46 МЛН