Ask HN: What are the best resources to learn Rust in 2025?
5 points by _Crownwell 13h ago 6 comments
Ask HN: Ideas to acquire "good taste" in programming?
6 points by danielciocirlan 1d ago 10 comments
Rust and WASM for Form Validation
45 slau 23 7/4/2025, 12:24:50 PM sebastian.lauwe.rs ↗
The UI is here https://loda-lang.org/edit/?oeis=2487
It can run from commandline for mining.
Implementation https://github.com/loda-lang/loda-rust
Everywhere the author used `unwrap` is a place where I would expect the program to crash if the operation fails, so I'm not sure what they imagine "proper error handling" in this case would look like. Take this snippet for example:
In javascript that looks like this: At a glance, the web-sys docs don't say, but I assume the error conditions that would trigger those `unwrap`s are:- The `window` global is missing or the code is running outside of the browser
- The `document` global is missing
- The page has no form element with an id of "login"
I don't see a reasonable thing to do in those cases except crash.
A more general point: I find WebAssembly works best when:
- Interfacing with the DOM and web APIs is still mostly done in javascript
- The wasm binary has a narrow interface consisting of a handful of functions with careful calling conventions
- The wasm binary avoids dependencies on either third-party packages or the standard library (e.g. rust's "no_std")
- The compiled code generously uses mutable "global" variables (note: local to the wasm module instance)
The rust + wasm-bindgen + web-sys strategy feels like the exact opposite of this, which doesn't strike me as very useful unless you just want to avoid writing javascript entirely.
WASM should be left to things like IPC/Canvas/WebGPU stuff, not things easily done with document.querySelector
No offense, but this is using a bomb to kill a fly.
I know it says this is just a demo but people will find this and do this thinking it’s normal.
Not great, not terrible.
What kind of validation are you going to do without a regular expression?
https://html.spec.whatwg.org/#email-state-(type=email)
But it is true that you can implement it with a FSM(which is what firefox does). Webkit uses a regex as well I think.> I’m using form validation as a placeholder. It shows all the crucial aspects to use WASM instead of JS, like wiring up DOM events to Rust functions, and then reacting to those events.
Of course there's always the argument that you'd add more javascript to "framework-ize" this a bit more, but the rust code is just targeting the DOM with IDs, so I don't think it's fair to compare it to any "framework-y" solution.
https://developer.mozilla.org/en-US/docs/Learn_web_developme...