Giter Site home page Giter Site logo

badboy / hellorust Goto Github PK

View Code? Open in Web Editor NEW
75.0 10.0 8.0 657 KB

Collection of resources & examples for Rust & WebAssembly

Home Page: https://www.hellorust.com/

License: Creative Commons Zero v1.0 Universal

Liquid 40.51% CSS 57.92% Makefile 1.56%

hellorust's Introduction


This site is unmaintained and read-only.

The Rust and WebAssembly working group now provides a lot of tooling, documentation, tutorials and other material. For a complete introduction to Rust and WebAssembly check out the Rust ๐Ÿฆ€ and WebAssembly ๐Ÿ•ธ book.


A collection of resources, articles, examples and links regarding Rust & WebAssembly

Website

Everything is automatically deployed and available on www.hellorust.com.

Development

The site is built using Cobalt. To compile everything and place it into the build/ folder, execute:

cobalt build

Deployment is automatically run through Travis CI on every push to the master branch.

Developing examples

Examples are placed in demos/. You can copy one of the existing examples or create a new one. Just pick a good short name as the directory name.

Please add a Makefile which compiles and copies all necessary files in place on invocation. See demos/add/Makefile for a simple example. Once you have done that add the example's name to the main Makefile, so it can be rebuild easily.

Add an index.liquid file for your example and make sure the following header is included:

permalink: /demos/slug-of-your-example
title: "Demo: Name of your example"
layout: site.liquid
---

Use HTML to structure your example explanation.

Contributions

All contributions are welcome. Please open an issue and tell us about your ideas. Pull Requests with new resources or examples are welcome as well.

License CC0-badge

Texts and example code on www.hellorust.com are licensed under Creative Commons Zero v1.0 Universal License (LICENSE-CC0 or https://creativecommons.org/publicdomain/zero/1.0/legalcode)

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Hellorust by you, as defined in the CC0-1.0 license, shall be dedicated to the public domain and licensed as above, without any additional terms or conditions.

External dependencies used in example code remain under their own license.

hellorust's People

Contributors

arkada38 avatar badboy avatar booyaa avatar colineberhardt avatar epage avatar geal avatar seppo0010 avatar tcr avatar tomashubelbauer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hellorust's Issues

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

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?

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.

License?

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

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.

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.

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.

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.