Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 11 of 11

Thread: JAVA vs ALL

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Location
    Greece
    Posts
    26
    My Mood
    Tired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JAVA vs ALL

    Good evening everybody.

    It's just half past twelve here in Greece. After spending my whole day reading about Antennas & Wireless Spread, as the exams are not so far, I remembered the yesterday conversation that we had with a friend about general programming.

    I think he is going to be a web developer and now he's learning C++. We were talking generally about our university and general career opportunities, when suddenly he whispered me the secret(it's a greek phrase, if anyone cannot finf the sense in that sentence). He told that C++ is much more better than JAVA and the struggle has just began.

    But, in the end, I ended up -once again- asking myself: Am I right? Did actually JAVA 7 fix all the previous mess?

    I guess this question annoys many minds and that was the reason to begin this thread.

    I eagerly wait your responses about JAVA's current benefits and anything you think makes JAVA special or even weak.


  2. #2
    Member
    Join Date
    Jan 2013
    Posts
    39
    My Mood
    Relaxed
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: JAVA vs ALL

    The benefit of java is:
    -Could be easy implemented in webpage;
    -Fast compilation
    -No istalation and thus fast starting up
    -mutiplatform

    but general C++ and C# are faster, this is because of
    The java code talks to the JRE and then to windows
    (Java app --> JRE --> windows)
    instead C++ goes direct to windows
    (.exe --> windows)

    that is the basic

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Location
    Greece
    Posts
    26
    My Mood
    Tired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA vs ALL

    So, we badly cooperate with JAVA, instead of C++ or C# ?

  4. #4
    Member
    Join Date
    Jan 2013
    Posts
    39
    My Mood
    Relaxed
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: JAVA vs ALL

    Still java is pretty good and for a wider audionce because of its multi platform.
    And its really good for web applications because they are easily intergrated.

  5. #5
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    963
    Thanks
    7
    Thanked 205 Times in 181 Posts

    Default Re: JAVA vs ALL

    general C++ and C# are faster, this is because of
    The java code talks to the JRE and then to windows
    I'm no expert but this needs a few qualifications.

    First speed depends on what the programming is doing. If it is interacting with resources on the internet that will be the bottle neck. (and if it's interacting with user input that bottle neck will be 1000x smaller/slower.) In such a case you could use an interpreted language for all that it would matter. At the other end of the spectrum you might require intensive computation that goes as fast as it can, and native code is the way to go. But, even then, native code can be called within Java, so it's still not a matter of "this language is faster than that".

    Another thing to bear in mind is that "speed" is not a thing that can be measured solely by the user's wall clock. Programs have to be developed, and maintained. And there is the speed (ease/cost) associated with the development and maintenance. Java may or may not be the way to go (I don't know enough to say and, anyway, it's case specific) but it's a factor to be considered especially when cross platform deployment is desired.

    Beware of comparing the runtime performance of good C# code with bad Java code. Java's earlier start means there is plenty of truly awful Swing code about. (Again, I'm not knowledgeable and am not a Java fanboy, so for all I know C# is just plain easier to develop in than Java for Windows gui apps. My point is that the comparison of development time and runtime speed should be between well written C# and Swing apps. And it really should be a comparison and not a retelling of urban legends.)

    Next, the fact that Java code is compiled to byte code and then, at runtime, that byte code gets converted into instructions executed by the CPU does not necessarily mean that the resulting program is slower than one where the compiler generates the instructions directly. The point is subtle but sometimes the CPU instructions that are most efficient for a given task depend on the context within which the task is being performed. So-called "ahead of time" compilers have no way of taking this context into account while languages supporting "just in time" compilation constantly adapt to what the running program is doing to produce CPU instructions that are the most appropriate.

  6. #6
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: JAVA vs ALL

    First we have to understand two key pieces:

    The first part is the Java language. This language allows you to define the intended operations of a program. Compared to C++ there are various key differences. In general C++ adopts a "permissive" ideology which provides some barriers, but in general tries to allow you to do whatever you tell it to do, whether that was what you intended or not. For this reason C++ tends to be a more difficult/time consuming language to program in, especially for beginners. Java tends to define a "conservative" ideology which identifies key pitfalls and tries to prevent the programmer from running into problems. However, this comes at the expense of certain programming styles and practices which can't be defined using the Java language.

    The second part is the Java runtime. This is independent of the Java language, and indeed isn't necessarily required to compile/run a Java program. All that is required is a compiler which outputs native code instead of Java bytecode, and indeed such compilers exist. Likewise, there's nothing stating that a C++ compiler can't compile a program into an intermediate code which requires a separate runtime. Now in general compiling Java programs to native code at compile-time is rare, as is compiling C++ code into intermediate code.

    So what is the Java runtime? It just needs the ability to convert Java bytecode into executable instructions which can be run by the native hardware. Does it need to be a software implementation? No! Theoretically it's perfectly valid to define a hardware architecture which can run Java bytecode natively. Likewise, there's no requirement that Java bytecode must be interpreted instruction by instruction. This was how early Java runtimes worked and indeed they did perform poorly. However, more common Java bytecode is compiled at runtime and the Java program can run natively. This feature has been in the "official" Java runtime since Java SE 1.3, which was released in the year 2000.

    What trade-offs do you get with Just-in-Time compilation? The biggest one is that the JIT compiler can pick and choose what optimizations to make based off of the hardware running the program. A statically compiled program must assume a least common denominator of hardware features on the target machine, so on machines which are missing any of these features will fail to run properly, and on systems with more hardware features available won't be able to take advantage of any potential performance benefits. However, JIT compilation requires execution time. With a statically compiled program all the compilation takes place at some pre-specified time and the user doesn't have to wait for the JIT compiler to do anything to run the program at full speed.

    So in conclusion:

    1. The C++ language is a much more permissive language than the Java language. It allows you to do various things which may allow you to closely target an intended application. However, there's no guarantees that the application will match the intended application regardless of what language you use.

    2. The Java runtime is not directly tied to the Java language, though it usually is. It's job is to facilitate the execution of Java bytecode, and as of recent (last 13 years or so) has been implemented using a Just-in-Time compiler. This means that in practice a Java program's performance can rival that of a C++ program. It also allows a Java program to be compiled once and it can be run on multiple platforms without any re-compilation of the source code.

    3. A well written Java program can out-perform a poorly written C++ program, and vise-versa.

    4. Performance isn't the "end-all" discussion of which language is better. There are many other factors which may be more important, such as developer time/experience, cross-platform compatibility, availability of existing frameworks/API's, etc. Java does have several features which C++ lacks, and vise-versa. The two are simply different and one is not always better than the other. Programming languages are just tools, and just as a hammer is not always the best tool for the job, C++/Java or any other language are not the absolute best for every situation.

    Incidentally, C# programs are also typically compiled to intermediate bytecode. Just because on Windows C# programs compile to a .exe extension doesn't mean that it isn't interpreted. Like the Java runtime, Microsoft's C# runtime has a JIT compiler. However, Microsoft intentionally implement their C# compiler to not be platform-independent. There do exist compilers for the C# language which can compile C# source code for other platforms, thoug

  7. The Following User Says Thank You to helloworld922 For This Useful Post:

    andreas90 (January 25th, 2013)

  8. #7
    Junior Member
    Join Date
    Jan 2013
    Location
    Greece
    Posts
    26
    My Mood
    Tired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA vs ALL

    Anyway, even if we are down from other languages, I will continue learning JAVA until being great at this language, because it seems much easier to me than C++, for example(overloading + or -? lol). And despite all the above, J2EE is very useful for a career as a developer.

  9. #8
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: JAVA vs ALL

    Quote Originally Posted by theo75 View Post
    And despite all the above, J2EE is very useful for a career as a developer.
    That's true. A side note, if I were interested in a career as a software engineer in Greece, I would definitely spent time learning C# and the .NET framework since it is very very popular in enterprise development in our country.

  10. #9
    Junior Member
    Join Date
    Jan 2013
    Location
    Greece
    Posts
    26
    My Mood
    Tired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA vs ALL

    Quote Originally Posted by andreas90 View Post
    if I were interested in a career as a software engineer in Greece
    I didn't say that because I would like to make such a career(i also don't absolutely reject it hah), but as a JAVA plus benefit. What you said about c# also is correct, as in our country, talking about software engineering, I always see that C# and JAVA is needed.

    Είσαι και παλιός εδώ μέσα απ' ότι βλέπω ρε andrews. Ωραίος.

  11. #10
    Member
    Join Date
    Jan 2012
    Location
    Hellas
    Posts
    284
    Thanks
    11
    Thanked 59 Times in 57 Posts

    Default Re: JAVA vs ALL

    Καλωσήρθες! Ψάχνω καιρό για Έλληνα στο φορουμ. Και ό,τι θες στείλε και προσωπικό μήνυμα αν μπορώ να βοηθήσω, αν και υπάρχουν πολύ πιο καταρτισμένα άτομα από μένα και σίγουρα μπορούν να βοηθήσουν περισσότερο.

  12. #11
    Junior Member
    Join Date
    Jan 2013
    Location
    Greece
    Posts
    26
    My Mood
    Tired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA vs ALL

    Να 'σαι καλά ρε andrews. Πιθανόν να σε ενοχλήσω σύντομα, καθώς έχω ένα δυνατό -για τον καιρό που ασχολούμαι με τη γλώσσα- project. Καλώς σας βρήκα, λοιπόν.