Hacker News new | past | comments | ask | show | jobs | submit login
Rust programming for web developers, by a web developer (codeamigo.dev)
154 points by plondon514 8 days ago | hide | past | favorite | 31 comments

Copy-pasting the if/else code (step 2) and then executing resulted in it spinning for about 20 seconds before I lost interest and killed it. The "Hello World" (step 1) did complete, after about 6 seconds.

Works for me, looks like your internet might be slow, at least when connecting to this site, as I believe it works by running the code in the cloud and streaming the results to you. Or perhaps it works on the machine, not sure.

Since Rust can compile to JS and WebAssembly, and Rust's compiler is written in Rust... could you compile Rust in a browser?

The hardest part would probably be getting LLVM (written in C++) to compile to webassembly, since that's what rust uses as a compiler backend.

It takes some work (mostly due to LLVM building code to run later in its build system as it goes), but it's very feasible. LLVM has been ported to Wasm (and before that to JS) many times, for example:

https://github.com/jprendes/emception (2021)

https://github.com/tbfleming/cib (2017)

https://github.com/kripken/llvm.js (2012)

I agree it would be great to see this repl running 100% in the browser!

I have been waiting for this to emerge for a few years, but I assume that it must be very difficult because it hasn't happened yet.

It's probably difficult and also seems mostly useless, right?

It's inconsistent for me - sometimes it runs fine and runs almost immediately, sometimes it hangs for a long time.

back button does not work. Bad site. No treat for you.

Thanks for the feedback (get it?)

Should be fixed now :)

This is a pretty cool idea. Thanks for investing time into making these. There's a few unsolicited (That's the way we do stuff on the Internet :P!) usability/UX improvements that I would like to suggest:

The stability of the compiler endpoint/service is really finicky, and it performs poorly (those could both be related to load issues, maybe it's just front-HN-page syndrome). Not sure if it's possible to replace it with another one or try hosting your own perhaps?

The code transformations are really unpredictable. Sometimes it asks me to copy/paste code, sometimes it starts with its own version of the code. Sometimes the next step "undoes" my fixes (I know Rust so I was "rushing" ahead with some changes, which is my fault). There's a few ways that could be done here, but IMHO the best would be to have a "use this snippet" button and to just not touch the code from the previous step. If the lessons have chapters and you want to set up the editor for the user, that's fine, but make sure it's obvious someone's moving onto the second chapter of the tutorial. At the end of the day, if you choose to just have manual copy-and-paste (the least ergonomic choice, IMO), that's also fine, but just make the experience consistent and predictable.

The layout is extremely disorganised on the page. There's a giant disconnect between the console, the editor, the run button, and the hints, and the test results. There is no well-defined user flow on the page, interactions feel very erratic. I can't offer any ideas here for how to fix the layout, because it will get very wordy. To sum it up though, the page needs more structure/hierarchy. This will also create space on the page, so you will be able to use some whitespace/negative space to create hierarchy too (it's a bit of a chicken & egg problem lol).

Lastly, the "checkpoint" doesn't always pass when it probably should, because there's no hint as to why it didn't pass, apart from a compiler warning. The compiler warning is important and should be fixed, but a couple of times it was simply because the injected snippet came with "previous" problems that distracted from the step/instruction at hand.

I can't really comment on the quality of the tutorial since I stopped after 16 steps; I couldn't keep going any more because I was incredibly worn out by the poor UX. Proceeding to the next step was was always some struggle in relation to UX, and not the content of the tutorial.

With that said, some things for content until step 16, I think some concepts are a bit inaccurately explained, but I suppose one could let that go because you wanted to keep the tutorial short.

Back to the drawing board. I have been spending a lot of time on lesson creation, because that's what I've been doing, then I run through the course because I made it and I know how to pass the tests. I'll need to take a step back, gather more feedback, and address the problems you've raised.

As for the unsolicited feedback, thanks!

Keep up the good work! I love interactive learning as a concept, and I think you're already most of the way there. Most of my complaint was more design related than lesson related.

I realised later that I can jump to lessons, so I skimmed what the rest of the content is. I think content wise it's good. Given its "Rs for web devs," my comment about inaccuracies might've been unfair. I assume the lesson meant to be bite-sized and playful/exploratory. So, its in a good format for that.

While I'm here, does anyone know anyone at indie hackers? I'd love to get in touch with them...

Writing web app Rust for some time now, love many things but really miss a GC.

Could I ask why? do lifetimes not do it for you?

Not OP, but lifetimes are pretty brutal in many cases. Consider deserializing a struct with fields that are borrowed--I'm not sure if it's straight-up impossible or just prohibitively difficult, but it's painful. Not an issue with a GC language.

I'm still rooting for Rust, but it's not for everything (yet).

Life times are either easy for trivial matters or add a lot of boilerplate in the other cases.

Many people just go RC<> but then you have RC<> everywhere.

I do understand the motivation to have lifetimes and no GC, and it's cool, but it makes things that are trivial in a language with GC often difficult in Rust (the problem might be with me only as I've stopped working with C around 1995 and have been on GC/automatic RC since then, starting with Perl).

why doesn't the back button work

"Please don't complain about website formatting, back-button breakage, and similar annoyances. They're too common to be interesting. Exception: when the author is present. Then friendly feedback might be helpful."


I believe the author is present, and this should have been a [Show HN]. The submitter's username matches the author's username on the site, and the submitter has replied to feedback comments as the author would.

(Not the previous commenter, yet thought this context was the most relevant)

10 years from now there will be something else that people complain about in unison. This rule isn't helpful nor forward-thinking.

We can always update the examples. The principle of not commenting about superficial annoyances is unlikely to change, and I think it's helpful (that's why we added it! actually, users asked us to add it, IIRC).

Because… JavaScript.

Note: I had to disable uBlock Origin on the page for the "run" button to actually run the code.

Interesting, I'll need to look into this, thanks!

I dunno if you changed it by now, but it works for me with uBlock Origin. Perhaps OP is using different filters or rules.

As first I thought this is about "Rust programming concepts that can benefit you in JS as well", but this way it is good too. And maybe just my bad english anyway.

agree, I can't tell how this is Rust programming for web developers. It assumes we are all very beginner level web developer?

However it is cool to see so many Rust posts recently. Or maybe I am noticing them more since I am getting into Rust.

Not your English — it's definitely ambiguous.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact