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.

Where Next?

Popular Frontend topics Top

AstonJ
I like it! https://daneden.github.io/animate.css For those of you who visited hello.forum.devtalk.com you’ll have seen it in action on ...
New
andresriveros
I’m very interested in the Stimulus reflex approach for frontend development: It is a great way to integrate action cable very easily ...
New
AstonJ
Sprinkles of JS, or full frontend frameworks? What do you use and why?
New
First poster: bot
Why do ARM chips have an instruction with Javascript in the name (FJCVTZS)?. FJCVTZS is “Floating-point Javascript Convert to Signed fix...
New
finner
Some resources for Spring Home of Spring Spring Initializr Head First Spring with Reactor
New
AstonJ
Just discovered AssemblyScript (our portal is here). It…“aims to make it easy to compile to WebAssembly using TypeScript, no strings att...
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
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
KnowledgeIsPower
Hey, I have migrated by blog from Pelican to Astro (static site generator) Please give comments or feedback, thanks!
New
guaip
I’ve been doing front-end as a freelancer for 15 years. I have some PHP background and still do some backend stuff to this day, but I spe...
New

Other popular topics Top

AstonJ
Or looking forward to? :nerd_face:
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New