My school seems to mainly teach java

  • Java
  • Thread starter mattmns
  • Start date
  • Tags
    Java School
In summary: Java.In summary, Java is similar to C++, but has some differences. Java is based on a virtual machine while C++ is not. Java does not have header files, while C++ does. Java has a cleaner syntax than C++. Java is 5x as easy to use as OS implementations in C++ when it comes to GUI functions. Java is also less prone to compile errors. Java is slower than compiled Java.
  • #1
mattmns
1,128
6
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
  • #2
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
 
  • #3
Thanks, sounds good!
 
  • #4
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.
 
  • #5
Let's not get into a language debate here, dduardo.

- Warren
 
  • #6
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.
 
  • #7
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.
 
  • #8
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:
  • #9
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.
 

1. What is Java and why is it the main focus in my school?

Java is a programming language commonly used for creating web applications, desktop applications, and mobile applications. It is a popular language because of its versatility and compatibility with different operating systems. Your school may focus on teaching Java because it is widely used in the industry and provides a strong foundation for learning other programming languages.

2. Can I learn other programming languages besides Java at my school?

Yes, it is possible to learn other programming languages at your school. While Java may be the main focus, most schools also offer courses in other languages such as Python, C++, and JavaScript. It is important to have a diverse skillset as a programmer, so it is beneficial to also learn other languages.

3. Is Java the best language to learn for a career in computer science?

The answer to this question may vary depending on personal opinions and job opportunities. However, Java is definitely a valuable language to learn for a career in computer science. It is widely used in the industry and has a strong community for support and resources. It is also a good language for beginners to learn as it has a relatively simple syntax compared to other languages.

4. What are the job prospects for someone who knows Java?

Knowing Java can open up many job opportunities in various industries. It is commonly used for creating web applications, so there is a high demand for Java developers in companies that have an online presence. It is also used for developing mobile applications, so there are opportunities in the mobile app development industry as well. Additionally, knowledge of Java can be beneficial for roles such as software engineer, data analyst, and systems analyst.

5. Is Java difficult to learn?

Learning any programming language can be challenging, but with dedication and practice, it is definitely achievable. Java has a simple syntax and is similar to other programming languages, making it easier for beginners to grasp. With the right resources and guidance, you can become proficient in Java and other languages in no time.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
8
Views
3K
  • Programming and Computer Science
Replies
3
Views
3K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
3
Views
4K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
7
Views
679
  • Programming and Computer Science
Replies
4
Views
4K
Back
Top