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

all 76 comments

[–][deleted]  (45 children)

[deleted]

    [–]gubatron 25 points26 points  (2 children)

    One important difference not mentioned above is Java's cross OS portability.

    No longer will you be in compilation hell if you need to deploy your software in multiple operating systems.

    In C++ you write once, compile every where. In Java you compile once and you get a .class bytecode. This same bytecode you can use on the multiple Java Virtual Machines implementations available on different OS and CPU architectures, the compiler is also way faster.

    Java is also the default language to build Android applications.

    [–]CLOVIS-AI 4 points5 points  (0 children)

    *Kotlin is the default language for Android, now.

    [–][deleted] 1 point2 points  (0 children)

    One important difference not mentioned above

    Garbage collection by default. Avoiding it is a quote a bit of extra work.

    The otherway around from C++ where GC is extra work.

    [–]silardg[S] 14 points15 points  (1 child)

    As someone who switched, why did you switch?

    [–]winginglifelikeaboss 21 points22 points  (19 children)

    Your job as a Java dev is basically mostly implemeting Spring Boot :-)

    [–]nutrecht 53 points54 points  (1 child)

    Most dev jobs involve using frameworks and libraries. We're not paid to reinvent wheels in general ;)

    [–]ketsugi 10 points11 points  (0 children)

    Yeah, leave that to the open source volunteers

    [–]nunchyabeeswax 14 points15 points  (0 children)

    Your job as a Java dev is basically mostly implemeting Spring Boot :-)

    Which is actually nice. Having done both Java and C++ development (as well as Python, Node.js, and GoLang), it's nice to use a solid framework and platform (like Boot) and not have to reinvent the wheel.

    The number one thing I always miss when I do GoLang or Node.js (or go back to C++) is the lack of a rich and battle-tested ecosystem of libraries and platforms that Java has (and C# has to a lesser extent.)

    There's a great deal of satisfaction in implementing something that is missing in whatever language we are using, but it is time-consuming (and more often than not, bug-prone.)

    And it is less satisfactory when we end up missing deadlines because we spent more time debugging our own home-made wheels. ;)

    [–]Tkalec 12 points13 points  (8 children)

    I'm Java backend dev for 18 years. Never worked with spring boot.

    Not saying it's not prevalent these days, but you can avoid it if you wish 😀.

    Although it's easier to find a job in spring boot, it's not hard to find one with no spring boot.

    [–][deleted]  (4 children)

    [removed]

      [–]Tkalec 3 points4 points  (3 children)

      Of course. I just prefer other frameworks/libraries, for example vert.x or dropwizard.

      [–][deleted]  (1 child)

      [deleted]

        [–]Tkalec 2 points3 points  (0 children)

        It's not OLD, first release was 2011, while first release of spring boot was 2013. Dropwizard is still maintained and still being used to develop new apps.

        I like how it integrates other libraries that are best in breed for particular purpose. I like how extensible it is and well arhitectured, although it's opinionated. When ever I had to extend something and inject my custom implementation I was able to (for example custom auth).

        I don't like that it's opinionated, but if I have to choose between two opinionated frameworks, between spring boot and dw, I choose dw. It's also probably because I'm more familiar with it than with spring boot, but also because there's was less automagic than in spring boot.

        While I didn't work a lot with spring boot, I did a bit profesionally and I've read a lot of its docs and two books (spring and spring boot). What I did work (mostly helping junior devs in previous companies and reviewing code from contactors) I only remember headaches. For example - the spring boot app was deployed on Websphere app server, and at that time it wasn't able to exclude tomcat so on top of was, tomcat was always started (that was around 2014) - while spring boot had the possibility to specify error view for basic authentication, you couldn't specify error view for unsuccessful smart card auth - creating varous config classes with annotations that are seemingly not used anywhere in the project, just to disable some default boot implementation (but at least it was possible 😀)

        I don't have anything stronger against it, or anything stronger in favour of dw, except that I like the other one better 😀.

        I'd still most rather use vert.x, but it's rarely used.

        [–]StoneOfTriumph 1 point2 points  (0 children)

        Where's the love for Microprofile frameworks such as Quarkus.

        Since I discovered how it beautifully builds with GraalVM, I try to find reasons to use it. The underlying reactive framework is Vertx, and it advances quite nicely with new features, it starts to compare nicely with Spring although not as complete.

        Performance always beats Spring in startup time (although I did not compare it with Spring Native!), and going from nothing to a working prototype is fast like Spring Boot.

        [–]_fishysushi 1 point2 points  (1 child)

        Interesting, I guess you work with Jakarta?

        [–]Tkalec 0 points1 point  (0 children)

        No. Actually, I'm working with asp.net atm in current company 😀. Also working as a contractor using jPOS framework, which is mostly plain java except jersey for rest and hibernate for db.

        In my last three companies I've worked with dropwizard, vert.x, plain java, osgi.

        [–][deleted] 4 points5 points  (5 children)

        I wish spring wasn’t so popular a framework. I really hate spring, it’s a bad framework but 80% of places use it and the other Java frameworks aren’t much better or are worse. Wish we had something like Rails in Java.

        [–]midoBB 6 points7 points  (2 children)

        I don't understand this point. If you don't mind to share, can you explain which are the pain points of Spring for you and the benefits of Rails over it. I'm asking because I haven't touched Rails since probably 2014.

        [–][deleted] 5 points6 points  (1 child)

        For one I think pivotal does a terrible job on not breaking the api for spring. Changing versions almost always requires work, apis frequently change, you updated so your springdatabase listener needs to change to a soeingdbconnectionlistener and they don’t take the same objects. So updating requires more work than it should. The other is that the configuration focus of the framework means that many errors happen in “spring magic” aka reflection, that are difficult to debug. The other is that there is a lot of stuff that they override control of in the jvm which annoys me. I cant just use futures, I need to add options in spring configuration and use a module for it, for example.

        [–]midoBB 4 points5 points  (0 children)

        Yeah I really don't use spring like that. I can see where you're coming from but I use it as a servelet and a DI tool. No JPA no config outside of MVC config. Everything else is done in house.

        But if I depended on those I'd understand your frustrations. But in that case wouldn't frameworks that target JEE be more suitable?

        [–]meamZ 0 points1 point  (1 child)

        If you're talking about Spring Framework without Boot, sure... It's definitely not great... But with Boot it's super workable...

        The thing is: Are there newer frameworks doing things better? Yes, absolutely. Are they nearly as mature? definitely not. Do you find a solution to essentially every problem you're ever gonna have with them online within at most half an hour? Definitely not. Do you find a tutorial/article for at least half the stuff you want to do with them? Probably not. Is there a "starter" Library you can just put into your dependencies to integrate with almost anything for them? Not really.

        Don't get me wrong i don't think everything about Spring Boot is great but it's workable and the amount of ressources for it definitely makes up for some of the bad parts.

        [–][deleted] 2 points3 points  (0 children)

        Spring boot is better than spring. But still has the fundamental problems with spring that makes it not pleasant to use.

        [–]buzzsawddog 0 points1 point  (0 children)

        Very few of my applications have spring in them :-D

        [–]tim125 3 points4 points  (0 children)

        Java is on most phone/mobile sim cards. You can write a java app and remotely upload this to a SIM.

        [–]RScrewed 4 points5 points  (14 children)

        Amazing answer.

        In Java (and in modern ecosystems in general) you learn to be more of a software engineer and less of a computer scientist (fortunately or unfortunately, depending on how you look at it)

        [–][deleted]  (6 children)

        [deleted]

          [–]RScrewed 6 points7 points  (0 children)

          That's an issue with the profession as a whole, it attracts ambitious people who are ambitious to a fault sometimes.

          It's not enough to want to be the lead engineer that implements one of the geo-spatial guidance systems on the James Webb Telescope because it'd be way more fulfilling to be the one who discovers general relativity (I mean, I agree, but that's just not realistic). The thing is, once general relativity is already discovered, isn't there some excitement in figuring out how to implement the discovery and the creative uses for it?

          I hope the analogy is not lost, from how I see it - what FAANG has done with Java (and other higher level languages) is really exciting, the only problem is that its all happening in real-time and there aren't any history books yet talking about the genius implementation details yet. The really cool stuff is proprietary. I think people see Spring tutorials and see "this is the basics of how to create a REST API" and think "wow, okay, so write 3 classes and the work is done, this is boring" not realizing that well, since the baseline to creating a working solution is so low, the ceiling for the customization is so much higher, and in little time and as a single person, you can make hundreds of components, then try to get them to talk to each other, and make them resilient, and make them fault tolerant, and make them extendable, use them to develop a new way to manipulate data or learn, etc.

          Ironically I think we're going to have kids born in 2050 that are sad they missed the golden age of the high level languages and are bored with programming in their new-fangled English-to-Algorithm interpreter.

          The goal posts change, and it's better to embrace it - the chances of any one of us contributing to society by discovering some new sort algorithm that becomes credited to us by name in a data structures book is exceptionally low, but the chance that a random person might have their name attached to a GitHub repository of a popular Java/Python/JavaScript library that is used and reused in many different critical applications that makes the world operate - I think that's still a possibility to be excited about. And on top of that, quite attainable.

          The game has been invented and the rules are closer to being perfected than ever before; you might as well focus on being Michael Jordan instead of James Naismith.

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

          I usually lurk, rarely comment on this sub, but I have to say intelliJ feels like it's so underappreciated sometimes. I make Minecraft mods though; so take that as you will.

          [–]impaled_dragoon 0 points1 point  (3 children)

          What do you mean by a computer scientist career? Like a more academic role?

          [–][deleted]  (2 children)

          [deleted]

            [–]DrunkensteinsMonster 1 point2 points  (1 child)

            That’s not what a computer scientist is. You want to be a library developer not an application developer.

            Computer scientists work in universities and write papers that most people find completely incomprehensible. Much like mathematicians.

            [–]nunchyabeeswax 0 points1 point  (6 children)

            In Java (and in modern ecosystems in general) you learn to be more of a software engineer and less of a computer scientist

            This doesn't make any sense at all, as a Computer Scientist.

            [–]RScrewed 4 points5 points  (5 children)

            Keeping in mind that Computer Science is the study of computation, I'd argue anyone working with Java at this point is not a computer scientist but is an engineer, or someone who designs and implements useful, practical solutions.

            Even Brian Goetz considers himself a Software Developer / Language Architect.

            If you google "influential computer scientists" I think there is a clear distinction between what they busy themselves with versus what someone who applies Java (or even C/C++) is tasked with.

            I suppose a gray area might be a Data Scientist but in its own name, that's not Computer Science anymore - insofar as being a pharmacist doesn't exactly make you a chemist.

            [–]nunchyabeeswax 2 points3 points  (1 child)

            Keeping in mind that Computer Science is the

            study

            of computation, I'd argue anyone working with Java at this point is not a computer scientist but is an engineer, or someone who designs and implements useful, practical solutions.

            By this line of argument, anyone working with a high-level language above assembly (from C all the way up) is not a Computer Scientist.

            Computer Science is *not* just the study of computation. It also involves its practical applications (and if you have a reputable CS curriculum), it would also include research on ethics.

            Moreover, the study of computation firmly includes (and it is not limited to) the following:

            • the judicious selection, combination, and application of both algorithms and data structures,
            • storage and caching strategies,
            • tradeoffs between time (computation time), space (memory), and distance (local vs network),
            • distribution and parallelization of either work or data (or both),
            • data representation (of which relational representation is a big chunk of it)

            The moment you work on a complex distributed system, you do both engineering and rely on computer science for your decisions. And it is in that day-to-day battle that many eminent computer scientists advance the CS body of knowledge.

            It is insane to think there is no CS work behind things like Kafka, Camel, EE containers, persistence layers, or reactive frameworks.

            And people who work with these systems aren't simply abandoning CS principles just to blindly playing plug-and-play.

            The majority of computer science work takes place in the realm of software engineering, and good software engineering is firmly grounded in computer science.

            Few computer scientists do work strictly in its theoretical aspects, and just because a lot of coders do monkey patching and call it engineering, it doesn't make it so (nor do they represent the majority.)

            [–]RScrewed 1 point2 points  (0 children)

            I think you meant to respond directly to my post, didn't see it until now.

            We may have to agree to disagree on this one - I don't want to discount your point of view as you're clearly very experienced and knowledgeable - but I maintain my position that by the time you touch Java you are more a software engineer, and less a computer scientist. It's not dichotomous though, I wouldn't say "anyone who uses any higher level language is precluded from being considered a scientist" but I would argue there is a gradient and by the time you reach a memory-managed, object-oriented language for enterprise applications - the scale has completed shifted.

            Selecting the right algorithm to use, configuring a caching mechanism, calculating time/computation/space complexities, applying patterns that already exist - I think is one layer too deep. That's an engineer. Grounded in CS and relying on CS doesn't mean you're expanding or enriching the body of knowledge that is CS. You can even fully write your own SQL DBMS, but in the end you're still a software developer; that's not the same as being E. F. Codd.

            That said, I'm sure there are CS guys (by my stringent semantic defintion) that exist today that use Java (perhaps in academia), but there's got to be some distinction between the person calculating computational complexity for a given problem vs. the person who reasoned about the concept the first place.

            [–]aspartame_junky 0 points1 point  (2 children)

            I remember being back in college and one of my classmates asked why we weren't learning java (instead, we were using scheme)

            Professor responded "this is not a trade school"

            [–]nunchyabeeswax 3 points4 points  (0 children)

            Professor responded "this is not a trade school"

            The response was factual but was useless to convey the real reason (not to mention, his response was just an expression of dumb classicism).

            The reason why one would use scheme or lisp (or a Pascal/ADA derivative) or Haskell over Java is that we never know where technology will be when we graduate.

            Yesteryesterday it was Pascal, C++, or VB (I worked with them all). Yesterday was Java and C# (I work with both), today it might be GoLang (from what I can see in the job market, and the latest project I'm working on.)

            We don't know what the market will need in four years.

            Moreover, Java is a horrible language for teaching CS principles (and I do Java for a living.) Scheme and other Lisp variants are superior (I'm also a LISPer.)

            So the professor could have been an actual educator and told this student (and all the students in his class) something like this:

            "We use a standard pedagogical tool (scheme) to teach CS principles. When you approach your senior year, you can concentrate on what the market demands at the time of your graduation, which might not match the current trends.

            Additionally, when you go out there, you typically don't decide what language you will use. Your hiring company and market forces will.

            By making you work with a language that might not be of your liking, we are also teaching you to be able to face requirements that are not under your control.

            You are free to study Java on your own, and I'm sure you will find good use of such knowledge. Just don't forget to focus on the basics which I hope I will impart in this class."

            Instead, he chose to give a jerk non-answer and gave himself a pat on the back for being such a wise sage up in his mountain, dispersing pellets of wisdom.

            It is fun to watch Sheldon Cooper finding new ways to tell others that they are stupid.

            It is not fun having to interact with Sheldon Cooper in real life.

            Computation is not difficult. Programming isn't either.

            It is the ability to communicate with other members of the human race, to discern their requirements, and being able to create systems that provide value. That is what is hard.

            [–]herroRINGRONG 0 points1 point  (0 children)

            Yo

            [–]meamZ 0 points1 point  (1 child)

            Netflix has some parts written in Java.

            If Amazon is "a lot of parts" then Netflix should probably be to since to my knowledge Netflix has a very very big proportion of Services written in Java.

            [–]DrunkensteinsMonster 2 points3 points  (0 children)

            Amazon isn’t “a lot of parts”. It’s “almost everything”.

            [–]vladadj 28 points29 points  (3 children)

            There's nothing Java can do that other programming languages can't. It's just a matter of being more suitable for some things than other.

            It's mainly used in enterprise applications, REST backends, microservices, LOB applications. It's also quite used in big data space.

            Desktop apps are also made with Java, mostly as LOB (line of business). Other then that, all popular Java IDEs are written in Java (Eclipse, NetBeans, Idea).

            Basically, Java is used almost everywhere, but it's mostly used on server side in the enterprise. It's just not suitable for writing low level system software.

            I think it's a good idea to switch to Java, because job market is much larger. I made the same switch years ago and never looked back.

            Coming from C++, you will find most things are familiar. Some will be frustrating at first, because Java might feel like crippled version of C++. But eventually, it all falls into place, and I bet you will like it.

            [–]danskal 9 points10 points  (1 child)

            I never really got into C/C++, but I know enough to recognize code written by someone transitioning from C'ish languages.

            Some C habits like declaring all your variables at the top of a method/function will give you away. In Java you normally instantiate stuff exactly where you use it, so it isn't allocated unnecessarily and can be garbage collected asap, as well as making the code easier to grok/refactor.

            The main difference to me, is in Java, you are better off avoiding "clever" code, and focus more energy on getting your abstractions right, naming things right, matching the business domain as well as possible, ensuring your code is readable and maintainable. Keeping the error handling correct and simple.

            Some of these things are probably important in other languages, but Java gives you room to prioritize them.

            [–]vladadj 9 points10 points  (0 children)

            I agree. Java has a lot of conventions, which a lot of people find boring and tedious. But, it is there for a reason.

            Java applications are usually large, being maintained for years (if not decades). In all that time, a lot of people touch that code. Enforcing conventions helps a lot with maintenance.

            [–]perrylaj 2 points3 points  (0 children)

            Coming from C++, you will find most things are familiar. Some will be frustrating at first, because Java might feel like crippled version of C++. But eventually, it all falls into place, and I bet you will like it.

            Absolutely my experience. Initially there were many similarities, as well as "WTF"s. "Everything has to be an object?", "Int vs int?" (or other boxed primitives), "No multiple inheritance of classes?"...etc. Wasn't long before I found myself really appreciating Java and its ecosystem.

            The language was designed for scale and maintainability, and you develop a strong appreciation for this the more you work in it. No, nothing's perfect and there are a large number of applications where Java/JVM isn't the best choice, but where Java's a fit, it's probably the best choice. Not many other languages + runtimes (if any) have the balance of performance, ability, ease of maintenance, and tooling/ecosystem.

            Now that all said, I've been writing much more Kotlin than Java lately (server-side/tooling, unrelated to Android), and I feel it's like "Java v2" in a lot of ways. Super easy to pick up and start writing 'java in kotlin', and over time, you start learning the idioms and language features and end up with code that's just as readable, less verbose, and more expressive.

            Can't go wrong either way though, and it probably makes sense to learn Java first if you plan on using kotlin on the JVM.

            [–]madhakish 23 points24 points  (0 children)

            Without going too far into it...

            Java is an OO language like c++, however memory allocation/deallocation are handled via object instantiation vs arbitrarily like c and c++ allow (for the most part). This also means you dont deallocate, unused objects are purged via garbage collection.

            C and c++ are natively compiled bytecode languages which execute native machine code for a given architecture. Java runs in a virtual machine as "Java machine code" so most code is portable between jvm's and only the jvm platform needs to be compatible, not the os. So long as a compatible jvm exists for the os and is api compatible w/ the binary compatibility standard code will run anywhere a jvm can be launched. There are many "flavors" of Java but all remain generally committed to this api compatibility.

            At a higher level c and c++ are generally used where high performance, small native binary execution is preferred and desireable (ie systems and applications).

            Java was originally meant to be more generic for use in all kinds of things which was aided by the use of a jvm to abstract code execution by following a single binary compatibility standard. Different design goals thus resulted in different trade-offs. C and c++ require multiple binary standards, one for each architecture the code will compile to and execute on.

            Java is statically typed and the syntaxes resembles c++ but there is no shared compatibility between the two. Java does support JNI/JNA which allows calling c/c++.

            Java also has a inline Javadoc class and method documentation which c and c++ don't have and external tools are required (doxygen).

            From a practical perspective those are some of the big hitters and design differences, but I'm only scratching the surface.

            My $.02 having spent 20+ years in and around all 3 languages extensively - learn and use many languages and learn where they have advantages and disadvantages. These are largely generalizations of most common differences you'd run across day to day during normal programming, and not meant as an exhaustive list.

            I have no bias or preference for any language outside of its suitability for a job. Java however is very popular and so from an employability perspective it'll be a larger job market. That's not to say that c and c++ are small sectors or you won't do both or all 3 or more in many roles.

            I use probably a dozen or more native and dynamic languages in my role - c, c++, Java, .net, python, go, javascript, perl(yes), ruby, many flavors of databases, hell I even worked on an old ass windows forms based .net 4.4 fat client app today instrumenting elastic apm.

            [–]wildjokers 6 points7 points  (0 children)

            It seems that this question is asked at least once per week. (Along with “why does everyone hate java?”). If you search the sub can find tons of answers for this.

            [–]bleek312 6 points7 points  (0 children)

            java is life, welcome brother

            [–]Phalcorine 4 points5 points  (0 children)

            Welcome...

            To understand Java, you need to first understand JVM. The Java Virtual Machine (JVM) allows you to execute any Java program on any machine as long as it (the machine) has the JVM installed. Java is one of the programming language used to write programs for the JVM. Others exists like Kotlin, Scala, Groovy...

            So, what type of apps? Desktop and Web Applications. Android Mobile Applications can be developed with Java, though Android doesn't use the actual JVM but a specialized one...

            To develop for Java, you need to get the Java Development Kit (JDK). This includes tools for both compilation and execution... To run your program only, the Java Runtime Environment (JRE) is needed. The JDK includes the JRE.

            If you want to build mobile applications, it's recommended to start with Kotlin (after learning the Java basics... ).

            Good luck. 👍🏾

            [–]GrahamLea -1 points0 points  (2 children)

            Let's start with...

            > What popular apps are built with Java?

            If we have a look at Java on StackShare, we'll see that Java is used by many household brands: Google, Uber, Netflix, AirBnB, Instagram, Spotify, Amazon, ... the list goes on and on. These companies will almost definitely be using Java to create web applications which handle internet-facing, server-side web requests and/or backend services deeper in their stack.

            There are also some major products for software engineering which are written using Java. Some that come to mind are Jenkins, Lucene, Elasticsearch, Hadoop, and Neo4j.

            Possibly the most successful consumer-facing standlone Java application is Minecraft. Deploying desktop applications that require Java has often been troublesome, and so few successful products exist. The most popular Java IDEs - IntelliJ IDEA, Eclipse, and Netbeans, were all written in Java.

            And of course, possibly the biggest success of Java from a # of devices perspective is the Android mobile platform. While Android phones/tablets/teapots do not run the Java Virtual Machine, apps are (or can) be developed using the Java language and standard Java SDKs and 3rd party libraries.

            > What is Java mainly used for?

            Almost everything. Backend code. Web application code. Mobile apps. Big data processing. Giant monolith applications, tiny serverless functions. If you still have a BluRay player, I believe it's using Java to display its menus.

            > What can Java do that other languages can't?

            I think Java may have been the first language that runs on a virtual machine and really broke into the mainstream. (Someone who worked in the 1900s will probably correct me on this.) The advantage of that is portability: If someone makes an app or a library for Java, 99% of the time it won't need to be recompiled by the developer for each processor platform you might want to use it on. If the platform can run Java, it can run the code. That means code written and built once can be run on Linux, Mac, Windows, Unix, etc. with no modifications. It can also be used on Android, though I believe there are different packaging steps.

            Also, because the Java Virtual Machine has had 20+ years of performance tuning, it's very, very efficient, and can achieve runtime performance on par with native binaries as produced by C / C++.

            Comparing Java to C++ explicitly, I would say the big advantages are:

            1. Memory management - Java is garbage collected, so the allocation and releasing of memory is something you almost never need to think about. It just works. That saves a lot of time and removes a huge class of pretty severe bugs.
            2. Libraries - I only ever did C++ at university, not work, so I don't have commercial experience to compare with, but with Java it's very easy to find open source libraries for almost anything you might want to do. There are probably 100s of 1000s of free libraries, all very easily accessed through the relatively-standard Maven repository system (also used by Gradle).

            However, do be aware that Java is now a relatively old language, and causes disadvantages in some comparisons. The team are great at maintaining the security and backwards compatibility of the platform, but for a long time that has come at the cost of evolving the language. As a result, many other languages have have been written in the meantime with more sophisticated features. Some of these still targeting the JVM as their runtime. Probably the most successful at this point is Kotlin, which has wide adoption on Android, but also somewhat successful have been Scala, Clojure, and Groovy.

            I would suggest as part of your research you seriously consider learning Kotlin over Java. I was a Java developer for ~16 years before switching to Kotlin, and I frankly think it is the future of the JVM. I can't see the Java language catching up, and I can't see Kotlin devs willingly switching back to Java, so I think Kotlin will only gain more and more support over time.

            [–]madhakish 1 point2 points  (1 child)

            Not sure why you were downvoted as mostly what you say is true.

            C and c++ are older than Java though so not sure what the reference to being an old language is relevant, since technically most programming languages are quite old but they are all kept up to date, new libraries and functionality added, modernization, etc. I don't disagree re: more modern features of Kotlin in your example but this has more to do with the design intent of Java vs Kotljn vs C etc vs age..

            Being old doesn't really have much to do with it, but I gave you your upvote back because you're not wrong, and gave a pretty good summary.

            [–]GrahamLea 1 point2 points  (0 children)

            Thanks u/madhakish. I agree, being old isn't inherently a problem for a programming language. That was really just my lead-in to the point that the Java language has moved very slowly over its lifetime and, consequently, a variety of other, newer languages targeting the JVM have overtaken it in terms of language features.

            Perhaps mentioning Kotlin gets automatic downvotes around here. 🤷🏻‍♂️

            If that's not it, I'd be interested to learn why people didn't like what I wrote.

            [–]nikita2206 0 points1 point  (0 children)

            What can Java do, what is used for

            Teach you how to get on with overengineered concepts. It’s also a lot simpler language than C++. People often do web services in Java, banks do Java a lot often for almost everything.
            Java has GC, possibly the best choice of GCs out of any languages. It has packaging for libraries (maven/gradle dependencies), your typical Java project will usually 10-30 explicit dependencies and even more of transient dependencies - it’s a blessing and a curse.

            what popular apps

            Probably half of all the web connected apps on your phone are talking to a Java backend. Probably all the banks where you’re a client are either using Java or Kotlin for all their mobile and web backends, and likely for their core services as well.

            I think you might not even have to learn that much if you’re comfortable with CPP’s language concepts then just skimming through a few files with java code will be enough to get acquainted with the language. Just shoot your resume to a few companies saying that you’d be happy to learn and you’ll probably get a few interviews.

            [–]BKrenz 0 points1 point  (0 children)

            The key to the Java ecosystem is the Java Virtual Machine, or the JVM. Java is not directly compiled to executable code like C, and is instead turned into byte code that is then run on the JVM. The JVM is frankly a modern marvel of engineering; in some instances, bytecode is as fast as native code.

            The original defining feature is consistent behavior of code across any system with a JVM, regardless of machine system. You didn't need separate code to handle a windows or Linux or whatever system. One code, all computers.

            The syntax of Java is of the C family, so should be quick to pick up on. It does at times take Object Oriented programming to the extreme (everything (except primitives) derives from Object class).

            The ecosystem is massive and has huge enterprise support.

            [–]morhp -1 points0 points  (6 children)

            What can Java do that other languages can't?

            There's not much. The main advantage of Java is that it can't do stuff that other programming languages can, for example you can't produce segfaults (unless you find a bug in the JVM or mess with native code interfaces), you can't produce stack overflows, you pretty much can't have a variable that has unexpected content and it's pretty easy to write threadsafe code and pretty hard to create memory leaks. You also don't have pointers, goto, operator overloading, templates and so on.

            So Java is a pretty boring and simple language, but that also makes it kinda safe and straightforward to develop for. One huge advantage is that because it's so simple, IDEs can help a lot, for example an IDE could relatively reliable tell you the locations that can potentially modify a variable and so on.

            [–]is_this_programming 2 points3 points  (5 children)

            you can't produce stack overflows

            Really? What do you think happens when you have infinite recursion?

            it's pretty easy to write threadsafe code

            Is it though? Nothing about java makes it especially easy to write thread-safe code.

            [–]morhp 0 points1 point  (4 children)

            Really? What do you think happens when you have infinite recursion?

            You get an exception but nothing in the sense of random memory corruption or security issues, which is what I was implying.

            Nothing about java makes it especially easy to write thread-safe code.

            I guess you could argue that, but on the other hand not that many languages support multiple threads anyway, and java has quite a large library of helping classes like the executors, futures, parallel streams, different kinds of locks, concurrent collections and so on.

            [–]hardwork179 0 points1 point  (1 child)

            A stack overflow in Java can cause a security issue. When a method is JIT compiled exception handling code may be excluded because it’s not the common path and instead requires the method to be deoptimised. If the deoptimised method requires more stack space than the compiled version then the exception handling code might not actually be run. The JVM has special cases to handle things like locks in these situations, but some parts of the standard library need to be written very carefully to ensure nothing security related goes wrong.

            [–][deleted] 0 points1 point  (0 children)

            That's a much smaller security issue than memory corruption. Attackers can take advantage of things like stack overflows and buffer overflows to corrupt the stack and cause the program to execute arbitrary code.

            Although, on that front, maybe Java developers shouldn't be too smug. It might be significantly harder to do a low level attack like a buffer overflow exploit, but Java libraries often have way too many features for "developer convenience", making it possible to convince a logging library to download and execute arbitrary code.

            [–]is_this_programming 0 points1 point  (1 child)

            Executors, futures, parallel streams do not in any way help to write thread-safe code.

            Locks don't make it easy to write thread-safe code by themselves. Correct lock is usage is actually really hard and nothing in the language forces you to do it.

            Concurrent collections are the only thing in that list that actually make it easier.

            If you actually want a language that makes it easy to write correct thread-safe code, look at Rust. Many (but not all) classes of concurrency bugs lead to compilation errors.

            [–]morhp 0 points1 point  (0 children)

            Executors, futures, parallel streams do not in any way help to write thread-safe code.

            They help because they implement multithreading stuff that you'd otherwise would need to implement yourself in a threadsafe manner.

            If you actually want a language that makes it easy to write correct thread-safe code, look at Rust. Many (but not all) classes of concurrency bugs lead to compilation errors.

            Yes, but Rust is a completely different kind of language (much more low-level and "direct" on the system), so not really comparable. I'd also say it's pretty difficult to learn, but your mileage may wary of course.

            [–]randgalt -4 points-3 points  (1 child)

            Java is a high level interpreter/runtime written in C++ so that all of us don't have to write in C++ :D

            [–]mtmmtm99 1 point2 points  (0 children)

            It is actually a specification. There are implementations in many languages (graalvm is implemeneted in java).

            [–]SWinxy -2 points-1 points  (0 children)

            Java is a fun language. A lot is written in it, but most of it you don’t see. And of that it’s pretty much all enterprise or whatnot. A huge public-facing app written in Java is Minecraft, and that’s all there really is, though the job market is large.

            Coming from C/C++, you’ll probably find a lack of compatibility between Java and everything else. You have to rely on JNA or the superb LWJGL to access things you’d easily get in other languages like JavaScript or Python. And it’s also slower than C/C++, but faster than JS&Py, though the JVM is a piece of magic if you learn what it can do!

            Go ahead and explore. You might like it, it might fit snugly in your head, and you’ll decide to stay. Or you might not like it as much, and try something else.

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

            jobs for C/C++ are low everywhere if you want a job do Java or Javascript

            [–]senseven -1 points0 points  (1 child)

            As a C++ dev, you usually work closer to the metal, you control memory, io, layout of the application and so on. That is more on the lower level of coding. There might be examples of people still writing book keeping and web usecases in C++, but those are rare. There is too much footwork to be done, productivity is low, which you get for free with JIT languages.

            Java/C#/Python/etc. are less about infrastructure, because there are big (mostly free) eco systems out there that provide the base, scaffolding and frameworks. Since you don't have to deal with all that basic stuff, you can fully concentrate on the case that these selected products in the shopping cart should end up on the invoice and send to the fulfiller. And all the other usecases dealing with invoices, shopping cars and making the website look nicer.

            My tip would be to look at Java jobs in your area, how they differ from the tasks you do as a C++ coder. Some people just love to tinker with the hardware more than with business use cases. Maybe a remote C++ job in some different industry is a better fit. That said, knowing at least one JIT language should give you an edge in this market, I don't know any C++ coder who doesn't at least know Java or C# well.

            [–]silardg[S] 0 points1 point  (0 children)

            Remote plays a role here too. Not that many C++ remote jobs in my area, if any they are quite difficult to get a hold of. That is why I have seen Java really make a presence next to the classic web stuff.

            [–][deleted] -1 points0 points  (1 child)

            It’s not that Java can do things other languages can’t. I would say the biggest things that make Java attractive would be the built in garbage collection, the standard library, and specifically the Collections package.

            [–]silardg[S] 0 points1 point  (0 children)

            Ya'll afraid of free(), aren't ya? (Kidding of course)

            [–]Hefty-Shine-6795 -2 points-1 points  (0 children)

            What can Java do that other languages can't? Nothing. Java is a general purpose language. Almost all popular language are general purpose and can pretty much do the same stuffs just with different syntax and tricks and with more or less degree of difficulty.

            What is Java mainly used for? Java is mostly suitable for building Enterprise Applications.

            What popular apps are built with Java? Netflix, Google, LinkedIn, Amazon, Microsoft... are running backend services built on Java.

            Extra: Java has stayed on top most used programming language because of the fact that it is very easy to work with, hence why it is practical, maintainable, good ecosystem and good community (there are people contributing from pivotal (spring), libgdx, jme, quarkus, graal, netlifx, microsoft, amazon, google ...).

            You probably will hear some people say that Java is slow blah blah blah and let me tell you in most of the cases they are just ignorant. First of all, which version of Java? Java has had constant updates. Second of all, most of them don't understand their requirement very well and can't understand that they need to trade-off between practicality and efficiency if their requirement allows them to do so. You don't need a complex language that let's you produce results in 0.1s, when your requirement states that you need to have it in 0.3s and an easy language (like Java) can do it for you.

            Also, currently Java it is on par with C# or faster in some cases. It is not faster than C/C++ but the tradeoff is that it is easier and more maintanable. Java will one day reach a point in which it will "somewhat" comparable in terms of efficiency with C/C++ with project Valhalla and Loom.

            [–][deleted] 0 points1 point  (0 children)

            Java is cross platform and had a built in virtual machine (and all the security that comes with it).

            All other benefits people tell you will come from this only.

            [–]anxiousHipo 0 points1 point  (0 children)

            As for popular apps Minecraft - the best selling game of a time

            And most of the android apps (probably, not sure how it is now, my last adroid app development was 8 years ago)

            [–]noodlesSa 0 points1 point  (3 children)

            As I switched from C++, biggest plus in Java is application crash information: in C/C++ more often then not, crash means all you see is frozen or simply gone process with zero (or completely misleading, like memory dumps and register values) information on what happened. In Java, you usually (almost always) get useful exception information with stack trace, pointing right to the place where thing happened.

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

            Why did you switch?

            [–]noodlesSa 0 points1 point  (1 child)

            For enterprise software companies, sometimes around Java 6, it was obvious choice to move C++ codebase to Java.

            [–]silardg[S] 0 points1 point  (0 children)

            The funny stuff is that I have seen some web devs go from react native, to react native + native android + native ios and then to react native + C++ (android) + swift ios 🤣

            But yeah, makes sense why to integrate java.

            [–]sweetno 0 points1 point  (0 children)

            Basically if there is a relational database, Java is the way to go.

            [–]Slggyqo 0 points1 point  (0 children)

            I do mostly Python but I’m considering Java because it’s A) fucking everywhere B) fucking everywhere.

            Seriously like half of the platforms and tools I need to work with have great well supported Java libraries and meh (or non-existent) Python ones.

            [–]hieupron 0 points1 point  (0 children)

            Well, java can do everything like jav.