4 comments

  • frabia 38 minutes ago

    what's the benefit of UIs in the canvas with Rust, as opposed to HTML/CSS/JS?

      zionsati 27 minutes ago

      For a lot of front end devs, CSS/JS are frowned upon. We use it because we have to. In fact, we typically avoid JS by having TypeScript transpiled to JS. Not to mention CSS is still very inconsistent across the various browsers.

      Porting HTML/CSS/JS to native apps is another big problem, which is why we ended up with Electron/WebView. The amount of RAM it gobbles up just to run simple apps is pretty horrible.

      Why Rust? It's a strongly typed application language across browser and native. It also has a massive ecosystem and this allows us access to all of it.

      BTW canvas is only the renderer. There's a lot of engineering that went into making the canvas not a typical "canvas UI app". We have solved accessibility, touch gestures, direct/immediate draw etc.

      There's more reasons behind this if you're keen, I've written up a more comprehensive doc https://dev.to/zionsati/html-javascript-css-should-have-died...

        frabia 18 minutes ago

        ts is superset of js, so I wouldn't say you avoid it. It's like saying you run to avoid walking.

        On the web, I get that CSS is not straightforward, and HTML is not the coolest technology, but by using the canvas you also lose a lot stuff that you need to rebuild from scratch: accessibility and interactivity, responsiveness, etc. So the only argument that I'd buy is that it has lighter & more performant UIs, which I get it might, given that the canvas uses the GPU, but is it worth the effort? Like, is it THAT much better?

        I get the argument of native apps though. I guess if you want to build one interface and serve it both as a web and native app, it could make sense.

        Edit: thanks for the link - I'll look it up. Also I didn't mean to sound too annoying. I'm starting to see UIs built in Rust but I'm still struggling to see the hype.

          zionsati 3 minutes ago

          Yeah all good. They're all good questions.

          My point around ts is people want strongly typed languages these days.

          The bigger problem with HTML/CSS is, when you're trying to do more sophisticated things (see the immediate drawing page on the demo), you'll find you need to use a canvas/HTML5. That then becomes a mini UI framework of its own...

          For simple webpages, HTML/CSS is probably still the best way to go. But I wouldn't say the same for webapps?