Advertisement
6_2008-2009 Miscellaneous #205578

C++/Java

The differences between C++ and Java

AI

एआई सारांश: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

सोर्स कोड
original-source
<P ALIGN="CENTER"><FONT FACE="Verdana" SIZE="-1"><U><B><FONT SIZE="+1">C++
		Vs Java(Ham vs Chicken)</FONT></B></U></FONT></P>
	 <BLOCKQUOTE>
		<P><FONT FACE="Verdana" SIZE="-1">C++ is one of the most powerful
		 language and will be used for a long time in the future inspite of emergence of
		 Java. C++ runs extremely fast and is in fact 10 to 20 times FASTER than Java.
		 Java runs very slow because it is a byte-code-interpreted language running on
		 top of "virtual machine". Java runs faster with JIT (Just-In-Time) compiler,
		 but it is still slower than C++. And optimized C++ program is about 3 to 4
		 times faster than Java (with JIT compiler). </FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1"><B>Then, why do people use Java?</B>
		 Because it is pure object oriented and is easier to program in Java, as Java
		 automates memory management, and programmers do not directly deal with memory
		 allocations. 		 Because of manual memory
		 allocations, debugging the C++ programs consumes a major portion of time.
		 </FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1">Since C++ programmers are abundant, it
		 is recommended you do programming in object-oriented "C++" for all your
		 application programming or general purpose programming. You can take full
		 advantage of object oriented facilities of C++. The C++ compiler is lot more
		 complex than "C" compiler and C++ programs may run bit slower than "C"
		 programs. But speed difference between "C" and "C++" is very minute - it could
		 be few milli-seconds which may have little impact for real-time programming.
		 </FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1">Since computer hardware is becoming
		 cheaper and faster and memory 'RAM' is getting faster and cheaper, it is worth
		 doing code in C++ rather than "C" as time saved in clarity and re-usability of
		 C++ code offsets the slow speed. Compiler optimizer options like -O or -O3 can
		 speed up C++/C which is not available in Java. Nowadays, "C" language is
		 primarily used for "systems programming" to develop operating systems, device
		 drivers etc.. </FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1"> Prefer to use web-server-side
		 programing "Fast-CGI" with C++ and HTML, DHTML, XML to get better performance.
		 Hence, the golden rule is "Web-server side programming use C++ and web-client
		 side (browser) programming use Java applets". The reason is - the server-side
		 OS (Linux) is under your control and never changes, but you will never know
		 what the client side web-browser OS is. It can be Internet appliance device
		 (embedded linux+netscape) or computers running Windows 95/98/NT/2000 or Linux,
		 Apple Mac, OS/2, Netware, Solaris etc.. The advantage of Java language is that
		 you can create "Applets (GUI)" which can run on any client OS platform.
		 </FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1">Java was created to replace the
		 Microsoft Windows 95/NT GUI APIs like MS Visual Basic or MS Visual C++. In
		 other words - "Java is the cross-platform Windows-GUI Api language of next
		 century". Many web-browsers like Netscape supports Java applets and web-browser
		 like Hot Java is written in java itself. But the price you pay for
		 cross-platform portability is the performance, applications written in Java run
		 very slow. </FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1">Hence, java runs on
		 <FONT COLOR="#FF3333">"client"</FONT> and c++ runs on <FONT
		 COLOR="#FF3300">servers</FONT>.</FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1"><I>Some facts:</I> The usage of char *
		 and strcpy causes horrible memory problems due to "overflow", "fence past
		 errors", "memory corruption", "step-on-others-toe" (hurting other variable's
		 memory locations) or "memory leaks". The memory problems are extremely hard to
		 debug and are very time consuming to fix and trouble-shoot. </FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1">Memory problems bring down the
		 productivity of programers. Memory related bugs are very tough to crack, and
		 even experienced programmers take several days or weeks to debug memory related
		 problems. Memory bogs may be hide inside the code for several months and can
		 cause unexpected program crashes. </FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1">The memory bugs due to usage of char *
		 and pointers in c/c++ is costing $2 billion every year in time lost due to
		 debugging and downtime of programs. If you use char * and pointers in c++ then
		 it is a very costly affair, especially if your program size is greater than
		 10,000 lines of code.</FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1"></FONT></P>
		<P><FONT FACE="Verdana" SIZE="-1"></FONT></P></BLOCKQUOTE>
मूल टिप्पणियाँ (3)
Wayback Machine से पुनर्प्राप्त