DEV Community


Do you use web assembly? Help me with this 🐙

andresmontoyain profile image Andrés Montoya ・1 min read

Hi everyone, I have a question about web assembly (I don't know if someone here use it), the thing is that, why this technology has its own variations in other languages? I mean, I can write web assembly code in Python, Java, JavaScript, c#, rust, etc... But this affect the result? If I write my code in Python, will affect the performance if I write the same in rust? Or the output in both would be the same? I'm asking this because I have one idea, which is, all the heavy code that my server needs to be care, I can write in web assembly and the front end does the heavy stuff. Like for example, if I want to rotate an image and then add it some colors, instead of using a lambda function or whatever that needs a server, I can use this awesome front-end technology! What do you think? Thanks!

Discussion (2)

oliverjumpertz profile image
Oliver Jumpertz

Hey, cool that you are interested in WebAssembly! I'll try to explain some basics as good as possible. :-)
WebAssembly is a binary format, just like Java or Python has its byte code which is the thing that is actually run by the respective runtimes. (You can read more about it here:
The idea is to put something on JavaScript's side which can better be targeted by high-level languages like C/C++, Java, C# or, as you mentioned, Rust or Python and can also be used from JavaScript (like Python has a great native Interface and which is one of the reasons it got so popular beside its elegance and simplicity) easily. Some nice side effects are that it is also really fast and brings more speed to the web.
To target WebAssembly you will most likely need an alternative compiler or a plugin for your language of choice to target WebAssembly. That will also affect the resulting byte code, so yea, output may vary. BUT: It is more important to use a language you are actually capable of or like working with than worrying about performance. The differences will not be so huge that the choice actually matters, at least for a small project.
For a larger project, the quality and performance of the resulting code and also the file size may be more important but I would only start wrapping my head around that when it's time and become necessary.

andresmontoyain profile image
Andrés Montoya Author

Thank you so much for your long response!☕🎉

Forem Open with the Forem app