My school seems to mainly teach java

  • Context: Java 
  • Thread starter Thread starter mattmns
  • Start date Start date
  • Tags Tags
    Java School
Click For Summary

Discussion Overview

The discussion revolves around the comparison between Java and C++ as programming languages, particularly in the context of a computer science class that primarily teaches Java. Participants explore the implications of this shift, the compatibility of programming skills between the two languages, and the suitability of Java for specific applications, such as creating math learning programs with graphics.

Discussion Character

  • Debate/contested
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Some participants suggest that Java is a "regularized" version of C++, maintaining core concepts while avoiding certain complexities of C++.
  • Others argue that Java's structure differs significantly from C++, particularly in its pure object-oriented nature and lack of multiple inheritance.
  • Concerns are raised about the reliance on managed code in Java compared to the lower-level programming capabilities of C++.
  • Participants discuss the performance differences, with some claiming Java is slower due to being interpreted, while others assert that Java can perform comparably to C++ in certain scenarios, especially with JIT compilation.
  • There are questions regarding the necessary Java SDK version for programming and whether it includes all required components.
  • Some participants express personal preferences regarding syntax, noting that they find Java's syntax cumbersome compared to C++.
  • Discussions include the implications of using Java for graphical applications and whether it is suitable for the intended projects.

Areas of Agreement / Disagreement

Participants express a mix of agreement and disagreement regarding the merits and drawbacks of Java versus C++. While some acknowledge the benefits of Java, others emphasize the importance of understanding C++ and its lower-level capabilities. The discussion remains unresolved with multiple competing views on the topic.

Contextual Notes

Participants highlight various limitations and assumptions, such as the potential for deprecated functions in different Java SDK versions and the varying performance characteristics of Java and C++ depending on the specific use case.

mattmns
Messages
1,129
Reaction score
5
Next semester I plan on taking a comp science class, and my school seems to mainly teach java. I always considered the standard language to be c++, I think it was a few years ago here, but I guess they recently switched over.

My questions are:

Are there any major differences between Java and C++, as in if I was able to program decently in one, would I be ok in the other?

Also, I plan on continuing to use linux. Is this going to create a problem with Java programming?

One more thing. I will be mainly making simple math learning programs (probably with heavy graphics), will this be ok with both? I am guessing yes, maybe one is better than the other? My high school math teacher was really into Java, so I am going to assume that it works well enough for most things.

Thanks.
 
Technology news on Phys.org
Java is basically a "regularized" C++. It maintains all of the core C++ concepts, but avoids all of the syntactic and debugging nightmares that are inherent in C++. The syntax is similar, but the structure of the language is rather different. I consider them to be closely related languages.

Java will run anywhere, including on Linux.

You can do anything in Java, short of writing a device driver perhaps.

- Warren
 
Thanks, sounds good!
 
Its a shame the college board got rid of the C++ curriculum. I think it is important for students new to programming to understand low level concepts. People are getting too reliant on managed code. I remember the day when you were thrilled to have 16k of memory and wrote highly optimized code.
 
Let's not get into a language debate here, dduardo.

- Warren
 
One more question. The "Java Class" thread says that I need to download J2SE 1.4.2 SDK; however, I do not see one listed as that, I do see J2EE 1.4.2 SDK, though. I am going to assume that is what I need. Also, I do not have java installed at all on my computer, not that I know of at least, will I need to install the J2SE 1.4.2, or does it come with the sdk? Thanks.
 
No, you want J2SE 1.4.2 SDK. Try here:

http://www.sun.com/download/index.jsp?cat=Application%20Development&tab=3&subcat=SDKs%20(Software%20Development%20Kits)

The SDK includes everything you need.
 
chroot said:
Java is basically a "regularized" C++. It maintains all of the core C++ concepts, but avoids all of the syntactic and debugging nightmares that are inherent in C++. The syntax is similar, but the structure of the language is rather different. I consider them to be closely related languages.

Java will run anywhere, including on Linux.

You can do anything in Java, short of writing a device driver perhaps.

- Warren

Some differences between Java and C++

- Java is a pure object oriented language, while C++ can use a hybrid of OO and procedural/imperative constructs (global functions, structs, etc.)

- Java is based on a virtual machine. Compiling a Java program does not produce a native, OS depedent executable. It produces bytecode which can they be interpreted by a Java bytecode interpreter. This makes Java somewhat slower and bigger than C++

- C++ has multiple inheritance while Java does not -
althought it does have interfaces, which a class can implement many of. These are similar to "pure virtual" classes in C++ - they have only function declarations and no instance variables

- Java has no header files - definitions are never separate from declarations (with the exception of interfaces as noted)

- Java does not have compiler directives (#define, #ifdef, etc.) . There is no "preprocessing" stage. This can really make C++ code a mess - whey you have lots of #ifdef's for portability purposes

- C++ has templates while Java does not: these allow you to define a "parameterized" data structure - for instance if you have a stack, and you want to have a stack of integers and a stack of characters, you could write a class that handled stack operations with a template, and declare something like stack<int> int_stack and stack<char> char_stack. This would ensure type safety in your data structure, something that would be impossible to guarantee with Java for a generalized data structure ( You would have to have your class operate on Object(the parent of all classes) or some other parent class, but then you when you did the operations, they would always "cast down" to object upon manipulation).

- I hate to be subjective, but I feel that Java's GUI functions are 5x as easy to use as OS implementations in C++ such as MFC on windows and GTK, QT on linux.

- As noted, the syntax in Java is much cleaner and regular
 
Last edited:
Plus:

- Interpreted Java is much slower than C++ code
- Java is not only a programming language, but also a set of libraries, and a technology

I agree with dduardo that universities should not discard C++ which offers lower level programming, and necessarily, more power to the programmer.
Knowing C++ it would have been very easy to learn Java in a few weeks.
In my university programming was introduced with C++ and later we had a module for Java Programming. But I had learned Java independently knowing C++ earlier.
 
  • #10
In my opinion Java syntax is quite troublesome and I don't like the lack of .hpp files.
 
  • #11
danne89 said:
In my opinion Java syntax is quite troublesome

How so? Nothing wrong with that, I'm just wondering why :smile:.

Edit: gnome, wouldn't it be better for him to get the latest version of the JDK (well, J2SE 5.0)?
 
Last edited:
  • #12
Edit: gnome, wouldn't it be better for him to get the latest version of the JDK (well, J2SE 5.0)?

That was my thought, as well; however, the book and/or instructor may be making use of deprecated functions in J2SE 5.0 that may not be so deprecated in the J2SE 1.4.2 release (if there are any - I'm not sure).
 
  • #13
Damn you graphic, you're a smart one :smile:.
 
  • #14
so-crates said:
Compiling a Java program does not produce a native, OS depedent executable.
Such compilers exist; they just don't come with the JDK.

- Warren
 
  • #15
ramollari said:
- Interpreted Java is much slower than C++ code
This is a myth; the actual difference in speed depends strongly on what you're doing. If you're doing a lot of math in a loop, e.g. scientific computing, Java will be almost as fast as C++, and in some cases a bit faster. This is thanks to the JIT, of course.

- Warren
 
  • #16
chroot said:
Such compilers exist; they just don't come with the JDK.

- Warren

This wouldn't have anything to do with JNI would it? I don't know about JNI, so..
 
  • #17
No, Nylex, I'm talking about commercial products, e.g. Jet:

http://www.excelsior-usa.com/jet.html

The JNI (Java Native Interface) is just the mechanism by which a Java program can interface with code written in other languages.

- Warren
 
  • #18
Nylex said:
How so? Nothing wrong with that, I'm just wondering why :smile:.

Edit: gnome, wouldn't it be better for him to get the latest version of the JDK (well, J2SE 5.0)?

Maybe because I'm a C++ programmer by nature, I prefare shorter keywords, like in C++, and think it's iritating to write "public class HelloWorld extends Applet". Public should be default and the extends keyword seems unneccesarily long to me.
 
  • #19
Warren: ahh ok, sorry!

danne89: how do you do inheritance in C++? I don't think I got that far when I tried learning it. I prefer seeing the words myself, the whole :: thing in C++ is a bit confusing (I can't even remember what it's for!).
 
  • #20
Nylex, like this:

Code:
class Square : public Shape
{
...
}

- Warren
 
  • #21
This makes Java somewhat slower and bigger than C++
Compiled Java programs are much smaller than their C++ equivalents.
Java is slower, but I don't find that an issue. The most annoying I think is the loading time (time it takes for VM to start, load class files and start execution).
 
  • #22
el-half said:
Compiled Java programs are much smaller than their C++ equivalents.
Java is slower, but I don't find that an issue. The most annoying I think is the loading time (time it takes for VM to start, load class files and start execution).

The VM is only required for interpreted Java programs. If you use JIT compilers, there is no need for the VM and dynamic loading of class files.

chroot said:
This is a myth; the actual difference in speed depends strongly on what you're doing. If you're doing a lot of math in a loop, e.g. scientific computing, Java will be almost as fast as C++, and in some cases a bit faster. This is thanks to the JIT, of course.

JIT compilers are part of the solution, but they are not optimized enough to compete with C++ compilers. The future however will gradually bring better compilers for Java.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
Replies
8
Views
3K
Replies
86
Views
4K
  • · Replies 8 ·
Replies
8
Views
4K
Replies
3
Views
4K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 18 ·
Replies
18
Views
10K
  • · Replies 6 ·
Replies
6
Views
3K