Book Review: JavaScript for Data Science (2020)

Disclaimer: all screenshots were produced from the digital version of the book, but I do own a physical copy of it.

alt text

Though most entries on this website usually consist of hands-on guides and random programming tutorials, I will from now on try to share some books or articles that I have read and found interesting.

I remember first hearing about JavaScript for Data Science on Twitter, as I was looking for a Pandas-like package for the Node.js ecosystem. It only took a few days for my copy to arrive, and to say that I was somewhat disappointed when I first read through it would be an understatement.

For some reason that I will try to explain further down in this article, I however found myself going back to it times and times again over the weeks that followed, picking up here and there various concepts that I wasn’t necessarily very familiar with.

So is this book worth your time? Absolutely, provided that you are fully aware of who its target audience is, what it can teach you, and what it can’t.

A great book, a bad title

I have read a fair amount of criticism about this book, both on Amazon and on Hacker News, and I must say that I find those negative reviews a bit harsh. What’s most surprising is that the majority of that feedback doesn’t seem to be related to the actual content of the book, but rather to the misleading nature of its title: JavaScript for Data Science.

alt text

Funnily enough, the authors themselves seemed to be quite aware of this potential issue when they published their book, as outlined in the opening chapter:

“David Beazley thought that “JavaScript versus Data Science” would be a better title for this book. While that one word sums up how many people view the language, we hope we can convince you that modern JavaScript is usable as well as useful. Scientists and engineers are who we were thinking of when we wrote this book [..].”

As a matter of fact, I personally think that a much better title would have probably been “JavaScript for the data scien tist. The reason why I’m saying this is, as we will see further down this article, that “JavaScript for Data Science” actually contains very little about data science.

See for yourself:

Table of content
Chapter 1: Introduction
Chapter 2: Basic features
Chapter 3: Callbacks
Chapter 4: Objects and Classes
Chapter 5: HTML and CSS
Chapter 6: Manipulating Pages
Chapter 7: Dynamic Pages
Chapter 8: Visualizing Data
Chapter 9: Promises
Chapter 10: Interactive Sites
Chapter 11: Managing Data
Chapter 12: Creating a Server
Chapter 13: Testing
Chapter 14: Using Data-Forge
Chapter 15: Capstone Project
Chapter 16: Finale

Something just doesn’t feel right, eh? Where are we going to find the usual Supervised / Unsupervised / Deep learning chapters that all data science books contain? Well here’s the thing: we aren’t. And this, dear reader, is precisely what I think makes this book a must-read.

A book for data scientists, but without any data science

You’ve already probably guessed it: reading “JavaScript for Data Science” won’t really show you how to perform any data science-related work using the JavaScript language. So what are we in for then?

Well a lot of the data practitioners that I know are extremely knowledgeable in their field, but might not have had much practical exposure to anything outside of their core competencies. And that’s perfectly fine: it’s impossible to know everything.

The goal here isn’t to turn you into a full-stack web developer, but to teach you enough JavaScript to help you boost your data science projects.

What this book does indeed very well, is show a data scientist who’s already very familiar with either Python or R and machine learning concepts, how to utilise the most popular programming language in the world as a perfect complement to their regular tech stack.

Should you ditch Python altogether and run your deep learning models in JavaScript? That doesn’t seem like a good idea. At least, not at the moment.

But what if you instead wanted to, say, build a web app that shows the loss of that same model as it learns? This time, using JavaScript would make a lot more sense.

Data visualisation in general (including dashboards), dynamic reporting, and exploratory analysis are all perfect use case scenarios for developing rich responsive UIs. And no language can beat Javascript when it comes to these.

JavaScript 101, Website 404

As you might expect from pretty much any technical book, the authors start with a short introduction to the basics of JavaScript. But don’t expect to spend more than a couple of chapters to cover the fundamentals.

You’ll indeed soon realise that pretty much everything that the authors assume that you should already know if you’re coming from Python or R, is either skipped or only partially covered. A good example of this, is the fact that very little time is spent explaining what NPM is and how it works. As their primary audience are data scientists and practitionners in general, it is assumed that you are familiar with either PiPy or CRAN, and that you should therefore have no difficulty adapting to a new package manager.

Which makes sense. As the book is rather short (175 pages) and nonetheless covers quite a wide range of topics, you will only be shown a high-level overview of each covered topic. Yet, I found the content to be quite informative and very clearly written, with an emphasis placed on laying the groundwork before inviting the reader to discover more on their own if they so chose to.

“JavaScript for Data Science” will however teach you everything you need to know about paradigms that you might not know, such as callbacks or more importantly promises. The assumption again here is that though Python does support asynchronous programming, your daily job as a data scientist probably hasn’t exposed you much to what is a very important part of everyday programming in JavaScript.

Rather than teaching you another language to do the exact same thing that you’ve been doing for years (hey Julia!), this book shows you all the cool stuff that JavaScript is very good at and that could enhance your creativity as well as help you think how you approach data science problems in a different way. We’re talking here about creating a web application with Node.js or React, brushing up on your HTML and CSS skills, learning how to parse JSON files, getting familiar with powerful data visualisation tools like Vega Lite, etc..

alt text

Oh, one last thing: I personally found this “we’ll just show you how XXX works but there’s plenty more you can learn about it if you’re interested” approach to be particularly well-suited for the targeted audience. This book will point you in the right direction, never overstaying its welcome.

On the downside, every chapter of this book used to be available for free on a dedicated website that unfortunately no longer seems to be active. Please note that I’m writing this article over 3 years after the initial release of the first edition.

Why is it good then?

At this point, you might still be thinking that reading “JavaScript for Data Science” is not worth your time, while I think it actually really is. I’ll even go as far as saying that it’s a must have for any data analyst or data scientist.

The misleading title will force you out of your comfort zone, show you how to implement your work differently, and introduce you to a bunch of concepts that you might not necessarily have had a chance to encounter. What I’m trying to say here, is that you probably already own a few books about data science in R and Python, a couple more on statistics, and a few other specifically about machine learning.

To quote a user named bluishgreen on Hacker News:

“Taken in that context this is an excellent book written with empathy for the Data Science user who is usually making uneasy excursions which they hope and pray is only temporary into Javascript and running back to Python the first time they encounter a Promise or a Callback.”

alt text

Actually, my main gripe about this book, is that it should have misled its potential readers even more. Some chapters on minimalist CSS frameworks such as Pico.css, or React Native and Electron would have made “JavaScript for Data Science” even more enjoyable.

Suggestions for a second edition

Since the original release of the book in 2020, the JavaScript data science community has been very active. I’d love to see some if not all of the following topics covered in a new version of

  • A better alternative to Data-Forge, preferably Arquero (read my article on Arquero here)
  • A Jupyter-like notebook environment such as Starboard (also check out my article here)
  • An overview of the popular ObservableHQ data exploration platform
  • A more comprehensive plotting library, like Apache eCharts for instance
  • I personally have zero interest in writing CSS style sheets from the ground up, and instead rely on the power and simplicity of minimalist CSS frameworks. You’ll find some examples in an article that I recently wrote

Further reading

  • Maya Gans, one of the authors of this book, has some very interesting data science-oriented videos on YouTube, like this one for instance:
  • Amelia Wattenberger’s “Fullstack D3 and Data Visualization: Build Beautiful Data Visualizations with D3” is, in my humble opinion, a must-have for any data practitionner who wants to powerful JavaScript can be for data visualisation

alt text

  • Burak Kanber’s “Hands-on Machine Learning with Javascript” might also be a good entry point to the JavaScript ecosystem for data science enthusiasts, but I must admit that I haven’t had the chance to read this book

alt text

What’s next

I firmly believe that the data science industry as a whole should rethink how the work it produces is ultimately shared and consumed. I would love to see more ingenuity in how we are making make datasets and model outputs accessible to the non tech people that we collaborate with.

Data scientists should have their say in the writing of the tools that interface data with humans because of their domain knowledge. Ultimately, this is of course the work of software engineers, but I really do encourage all data practitionners to develop their front-end skills. I think it’s well worth the effort.

Are you tired of writing the same Jupyter notebooks over and over again? Why don’t you build a small web or mobile app for your next data science projet?

The NPM ecosystem is a great place to start if you’re interested in brushing up on your JavaScript skills. Give the following packages a try:

I really like this boook, I love JavaScript, and so should you!