/rustin

web toy built by js & rust

Primary LanguageRust

rustin

中文

Let's build web pages by rust & js!

📎Plan

  • Test the efficency of wasm, using Rust in browser.
  • Create a scaffold, using Rust and Web Worker, for future web development.

A type of machine code for browser to handle time waste jobs, which can assembly from multiple programming language.

Test

A non-block calculation in browser implement with web worker, mean while, we can use wasm to handle time waste job. All for a better experience of web site. design

Result

Algorithm Size Count Pure Javascript(ms) Rust in warm(ms)
MD5 50000 1000 2409 521
bubble 20000 1 821 1095
QuickSort 20000 1 9 3
Standard 20000 1 4 2
Bubble 200000 1 99549 114333
QuickSort 200000 1 22 36
Standard 200000 1 51 26
MD5 500000 1000 24344 4866

🧵 Worker

Web Workers is a simulated multi-thread environment in browser.

  • No block to main thread.
  • Asynchronous communication.
  • More efficient.
  • ...

🐂 Rxjs

A paradigm of programming, functional and reactive. It's a perspective of time, we handle data and event during all the time. A different perspective for dealing with data flow and event.

  • Functional
  • Reactive
  • operators
  • handle complex events
  • Synchronous or Asynchronous.
  • Broadcast
  • ...

😋 Rust

Rust is a language for future with many advanced programming tech.

slogan

From offical site:

A language empowering everyone to build reliable and efficient software.

  • Performance Rust is blazingly fast and memory-efficient: with no runtime or garbage collector, it can power performance-critical services, run on embedded devices, and easily integrate with other languages.

  • reliable Rust’s rich type system and ownership model guarantee memory-safety and thread-safety — enabling you to eliminate many classes of bugs at compile-time.

  • Productivity Rust has great documentation, a friendly compiler with useful error messages, and top-notch tooling — an integrated package manager and build tool, smart multi-editor support with auto-completion and type inspections, an auto-formatter, and more.

My opinion: It's kind of wierd to use rust for frontend developer who using javascript all the time.

  • struct | trait | type
  • ownership
  • multi-thread
  • so on

But we can take nourishment from comprehensive documentation by offical. Those advanced techs.

Not a bad trial for full-stack engineer to use Rust(server / wasm)。

📖Resources

documentation

Library & Tool

🌚Not working now

  • import c module(.h)
  • File system | IO
  • multi-thread

🌝Usually for

  • Algorithm
  • Image processing
  • Basic data structure.
  • Text processing
  • Game application