This article is more than 1 year old

When it comes to ML, reports of JavaScript's death are exaggerated

Python is not the be-all and end-all of writing smart algorithms

Machine learning is fast becoming one of the high-growth areas for developers – but what language should you employ, given that so many exist?

If you believe the statisticians, Python is the default choice for many.

50 per cent of data scientists and developers use Python, with 33 per cent prioritising it for development, according to a Developer Economics survey of 2,022 people from earlier this year.

But where does that leave JavaScript? Like Python, it been at the forefront of web development for about 20 years. JavaScript has enjoyed a golden age during the last two decades thanks to the explosion in web programming and building for the browser.

JavaScript has become core to the web, the world's biggest development platform, with hybrid apps for mobile often written in JS and some cryptocurrencies that are building their apps in JavaScript because of its portability and the availability of developers.

People liked JavaScript so much, it's been ported from client to server side with Node.JS.

Has it been left behind by the Python revolution?

The short answer is yes. Developer Economics makes it clear how far JavaScript has fallen out of favour. It's fifth in usage when it comes to ML, well behind Python, C/C++, Java and R.

a canopy of tall trees in a clump in a forest, sunlight streaming through, viewed from below

Want to learn machine learning in 15 minutes? Start here...


There are, however, signs that not everything is quite so bleak for JavaScript and there's still room for the language. The Developer Economics research shows that developers new to data science and ML still experimenting with the technology prioritise JavaScript more than any other language.

Developers also prioritise JavaScript over R – the open-source language used in statistical programming taken, in recent years, into the Redmond fold with SQL Server.

Steve Purves, senior software consultant at Expero, suggests JavaScript is not yet dead in the water as a language.

For Purves, ML developers have to consider the bigger picture. "You need to start to think how to make things happen – about the practical applications." This, he says, is where languages other than Python really do have a part to play.

Online supermarket Ocado has developed a very simple model to tag and prioritise emails that were coming into the office. It uses Python. The project is not business transformative but something simple and helpful, and Python is just one very small part of the project.

According to Purves, this is a classic example of how JavaScript can be used.

"In this case, someone on mobile is connected to a little server in the cloud and that little server has connected to a big server. What happens is that you can do some work on the device, and if a bit of data is interesting then you can send it to the next level. The problem is that on high-res images, face recognition is hard – you either reduce the size of the image or apply a simple algorithm – that's accurate 60 per cent of the time.

"Or you can work out which frames to send up to the next level – which has 96 per cent accuracy. So, it can then be sent up to the next level. But the point is that JavaScript is being used on the device itself before sending it elsewhere for the computing."

So, although it's true that most of the heavy work in machine learning is going to be calling on Python, JavaScript has a place in the mix.

However, when it comes to academia and how the next generation of data scientists is being taught, JavaScript is way down in the foodchain. Ken Benoit, professor of quantitative social research methods at the London School of Economics, says that it's pretty much a choice between Python and R as to which one to use.

He says that JavaScript does play some part, thanks to visualisation abilities. "There are libraries for pretty much everything in JavaScript, including ML. It's used primarily because of this availability and how it renders in a browser. For example, one of the best graphics tools out there is D3, a JavaScript library, and can be used for pretty much anything in data visualisation. But if you're trying to do neural networks for developing a self-driving car for example, then JavaScript has no part to play," Benoit says.

Bearded hipster twins - illustration

More than half of GitHub is duplicate code, researchers find


There's a bit of a self-fulfilling prophecy here. "Why is Python massive?" asks Purves. "It's because there's a massive Python library. It will be hard to dislodge the ecosystem."

The guidance from Developer Economics is that anyone looking to go down the ML route shouldn't be tied down by what's popular or not. "There is no such thing as a 'best language for machine learning' and it all depends on what you want to build, where you're coming from and why you got involved in machine learning," the report states.

There's no indication that Python will maintain its preeminence in perpetuity. Other languages are already beginning to emerge – Julia, Lua and Torch, for example – and Python could lose some of its influence.

According to Benoit, R will become more important in future. "There's a split between people coming to the subject from a maths and statistical background – they're happier in R, while computer scientists tend to opt for Python," he says.

Purves, though, reckons JavaScript still has a part to play and the future is not an all-encompassing Python whole. As ever, it's about picking the "right" language for the job. In this case, the "right" language for the particular facet of ML or project you are working on.

"If you're building a language with a web front end you're going to be looking at JavaScript. You need different tools for different things," he says. ®


Similar topics


Send us news

Other stories you might like