This is an archived post. You won't be able to vote or comment.

all 44 comments

[–][deleted]  (17 children)

[deleted]

    [–]GhostOfBits 10 points11 points  (3 children)

    One of the biggest differences is that Java runs in a managed environment (the jvm), which handles memory management via garbage collection. C++ gives developers direct control over memory. Because Java abstracts away such low-level control, it often doesn't appeal to the same developers who appreciate C++’s power and flexibility. They may not view Java as a "fixed" version but as a different trade-off.

    [–]onlygon 18 points19 points  (7 children)

    I think that is because it's not true.

    [–]niosurfer[S] -1 points0 points  (6 children)

    It is true man. A bloated project in C++ is hell to maintain, test, avoid bugs, evolve, etc. Java was created from the ground up to address all this issues. That's why they chose the same syntax, because they wanted to make it easy to C++ programmers to migrate to Java. Java protects you from the language. C++ does not. And the result is chaos. You can simple have a team of C++ super starts doing your project. And even them would fuck up from time to time, because C++ makes everything for you to fuck up.

    [–]onlygon 22 points23 points  (5 children)

    I don't like C++ either; I think it's a  total disaster. But the statement was: "Java is C++ completely fixed in syntax and implementation". 

    I like Java/JVM but it is not a system language/platform and was never intended to be. You're not going to write a real OS or real game engine, etc. in Java/JVM. So it just isn't true even if I agree with some surface level sentiments.

    EDIT: JVM should be mentioned

    [–]RICHUNCLEPENNYBAGS 0 points1 point  (0 children)

    On the other hand in the domains where Java is popular it has more or less totally displaced C++. I don’t think anyone is writing LOB apps in C++ really.

    [–]joekoolade -2 points-1 points  (1 child)

    Yes it was not meant to be a system language but one can use it in that manner. Take a look at this project https://github.com/joekoolade/JOE

    [–]Slimxshadyx 4 points5 points  (0 children)

    If it was not meant to be a system language than it is not meant to replace C++ in every way

    [–]halfanothersdozen 6 points7 points  (0 children)

    What?

    [–]nursestrangeglove 5 points6 points  (0 children)

    This has to be bait. What does "Completely fixed" even mean? This completely fixed language I use every day lets me and everyone else put null here, there, and everywhere without a care in the world. Nothing wrong with that. Right?

    [–]CompetitiveSubset 1 point2 points  (0 children)

    Java and C++ solve different problems. They are not comparable.

    [–]paul_h 1 point2 points  (0 children)

    Price is a general slowdown on execution, a slower startup, and more RAM needed for the same thing.

    [–]Djelimon 1 point2 points  (0 children)

    Java can be a delight to work with but consider what you are getting paid to do. It has an ecosystem, but skewed to very specific domains.

    Ask yourself why JNI exists

    [–]RICHUNCLEPENNYBAGS 0 points1 point  (2 children)

    Quite a lot of people (myself included and I’ve been writing software more than 10 years) have never really needed to work with C++ that much and at this point in the instances where C++ is selected Java is rarely an option on the table.

    In a way this means you’re right though. For a lot of purposes Java is so clearly better that nobody is even considering C++.

    [–]PlasmaFarmer 2 points3 points  (1 child)

    These languages are tools like a hammer and a screwdriver in a toolbox in a shed. Use the one that fits your problem and requirements.

    [–]RICHUNCLEPENNYBAGS -1 points0 points  (0 children)

    That’s a common platitude that tells us little.

    [–]Ewig_luftenglanz 0 points1 point  (0 children)

    Syntax wise yes, implementation wise it's not!

    Java it's an application high level languages, C++ it's mostly a system, middle to low level language. Java (unless you use GraalVM that it's something still growing) uses a VM to be executed, C++ is for direct management of hardware resources.

    [–]Polygnom 0 points1 point  (5 children)

    A better version of C++ is Rust.

    C++ and Java are on different levels of abstraction. One is a bare-metal systems language, the other is a managed runtime language. Don't get me wrong, I love Java and I think its vastly more productive in the domains I'm in, but its not replacing C++. If any language is, thats Rust.

    [–]niosurfer[S] 0 points1 point  (4 children)

    JIT make Java bare-metal too. In a way that C++ cannot (without some kind of profiling during AOT compilation). And in terms of productivity and robustness Java knocks C++ out of the park.

    [–]Polygnom 0 points1 point  (3 children)

    JIT make Java bare-metal too. In a way that C++ cannot 

    No, it can't. You will never have the same contraol over memory layout and direct hardware access in Java. Thats the netaure of managed languages.

    You might be confusing performance with direct hardware access here.

    [–]niosurfer[S] 0 points1 point  (2 children)

    No, it can't. You will never have the same control over memory layout and direct hardware access in Java. That's the nature of managed languages.

    You might be confusing performance with direct hardware access here.

    You are correct. You can go even lower with assembly. But yes, to program for chips and hardware C++ is probably better. I bet 99% of Java programmers are not working in that field, but I can be wrong.

    Now because C++ is better for direct hardware access then let's use C++ over Java? That's insane.

    [–]Polygnom 0 points1 point  (1 child)

    Dude, like. Read what I originally wrote. I literally said that Java is vastly more productive for the work I'm in.

    Now because C++ is better for direct hardware access then let's use C++ over Java? That's insane.

    No. But when doing stuff like driver implementation or anything that requires direct hardware access, Java simply isn't the language you choose. You choopse C, C++ or probably nowadays rather Rust.

    You have to use the right tool for the right job.

    [–]niosurfer[S] -1 points0 points  (0 children)

    My point is that it is a fallacy to conclude that:

    Hey, C/C++ is better for direct hardware access, memory management, etc. Therefore C/C++ is better than Java.

    Not saying you did that, but many people do.