Summary
Data Science is traditionally the domain of Python; perhaps R, Swift, or Julia. Wanting to use JavaScript in this context is traditionally thought of as walking into somebody’s house with muddy shoes. Nevertheless, JavaScript for Data Science works, and as people say “if it works, but it looks stupid – it isn’t stupid.”
Below, we present the tools that developers may use to process, analyze, and visualize data with JavaScript.
JavaScript’s version of the famous TensorFlow, this is the library that will satisfy your machine learning, and deep learning needs. Announced in 2018, for many this even was a true enablement of building smart services. What’s even better, is that this solved the problem of app distribution, and compatibility with one’s OS. Why worry about platform-specific ways of handling things? Just let browsers take care of that for you!
If you want more proof, that the library is indeed useful, and not a gimmick, then we have a video for you. Here is a short overview of one of the projects, TeamSportz.Pro, with a functionality built with tf.js.
If that video was not enough to convince you, there are dozens of other examples for you to see. The team made sure you saw them, and shared them with everybody in their GitHub repository.
The Verdict
With frequent updates, backing from a large corporation, and using TypeScript to provide type safety, we have no other choice than to tell you: go for it. There simply is not much more to say.
Repository
https://github.com/tensorflow/tfjs
The sibling of the popular plotly Python package (often referred to as Plotly.py), “can be used to produce dozens of chart types and visualizations, including statistical charts, 3D graphs, scientific charts, SVG and tile maps, financial charts and more.”
Interestingly, the library also powers the more popular Plotly.py package.
The verdict
While enjoying an immense popularity in the Python ecosystem, in the JavaScript world it is not nearly as popular; partially due to the reason of different uses of the two languages. Nevertheless, Plotly.js is a reliable choice for any of your future projects.
Repo
https://github.com/plotly/plotly.js/
Chart.js is the “simple yet flexible” JavaScript charting library for those who want to visualize some data.
It really is simple to get started: below you may find a basic set up, which renders a sample chart.
The Verdict
With an effortless set-up, and immense popularity as expressed by a considerable number of starts on GitHub, it’s a solid option. The only concern is its size: according to bundlephobia it’s…~ 64 kB (minified + gzipped).
Repo
https://github.com/chartjs/Chart.js
For many, considered a standard in visualizing data. It certainly belongs to the more powerful ones. The charts & graphs one can create are quite impressive. Especially with powerful integrations available for use.
One of them is the integration with Three.js. It allows you to create some spectacular graphs that let you immerse in the data & grasp it. Literally. In VR.
The Verdict
Is there anything more to say here than “absolutely yes”? Be careful of the bundle size, however. It's 89 kB, though you may decrease it beyond that.
Repo
Math.js is a very popular scientific library for JavaScript, and Node.js. With 1.1 million downloads a month, you can’t say it’s a niche solution. The number of scientific operations supported is overwhelming, while also offers you an easy way of working with complex numbers, fractions, units, and matrices.
The Verdict
Even though “only” plain JavaScript reigns over the library, there are built-in type declarations available for you. With the plethora of functionality, popularity, and full TypeScript support, we don’t have a choice – go for it! Did we mention that the tests cover 94% of total code?
Repo
https://github.com/josdejong/mathjs
An open-source effort, to create a set of basic functionality one may use in JavaScript. Package’s name should perhaps be stdmathlib, instead. That would indicate the focus of the author to develop a package of common, more advanced, mathematical operations… and indeed it seems the author pulled that off quite well! The number of built-in functions are quite impressive. The only concern is the large number of Issues currently open. We’d say go for it, though be careful.
The Verdict
The project is fine, and very much alive. There is more than a couple of thousand stars on GitHub, showing us that there are plenty of people liking the project.
Repo
https://github.com/stdlib-js/stdlib
A “powerful mathematics and statistics library” with plenty of useful functions for you to use in your next project.
It’s a part of a bigger project, mathigon.io, aiming to form the future of education… and Fermat is not the only thing they have shared with the community.
The Verdict
Overall, the maintainers are doing a pretty solid job of staying on top of incoming pull requests. The library is also a part of a larger ecosystem, so we see it developing even further, providing developers with more and more functionalities.
Repo
https://github.com/mathigon/fermat.js
Note: All libraries below may or may not run your code. We advise against using them in production apps, though ultimately, it is your choice.
Can’t say goodbye to your favorite data science libraries, but need to run them in a web browser? Even though we cannot say we are using JavaScript, we do remain in the realms of the same world.
Remember, though, that some of your favorite projects might not run in browsers. That is due to all the bindings to C/C++, and other features. Though maybe in the future we will have JavaScript libraries that use your GPU for the heavy lifting: developers are already exploring what’s possible.
Pyodide lets you run your Python run in browsers. The best aspect?
Pyodide makes it possible to install and run Python packages in the browser with micropip. Any pure Python package with a wheel available on PyPi is supported. Many packages with C extensions have also been ported for use with Pyodide. These include many general-purpose packages such as regex, PyYAML, lxml and scientific Python packages including NumPy, pandas, SciPy, Matplotlib, and scikit-learn.
If you are not a fan of Pyodide, there is another solution for you. RustPython allows you to run build a web app that will run Python code. You may even ship a full Python compiler to your users (should you need to do so for whatever reason).
Julia is a relatively new player on the market, with the emphasis “high performance”, while aiming to feel like a scripting language. This eliminates some drawbacks of the traditional choices for high-speed computing.
While you may write any app you may want with Julia, the consensus is, that it is tailor-made for scientific computing. So if you can’t live without some library, or just love the language that much, you should give Charlotte a try.
Swift’s legible syntax, and high performance, makes the language attractive to the data community. Need your code to run in Chrome or Firefox? Go to https://github.com/swiftwasm/swift, and follow the instructions.