Close
  • Latest News
  • Artificial Intelligence
  • Big Data and Analytics
  • Cloud
  • Networking
  • Cybersecurity
  • Applications
  • IT Management
  • Storage
  • Sponsored
  • Mobile
  • Small Business
  • Development
  • Database
  • Servers
  • Android
  • Apple
  • Innovation
  • Blogs
  • PC Hardware
  • Reviews
  • Search Engines
  • Virtualization
Read Down
Sign in
Close
Welcome!Log into your account
Forgot your password?
Read Down
Password recovery
Recover your password
Close
Search
Logo
Logo
  • Latest News
  • Artificial Intelligence
  • Big Data and Analytics
  • Cloud
  • Networking
  • Cybersecurity
  • Applications
  • IT Management
  • Storage
  • Sponsored
  • Mobile
  • Small Business
  • Development
  • Database
  • Servers
  • Android
  • Apple
  • Innovation
  • Blogs
  • PC Hardware
  • Reviews
  • Search Engines
  • Virtualization
More
    Home Applications
    • Applications
    • Development
    • Networking
    • Servers

    Ten Advantages Java Has Over C++

    By
    Darryl K. Taft
    -
    June 25, 2012
    Share
    Facebook
    Twitter
    Linkedin

      PrevNext

      1Ten Advantages Java Has Over C++

      1

      2Garbage Collection

      2

      Java is known for its garbage collection. Garbage collection (GC) is a form of automatic memory management. The garbage collector attempts to reclaim garbage, or memory, occupied by objects that are no longer in use by the program. A significant portion of C++ code is dedicated to memory management. Cross-component memory management does not exist in C++. Libraries and components are harder to build and have less natural APIs. Garbage collection leads to faster time to market and lower bug count.

      3The Build Process

      3

      When compared with Java, C++ builds are slow and complicated. Developers have noted that a full build in C++ might take up to 20 hours, while the same build might take only seven minutes in Java. For debugging C++, developers need a second build. Java has more approachable build tools like Ant and Maven, while C++’s Make and NMake are considered less so.

      4Simplicity of Source Code and Artifacts

      4

      C++ splits source into header and implementation files. It requires a big monitor to see .hpp and .cpp header file extensions and file name extensions at the same time. With C++, there is code in multiple places: some inlined in the header, some in the .cpp. Artifacts are compiler-specific, but there are many of them. Yet, with Java, there is just one .java, one .class extension.

      5Binary Standard

      5

      Java has a binary standard. In addition to being loadable as a class by a Java Virtual Machine, a Java Classfile can be used to compile against. C++ has no binary standard. C++ precompiled headers are compiler- and platform-specific. And C++ requires a large amount of source to be shipped in order to compile against it. Java defers platform-specific stuff to the runtime.

      6Dynamic Linking

      6

      There is no standard way to dynamically link to C++ classes. Java allows arbitrary collections of classes to be packaged together and dynamically loaded and linked as needed. With Java, there are no dynamic link library fiascos, also known as DLL hell.

      7Portability

      7

      As Java’s mantra has been “Write once, run anywhere,” Java is portable with very little effort. C++ is portable in theory, but in practice, you have to build another language (#ifdef’d types, etc.) on top of it. And C++ has significant differences from vendor to vendor, e.g., standards support.

      8Standard Type System

      8

      Java has:• specified, portable primitive types;• a built-in, specified, portable runtime library;• rich support for I/O, networking, XML/HTML, database connectivity;C++ does not.

      9Reflection

      9

      Reflection is the ability of a program to examine and modify the structure and behavior (specifically the values, metadata, properties and functions) of an object at runtime. Java has full runtime capability to look at the runtime. C++ has optional Run-time type information (RTTI) but no reflection. Reflection enables extremely powerful generic frameworks and provides the ability to learn about, access and manipulate any object.

      10Performance

      10

      Although performance is typically not considered one of the benefits Java has over C++, Purdy argues that garbage collection can make memory management much more efficient, thereby impacting performance. In addition, Java is multi-threaded while C++ does not support multi-threading. C++’s thread safe smart pointers are three times slower than Java references. And Java has HotSpot Java Virtual Machine (JVM), which features just-in-time (JIT) compilation for better performance.

      11Safety

      11

      Java eliminates pointers, which can allow arbitrary memory access and the ability to easily crash the process (core dump). There are no buffer overruns in Java, and code and data cannot be accidentally mixed. And Java includes bounds-checking. Bounds-checking is any method of detecting whether a variable is within some bounds before its use.

      12Five Reasons Why Java Has Not Been Able to Fully Supplant C++

      12

      13Startup Time

      13

      Java is not good for “instant” and short-running processes. The graph of initially loaded classes is pretty large. The code is either getting JITed to native code each time the JVM starts, or it’s initially being interpreted (HotSpot).

      14Memory Footprint

      14

      Java uses significantly more memory than C++, particularly for “small” applications—easily two orders of magnitude more at the extreme end of the scale. Memory requirements limit Java adoption on some devices.

      15Full Garbage Collection (GC) Pauses

      15

      Sooner or later, there is a part of GC that can’t be run in the background and can’t be avoided, which results in a temporary halt and makes real-time processing impossible. This can be havoc for distributed systems. However, there is possible partial amelioration by increasing the memory footprint.

      16No Deterministic Destruction

      16

      C++ has deterministic destruction; Java does not. Deterministic destruction is useful for managing resources. In C++, when objects are deleted, their destructors are executed immediately. This allows system resources to be released when an object is no longer needed.

      17Barriers to Native Integration

      17

      Operating systems are built in C/C++. APIs are typically C. Native GUIs and other OS-level functionality often require C callbacks. However, the Java Native Interface only allows Java to call native code that was written explicitly to be called by JNI.

      PrevNext
      Get the Free Newsletter!
      Subscribe to Daily Tech Insider for top news, trends & analysis
      This email address is invalid.
      Get the Free Newsletter!
      Subscribe to Daily Tech Insider for top news, trends & analysis
      This email address is invalid.

      MOST POPULAR ARTICLES

      Latest News

      Zeus Kerravala on Networking: Multicloud, 5G, and...

      James Maguire - December 16, 2022 0
      I spoke with Zeus Kerravala, industry analyst at ZK Research, about the rapid changes in enterprise networking, as tech advances and digital transformation prompt...
      Read more
      Applications

      Datadog President Amit Agarwal on Trends in...

      James Maguire - November 11, 2022 0
      I spoke with Amit Agarwal, President of Datadog, about infrastructure observability, from current trends to key challenges to the future of this rapidly growing...
      Read more
      IT Management

      Intuit’s Nhung Ho on AI for the...

      James Maguire - May 13, 2022 0
      I spoke with Nhung Ho, Vice President of AI at Intuit, about adoption of AI in the small and medium-sized business market, and how...
      Read more
      Cloud

      IGEL CEO Jed Ayres on Edge and...

      James Maguire - June 14, 2022 0
      I spoke with Jed Ayres, CEO of IGEL, about the endpoint sector, and an open source OS for the cloud; we also spoke about...
      Read more
      Applications

      Kyndryl’s Nicolas Sekkaki on Handling AI and...

      James Maguire - November 9, 2022 0
      I spoke with Nicolas Sekkaki, Group Practice Leader for Applications, Data and AI at Kyndryl, about how companies can boost both their AI and...
      Read more
      Logo

      eWeek has the latest technology news and analysis, buying guides, and product reviews for IT professionals and technology buyers. The site’s focus is on innovative solutions and covering in-depth technical content. eWeek stays on the cutting edge of technology news and IT trends through interviews and expert analysis. Gain insight from top innovators and thought leaders in the fields of IT, business, enterprise software, startups, and more.

      Facebook
      Linkedin
      RSS
      Twitter
      Youtube

      Advertisers

      Advertise with TechnologyAdvice on eWeek and our other IT-focused platforms.

      Advertise with Us

      Menu

      • About eWeek
      • Subscribe to our Newsletter
      • Latest News

      Our Brands

      • Privacy Policy
      • Terms
      • About
      • Contact
      • Advertise
      • Sitemap
      • California – Do Not Sell My Information

      Property of TechnologyAdvice.
      © 2022 TechnologyAdvice. All Rights Reserved

      Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.

      ×