Page 1 of 2 12 LastLast
Results 1 to 20 of 24
Like Tree1Likes

Thread: Why was java developed?

  1. #1
    metron95 is offline Member
    Join Date
    Dec 2014
    Posts
    7
    Rep Power
    0

    Default Why was java developed?

    I read a lot of posts on the internet regarding the use of java for internet applications vs C++.
    I am new to java and dont understand why I should leave C++ and switch to java.

    They say java is portable:
    Now when I write a C++ program on my macbook, and it works perfectly, I transfer it to my windows desktop through google drive. And compile it there. It works perfectly well there too. So, isnt my C++ program portable? Why would I need java for it?

    They say its platform independent:
    What is platform independent code? Is platform = operating system or the CPU architecture?
    If it has to do only with CPU, then shouldnt it mean that java should execute on any cpu without the need for the cpu specific JVM? Why is platform specific JVM needed to execute java code if java is platform independent.

    Why isnt C++ used in webpages?
    Its obviously faster than java to execute.

    I am really upset I cant find anything about this on google or any other book. Believe me i have tried reading everything on the topic.
    Your help is greatly appreciated. Happy Karma to you.
    Last edited by metron95; 12-03-2014 at 01:46 PM.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Why was java developed?

    Too much question, too much offense, too little thought behind it all. I'm going to respond to one thing.

    Why isnt C++ used in webpages?
    Its obviously faster than java to execute.
    Because software engineering is about a lot more than execution speed.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    metron95 is offline Member
    Join Date
    Dec 2014
    Posts
    7
    Rep Power
    0

    Default Re: Why was java developed?

    Quote Originally Posted by gimbal2 View Post
    Too much question, too much offense, too little thought behind it all. I'm going to respond to one thing.



    Because software engineering is about a lot more than execution speed.
    But, I think thats what a discussion forum is for. Right?
    If I am ignorant you can enlighten me.

    I think I better take the f word off the post.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Why was java developed?

    That would be a start. But then it is still more a rant rather than a proper question. You seem to like C++ a whole lot - then use it and be happy with it.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: Why was java developed?

    Java was not designed with speed in mind. It was supposed to run on all kinds of platforms.
    Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented,[10] and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA),[11] meaning that code that runs on one platform does not need to be recompiled to run on another.
    (Source: Java (programming language) - Wikipedia, the free encyclopedia)

    Portable: You say you have to compile C++ on Mac AND Windows. I can compile Java on my Linux box and run it on my Windows with no compilation in between. After it's compiled, the bytecode is interpreted, and runs on any platform. That's what makes it portable.

    Platform indepentent: Each platform has its own JVM. That makes sense since each processor has its own instruction set to do stuff for you. However, the bytecode mentioned earlier, can run on *any* JVM.

    Speed: The interpreted part *used* to make it slow. Also, interpreted will *always* be slower compared to compiled, because of platform optimizations the compiler may do. But if we stop hitting Java with the 10 year old stick, then you can see that the speed of Java nears that of C++ and other "competitive" languages". Also, speed isn't everything.

    For more information, here is a nice comparison list: Comparison of Java and C++ - Wikipedia, the free encyclopedia
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  6. #6
    metron95 is offline Member
    Join Date
    Dec 2014
    Posts
    7
    Rep Power
    0

    Default Re: Why was java developed?

    Quote Originally Posted by SurfMan View Post
    Java was not designed with speed in mind. It was supposed to run on all kinds of platforms.
    (Source: Java (programming language) - Wikipedia, the free encyclopedia)

    Portable: You say you have to compile C++ on Mac AND Windows. I can compile Java on my Linux box and run it on my Windows with no compilation in between. After it's compiled, the bytecode is interpreted, and runs on any platform. That's what makes it portable.

    Platform indepentent: Each platform has its own JVM. That makes sense since each processor has its own instruction set to do stuff for you. However, the bytecode mentioned earlier, can run on *any* JVM.

    Speed: The interpreted part *used* to make it slow. Also, interpreted will *always* be slower compared to compiled, because of platform optimizations the compiler may do. But if we stop hitting Java with the 10 year old stick, then you can see that the speed of Java nears that of C++ and other "competitive" languages". Also, speed isn't everything.

    For more information, here is a nice comparison list: Comparison of Java and C++ - Wikipedia, the free encyclopedia
    That was perfect. Thats all i needed to know.
    I misunderstood the steps involved in compilation and execution, and hence was confused why CPP is not the same as JAVA.

  7. #7
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Why was java developed?

    And to answer your title question. Java was developed as a programming language to support cable (i.e. TV) boxes.

    Regards,
    Jim
    DarrylBurke likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  8. #8
    metron95 is offline Member
    Join Date
    Dec 2014
    Posts
    7
    Rep Power
    0

    Default Re: Why was java developed?

    Quote Originally Posted by jim829 View Post
    And to answer your title question. Java was developed as a programming language to support cable (i.e. TV) boxes.

    Regards,
    Jim
    Really? Thats really weird. Those guys wouldnt have known the enormous impact java would have on internet.

  9. #9
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Default Re: Why was java developed?

    Quote Originally Posted by jim829 View Post
    And to answer your title question. Java was developed as a programming language to support cable (i.e. TV) boxes.

    Regards,
    Jim
    Somebody once told me that Java was named Java because you could even run it on a coffee machine...
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  10. #10
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,143
    Rep Power
    14

    Default Re: Why was java developed?

    Quote Originally Posted by metron95 View Post
    I am new to java and dont understand why I should leave C++ and switch to java.
    Programming languages are like tools. Different tools for different jobs. This is a bit like saying "I don't understand why I should leave hammers and switch to screwdrivers".

    Quote Originally Posted by metron95 View Post
    They say java is portable:
    Now when I write a C++ program on my macbook, and it works perfectly, I transfer it to my windows desktop through google drive. And compile it there. It works perfectly well there too. So, isnt my C++ program portable? Why would I need java for it?
    See how you have to compile your program multiple times? Java developers don't have to do this.

    The point of Java's portability is simply: I can build a jar on my system, and send that jar to anybody that has Java. You don't need the "select which platform you're using" step.

    Quote Originally Posted by metron95 View Post
    They say its platform independent:
    What is platform independent code? Is platform = operating system or the CPU architecture?
    See above. "Write Once, Run Anywhere" was the motto.


    Quote Originally Posted by metron95 View Post
    Its obviously faster than java to execute.
    Wrong. This is an outdated opinion.

    Quote Originally Posted by metron95 View Post
    I am really upset I cant find anything about this on google or any other book.
    Really?

    https://www.google.com/webhp?q=java%...ava+vs+c%2B%2B
    Comparison of Java and C++ - Wikipedia, the free encyclopedia
    C++ performance vs. Java/C# - Stack Overflow
    Java*vs*C++ g++ | Computer*Language*Benchmarks*Game

    And my personal favorite: Why Java?
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  11. #11
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: Why was java developed?

    Quote Originally Posted by jim829 View Post
    And to answer your title question. Java was developed as a programming language to support cable (i.e. TV) boxes.

    Regards,
    Jim
    Can I remind you guys of Project Star7? That's where the basis of Java is to be found. A PDA on steroids. Here's some background: https://www.youtube.com/watch?v=Ahg8OBYixL0

    Don't get scared of James Gosling's mugshot @0:06 :)
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Why was java developed?

    More important (imho of course) the entire concept of WORE (Write Once, Run Everywhere) is not so much that you can move code from machine to machine but code itself can do the same; it's like RPC on steriods; Java can spread like a virus ...

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  13. #13
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Why was java developed?

    WORE would get scary if the runtime itself would be able to spread itself around. But thank god: it can't, and thus WORE remains a massive overstatement. Write Once, Run Wherever a Compatible Version of the Runtime is Correctly Installed And Not Blocked.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Why was java developed?

    WORWCVRCINB?
    It'll never catch on.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  15. #15
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Why was java developed?

    Indeed - people replaced it with SAAS. Far more catchy.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  16. #16
    metron95 is offline Member
    Join Date
    Dec 2014
    Posts
    7
    Rep Power
    0

    Default Re: Why was java developed?

    Quote Originally Posted by KevinWorkman View Post
    Programming languages are like tools. Different tools for different jobs. This is a bit like saying "I don't understand why I should leave hammers and switch to screwdrivers".



    See how you have to compile your program multiple times? Java developers don't have to do this.

    The point of Java's portability is simply: I can build a jar on my system, and send that jar to anybody that has Java. You don't need the "select which platform you're using" step.



    See above. "Write Once, Run Anywhere" was the motto.




    Wrong. This is an outdated opinion.



    Really?

    https://www.google.com/webhp?q=java%...ava+vs+c%2B%2B
    Comparison of Java and C++ - Wikipedia, the free encyclopedia
    C++ performance vs. Java/C# - Stack Overflow
    Java*vs*C++ g++ | Computer*Language*Benchmarks*Game

    And my personal favorite: Why Java?
    Quote Originally Posted by KevinWorkman View Post
    Programming languages are like tools. Different tools for different jobs. This is a bit like saying "I don't understand why I should leave hammers and switch to screwdrivers".



    See how you have to compile your program multiple times? Java developers don't have to do this.

    The point of Java's portability is simply: I can build a jar on my system, and send that jar to anybody that has Java. You don't need the "select which platform you're using" step.



    See above. "Write Once, Run Anywhere" was the motto.




    Wrong. This is an outdated opinion.



    Really?

    https://www.google.com/webhp?q=java%...ava+vs+c%2B%2B
    Comparison of Java and C++ - Wikipedia, the free encyclopedia
    C++ performance vs. Java/C# - Stack Overflow
    Java*vs*C++ g++ | Computer*Language*Benchmarks*Game

    And my personal favorite: Why Java?
    1. Someone on this thread pointed out that java was built originally for consumer electronics like set top boxes. I read in a book that: Java was designed with the motivation of enabling developers to write one code be able to run it on devices with different CPUs. But, anyways the JAVA guys had to create a JVM for each particular CPU right? So then why didnt they create a individual compiler for each CPU. Is there a huge difference in JVM and Compiler that I am unaware about?
    Now, I read in a book that a compiler for a CPU takes a lot of energy and time to create. Then, is it the case that JVM can be created for each CPU with much more relative ease?

    2. To your last comment. Yes! I did read everything I could still I couldn't find a satisfactory answer. I googled "why was java developed/invented/created/..". Thanks for the links though.

    3. Dont take it on the offensive or feel I am trying to argue. I am just curious about its origins.

  17. #17
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Why was java developed?

    1. If the app needed compiling on each machine then a user couldn't simply take the app from a download site and run it locally.
    They'd have to compile it beforehand (as with C++). Having a JVM on the machine means they can just run the app.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  18. #18
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Why was java developed?

    One must keep in mind that this thread has a secret invisible part in the title - "why was Java developed almost 20 years ago?". Times and needs have changed in that long period of time, a more fitting and reasonable question today would be "Why is Java still so popular and in what areas of development?"
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  19. #19
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Why was java developed?

    Quote Originally Posted by metron95 View Post
    1. Someone on this thread pointed out that java was built originally for consumer electronics like set top boxes. I read in a book that: Java was designed with the motivation of enabling developers to write one code be able to run it on devices with different CPUs.
    That was me and I read that almost two decades ago. I was also told that by a Sun service manager (pre Oracle).

    But, anyways the JAVA guys had to create a JVM for each particular CPU right? So then why didn't they create a individual compiler for each CPU. Is there a huge difference in JVM and Compiler that I am unaware about?
    Now, I read in a book that a compiler for a CPU takes a lot of energy and time to create. Then, is it the case that JVM can be created for each CPU with much more relative ease?
    You are mixing things up. You are correct in your first sentence. And Sun (now Oracle) wrote different compilers and such (aka JDK) for different target architectures (as does third party vendors). That is why you need to select the proper platform when you download the zip files. But the JVM is a virtual machine. That is, it does not exist as a real machine but executes code like it was a CPU. The compiler is the tool which takes source code and compiles it to be run by the JVM. The compiler could actually be written in Java and run on the JVM itself.

    And to add some additional info. The Java compiler could be considered a cross-compiler. These are compilers written to compile code for a machine other than the current machine. They are used all the time. Especially in development environments where the target architecture can't possibly support such tools or isn't fast enough. If you every wrote code for a micro-controller, then it's a good bet you used a cross compiler.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  20. #20
    metron95 is offline Member
    Join Date
    Dec 2014
    Posts
    7
    Rep Power
    0

    Default Re: Why was java developed?

    Quote Originally Posted by jim829 View Post
    That was me and I read that almost two decades ago. I was also told that by a Sun service manager (pre Oracle).



    You are mixing things up. You are correct in your first sentence. And Sun (now Oracle) wrote different compilers and such (aka JDK) for different target architectures (as does third party vendors). That is why you need to select the proper platform when you download the zip files. But the JVM is a virtual machine. That is, it does not exist as a real machine but executes code like it was a CPU. The compiler is the tool which takes source code and compiles it to be run by the JVM. The compiler could actually be written in Java and run on the JVM itself.

    And to add some additional info. The Java compiler could be considered a cross-compiler. These are compilers written to compile code for a machine other than the current machine. They are used all the time. Especially in development environments where the target architecture can't possibly support such tools or isn't fast enough. If you every wrote code for a micro-controller, then it's a good bet you used a cross compiler.

    Regards,
    Jim
    Thank you for your answer Jim.
    1. Yes I completely understand and agree with you.
    2. But, my question still remains: What is the difference in developing different JVMs for different CPU architectures. and Developing different compilers for different CPU architectures. Isn't it the same? Or does the former take less effort.

    I guess what I am trying to understand is that: Oracle anyways needs to write a JVM for each CPU separately. Then why didnt it write different compilers for different CPUs. Or to rephrase, why did C++ not write different compilers for different CPUs.

    Why does JAVA need a compiler+interpreter to do its job. If its going to be platform independent doesnt it make more sense for them to write different compilers for different CPUs?


    3. I had another question: Why did the Java guys not use C++ to be executed by a Virtual Machine. Why did they write a whole new language?

    Again, I am just trying to understand why Java needed to exist, when they could add the functionality in existing languages?

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 06-13-2012, 03:45 PM
  2. for web application developed in struts
    By manohar.kavala in forum Struts
    Replies: 0
    Last Post: 03-28-2012, 09:38 AM
  3. PPT viewer which is developed in Java
    By maniselvaraj in forum Advanced Java
    Replies: 3
    Last Post: 12-16-2010, 11:08 AM
  4. A small free utility developed in SWT
    By alexpkb in forum SWT / JFace
    Replies: 0
    Last Post: 08-18-2009, 11:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •