Rust challenge 49/100 - rust javascript bindings
Table of content
What is this
The rules of the game are explained in my original post. I haven’t posted in a while but I want to get started again.
49th Challenge
Challenge
Today the challenge will be simple. Use rust bindings to create a hello world. Also, because there is a greate hype around AI generating code and images from text I will use both in this post.
Solution
Ferris the crab from the rust programming language drawn as marvel comic character. Created using stable diffusion
Ferris the crab from the rust programming language drawn as gta character.
We will use code pilot from github to generate the javascript binding. With the promt /* bind javascript */
the first prompt is as follows
This looks good at first glance but will actually jsut print out the text contained in our main.js
. main.js
was also generated with a prompt contains the text
Sadly that was the only suggestion, so I try with a different approach. Lets try again..
Again it looks promising, but it does not work either, so I give up and do some googling. Rust by Example tells us to use the cargo nodejs-helper
so lets try to add this to the prompt. Basically the helper just runs the javascript in a nodejs, the repos is found here.
However this is not what I’m trying to achive, this won’t run like a rust application. So I looked further and found wasmedge-quickjs. With this solution you also require wasmedge installed to run. So the code
is compiled using $ cargo build --target wasm32-wasi --release
and can then be run using wasmedge --dir .:. target/wasm32-wasi/release/wasmedge_quickjs.wasm
This is a somewhat working solution but I will probabyl explore this some more in the future. For now the challenge for today is done.
See github for today’s simple snippet.