When to use what language and why

Pages: 1234
Its been debated here for the past couple of months what language is "the best" or more appropriately, "the worst" which defines another as better inherently.

Well I'd like to straighten one thing out. There is no best language. There is no best paradigm. There is no best algorithm, method, optimization, technique, ANY OF IT. All good programmers know this, and all real computer scientists know that a language is just a tool in the science of computation. If some one builds a better screw driver, why not use it? Well perhaps this screw driver is only better at getting the job done faster, and not getting it done more efficiently. Or maybe it's great at both of those but the screws are not tightly in the wall because of it. This is comparable to the differences in all computer languages.

So one coder might ask "When should I use "XYZ"?" and when answered they might ask "why?"

I'm here to answer these questions.

When should I use Assembly: You should use assembly when you need the lowest level access to the hardware available. Or when you need to hand optimize things like algorithms and the like. That's not to say you can't use assembly for a desktop application, but it is entirely impractical. As a rule of thumb, use assembly when you need more raw control then you do quickly written and readable code.

When should I use C/C++: Well first of all, c and c++ are both lower level languages, not nearly as low as Assembly but low none the less. Now they are also non garbage collected languages, so you will have to deal with debugging memory leaks and the like, but that presumable flaw is one of the greatest strengths of languages like these. While you may spend more time writing and fixing code then you do optimizing the code, you have the power to optimize it a hell of a lot better than garbage collected code. So anyone who tells you "use java/C#/Scala/etc for you're Kernel/game engine/generic time and resource critical application" because they think you'll get it done faster, and thus make more money because of it, knows nothing about computer science nor economics. Build x number of shitty toys in a month and you're left with a pile of shit. build 1 amazing toy in a month and every one will want your toy...cause come on, who wants to play with a pile of shit?

Now you may think, if thats so why should i ever use languages like java/c#/scala/F#/etc? well the truth is some times you do want to implement faster than you want something to be efficient, and in some cases some of these languages do a better job at both.

So when should I use java: If this wasnt an impartial article I'd say never and leave it at that. BUT this is supposed to be neutral so Java is great for server based applications, as well as client based web apps. It's fast and great with databases, while at the same time having some over head. My biggest problem with java is it's not that great of a language, in fact it's pretty bad. But thats what people get for trying to turn a language designed to teach students computer science and OOP into an industry standard. It was never meant to be what it is today.

What about c#: Use C# when ever you'd think to use java. The way I see it is C# is just like java...except it works.

how bout functional paradigm languages like F#: you want to use languages that are functional when you need more platform independence. Functional languages make it easier to process your algorithm, method, function, etc independent of thread of CPU. It's great for multiple platforms, and multiple threading. This is also why scala excels at these things.


So all things considered you need to remember one thing when programming. It's not about finding the best tool out there and sticking to it like it's dogma. It's really about finding the best technique to learning how use these tools so you can have a full toolbox when it comes time to build your software.

Edit: I was late for class and forgot to add a "will add more later" and remove the above section.
Last edited on
What, that's it? Scripting languages like Perl or Python don't even get lip service?
Also, Java wasn't designed as a teaching tool, although it is or was used to teach OOP in some places.
It's really about finding the best technique to learning how use these tools so you can have a full toolbox when it comes time to build your software.


I agree to the above statement totally. I always like to use this analogy.

"If the hole is round, I would find a round peg to plug it in. Why would I use a square peg to plug into a round hole ?"

Of cuz you can use the square peg and "force" into the round hole but it will be tougher and you will bruise the round hole edges in the process.

Therefore, no ONE programming language is supposed to solve all problems, it is only know how to use the correct tool/software for that particular problem on hand. This require a developer to excel in multiple languages and frankly speaking, some developers prefer to specialize than generalize. To each his own I guess.
closed account (EzwRko23)
To the original poster:

1. You build your statement on a false assumption that languages are only tools. Computer languages are not tools. Compilers, debuggers, IDEs, editors are tools. Language is a different kind of beast - because language becomes part of the project you build with it. Language is more like building material, not tool. It affects lots more aspects than your tools. It affects not only the toolchain, but also the required skills of the coders on your team, the architecture of the application, available sets of libraries etc. It is like the whole building technology. Building from bricks is much different than building from concrete frame H.

2.
So when should I use java: If this wasnt an impartial article I'd say never and leave it at that. BUT this is supposed to be neutral so Java is great for server based applications, as well as client based web apps. It's fast and great with databases, while at the same time having some over head.


This is a pile of unjustified FUD. There is no such thing like inherent "overhead of Java". Java is slower at doing some things than C++, C++ is also slower at doing some other things than Java.

3.

My biggest problem with java is it's not that great of a language, in fact it's pretty bad. But thats what people get for trying to turn a language designed to teach students computer science and OOP into an industry standard. It was never meant to be what it is today.


Even more FUD. Java as a language has some defficiencies (like primitive types and boxing or generic type erasure), but:
a) these deficiencies are not severe enough to justify writing a book "Exceptional Java" or "Java FQA" like we have "Exceptional C++" or "C++ FQA"
b) it was designed to be a simple language, not an unstructured, unorthogonal feature-bag like C++
c) it was designed to fix problems of C++ as an application programming language, and although it does not fix all the things it could do, it does enough well that most application programming moved from C++ to Java (or C# - a MS Java ripoff ).


4.

how bout functional paradigm languages like F#: you want to use languages that are functional when you need more platform independence. Functional languages make it easier to process your algorithm, method, function, etc independent of thread of CPU. It's great for multiple platforms, and multiple threading. This is also why scala excels at these things


First learn functional programming, then make verdicts on it, not the other way round. Functional style has nothing to do with platform independence or multithreading. These are just features you get "by the way". The whole thing is about handling **state**. Actually also the different treating of state is what differentiates OOP from structural paradigms, and not presence/absence of inheritance and virtual calls (contrary to what many programmers think).

5.

So anyone who tells you "use java/C#/Scala/etc for you're Kernel/game engine/generic time and resource critical application" because they think you'll get it done faster, and thus make more money because of it, knows nothing about computer science nor economics.


We build EDA software engine in Java/Scala. This is extremely time and resource critical thing, involving lots of numerical computations. Somehow our prototype outperforms PSPICE written in... pure C. Why? Because we could used more complex, better algorithms, based on symbolic manipulation (which is pretty hard to do in C). The raw performance of our matrix inversion algorithm is probably lower than that of PSPICE, but for circuits that PSPICE builds a matrix 10x10, our software has to solve a matrix of size 2x2 - which is an order of magnitude faster. :P
Last edited on
Even more FUD. Java as a language has some defficiencies (like primitive types and boxing or generic type erasure), but:
a) these deficiencies are not severe enough to justify writing a book "Exceptional Java" or Java FQA like we have Exceptional C++ or C++ FQA
b) it was designed to be a simple language, not an unstructured feature-bag like C++
c) it was designed to fix problems with C++ as application programming language, and although it does not fix all the things it could do, it does reasonably well


Hi xorebxebx I am a bit curious. Based on your above comments, are you implying Java can solve ALL problems we encounter in software ? If not, under what scenario will you consider C++ to be a better candidate to solve the problem ?

Let me say my thinking. If I want to write a device writer for a hardware, I would go for C. If I want to write graphics intensive I would go for C++. If I want to write a new OS I would go for assembly and C. If I want to do text pattern matching and replacement, I would go for Perl. If I want faster web development I would go for Java, PHP. If I want more interactive web page effects, I go for Javascript.

So you see, I would see the problem on hand and select the relevant (or I feel capable) languages to tackle the problem. I do not see myself to use strictly Java for ALL the above problem I brought up for discussion sake.
closed account (EzwRko23)
Nowhere do I claim that Java can solve ALL the problems we encounter in software. But it fixes lots of problems not inherent to software, but inherent to C++ **for applications**. OS drivers or kernels are not applications.


If I want to do text pattern matching and replacement, I would go for Perl.

Actually Scala is definitely better and faster at it. At least on a different forum we compared a program for T9 simulation and Perl solution was more complex and slower.


If I want to write graphics intensive I would go for C++

C++ has no real advantage over Java for this. Raw numerical processing in Java is just as fast as in C++, while it is easier to code complex algorithms. Add multicore revolution to this , and Java is a clear winner here.
Last edited on
Ok since you classify OS drivers and kernels as NOT applications then would you classify programs that "talk" to hardware as applications ? E.g I once write a program to "read data" from COM port the compass and GPS is pumping in. Do you classify that as application ? For such program nature, do you think Java will be a good fit ?

Web page interactive effects using Javascript <- I guess no contention which language is better here correct ? Or you are proposing using Java applets, JavaFX ?
closed account (EzwRko23)

For such program nature, do you think Java will be a good fit ?


E.g I once write a program to "read data" from COM port the compass and GPS is pumping in.
Why not? Accessing COM ports is just as easy from Java as from C++.


Web page interactive effects using Javascript


JavaScript has its strengths and weaknesses. If it is simple, has to launch fast, and run everywhere yes I would definitely go JavaScript. If it had to do something complex and fast (like 3D visualization on multiple threads), JavaScript and Flash are no-go - they are too slow and resource hungry copared to Java. The only thing that could do this is a Java or Silverlight applet.

You see, Java is a general purpose language. And as a general purpose language it is much better than C++ - it has a much wider spectrum of applications. But on the other hand noone expects that a general-purpose language would be better for the tasks, where a dedicated domain-specific language is available like SQL, JavaScript or VHDL.
Last edited on
Xorebxebx, do me a favor and define computer science for me.
closed account (EzwRko23)
How would that be related to the topic?
You build your statement on a false assumption that languages are only tools.


Erm, they are actually.
Because I don't think you know what the definition is. If you did, you'd know that languages are tools used by computer scientists and they were invented to aid in the expansion of knowledge of just what is computable and how we can compute it.

edit: fixed typo
Last edited on
closed account (EzwRko23)
No, they are not tools. Languages are notations. The primary purpose of notations is communication between people and people and machines. Most of the language flame baits concentrate on comparing tools behing some language, not the language itself. That is why Java-the-language is perfectly valid language for writing an OS in, only the existing tools for Java (JVMs, compilers, etc.) were not designed for this purpose. But you can write just as good Java native compiler as you can for C++. Commercial Excelsior's Java compiler produces better code than GCC quite often.

Scala, Python and Ruby are much more powerful notations than C++ - you can express more in less words in them, and it is easier to understand both to humans and machines (this can be measured by metrics such as: grammar class, grammar size, size of compiler's code etc.).
closed account (z05DSL3A)
xorebxebx,

If you really want to get pedantry about such things; one definition of a tool is "Something to perform an operation; an instrument; a means". Language is a means of communicating ergo a language is a tool for communicating.

closed account (EzwRko23)
Well, right, but this is not the meaning of the word "tool" in the post of the OP.
Seraphimsan's post is not related to computer languages per se. It concentrates on tools, platforms behinf various languages. Anyway, it is extremely oversimplified analysis, he misses lots of important aspects and thus it is mostly useless.

Concerning tools:
For me as a programmer of a time-critical application, much more important is having a good profiler than having a high quality native code compiler. And C++ profilers suck a lot. Also because I can move much faster when using higher level language (I'm about 5-10x faster writing Scala after a few months of writing Scala than C++ after 5 years of experience), lots of time remains for profiling and optimizing. Therefore, superior performance of C++ compiled programs is only theoretical (or when time and budget are unlimited).
Last edited on
I'm not claiming my article was the best, in fact it was far from that.

Edit: i was going to go on a long rant about why xorebxebx's opinion's should be a moot point, but fuck, I just don't care anymore. I'm done here, there's no point arguing with him because he'll never admit fault. I've gained all I can from this community as far as knowledge goes. And I'm not great at giving advice to those who are learning here. I'm out. again.
Last edited on
closed account (z05DSL3A)
Seraphimsan,

I was in the process of writing something but then I was reminded;
Never argue with an idiot, they drag you down to their level and beat you with experience
so I hit cancel.

I think that it is time to ignore xorebxebx, I was willing to give him a chance...
Last edited on
Someone wrote:
You cannot argue with an ignorant man.
closed account (1yR4jE8b)
So when should I use java: If this wasnt an impartial article I'd say never and leave it at that. BUT this is supposed to be neutral so Java is great for server based applications, as well as client based web apps. It's fast and great with databases, while at the same time having some over head. My biggest problem with java is it's not that great of a language, in fact it's pretty bad. But thats what people get for trying to turn a language designed to teach students computer science and OOP into an industry standard. It was never meant to be what it is today.


This whole paragraph is a pile of bullshit. Java was meant to become the defacto industry standard for cross-platform development and that's where it is. Actually know what you are talking about when you post something. Unless you are confusing Java with Smalltalk.

I would also say that Java is an excellent language, I use it all the time for many different things from Desktop applications, to Cell Phone games, Database Applications etc.... Just because "omg it doesn't have operator overloading so it sucks" doesn't mean it's a bad language.

I'm about 5-10x faster writing Scala after a few months of writing Scala than C++ after 5 years of experience


I totally know the feeling, I've been programming using Ruby for just a few weeks now and I am way more productive with Ruby then I could ever be with C++ (6 years experience).
Last edited on
C++ has no real advantage over Java for this. Raw numerical processing in Java is just as fast as in C++, while it is easier to code complex algorithms. Add multicore revolution to this , and Java is a clear winner here.
May I bring up Runescape? Personally I plan on pursuing video game programming as a career, so I really just care about what programming language will be fast enough to get me 60 FPS. Feel free to offer arguments for some other language, C++ does tend to be a pain under many situations, but I'm unaware of any programming languages that give me the same speed on a language that provides the organization that C++ does (which isn't all that much.)
Pages: 1234