Which scripting language should we use?

which scripting language choose

As a developper it’s a question that you often have to ask, since a good developer is a lazy developer (Three virtues) we usually use the language that we “master” but is it always a good solution?

In our application we have the following stack :

  • AngularJS for the webapp
  • Java for the backend
  • MongoDb for our database

During our development phase we often have to develop some scripts to update our database, change the configuration etc. and have to ask ourselves which language should we use. We currently have 3 types of scripts (of course the following languages can be useful in many other cases but we will keep the scope to the scripting in this article) :

Creation date : 1990

Last version : 3.6.0 (December 2016)

Package manager : PIP

Object oriented language

Easy to learn

Large community

Creation date : 2009

Last version : 7.4.0 (January 2017)

Package manager : NPM

Javascript

Easy to use if you know javascript

Use asynchronous mecanisms

Creation date : 2003

Last version 2.4.7 (June 2016)

Allow the use of java libraries

Java

Easy to use if you know Java

STATISTICS

Every year stack overflow does a big survey (~50 000 votes) to analyze different aspects of a developer work, you can see below the most popular technologiesCheck it out!

stack overflow survey

So, what does this chart teaches us?

We can see that only 0.34% of the answers are about Groovy, it’s probably biased as Groovy uses Java, but what’s more interesting is that Java and Python are almost at the same level (roughly 30%) and NodeJS 17.2% (but uses Javascript).

REAL LIFE EXAMPLE

In order to compare the three languages, we developed a simple algorithm which find a document in our mongoDb database, updates it and then find it again to show the result.

Python

python update db mongo

~10ms

NodeJS

nodejs update db mongo

~40/50ms

Groovy

groovy update db mongo

~15/20ms

On those examples we can see that:

  • Python uses the less lines
  • The async behaviour of NodeJS makes the algorithm harder to understand for people who are not used of reading Javascript
  • The queries are more complicated to write in Groovy
  • Python and NodeJS have a syntax similar to mongo

As a conclusion, in this example we can see that the simpler language seems to be Python.
I would personnaly recommend Python because of his simplicity, even though NodeJS allows us to directly use JSON object.
We can see that NodeJS is significantly slower than the two others languages.

PERFORMANCES

Depending on the use case, looking at the performances can be interesting while comparing different languages.
We’ve already seen in our previous example that nodeJS seems to be slower than the two other languages, now we will compare the performances
on differents algorithms.

We can see that nodeJS and Java are faster on 3 of the 4 algorithms, but each language has his own specifity.
What’s really interesting is the CPU load, nodeJS uses less CPU than the other 2, it can be useful if your program does heavy calculations for example.

CONCLUSIONS

So now, which language do I chose?!

I don’t think that there is a good answer to this question, it always depends on the use case.
To chose a language, in my opinion you need to answer the following questions :

  • What kinds of languages are my team comfortable with?
  • What kind of applications do I want to build?
  • Do I really need to take the performances in consideration?
  • How easy is it to recruit for this platform?

When the team has answered those questions, just pick a language and stick with it, coherence is the key, don’t use 3 differents language to do the same things.

At Dexstr we’ve decided to use Python scripts which is more in adequation with the world of data science.

Léo, Front end lead developper.

Share on LinkedInTweet about this on Twitter