AstonJ

AstonJ

Swift vs Rust for WASM/WebAssembly

Wondering if anyone has any thoughts on choosing between these two languages for WebAssembly?

I definitely want to explore wasm, and really love the idea of learning both of these, however, I can only squeeze one in right now.

Anyone have any thoughts? Which might be the easier route? Which will be more useful/fully featured/supported? etc.

Here are some pros and cons (from a personal perspective so far):

Rust

  • Can also be used with Elixir/Erlang nifs
  • Can also be used in other areas such as general web dev
  • Huge community support

Swift

  • Can be used for iOS/macOS apps
  • While can be used for other areas (such as web dev too - I get the feeling not quite as well as Rust)
  • Huge Apple support

Most Liked

SmithyTT

SmithyTT

Rust.

Swift for WebAssembly is not quite there yet…

herbert

herbert

Author of Hands-on Rust

I don’t have a lot of experience with Swift, so I can’t really comment on it. Rust works very well with web assembly (some assembly required, heh). One of the reasons I picked up Rust was that it made it easy to write tutorials and include a web-runnable version (my Roguelike Tutorial series has each example as a playable web game - e.g. https://bfnightly.bracketproductions.com/rustbook/wasm/chapter-74-darkcity/ ).

There are downsides. If you link with C libraries, chances are you have to come up with some shims to handle the bits of the C library that don’t exist in WASM-land. Also WebGL is almost but not quite compatible with regular GL - so for graphics you’ll have to tweak things a bit.

herbert

herbert

Author of Hands-on Rust

I may have messed up the link, sorry! http://bfnightly.bracketproductions.com/rustbook/ should work.

Rust is a systems language, so its harder than Python and other very high-level languages. It tries really hard to not surprise you, and once you have the basics down it’s a relatively smooth learning curve. Some things - like threads - are much easier than other languages. Other things like the borrow checker will cause a bit of head-scratching at first.

Popular Frontend topics Top

New
AstonJ
DHH might like you to believe they are a thing of the past: https://twitter.com/dhh/status/1275902566719610880 I actually went down thi...
New
pippo12
Hello, I hope you have some tips for me. I am looking for further education including certificates (or similar) which are also accepted ...
New
mafinar
Just like I did one on Tailwind some time ago, I am going to play with AlpineJS the next few days. It’s a nice little JS framework that ...
New
ClaudiaGiv
Hi all, I recently started working with Svelte and created a small app with SvelteKit in order to understand better the framework. I hav...
New
First poster: bot
A 3D racing game built with ClojureScript, React and ThreeJS
New
SynergyRob
I invented a game of double Chess called Synergy Chess. I am not a coder. I hired someone to write the program. People can play online fo...
New
harwind
Why does the image in my <img> tag appear larger than its specified width within a flex container? Here’s my HTML and CSS code: HT...
New
DevynClark
Does anyone know of any companies that are accepting remote work for junior front-end devs or UI designers? I’m not even looking for some...
New
jaeyson
Hi Elixir and React friends! I read a post (Stephen Bussey - React in LiveView: How and Why?) on use case for reaching react for complex...
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
New
AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
PragmaticBookshelf
Author Spotlight Erin Dees @undees Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New