BairesDev
  1. Blog
  2. Software Development
  3. Can JavaScript be Used for Data Science?
Software Development

Can JavaScript be Used for Data Science?

JavaScript is a popular programming language. One that has grown in scope in the last decade. But, does it have the tools and functionality to do Data Science?

Elizabeth Moss

By Elizabeth Moss

BairesDev Business Development Executive Elizabeth Moss is responsible for partnership growth, increasing profitability, and customer acquisition.

6 min read

Featured image

JavaScript is the backbone of the internet. Created back in the 90s as a way to manipulate the content in web-browsers, it has grown both in popularity and functionality. Becoming one of the most popular programming languages in the world.

With its rising popularity, many wonder if it would be a good fit for data scientists, and for data analysis in general. The answer is not so simple. Let’s take a look at the pros and cons of JavaScript as a Data Science language.

The Argument Against JavaScript

No data scientist in their right mind would recommend newcomers to learn JavaScript first. Python, R, Scala, and Julia are often quoted as THE programming languages for data science. But why is that?

David Beazley, the author of JavaScript for Data Science, tells us in the first few pages of the book that he had originally planned to call his work JavaScript Vs. Data Science, as an acknowledgment of JavaScript’s reputation.

JavaScript is famous for its many quirks, some of them relating to the way it handles numbers. As a common example, in the IEEE 754, floating-point standard NaN (not a number) was introduced as a representation of a value that cannot be presented within the limitations of the numeric type.

In simple terms, divide by zero and JavaScript will return a NaN. Not the most informative or helpful answer. Worse yet, the language still recognizes NaN as a number, so if you check for type alone, you won’t catch that pesky rascal.

Honestly, that’s a minor inconvenience, but one that points to a much wider issue: JavaScript is dynamically typed and has a rather loose way of figuring out what’s a number or a string. Once again, nothing that can’t be avoided, but that definitely requires some defensive coding.

Handling big numbers is also an issue. Not only is JavaScript inaccurate when working with big numbers, but the fact that it doesn’t have support for multithreading or parallel processing means that you can forget about big data. Neither JavaScript nor Node.js are suited for computationally intensive, CPU-bound tasks.

Most of these issues can be navigated through, but the final nail in the coffin is opportunity cost. As a data scientist, why would you spend an inordinate amount of time learning JavaScript when you already have a plethora of languages that do it better and with less effort?

Each hour invested in JavaScript is one less hour invested in other languages… but that might not be a bad thing.

The Case For JavaScript

Beazley’s main argument in his book is that modern JavaScript has tackled many of these issues and that the JavaScript community’s interest in data science has grown exponentially in the last few years. This has fostered tools and resources that make it a competitive choice.

Perhaps the first point in JavaScript’s favor is its ease of use and readability. Case in point, if you are reading this from your computer, you just have to press F12 and you have a JavaScript console ready to go on the spot.

JavaScript is very easy to learn, and due to its popularity, there are literally thousands of resources to help you learn its ins and outs. One quick look at StackOverflow’s stats reveals that the amount of information in JavaScript is simply staggering.

Another point in its favor is that more and more companies are using web technologies with a Node-based stack to build their products. If a data scientist is going to work closely with the product developers then speaking a common language is definitely an asset.

Better yet, the fact that everyone is working with the same technology means that integration with other products and services is easier, requiring less overhead and preparation. Just like how it is easier to communicate with someone when everyone speaks the same language.

TypeScript, a superset of JavaScript developed by Microsoft, solves one of the main criticisms against JavaScript, the fact that it´s weakly typed. In fact, with TypeScript, the language is more strict than Data Scientist’s darling, Python. Statically-typed languages tend to foster better practices and less buggy code and that’s why there has been an explosion in TypeScript development companies and services.

And speaking of Microsoft, Napa.js is a fantastic alternative to Node.js if multithreading is your concern. While still in its early stages, and not the most optimal solution. It shows just how much interest there is in pushing JavaScript as an all-purpose programming language, including for data science. But that’s not all…

New Tools for Data Science

One of the most common arguments against JS is that it lacks the libraries for data science of more robust solutions like R and Python. We absolutely agree with that argument. Even the most ardent defender of Javascript will have to concede that any aspiring data scientist needs another tool in their repertoire.

The data-science landscape for JavaScript is growing exponentially, five years ago no one would have thought that TensorFlow would have a functional JavaScript library, and yet, here we are.

Having said that, the ecosystem for data science in Javascript is growing. Take for example D3.js, a popular library for data visualization that provides a fantastic set of tools to build dashboards, reports, and data stories via browser.

Another fine example is TensorflowJS. For those who don’t know, Tensorflow is one of the most popular Machine Learning libraries out there. With its JS variant, you can run machine learning algorithms directly in your browser and/or on a Node.js server.

But why would you want to do that? Yes, a browser environment isn’t the most optimized workspace. But, on the other hand, it’s very convenient for quick prototypes, small projects, and apps that don’t require a lot of memory. Why create a virtual environment when a simple browser will do just fine?

The fact that we are getting these tools for the language that powers the internet and web applications, in general, is opening the door to new possibilities. With browser-based data science, we can play with new ways to process and present data in a friendly environment.

Imagine having a web app that acts as a presentation for your data story, everything coded as a frontend solution with JavaScript, HTML, and CSS. Anyone with a smart device and an internet connection can access the results in seconds.

This surge of JavaScript in Data Science points to the fact that the field is expanding. Data scientists are no longer expected to be the person sitting in a dusty corner analyzing data. They are storytellers, who have to find ways to present their results and foster data-driven environments.

Another Tool in The Toolbox

Perhaps we are not ready for a world where knowing JavaScript is enough, but as an auxiliary skillset, it’s a perfect asset for data scientists. What’s important here is that this won’t probably revolutionize the field, but what it will do is increase its scope and reach. A net positive in the end.

Elizabeth Moss

By Elizabeth Moss

Business Development Executive Elizabeth Moss helps support and grow BairesDev by forming strategic partnerships, increasing profitability, and aiding in customer acquisition. Her previous work experience includes success at tech giants such as Adobe and Jalasoft.

Stay up to dateBusiness, technology, and innovation insights.Written by experts. Delivered weekly.

Related articles

Contact BairesDev
By continuing to use this site, you agree to our cookie policy and privacy policy.