Why is Java more popular than C++

Pages: 1234... 6
closed account (o1vk4iN6)
rapidcoder wrote:
The similar thing is if you compare the numbers of open source projects by language. Java is certainly more popular than C++ now.


That's only cause there is no such thing as a closed source Java program. ah ha.

Java's more popular than assembly (assuming, by your logic), yet that doesn't mean they aren't in demand. Who do you think makes the Java virtual machine ? It doesn't matter what's more popular really (java will never fill that hole), that's like saying you like dubstep because it's mainstream and everyone else likes it so you do too. I know someone who has to work with Java, they have the strict option on (can't remember what it's called) you basically need to handle each and every exception or it won't compile. So if you're thinking your programming in Java and you like it, just wait til they start flipping switches.
Last edited on
This means there is more code written in Java than in C++


Where did you get this??? Many games, parts of operating systems, etc. Are coded in C++ becuase java is pretty, SLOW. I think Minecraft is the only real game programmed in Java. Name 10 good games programmed in Java that is programmed in C++. In my opinion, C++ is more popular.

P.S. - C++ was created before Java, so don't you think more code would be written in C++? That's like saying C++ has more code written in it then Assembly or C.
Last edited on
@Fredbill30:

Operating systems? Name at least two. The last one I recall was Symbian, but it is dead. All major ones: Linux, Windows and Mac OS X are written in pure C. Windows has some C++ userland libraries (all those COM layer), which is pretty... horrible.
Linux and MacOS X kernel as well as glibc was written in pure C. The same is true for Android.

C++ is popular in AAA games. I never said it was not. But AAA games are a tiny part of the market related to computer programming. It is even a small fraction of gaming market. Minecraft, Angry Birds, Runescape, Farmville, which were all *not* written in C++ but generated more revenue than many AAA games. Zynga shares were for long time worth more than whole EA. Add to this a long tail of indie games, mobile games or web-games. C++ is in niche.

Most people (in college) think Java is not as popular as C++ because they only see what's on the desktop. But desktop almost doesn't count today.

When you search something on Google, Java code is used in your search processing. When you check GMail - the UI is created with Java (exactly GWT). When you post something on Facebook - yup, Java in there too, side by side with PHP. When you tweet on Twittter - powered by Java (and Ruby too). When you use an application on your smartphone - Java there (or Objective-C if it is iPhone). When you go online shopping - .NET or Java usually powers the site. Go to a bank - Java apps in the counter terminals, Java on servers, Java powering online banking sites (and even sometimes client side auth. and encryption). You pay by your credit card - yup, Java code does processing the request. Java apps are run even on smart cards, all blue ray players, many TVs, etc - lots of embedded stuff run Java.

There are many apps written in Java, but you don't see it is Java, because it is mostly server-side.


C++ was created before Java, so don't you think more code would be written in C++?


You misread my post. I was saying there is more Java code *being* written *now* than is in C++. Not cumulative numbers. There is probably more code written in COBOL than any other language, but that doesn't mean COBOL is popular now.


That's only cause there is no such thing as a closed source Java program. ah ha.


Bullshit. And easy to disprove:
1. Oracle SQL Developer. Closed source. Pure Java.
2. thousands of web-apps
3. thousands of Android apps


Java suxxx....long compilation, heavy IDE, not instinctive too far from real hardware :)


Another bullshit.
Long compilation? C++ compiles two orders of magnitude slower, especially if you use heavy templated code. It can't do automatically proper dependency analysis and incremental compilation and recompiles the same stuff again and again. This is one of the major complaints against C++. Among statically compiled languages, Java is one of the fastest out there.

Heavy IDE? On a 5 year-old computer of your grandma, maybe. IntelliJ IDEA starts in 5 seconds on my laptop and takes only 1/20 of available memory. I don't need it to be any faster. Funny, lots of C++ heavy companies use Eclipse CDT as their tool for C++, LOL (e.g. it was an official IDE of choice for all Symbian C++ development).

Far from hardware? Not any more than C++. In both you can and *have to* resort to assembly to get full control.


What overhead is incurred by a "properly" set up SecurityManager? Has anyone ever benchmarked the approximate cost of running in a sandbox?


Whatever the overhead was, C++ already lost this point. In C++ you simply have no such functionality.

And as for the native access, overhead of a JNI call is negligible compared to syscall overhead (at least two context switches). So whether you interface with OS from Java or C or even assembly, performance is exactly the same.

Last edited on
It's funny that you bring up Minecraft. Did you know that Mojang is developing at least 3 entirely separate versions of the game? The original PC version is in Java, but this only works on PCs. They have another version, pocket edition, for mobile devices, plus a third C++ version for XBLA. Each version had to be written entirely from scratch. For a language that's supposed to be entirely portable this is a really bad track record.

That's not even mentioning the technical problems Java has caused for the PC version. Many users are forced to launch Minecraft with strange command line parameters to stop Java from crashing due to insufficient memory (even if the computer obviously has enough). The game could easily use at least 50% less memory just by cleaning up garbage earlier rather than later. Older versions of the game had glitches that only occurred on Linux.

Of those games you listed, only Runescape is really a good candidate for Java. Really, Runescape is the only Java game I can think of that chose the right language. It runs in a browser for any PC platform and can actually take advantage of a lot of the language's features. Java games were few and far between before smart phones started requiring it.


There are no closed-source Java apps because Java is so easy to decompile. Let's look at Minecraft again. It is not only compiled into bytecode but is run through an obfuscator for every release, yet the community manages to decompile it every single time. This simply does not happen with mature native languages like C and C++ where the code is so optimized that it is impossible to reconstruct the original code.

Of course, lots of Java apps can remain effectively closed-source because the users never see Java. This brings me to another point: forcing end users to run a JVM is unprofessional. People expect to see programs that just run, without some strange corporation's logo popping up all over the place. This is one of the reasons why most Java programs are hidden, either behind servers or inside "embedded" systems.


Far from hardware? Not any more than C++. In both you can and *have to* resort to assembly to get full control.


Okay, so how do you include inline assembly in Java?


Whatever the overhead was, C++ already lost this point. In C++ you simply have no such functionality.


You have to be delusional to think that Java is inherently secure just because you set up a SecurityManager. Why do you think there are so many JVM updates?
@rapidcoder

I never asked you to name me games that aren't programmed in C++ nor Java, I meant pure Java, and I don't consider those silly web applications games anyway.

Okay, so how do you include inline assembly in Java?


I'd also like to know this.

forcing end users to run a JVM is unprofessional

I was just about to get to this, but Telion beat me to it.

Also - the JVM is crap unless their is one programmed for the targeted platform. So that really goes against the
"Compile once, use anywhere"
quote or whatever its called.
closed account (o1vk4iN6)
@rapidcoder

Just saying, where ever there is Java there is a C/C++ virtual machine running right beside it :). So basically everything you just mentioned was all for naught cause it just proves how portable and widely developed C is. Also pretty sure facebook went full HTML5 so it'd work on everything.

Bullshit. And easy to disprove:
1. Oracle SQL Developer. Closed source. Pure Java.
2. thousands of web-apps
3. thousands of Android apps


See you didn't get the joke or sarcasm. Probably blinded by your rage of people who, in their opinion, don't like Java.

Just saying, where ever there is Java there is a C/C++ virtual machine running right beside it


Oh, yeah. But it's probably not the kind of popularity OP was refrerring to. This is the same as C++ in the browser, so you could say all web-apps are in C++. Or you could even say that all software is machine code and therefore machine code is more popular than whatever higher level language. That argument is of course totally flawed. Only very, very few programmers work for developing VMs* or web browsers** or operating system kernels*. Most money is in applications.

* As I said before, in most those low-level cases, there is no C++. At least not that C++ as Bjarne Soustrup or Herb Sutter would write today. It is either pure C (Linux and OS X kernel) or some C with classes (JVM).

** Some web browsers are constantly moving away from C++. E.g. recent versions of Firefox has large portions written in JS. And BTW, JS is pretty a fast language today - in some cases even just as fast as C, and typically only 2-10x slower.


That's not even mentioning the technical problems Java has caused for the PC version. Many users are forced to launch Minecraft with strange command line parameters to stop Java from crashing due to insufficient memory (even if the computer obviously has enough). The game could easily use at least 50% less memory just by cleaning up garbage earlier rather than later. Older versions of the game had glitches that only occurred on Linux.


Poor developers blame their tools. This means Mojang programmers suck at optimizing code. But if the things you write were so serious, someone would come up with a C++ version of Minecraft that would take original Minecraft over. It didn't happen so far.


I never asked you to name me games that aren't programmed in C++ nor Java, I meant pure Java, and I don't consider those silly web applications games anyway


Games written in Java:
- Minecraft
- Runescape
- Jake2 (Quake2 port, so AAA production, and does more FPS than original)
- for more games look at www.java-gaming.org (there are actually plenty of games written in Java)

Again: don't judge Java popularity by a very tiny fraction of the market as those AAA PC games. Android gaming market alone is worth more and most games for Android are Java.


There are no closed-source Java apps because Java is so easy to decompile. Let's look at Minecraft again. It is not only compiled into bytecode but is run through an obfuscator for every release, yet the community manages to decompile it every single time. This simply does not happen with mature native languages like C and C++ where the code is so optimized that it is impossible to reconstruct the original code.


Good joke. This *does* happen with C and C++ code all the time. Crackers do it and it is pretty easy***. Every useful closed source C++ app has a crack somewhere on the Internet.

Also decompiled Java code is far from the original. You do simple tweaks, mods or cracks, but working on a code where every variable and function is named aaabdfkjk would be a nightmare. You can't grab someones closed Java code and create a competitive product basing on that code - it would be easier to start from scratch than to work on a decompiled codebase. Guess why noone has rewritten Minecraft with all of bugs fixed, yet? There is a huge difference between modding a few lines and developing a product.

*** Crackers don't even need to decompile. Many cracks are developed at the assembly level and assembly is sometimes more readable than C++ code produced by inferior coders. Compilation is no protection at all. Just ask someone doing RE as a job.


Okay, so how do you include inline assembly in Java?


I can write a code in assembly (or any natively compiled language), compile it to .so or .dll and call it directly from Java. Smart JVM can inline them if needed.


forcing end users to run a JVM is unprofessional

This is like saying "forcing end users to run <insert any OS> is unprofessional". Now go and port all your C++ programs to Azul Zing OS :P Oh, no C++ compiler? I guess you have a problem now...

If C++ is so portable, why most of desktop apps have problems running even on various versions of the same Windows OS? Forgetting about Mac OS X or Linux or less popular flavours of BSD.

In reality end users don't care and noone asks them. Most of them even don't know if client software is running Java or not (just recently we had a video conference on Webex and someone asked, "oh, so Webex is a Java applet? I thought it was HTML5" :D)
Last edited on
I think we're really hitting hard on rapidcoder here. He's making good points based on his experience, and he doesn't have such a no-life that he can spend time to research and make sure everything he says is valid.

C++ and Java have their uses. Don't make my mistake of saying one language is worse because it cannot do the same thing as the other in the same way.
But if the things you write were so serious, someone would come up with a C++ version of Minecraft that would take original Minecraft over.


I don't agree to all the java bashing either (although its really not one of my favourite languages for entirely subjective reasons), but that's just silly. Who in their right mind would completely rewrite a complete application with millions of sales just because a few people had problems running it (and which runs reasonably stable for everyone else)?
Rapidcoder, you're being a hypocrite. You said you can de-compile Java to make mods, tweaks only, when you're bashing C++ for being able to crack it. A crack is a "mod" and you're acting like you can completely de-compile C++ code and take the source. In Java, you basically can de-compile and get the whole code with changes in variable, function names.
@Fredbill30, there are decompilers that can decompile optimized C++ to a similar level - the program structure is not lost in assembly - method calls, system calls (with full name), loops, conditions, classes, structures, arrays. Only local variable names are lost. Java is even better, because it can obfuscate method names, while in C++ all public method / function / class names are visible in the generated code.

Anyway, code without variable, method, and class names has no value, except for doing a small mods, e.g. cracks. You can't do any serious development with decompiled Java code.


The decompiled readability level of the code shown below is far beyond what you can do with obfuscated Java code:

http://boomerang.sourceforge.net/cando.php

Summary:
1. you can mod/crack obfuscated Java code and you can mod/crack stripped C++ code
2. you can't use decompiled code in Java nor in C++ to gain competitive advantage in your software project

BTW: Some obfuscators can produce bytecode that has no Java source equivalent. E.g. Java has no goto, but JVM does have goto opcode. Java has no return type overriding, JVM does have. So a clever obfuscator can easily make a Java decompiler just bail out and you are left with reverse-engineering by hand, exactly as in C++ case.
Last edited on
closed account (o1vk4iN6)
rapidcoder wrote:

Oh, yeah. But it's probably not the kind of popularity OP was refrerring to. This is the same as C++ in the browser, so you could say all web-apps are in C++. Or you could even say that all software is machine code and therefore machine code is more popular than whatever higher level language. That argument is of course totally flawed. Only very, very few programmers work for developing VMs* or web browsers** or operating system kernels*. Most money is in applications.


The same thing can be said for Java, how many Java programmers actually program for 1/10 of what you said. They are probably writing code that isn't portable and only works on a PC on windows. A VM isn't generated, it still has to be programmed so I don't see how that compares to machine code that is generated. You were talking about how Java is everywhere, not how many people actually program for that, point being if someone wasn't there programming C there wouldn't be someone there programming Java. Who cares about money ? If you get into programming for money I don't see you surviving long.
Who cares about money ? If you get into programming for money I don't see you surviving long.
But if you aren't paid, you'll have to do something else.
This increasingly vacuous discussion has got nothing even remotely do do with 'General C++ programming'.

Is there someone who could move this bilge to the lounge? Please. Pretty please.

JLBorges wrote:
...vacuous...


Great word...

I don't necessarily agree with all the bashing of Java, but I thought it was funny what was said on the "Download" page of the software that rapidcoder linked to to prove his point.

Boomerang Decompiler wrote:
This release is strictly for developers and experimenters, to get an idea of what Boomerang is about without having to download and compile a lot of code. Machine code decompilation, unlike Java/.NET decompilation, is still a very immature technology, so if you're hoping to decompile a large binary with this release you will be disappointed. Please read the documentation on the Boomerang web site.


That kinda goes completely against what he was trying to prove, lol. That being said, I think I just found a new favorite toy...

Found another quote from the Boomerang software...
Boomerang Decompiler wrote:

Does it matter what language my software is written in?

Yes. If you are trying to recover Java or Visual Basic source code you're in luck. There are many Java and Visual Basic decompilers, many of which can give you excellent recovered source code in minutes. Your own developers should be sufficiently qualified to wield these tools and complete source recovery should take less than a month.

On the other hand, if you're trying to recover C/C++/asm or some other compiled language, you will require expert source recovery services. The state of the art is much more advanced in recovering asm and C than C++ or other languages. C++ recovery is possible but takes longer.


Sorry rapidcoder, I had to.
Last edited on
They are referring to decompiling unobfuscated, unstripped Java code. Yeah, then you can recover it fully. I find it an advantage. But if you try to decompile obfuscated Java code, you get all the same problems:
1. lost all names, no debugging symbols
2. lost original program structure - e.g. methods inlined, lost for loops, lost inner classes etc.
3. decompiler choking on some more advanced obfuscation techniques, like aggressive overrides or overloads (you get the same name for several different things - decompilers crash or produce incorrect code)
4. inability to recover features not found in Java, if the original source was not in Java but in some higher level language - generally you get a total mess if you try to decompile a Scala or Clojure generated Java code.

Ok, so maybe the difference would be that if you had a good decompiler, you could compile the recovered code back. But what is its value? The recovered code is such a mess, that you can't do anything with it except simple mods. Which you can do in C++ as well, without using even a decompiler.

Actually no-one, except some fresh guys from college, finds native compilation a protection against anything. Just ask the guys doing RE as their job.


The same thing can be said for Java, how many Java programmers actually program for 1/10 of what you said. They are probably writing code that isn't portable and only works on a PC on windows


This is totally wrong and means you probably never worked in IT industry, yet. Non-portable Windows programmers usually use C# on .NET. This is not Java's territory. If you don't need portability, .NET is better, because it has better Windows integration. Most Java programmers do:
1. Server side apps, usually on Linux/Unix (Windows with its crappy I/O scheduler is a nogo for serious high performance server-side)
2. Mobile development for Android
3. Science (especially AI, physics, data mining)

Last edited on
closed account (o1vk4iN6)
rapidcoder wrote:
They

who's they ?

What do any of the things you listed require java's portability ? Mobile development for Android, only because they are forced to. Unreal engine which runs on basically system doesn't run on Android if only because it forces Java onto you. People I know that use programs for physics, data mining, etc don't rely on Java as that's where speed is actually a factor they have to worry about and still their calculations take days. I could only imagine how many years it would take with Java. The majority of people that program in Java don't care about portability, if someone makes a Java game for PC they won't be able to port it for Android without recoding the entire thing from ground up because of the hardware difference. Although Java is portable what it is used for may not be.
Android doesn't force you to use java - but it is much easier to create apps in Java than in NDK.

Also, Java is not any slower than C++, at least not by that much that it would count in scientific applications. Ok, so the calculations would take a day and a half instead of a day. So what? Who cares? Thanks to Java you could start the calculations two weeks earlier, because with C++ you'd still struggle with making it run without random segfaults. Researchers use also things like Matlab, R or Python very heavily, which are extremely slow compared to Java - just for the same reasons. Speed of execution doesn't matter that much in those applications. C++ coders usually overstate the value of performance, because it is the only thing that C++ does (slightly) better than other languages.
closed account (o1vk4iN6)
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. It would mean waking up in the morning and having it finished rather then waking up waiting all day going to sleep and it not being finished til the next day. That is a significant amount of time.

Speed isn't the only thing that's C++ does better, it's the only one comparable. I will never use a language that forces me to handle every meaningless exception and force formats onto me for the sake of compensating for the lack of performance.
Last edited on
I now have a sticker:
I SUPPORT RAPIDCODER
Last edited on
Pages: 1234... 6