Live data from Hacker News

Oxidizing Source Maps with Rust and WebAssembly

hacks.mozilla.org

11–20 of 32 posts

Re: Oxidizing Source Maps with Rust and WebAssembly

#11

> Tom Tromey and I have replaced the most performance-sensitive portions of the source-map JavaScript Library’s source map parser with Rust code that is compiled to WebAssembly. The WebAssembly is up to 5.89 times faster than the JavaScript implementation on realistic benchmarks operating on real world source maps. Wow. Some people have been wondering if Rust has a "killer app", but this could be it. Right now WebAss…

Why do you say Rust is easier to start with than C or C++? [Disclaimer : i'm old enough to dream in K&R C and later ANSI C, and then C++, but am more than enthused about Rust, so a genuine question]

Perhaps he means the tooling for using emscripten with rust is superior, and easier to get set-up? (i'm not actually sure if it is, i've never tried it). I'm really excited about the future of rust and have really enjoyed writing a raytracer in it, but I don't see how it's an easier-to-use language than C or C++. Easier to write safe code in sure, but not easier to pick up for a newbie.

Re: Oxidizing Source Maps with Rust and WebAssembly

#12

> Tom Tromey and I have replaced the most performance-sensitive portions of the source-map JavaScript Library’s source map parser with Rust code that is compiled to WebAssembly. The WebAssembly is up to 5.89 times faster than the JavaScript implementation on realistic benchmarks operating on real world source maps. Wow. Some people have been wondering if Rust has a "killer app", but this could be it. Right now WebAss…

Why do you say Rust is easier to start with than C or C++? [Disclaimer : i'm old enough to dream in K&R C and later ANSI C, and then C++, but am more than enthused about Rust, so a genuine question]

Maybe it's not easier to start depending on languages you are familiar with, but I think after the starting phase it gets easier by having standard libraries for common things like hashmaps, by having a much easier to configure build system, and by having a very solid package manager. Longer term into a project the actual language's features remove a lot of C or C++ snafus you can run into, though in fairness they also make certain common patterns obsolete which can be very frustrating until you get used to them.

Re: Oxidizing Source Maps with Rust and WebAssembly

#13
post #11

Earlier quoted context omitted.

Why do you say Rust is easier to start with than C or C++? [Disclaimer : i'm old enough to dream in K&R C and later ANSI C, and then C++, but am more than enthused about Rust, so a genuine question]

Perhaps he means the tooling for using emscripten with rust is superior, and easier to get set-up? (i'm not actually sure if it is, i've never tried it). I'm really excited about the future of rust and have really enjoyed writing a raytracer in it, but I don't see how it's an easier-to-use language than C or C++. Easier to write safe code in sure, but not easier to pick up for a newbie.

> the tooling for using emscripten with rust is superior

emscripten is no longer required for Rust to target WASM. There is a new target of wasm32-unknown-unknown. This project gives you quick bootstrap instructions into WASM with Rust:

https://github.com/koute/stdweb

Very quick to get started with, and the examples get you going quickly. I just used it yesterday (nothing fancy), and everything worked right out of the box.

Re: Oxidizing Source Maps with Rust and WebAssembly

#14
post #11

Earlier quoted context omitted.

Perhaps he means the tooling for using emscripten with rust is superior, and easier to get set-up? (i'm not actually sure if it is, i've never tried it). I'm really excited about the future of rust and have really enjoyed writing a raytracer in it, but I don't see how it's an easier-to-use language than C or C++. Easier to write safe code in sure, but not easier to pick up for a newbie.

> the tooling for using emscripten with rust is superior emscripten is no longer required for Rust to target WASM. There is a new target of wasm32-unknown-unknown. This project gives you quick bootstrap instructions into WASM with Rust: https://github.com/koute/stdweb Very quick to get started with, and the examples get you going quickly. I just used it yesterday (nothing fancy), and everything worked right out of th…

[deleted]

Re: Oxidizing Source Maps with Rust and WebAssembly

#16
parse_mappings is incorrect. It has the following line:

  Vec::::from_raw_parts(capacity_ptr, size, capacity);
But size is wrong. size here is the number of bytes that JavaScript instructed Rust to allocate. It's not the size of the Vec::.

This should be harmless as the resulting Vec is immediately deallocated, so the only thing that size is used for is deinitializing values, and since the values are usize there's nothing to deinitialize. But it's still technically incorrect.

Re: Oxidizing Source Maps with Rust and WebAssembly

#17
The get_last_error() snippet shows LAST_ERROR as being a static mut (which IIRC requires unsafe access as it's not thread-safe). But the parse_mappings() snippet shows safe access to LAST_ERROR using an API that clearly indicates it's not just an Option. I assume that at this point it's actually a std::thread::LocalKey.

Re: Oxidizing Source Maps with Rust and WebAssembly

#18

Earlier quoted context omitted.

Why do you say Rust is easier to start with than C or C++? [Disclaimer : i'm old enough to dream in K&R C and later ANSI C, and then C++, but am more than enthused about Rust, so a genuine question]

I would guess that a language in where the compiler holds your hand so you don't shoot yourself in the foot is probably by definition a bit easier than one that hides traps for you behind corner every now and then :)

While I generally agree with that sentiment, Rust's compiler is so hard to please that a lot of C/C++ developers find it hard to do it. I think for a beginner it's even harder.

C is so small a language that you can learn it much quicker. The problems surface later on.

Re: Oxidizing Source Maps with Rust and WebAssembly

#19
post #18

Earlier quoted context omitted.

I would guess that a language in where the compiler holds your hand so you don't shoot yourself in the foot is probably by definition a bit easier than one that hides traps for you behind corner every now and then :)

While I generally agree with that sentiment, Rust's compiler is so hard to please that a lot of C/C++ developers find it hard to do it. I think for a beginner it's even harder. C is so small a language that you can learn it much quicker. The problems surface later on.

What do you mean by 'hard to please'? The joke about the compiler being some beast you need to sacrifice a goat to seems to put the blame on the wrong end of the computer imo.

Unless what you are doing is not fit for what guarantees Rust gives you, the compiler should just be a crutch in case you missed a step.

Re: Oxidizing Source Maps with Rust and WebAssembly

#20
post #18

Earlier quoted context omitted.

I would guess that a language in where the compiler holds your hand so you don't shoot yourself in the foot is probably by definition a bit easier than one that hides traps for you behind corner every now and then :)

While I generally agree with that sentiment, Rust's compiler is so hard to please that a lot of C/C++ developers find it hard to do it. I think for a beginner it's even harder. C is so small a language that you can learn it much quicker. The problems surface later on.

> While I generally agree with that sentiment, Rust's compiler is so hard to please that a lot of C/C++ developers find it hard to do it. I think for a beginner it's even harder.

I think it's hard for those who carry "mindset-baggage" from C/C++. My first attempt at Rust was a failure mostly because I thought it was sort of a "weird C/C++".

Post reply on HN