Ldraw: Lego Modeling in Rust
segfault87.github.io
segfault87.github.io
I created this to study Rust(yes, I'm still new) and to explore what's possible with current Rust and WebAssembly. I think it turned out to be okay to continue with Rust and I'm more than happy.
Currently it comprises of a parser which reads LDraw(https://ldraw.org/) file format and a basic renderer. For now the page itself is just a single page with rotating 3d model but eventually would transform into a complete website for creating and sharing your own creations.
If you are interested you can track the development at the GitHub repository(https://github.com/segfault87/ldraw.rs) It's slightly outdated and the current code heavily relies on the bleeding edge of Rust (e.g., nightly, async await, futures 0.3, wasm-bindgen, ...) and needs to be cleaned up before pushing.
If you want more complex model you can try this instead: https://segfault87.github.io/ldraw-rs-preview/#models/6973.l...
After doing this project, how would you say you feel about this stack? Yay? Nay? I know that's a vague question, but curious if you ran into any particular troubles. I'm not sure how ready WASM is for production apps.
1. Heavy computation with no UI.
2. Stuff that renders to Web GL.
For the rest your still best off with JavaScript. 2D graphics is pretty borderline I'd say. More work in Rust+WASM, but doable.
Rust itself is wonderful, and well worth learning for the backend if you ever do that kind of stuff.
Learning Rust can be tricky sometimes. Sometimes it requires you to rethink the way how you code - especially when dealing with the borrow checker.
If you have to do async tasks (fetch, promises, ...) wait until async-await lands on Rust. It's possible on nightly Rust and wasm-bindgen git but it's not stable. Proceed with caution.
RuntimeError: "unreachable executed"
r https://segfault87.github.io/ldraw-rs-preview/2.index.js:1
r https://segfault87.github.io/ldraw-rs-preview/2.index.js:1
Gt https://segfault87.github.io/ldraw-rs-preview/2.index.js:1
__wbg_new_1719c88e1a2035ea https://segfault87.github.io/ldraw-rs-preview/index.js:1
a https://segfault87.github.io/ldraw-rs-preview/2.index.js:1
<anonymous> https://segfault87.github.io/ldraw-rs-preview/index.js:1is wasm unsupported ?
I've never used wasm before, but I am curious how people feel about the size of the binaries. I am a JS developer and am well aware how bloated a project can get quickly. I agree with the majority that we need to keep our projects lean - especially for the web/mobile, hence this general inquiry.
- I built a simple hello world in Rust (alert message) and the binary weighed 1kb - nice!
- I found some sample code ~100 lines of Conway's game of life[1] and that binary is 28kb.
- I see Ldraw weighs around 131kb - still very impressive.
I don't know yet how wasm will be used in the world professionally, and it is very exciting to me as I am really interested in Rust, but will we start seeing some HUGE binaries out there?[1] https://rustwasm.github.io/book/game-of-life/implementing.ht...
Perhaps the idea is that the user models the object entirely by writing Rust code.
Just wait for Rust to get a DOM API and MVC/data binding framework. UI responsiveness will be incredible, and webapps will feel light weight again. I see a good Rust web frontend library eating React/Vue's lunch.
Rust is not exactly easy and flexible, but everything else about it is absolutely great. I think people who will use/learn Rust are top x% or xx% developers who have decent experience in programming and probably understand pretty well how computers and computer systems work.
Javascript has democratized programming and React/Redux stack is widely accepted by developers as well as people looking after business interests in companies doing software development.
Rust would probably make world (of software) a better place, but there would be much less developers available and there already is global shortage of devs while demand is increasing. I don't see Rust replacing JS or React/Vue anytime soon.
One should not overestimate the importance of secure/fast over "gets shit done easily with minimal learning curve" on most projects.
Don't underestimate people's intelligence! (Or overestimate your own.) I think people will get it. Javascript is also very cognitive heavy.
And surely you're joking when comparing JS's cognitive load with Rust's...
Javascript without types and an IDE takes thought. You have to keep remembering which things are which type and how they get plumbed though the stack.
Honestly I'd even say Rust is easier. But I've written a lot of Rust.
Typescript with an IDE makes Javascript easier.
The "Rust is hard" meme needs to die. The language designers have worked tirelessly to ensure that the language is accessible and productive.
I can grab an average teenager without any kind of programming experience, and teach him enough in one day (maybe 2), for him to google, and copy paste him a working site with some interactive elements.
Sure it will have a ton of bugs, probably only work on his browser, but it will work.
For programming in rust, you need to have at least basic understanding of hardware model and operating systems, know concepts such as stack/heap, references/pointers etc.
Its a ton of additional stuff you need to know, before you can even start. None of that is particularly hard (well most of it). But it's a lot of it.
There are productive JS fronted developers who wouldn't be able to tell you what event based loop is.
Alas, my experience (and I've benchmarked this extensively) is that it's almost always the DOM / rendering that is the bottleneck in web apps. JavaScript isn't as fast as Rust, but it's pretty damn fast. I wouldn't expect Rust bindings to the DOM to improve much. For that kind of thing, I think we need improvements to the DOM api (and CSS layout model) itself (perhaps a more restricted opt-in fast path).