Giter Site home page Giter Site logo

hellorust's Issues

A new example on how to work with the imported memory

It would be nice to update the example which shows the usage of imported memory and show how to use it for passing arrays into webassembly and getting the result back. Would be an interesting and useful example I think (quite a common use case).

It's clear that the one can simply export alloc() and dealloc() functions from Rust and then use them in JavaScript to allocate memory, fill it and pass the pointer to Rust, but it would be also interesting to see how to do the same with the imported memory (I believe in this case it saves the caller from explicitly calling alloc() function, but I'm not sure about that)

Demos should use extern fn?

I think that the various demos here should declare the exported functions with extern -- at any rate, I needed to do so to get a minimal example working when built with cargo, after following the setup instructions here.

Faults in the setup/wasm-target guide

I tried to follow this guide, but it seems to have some issues.

First "rustup update" will only update what is already installed, if the correct (platform dependent) nightly toolchain hasn't already been installed this won't do the trick, so next step will fail.

Second, rustc does not seem to recognise +nightly as a command, I haven't figured what the right thing to put instead is, so this is where I'm stuck.

Ok, that was a messup with two different installs, looks like I got it working.

I'm on 64-bit Windows 7 by the way.

Vector element type in alloc function is unspecified

It seems to me that Rust will pick a random type for the element of the vector you are creating in the alloc function:

pub extern "C" fn alloc(size: usize) -> *mut c_void {
let mut buf = Vec::with_capacity(size);
let ptr = buf.as_mut_ptr();
mem::forget(buf);
return ptr as *mut c_void;

I am actually surprised that it compiles, since the element of the vector could be anything. Swapping line 7 by let mut buf = Vec::<u64>::with_capacity(size); or let mut buf = Vec::<()>::with_capacity(size); still compiles. I am wondering, which type is Rust choosing when you leave it up to inference? Are you sure it is u8?

base64 in rust vs browser's built-in

I'm not sure if this is the sort of demo you're interested in, but I threw this together and was pleasantly surprised by how good the performance of the wasm'd rust was. On my machines, it's several times faster, with the lead increasing as input sizes grow. Firefox's wasm runtime seems a step ahead of Chrome's, also.

Hellorust should be CC0 licensed.

Since the content of the hellorust.com (and all examples) is intended to be copied freely, it would be better licensed CC0, with basically no restrictions.
This applies only to the code in the examples; libraries in use will have their own license.

We will track here the consent of all contributors:
Please drop a comment here if you consent or disagree. Link to CC0 license. Once we gather consent following will be merged: #22

Integer overflow in factorial demo

Currently, the value is stored as an i32. It can only hold values from ~±2*10^10, hence store factorials <= fact(12). Everything above will overflow. This can be observed by the naked eye when computing factorial 17 and 18, as they'll go negative :D

I see two options - use an i64 as datatype or restrict to factorials <=12 instead of 20.

License?

What is the license of this repo, please? :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.