Which scripting language should we use?
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
Creation date : 2009
Last version : 7.4.0 (January 2017)
Package manager : NPM
Use asynchronous mecanisms
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 technologies. Check it out!
So, what does this chart teaches us?
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.
On those examples we can see that:
- Python uses the less lines
- 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.
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.
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.