Why is Java more popular than C++

Pages: 123456
Can you run Java on a GPU?
So do I:

THE ONLY FIRST ORDER DEFICIENCY IN JAVA IS ITS PROCLIVITY TO UNERRINGLY ATTRACT UNINFORMED, OPINIONATED AND INTELLECTUALLY DISHONEST BLABBERMOUTHS.

Can you run Java on a GPU?


Can you run C++ on a GPU?

If you treat both questions literally, then answer is: no to both*.

But if I interpret your question as - can you write a Java program that does some computations on GPU, with a little help of additional API or DSL - then answer is: obviously yes!

See: JOCL, JavaCL, OpenCL4Java. There are probably also some CUDA bindings.

* Actually ScalaCL can run Scala on GPU in such a way, that there is no need to learn any special language nor complex API. All you use is pure Scala code. I guess you can't do it with C++ - e.g. CUDA compiler understands only C.


// Added later: oh, actually Java can be run on GPU thanks to rootbeer1 which directly compiles Java bytecode to CUDA:
https://github.com/pcpratts/rootbeer1



Obviously you wouldn't care for half a day, why do you say it's no slower then say it'd take an extra 12 hours ? 12 hours is a significant amount of time if you are waiting for it


So you lost 12 hours for longer Java execution, but saved a week or more for coding. That's scientists use Python or MatLab even more often, although it is much slwoer than Java. What I do in Python or MatLab in a day, it would take a month in C++. Execution time is then irrelevant. In science most time goes into preparation of experiment (in CS: designing and coding the algorithms), not running the experiment itself.
Last edited on
L B:
I now have a sticker:
I SUPPORT RAPIDCODER
+1
I SUPPORT RAPIDCODER

Sure, inventive tireless trolling is a good way to keep a forum entertaining. The latest tangent about "science" was particularly funny (oh I so *wish* execution time was not the limiting factor for so much of physics, chemistry, and molecular biology)
Science is all about prototyping. Prototyping must be fast. Researchers mostly care if they manage to get results before the paper submission deadline. So there is no time for hand-tuning stuff. There is no time for writing beautiful code. No journal publisher asks about how you wrote your code.

And most science is even not about getting results fast. Most science is about getting some results at all. That's why they'd run sophisticated simulations in MatLab or build statistical models in R, or process huge data volumes with Mahout (Java) on top of Hadoop (Java), rather than doing it all from scratch in C++.
closed account (o1vk4iN6)
So if I want to write bad spaghetti code that is what java is for, got it.
Last edited on
@xerzi
How did you get that from anything that was said in this thread. No one said you have to like/use Java, but coming up with these shitty arguments to "prove" java "sucks" is stupid.
closed account (o1vk4iN6)
The post above of mine stated that. I'm not trying to prove anything, I'm simply disagreeing with his opinion.
Last edited on
So there is no time for hand-tuning stuff.

You mean manual optimizations, or what exactly, inline assembly? Move semantics?
Guys, is it really that difficult to understand? Science is hard. Hard problems can be very challenging to solve using high-level languages, and practically impossible to solve using lower-level languages. There is only so much complexity human mind can deal with.

Do you care for efficiency when you struggle to even get something working? Besides, how much can you win in execution speed? 2x? 10x? This is nothing if you risk spending few months working on something, and then realizing you must start from scratch because there is no way you can actually finish it.

BTW, this is not speciffically about C++ and Java. I don't like Java the language, besides it is only a tiny bit more high-level than C++.
closed account (N36fSL3A)
I'm not saying Java sucks, as it is my second language choice, I just like C++ better.
I like to think that no language is superior to any other; they are simply all used for different purposes and all have different benefits and penalties. To assign a value to any one of those benefits/penalties and call one language overall better than the other is highly artificial and subjective. :/

-Albatross
Last edited on
I like to think that no language is superior to any other; they are simply all used for different purposes and all have different benefits and penalties.

I agree. Even Malbolge has a specific purpose that other languages can't quite match.
Last edited on
@Albatross
I like to think that no language is superior to any other; they are simply all used for different purposes and all have different benefits and penalties


The original question is about more popularity of Java compared with C++. It is not about which language is better.:)
True but sometimes people think popular = superior. Back in the 90's I was using and learning Borland Turbo Pascal and the programmers who used Turbo C++ would attack the Pascal with various examples.

Popular is not always better. If you want the best learn ASM... it will fry your brain cells... but there is no equal. :D

I don't know if anyone hit on this reason, but Java is supported by Oracle Corporation and is promoted for use in many "browser based" applications thus making it most desirable for low level web games (as seen on Facebook).

C++ has a high learning curve and is used for machine based applications. The popularity (in my opinion) is on market flux.
Popular is not always better, but popularity certainly adds lot of value. That's why we are still programming in Java, even though Haskell or Scala are much better designed.

Popularity means: lots of tools, lots of libraries, lots of programmers, good support and also no worries the technology goes away in the next five years.
As for me my most popular language is PL/X for IBM mainframe. Though it is a very weak language compared with such languages as Java and C++ but I like it.:)
I think Java is popular because of its 'portability', it can run in your browser and on any desktop with a java virtual machine.

Although I have nothing against Java, it seems to me that people who learn higher level programming languages in general (whether it is java, visual basic, python, even C++ compared to C or assembly) care less about optimization than the language below it, of course this is if your first language is one of those.

An assembly programmer can optimize >= a C programmer, a C programmer can optimize >= a C++ programmer, a C++ programmer can optimize >= a Java programmer, etc.

The down side of starting to learn programming with a lower level language is that because it takes longer to develop applications, newbie's often get bored and stop learning and/or lose interest. although that isn't much of a problem if you are being taught instead of self-taught.

An assembly programmer can optimize >= a C programmer, a C programmer can optimize >= a C++ programmer, a C++ programmer can optimize >= a Java programmer, etc.


No. Substitute optimize with microoptimize, than I agree.

Most low level coders I met (esp. those with MS in electronics, not CS) have no good knowledge of algorithms except very basic ones. They might be better than compiler at saving a few CPU cycles here and there, they might know hardware much better, but forget about big-O optimizations. Also the complexity of problems you deal with writing low level industrial software is usually very low.

To write high performance software you usually need optimizations from both levels. That is why I advocate mixing languages - do high level in a truly high level language and some performance critical components even in assembly.
Pages: 123456