Picking the right language for the task..


In the past year I had to juggle multiple programming languages much more intensively. While it helped me to improve my skills and refresh, I also came to some conclusions.

Knowing to select a language for a task, knowing these languages and their capabilities is useful in RnD area as time and effort can be saved in writing the code and focus can be put to the actual research.

Below views are my personal opinions based on past experience. They might not be the most correct.

C/ C++

Best for high performance, real time work. Can be a hindrance for quick testing or prototyping. My usual setup is CMake + C++, commonly used for OpenCV projects, etc. I’m not very happy when it comes to things like REST calls, JSON objects…

IDE support can be sometimes bit annoying, esp. finding an open source one, they tend to hog memory or CPU. I use QT Creator, VS Code ( != visual studio**) and just plan text editors.

Yet when written well, its in it’s own class of beauty 😛

Python

After a long pause, I got back to using python. I paid more attention on code quality, learnt more of specific python3 matters.

Quite nice for quick prototyping, etc. Can handle many things well. Specially scientific calculations, matrices, etc got excellent support with libraries such as Numpy and Scipy. In essence, it is entirely possible to use Python in place of Matlab and can be quite faster and of course free of charge.

These libraries are good in performance too, thanks for nice support for calling C/ C++ API’s from python, computationally intensive algorithms can be written in C/C++ and wrap around Python. (C++ calling from Java was a nightmare in comparison). This same feature would be useful when providing Python API’s for C/C++ libraries or calling computationally intensive, optimized algorithms.

I’m not very convinced of production-level code, probably better to convert to Java or C++ (or use a wrapper?) when bundling. These questions mainly arise when dealing with proprietary code that has to be deployed to customers. There is bytecode based distributing option like Java, but I don’t know much about options.

Python definitely do better than JS for prototyping, esp. matrices, etc stuff.

JavaScript

Alright for quick prototyping with NodeJS. Being a born-in-browser language, it’s support for web and related things, async programming is nice.

However, for larger projects, consider writing in Typescript or similar typed language for better code quality and ease of debugging/ IDE support.

There is at least 2 libraries for everything, but finding a feature-complete, good ones isn’t that easy. Don’t even bother to do matrix calculations or “big-data”/ statistical stuff in this 😛

I rather stupidly implemented a camera calibration tool on JS since the debug framework was NodeJS + browser, pretty much wrote everything including a bug-freed Levenberg Marquardt solver.

Java

Despite “write once, run anywhere”, C++ is preferable on some ends (with many FOSS libraries available in most platforms). Java can do pretty much everything like C/ C++, but that doesn’t mean it should be used for everything!

However deploying in many platforms is easier with Java . Yet I don’t fully agree on “enterprise grade stuff is written in Java” story.

I believe Java usage in Enterprise environments got accelerated with Sun certifications, hardware, the very nature of JVM and there are many mature tools written in Java. My disagreement comes because there are better tools out there for certain jobs but some people cannot do anything without Java which can become a bottleneck in RnD environments.

Languages/ frameworks should be chosen for the task and situation, not by the fact the programmer or system architect is __ years experienced with Java based systems.

PHP

This used to be my de facto choice for server side web apps, rendering, etc. WordPress, Joomla, etc are written on PHP!

It’s quite fast (According to a recent benchmark I saw, PHp7.0 is only slower than -o2 C++ code. In the sense of variables typing, PHP is similar to Javascript and the code can look very messy.

Decent looking and readable code can be written in PHP with good use of classes and using well made frameworks. In terms of web-servers, Java tend to be generally slower in this area, and PHP is optimized and pretty much made for this job.

Conclusion

While it is possible to do pretty much everything from all these languages, it should be noted that all of these languages are written in C/ C++ in general – why? performance. But that doesn’t mean everything should be written in C/ C++.

Some people like to write everything in Java, C/C++ or Python, what I wanted to point out in this rather entangled and not-so verbose post is that tools are there for convenience and to get the job done!!

Don’t use a sledgehammer to crack a nut
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s