1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Courses Recommended computer science course

  1. Aug 2, 2005 #1
    From a few university webpages I see the recommended computer science course for science majors utilizes Java. Is there any particular reason for this? I thought Fortran (and others like C/C++) was the main programming language of science...

    Edit: Oops, I didn't mean to post this in academic & career guidence section...
     
    Last edited: Aug 2, 2005
  2. jcsd
  3. Aug 2, 2005 #2
    I can think of a couple reasons

    1) Syntax is cleaner than C, and much, MUCH cleaner than C++ for the OO stuff.

    2) No header files or other preprocessor mess to deal with. No linking stage the programmer has to deal with (its all done dynamically). Therefore, no makefiles to deal with. Make sure your CLASSPATH is set right, and you are good to go.

    3) No need for messy pointers or screwy C++ references. Every non-primitive variable (i.e. everything not an not int, float, char, etc.) is passed by reference.

    4) Automatic garbage collection. You don't have to specifically deallocated every object you instantiated. C++ has smart pointers implementations but they are not built into the language so they are not as nice.

    5) Automatic array bounds checking. Helpful when you are trying to debug, and have no idea why your pogram quits with some weird error "Access violation 0x00e48d at 0x08343d"

    6) Exceptions. C++ has these, though I have never encounterd code that actually uses them, because the standard libraries don't use them. To tell the truth it can get annoying in Java to have to either catch or throw every single exception. But in the end, it makes your programs alot more robust and gives much more meaningful error messages than something like what I wrote in 5). And Java exceptions include a full stack trace.

    7) No multiple inheritance. Java classes can implement multipe interfaces, which are akin to pure virtual classes in C++, but they cannot inherit from more than one class. Granted, you don't have to actually use this feature, but rest assured other programmers will. And someday you might have to read their code.

    8) Alot more platform agnostic than C and C++.

    10) A standard graphics library and GUI, that works pretty well cross platform. C++ has a couple of these, but there are not part of a standard library and not as nice, although they are primarily because of the clunkiness of the C++.

    These advantages far outweigh the disadvantages of Java (speed, templates are actually useful, I/O library is somewhat clunky ) for a beginning program course IMO. Perhaps Java is not the best language for an intro course (Python or god forbid, VB would probably be better for that), but for courses that are trying to teach concepts and not necessarily implementations, I understand why professors would prefer using it over C or its retarded OO cousin C++.
     
    Last edited: Aug 2, 2005
  4. Aug 2, 2005 #3
    i just took an intro to compsci course, and it was centered around Java programming. much like your situation. Java is a pretty clean, simple to use language. he did intro C/C++, and it was messier.

    it was a fun course, just be open minded.

    ps: writing Java programs that algorithmically solve problems are pretty cool
     
  5. Aug 2, 2005 #4
    So it is basically used to teach, or is it also used in serious numerical analysis and whatever else physicists use programming for?
     
  6. Aug 2, 2005 #5
    its a teaching tool in my opinion for algorithm/functions but people do use it for webapps. I hear its poorere in memory mgmt than c/C++
     
  7. Aug 2, 2005 #6

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Java is definitely not just a teaching tool. It's used in many "serious" applications, but it has its disadvantages, as have been described. Other languages like Python, Perl, Matlab (script), or C++ might be better for different applications. Your best bet is to learn a number of different languages, and use the best for each problem. Once you've learned a couple of languages, it takes little effort to learn another.

    - Warren
     
  8. Aug 2, 2005 #7
    Java is an excellent first language for all the reasons that so-crates pointed out, it's also very powerful, once you get past the applet stage.

    The most important thing to walk away with from your first programming class is an understanding of programming basics. Once you know how to: declare variables, declare and access arrays, call methods, write methods, create and use loops, do basic decision making with "if/then/and" statements, understand the concept of OOP, and are able to write a few simple classes, it's easy to move on to any language that interests you. The rest is mostly syntex and learning the libraries so you don't have to reinvent the wheel every time you need to accomplish something.
     
  9. Aug 2, 2005 #8
    I already know Python/C/Assembly and some basic C++/Java. I was really getting at the fact that Fortran and C are used a lot in science and that we should be learning those, but I guess I neglected the fact that they may not be the easiest first languages.

    I agree with everything said here about Java, though.
     
  10. Aug 2, 2005 #9
    Pick the one that fits you most, the one that most interests you, and remember not to contradict yourself in any circumstances which can lead you to suffering ...
     
  11. Aug 3, 2005 #10
    Java is definately a very powerful language that is not at all a "teaching" language, like possibly something like Pascal is these days. However, I don't think Java is usually the best language to run your typical physics program in, because it's reliance on running through a VM tends to really slow down large numerical calculations.

    Java is great for GUI type programs, and web interface programs (where you don't know what type of machine / OS your web user will be using) or even cell phones (easy to animate and allows easy accessorizing and cross compatability)

    but for heavy calculational physics programming, nothing beats C++ IMHO.

    ~Lyuokdea
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Recommended computer science course
Loading...