Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

My school seems to mainly teach java

  1. Mar 29, 2005 #1
    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.
     
  2. jcsd
  3. Mar 29, 2005 #2

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  4. Mar 29, 2005 #3
    Thanks, sounds good!
     
  5. Mar 29, 2005 #4

    dduardo

    User Avatar
    Staff Emeritus

    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.
     
  6. Mar 29, 2005 #5

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Let's not get into a language debate here, dduardo.

    - Warren
     
  7. Mar 29, 2005 #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.
     
  8. Mar 29, 2005 #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.
     
  9. Mar 30, 2005 #8
    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 similiar 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: Mar 30, 2005
  10. Mar 30, 2005 #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 learnt Java independently knowing C++ earlier.
     
  11. Mar 30, 2005 #10
    In my opinion Java syntax is quite troublesome and I don't like the lack of .hpp files.
     
  12. Mar 30, 2005 #11
    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: Mar 30, 2005
  13. Mar 30, 2005 #12

    graphic7

    User Avatar
    Gold Member

    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).
     
  14. Mar 30, 2005 #13
    Damn you graphic, you're a smart one :smile:.
     
  15. Mar 30, 2005 #14

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Such compilers exist; they just don't come with the JDK.

    - Warren
     
  16. Mar 30, 2005 #15

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  17. Mar 30, 2005 #16
    This wouldn't have anything to do with JNI would it? I dunno about JNI, so..
     
  18. Mar 30, 2005 #17

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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
     
  19. Mar 30, 2005 #18
    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.
     
  20. Mar 30, 2005 #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!).
     
  21. Mar 30, 2005 #20

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Nylex, like this:

    Code (Text):

    class Square : public Shape
    {
    ...
    }
     
    - Warren
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: My school seems to mainly teach java
  1. Java problem. (Replies: 4)

Loading...