Which Language Should I Use?

(Ref Id: 1391901692)

Choosing a language for LIMS development often boils down to which one(s) your lead programmer is most comfortable with. However, leaving this important decision to chance can be a recipe for disaster. At a minimum the language choice should take the entire development team into consideration.

Let's say Developer A writes in C++ and another writes her code in Java. Developer A leaves the company. What happens when the C++ code needs to be modified or a bug needs to be fixed? You need another C++ developer.

Let's look at an example using conventional C++ and Java.


using namespace std;
class HelloWorld {
public:
string helloWorld(){
cout << "Hello World" << endl;
}
};
int main(){
HelloWorld w;
w.helloWorld();
return 0;
}

Note: The above is compiled using g++ HelloWorld.bad.cpp -o HelloWorld.o

Now let's look at the same program written in Java:


1 public class HelloWorld {
2
3 String helloWorld(){
4 System.out.println("Hello World");
5 }
6
7 public static void main(String [] args){
8 HelloWorld h = new HelloWorld();
9 h.helloWorld();
10 }
11
12 }

This is compiled using javac HelloWorld.java

Both of these code snippets actually have the same error. Look closely at the helloWorld() method in each of them. They are declared as string, meaning that they should both return a string datatype, but the methods are not returning anything.


The Java compiler catches this and refuses to compile it:



./HelloWorld.java:9: missing return statement
}
^
1 error

But the C++ compiler does not fail to compile (even if you include the all-important -Wall warning flags):



./HelloWorld.o
Hello World
Segmentation fault

Would your average developer know how to figure out what the cryptic 'Segmentation fault' was eluding to? Would they know to check for all compiler warnings before releasing the system? The answers to these and questions like it should drive language decisions. In a production environment the amount of time it takes to resolve a problem can have a definite impact on your overall effectiveness (and/or bottom line). Higher-level languages are often better for business scenarios because you will not normally have to deal with issues like segmentation faults.

This does not mean that you should never write a LIMS in C++. What it does mean is that you should use the right tool for the job. Lower-level languages should be utilized to write servers and infrastructure components where performance is the driving factor. For business-level logic and operational code you should consider utilizing a higher-level language -- one that is more friendly for the average programmer.

Go Back

Citation: Which Language Should I Use?. (2014). Retrieved Sun Oct 22 02:23:45 2017, from http://www.limsexpert.com/cgi-bin/bixchange/bixchange.cgi?pom=limsexpert3;iid=readMore;go=1391901692