LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LQ Articles Discussion (https://www.linuxquestions.org/questions/lq-articles-discussion-68/)
-   -   DISCUSSION: Java vs. C++ (https://www.linuxquestions.org/questions/lq-articles-discussion-68/discussion-java-vs-c-498583/)

Mister_Ex 11-04-2006 11:19 AM

DISCUSSION: Java vs. C++
 
This thread is to discuss the article titled:
Java vs. C++

Quote:

Students.java or Students.cpp? A review of C++ versus Java, and which should be used in classrooms Sean Enck Kettering University Computer Science Undergraduate enck6535[at]kettering.edu ABSTRACT This paper aims to compare C++ and Java in a university setting. The question posed among staff and students at some universities is: should we be teaching Java or C++ as the current programming standard? Both are viable options, but would students benefit more from either language? The following discussions of both C++ and Java will give a little background or history of the language. The pros and cons of both Java and C++ will be weighed against each other in a classroom setting, what is good for students when it comes to programming languages and what would make a student struggle? The next step involves an implementation of algorithms and coding which will be used to show the amount of iterations C++ and Java can do within a 1000 millisecond time interval. Several experiments have been designed to test different code in each language. These experiments include an integer assignment, an array filling assignment, a recursive method, generic system output, a bubble sort, and finally retrieval of the current directory. This same code will be reviewed to see how many lines of code it takes for Java and C++ to have done the same amount of work. These results will be interpreted as to which language is the better language as far as speed and ease of use. Once both Java and C++ have been covered the future languages that are available for teaching courses in the next several years will be reviewed briefly. Finally, the better teaching language will be discussed and the reasons for the choice will be given.

pda_h4x0r 11-06-2006 02:58 PM

Java is easier to teach and to understand than C++ (read: NO POINTERS, TOTAL encapsulation), but C++ is still the industry standard for application development (it's faster, more compact, takes advantage of hardware, closer to machine-level, etc.), and is a MUST-learn. Personally, I believe that they should be taught the same year--Java first semester, and C++ second semester.

NullTerminator 02-19-2007 04:49 PM

A couple clarifications
 
Overall I enjoyed the article. The hard measurements reinforce our general conception that C++ is faster and closer to the hardware. Java is excellent for learning OOP, especially if you study the swing libraries and the Model-View-Controller architecture.

Another aspect to consider when deciding to specialize in java or C++ is the job market. Java was hot a couple years ago, but there are now loads of java programmers out there. You will need more than a programming language alone to compete in the job market.

Quote:

Executables – Programs compiled into files that are attributed with the .exe file tag.
These programs are mostly developed in accordance to Microsoft’s .NET Framework.
I would hesitate to say mostly with .net framework. I've been programming C/C++ for twenty years and yet to use .net runtimes. We also do a lot of OS400 programming in C++ with no .net available.

Quote:

<u>Java in the Real World</u>
Quote:

Though Java programs are .java files, they can be compiled to self running .jar files to allow for clickable running in a given Operating System (similar to an executable file in Windows). This concept allows for a Operating System migration with Java programs to require little to no hassle compared to a C++ change.
1) .java source files are compiled into class files. .class files are combined into an archive call a .jar file. If the jar file contains the proper manifest it can be considered an executable jar.
2) The idea of a 'self running' jar file is misleading. It still requires that a suitabl java runtime environment be installed.
3) It is only 'clickable' if the OS recognizes the .jar extension and has a proper java command line mapped to call the main class.

Quote:

Whether we discuss Perl, PHP or any other mostly web-based language, the question of portability begins. Though they are often fast and require only a server, they are also not as easy to set-up for single users without server access. Yes, Perl or PHP can be run on a single computer but this is no easy task. Often times this sort of task will require an Internet server to be installed along with other packages for a specific language.
1) perl and PHP ARE VERY portable.
2) perl in a cgi context is web based, but perl does very well as a scripting language without any web aspect. It is easy to set up on a single machine and extremely useful for programs requiring heavy text parsing/processing.
3) PHP is primarily a web based language, but a standalone interpeter can run scripts independently of the web.

juvestar15 03-24-2007 09:56 AM

I've just finished my university studies so hopefully I can add something useful. :)

A year or two before I started(2003) a Computer Science degree, the primary language taught was C++. The then changed to Java and restructured the entire course around it. First year we had Programming Java 1 and 2. Second year I did "Object Oriented Programming 1 & 2", it was pretty much Swing, threads, JSP and Servlets. In my 3rd and final year was the first chance to study C++( however it was optional). The lecturer got the labs setup with .NET but really didn't mind what we used to write the code. In my 4th year which I did a honours degree, they introduced a "Algorithms and Structures" subject for first years which was all C++.

They must have realised putting all their eggs in one basket(ie. use java exclusively) was a bad idea. As I look for jobs now there's pages and pages for J2EE/Java developers. The interesting ones (to me anyway ;)) are the ones that want C++ experience. Speaking to lecturers around he uni. though, they don't think it should be a Java vs. C++ debate(at first anyway). They're all for python or some type of scripting language then going on with something more complicated. Before uni. I had programming experience in VB so I found java/c++ quite easy. The important thing is to teach concepts first(using an easy language), then figure out which more difficult language to go with. I know time is tight and that's why they want a language that does everything AND be easy at the same time. From what I've seen, that just puts students off programming.

One extremely frustrating thing they never paid attention to was deployment of the programs we had just created. Sometimes I need to write a program up quickly for me or a friend and find myself in a hole. I spent 3 years learning java but was never taught about .jar files. That's fine, I'll pick it up myself. But lets says I sent my .class files to a friend, he then has to install all the java libraries and goto the command line or setup class paths. Same with C++ in .NET and all the .Net libraries. C++ has the advantage though because you don't need .NET to write C++ programs. That's pretty much why I'd lean towards C++. If you get an idea in your head and you put some code down, it'll be easily distributed.

vki 04-01-2007 09:52 PM

I am personally of the believe that C is a far superior language than java. Having known and used C independently for some time then being taught java in the class room I have been able to distinguish some key elements that I dislike about java. For example the incredible ability of java to turn simple tasks into cumbersome blocks of code. A very simple example would be just doing standard io you have to make objects just to take in command line arguments, seems overly cumbersome to me :\ but maybe I'm just old school. I don't want to keep ranting at risk of sounding like a cynic

But to each his/her own...

NullTerminator 04-02-2007 06:34 PM

vki,

Command line arguments? You mean like an array of Strings that's passed to main(String []args)? How simple is that?

Code:

// something like this?
public static void main(String []args) {
  for( int idx=0; idx< args.length; ++idx){
    System.out.println(args[idx]);
    }
}  // end main

If you want something fancier, there are many getOpt ports for java.

Java is great for network i/o, and servlets are a lot easier to code that C/C++ cgi. But, for windows gui applications I'd say C/C++ wins.

I don't think anyone will argue that java is faster than C, but development costs may be less with java depending on the project. Want to learn some patterns and MVC architecture - go with some swing lessons. It takes OO to a whole other level. Learning java is a great OO teaching mechanism. The whole idea of programming to interfaces and implementing in derived classes will give great background for future C++ learning and development.

Don't expect to succeed as a programmer with an either/or attitude. You will eventually need both, and maybe some vba and shell scripting thrown in. We do a lot with java web front ends and C stored procedures on the back end.

\0


All times are GMT -5. The time now is 07:26 PM.