Member-only story

How to use your native library in Javascript world

sendilkumarn
3 min readDec 10, 2017

--

Do you have an existing library in native languages (like C, C++)?

Have you ever wondered or wanted to use that library in your node application or browser?

If you have answered ‘yes’ for both the questions, then this post is for you.

WASM is yet to have fully spec’ed Garbage Collection, which also delays the direct DOM interaction via the WASM. So, if you ever want to interact with your DOM, you have to wait. Garbage Collection is something that can be expected in a year. 🦄

So consider that you have a native application, that is blazingly fast (as we all know)🏃. How cool will that be, if we get those benefits on the web straightaway?

🗒 Yet I have a personal feeling, that there is no stronger case to use web assembly. It definitely promises a lot and offers easy wins. We still have to wait and see how they mature and use them in more optimized way

The first step is to convert your native application into something that is understandable by the browser or node with tools like emscripten / binaryen

Wait, What?

Take your native application. consider that the application is written in cpp.

Specify the cpp compiler with -std flag, currently only the version11 is supported. The flag -O2 instructs the compiler to generate the output with more Javascript optimizations and LLVR optimization.

--

--

sendilkumarn
sendilkumarn

Written by sendilkumarn

🚶explorer, learner. Docendo discimus

No responses yet