I am trying to develop an (web and mobile) app which heavily relies upon linear algebra. The app is primarily about image processing. I am trying to find a suitable package for the requirement. Being a python developer, I know about numpy and scipy which used blas/lapack for fast computation.

Is there anything like this(numpy) in javascript ? I am currently prototyping in reactjs, but eventually I would move to react-native.

P.S.: I have tried some of the packages like numjs, ndarray and vectorious. However, I am not sure they can provide sufficient speed in react-native.


If you're doing image processing, you're probably using OpenCV, which has support for Android since 2010 and iOS since 2012. react-native-opencv takes advantage of this cross-platform support to propose React Native bindings with this library. This tutorial does a step-by-step explanation about how to integrate OpenCV with React Native.

Besides that, unfortunately, there are not really any JS lib that are optimized for algebraic computation. @kgryte already wrote an excellent answer on Stack Overflow explaining why - I won't duplicate information, but it basically goes like: there aren't really any hard technical barrier, but not a lot of people need to do efficient computations in JS, so there aren't a lot of library doing that, further pushing the dev requiring efficient computations to other languages, and so on - vicious circle!

Let's note that with the rise in popularity of JS, Google has recently made its renowned deep learning library TensorFlow available in JS, with NodeJS and browser optimizations. Nothing is precised in the docs about mobile optimizations, I guess for the following reasons (which are also valid for explaining the non-existence of computation-optimized React Native libs):

  • The mobile is not often viewed as the right place for expensive computations, because of low speed and high battery usage
  • If mobile JS is used as a webview, there are several layers between the JS and the hardwware (JS / JS engine / Browser / Native layer), each of them slowing down the code
  • If mobile JS is transpiled to native code, as in React Native, transpilation is often performed at the expense of native API reduction and speed optimizations, both slowing down the code
  • If an app needs to be fast, it is often directly written in native code, so, no React Native

In a nutshell, there isn't any JS lib optimized for computation in React Native (besides the ones you precised) because it would be quite a bad developer choice to both require fast computation and the usage of React Native. The only choices that are available to you are React Native bindings for libraries written in native code, like OpenCV.

  • Thanks for the explanation. I guess I have to find some other alternatives (except js) to solve this problem. – Lau Kumra Apr 13 '19 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.