Programming in JAVA

Discussion in 'General Off-Topic Chat' started by BloodWolfJW, Sep 4, 2011.

Sep 4, 2011

Programming in JAVA by BloodWolfJW at 7:41 AM (1,016 Views / 0 Likes) 17 replies

  1. BloodWolfJW
    OP

    Member BloodWolfJW Marotheit

    Joined:
    Feb 11, 2011
    Messages:
    220
    Location:
    Colorado Springs
    Country:
    United States
    So, I'm taking programming class in high school. To my unfortunate knowledge, we are three weeks into coding in JAVA. I expected C++, but you can't win 'em all, right? Anyway, I was wondering what are the pros and cons of programming in JAVA?
     
  2. JoostinOnline

    Member JoostinOnline Certified Crash Test Dummy

    Joined:
    Apr 2, 2011
    Messages:
    10,834
    Location:
    The Twilight Zone
    Country:
    United States
    I don't know about pro's and con's, but I suggest you use Eclipse and link it to java API.
     
  3. bowser

    Member bowser Mwa ha ha ha!

    Joined:
    Sep 1, 2008
    Messages:
    2,178
    Location:
    GBAtemp ↑↑↓↓← → ← →BA
    Country:
    India
    Well one of the main pros is there are no pointers in Java [​IMG]
    (always found it hard to understand pointers)

    And I personally find it easier to program in Java than in C++

    Cons are you can't write homebrew in Java [​IMG] (I think)
     
  4. BloodWolfJW
    OP

    Member BloodWolfJW Marotheit

    Joined:
    Feb 11, 2011
    Messages:
    220
    Location:
    Colorado Springs
    Country:
    United States
    No coding homebrew?! NOOO!!!!
     
  5. JoostinOnline

    Member JoostinOnline Certified Crash Test Dummy

    Joined:
    Apr 2, 2011
    Messages:
    10,834
    Location:
    The Twilight Zone
    Country:
    United States
    After learning java I find it pretty easy to understand other languages. I'm not at the point where I can write my own homebrew, but I've been able to mod several apps without prior knowledge of C.
     
  6. SifJar

    Member SifJar Not a pirate

    Joined:
    Apr 4, 2009
    Messages:
    6,022
    Country:
    United Kingdom
    As a point of interest, Android apps are written in Java. You could potentially look into Android development if you become competent in Java. But no, you cannot write homebrew for any of the popular consoles (Wii, DS, PSP, PS3, 360) in Java AFAIK. However, as JoostinOnline said, learning Java (or any fairly standard programming language) should help to familiarise you with a lot of the basic concepts of general programming, which will make it easier to learn other languages, such as C(++).
     
  7. ronfar23x

    Newcomer ronfar23x Member

    Joined:
    May 13, 2010
    Messages:
    17
    Country:
    United States
    Having learned Java in college and keeping up with the changes in the specs, I can offer several pros and cons.

    Pros:
    Cross platform. Will work on any system with a native JRE (Java Runtime Environment) written for it.
    NO POINTERS! (as bowser stated above)
    Handles its own garbage collection to prevent memory leaks. Although you can introduce leaks if you feel like doing tricky stuff...
    Excellent entry language for anyone wanting to learn C/C++ later.

    Cons:
    Cross platform. No JRE, no Java programs. AFAIK the PSP is the only system that currently has a JRE, a homebrew called PSPKVM.
    Resource intensive. The virtual machine must first convert the Java bytecode into native code that your machine can execute, or alternatively run it as an interpreted language similiar to Pascal or BASIC.
    Always being updated. Sun/Oracle is always changing the language specifications.

    I would actually recommend that you try your hand at game programming with Java for PC or web though. It is an excellent way to learn the programming structures needed for games.
     
  8. Coto

    Member Coto GBAtemp Addict

    Joined:
    Jun 4, 2010
    Messages:
    2,278
    Country:
    Chile
    Java is much like C but OO (Object Oriented), with their own classes and stuff. Personally, I don't like it that much, just because it's a language that requires the client compiling all the code, which isn't light when you consider a lot of visuals, gfx, etc, plus slowing down the system overall.
     
  9. Mazor

    Member Mazor Z80 master arch

    Joined:
    Feb 14, 2008
    Messages:
    547
    Country:
    Sweden
    What kind of argument is that? How can the lack of a language feature of this crucial kind be beneficial?

    Speaking of pointers specifically, the lack of them in Java can actually make achieving what you in C and C++ would do with pointers harder. For instance you would in Java instead of simply using a pointer to a variables adress, as in C and C++, have to copy the value of the variable to a field wrapper object and then use a reference to point to it.



    I could also list some pros and cons, but ronfar23x already did a pretty good job in listing the main concerns and this wikipedia article covers the rest you need to know for the basic differences between the languages.

    The thing is, for a introductory high school programming course it should be almost entirely irrelevant if you are coding in Java or C++. As far as you're concerned when learning the basics, Java takes its syntax straight from C++ using object orientation. While you're still learning the basics, you'll mostly be writing the exact same code you could be writing in C++ with only a few minor differences (mainly in the very few lines of code that define the entry point of the program) .
     
  10. bowser

    Member bowser Mwa ha ha ha!

    Joined:
    Sep 1, 2008
    Messages:
    2,178
    Location:
    GBAtemp ↑↑↓↓← → ← →BA
    Country:
    India
    Makes it harder to write viruses.
     
  11. Mazor

    Member Mazor Z80 master arch

    Joined:
    Feb 14, 2008
    Messages:
    547
    Country:
    Sweden
    With your logic, a language that has as little features as possible is top tier.

    We might as well just make a language that compiles as an empty file into an empty binary.
     
  12. bowser

    Member bowser Mwa ha ha ha!

    Joined:
    Sep 1, 2008
    Messages:
    2,178
    Location:
    GBAtemp ↑↑↓↓← → ← →BA
    Country:
    India
    Java lacking pointers doesn't make it a language of few features. It has a lot of other great features that C++ doesn't have. At the same time, it also lacks some features of C++. Forget about just C++, on a broader scale there are so many other languages out there like PHP, Ada, etc. to name a few. Each one has its own pros and cons. Each one is best suited for particular applications.

    Applications that require a high degree of control by the programmer on memory management are better off written in C++. It's easier to write complicated programs in Java because of the availability of a large number of built-in and 3rd party libraries, not to mention its high portability to different environments. I think Ada is used a lot in defense/military applications (I may be wrong about this one).

    Pointing back to your original point (pun intended [​IMG] ), lack of pointers can be beneficial because it simplifies programming and also provides security to a certain extent.
     
  13. Mazor

    Member Mazor Z80 master arch

    Joined:
    Feb 14, 2008
    Messages:
    547
    Country:
    Sweden
    The "increased security" argument you're pulling is terrible. It's ridiculous to deliberately limit the power of a language by removing features, limiting the tools available to the developer just to prevent him from using them maliciously.

    More importantly, you should read up on what's actually going on. If anything Java leads to less security at large as the many ways Java lets you go past system security make software written in Java a lot more vulnerable than C++ counterparts.

    To make it clear, I'm no C++-fanboy. See my own post that I linked at the top of this post. For pointers, I won't further argue against the fact that a lack of them would be beneficial, the truth is that it can be hard to compare high level languages to lower level ones and the answer is very situational. On the whole though, understanding things like pointers will apart from letting you use a very powerful tool help you in pretty much any imperative programming language and is definitely something you should learn about if you want to become a good programmer.
     
  14. Linkiboy

    Member Linkiboy GBAtemp Testing Area

    Joined:
    May 14, 2006
    Messages:
    4,888
    Country:
    United States
    there aren't pointers from the java programmer's perspective, only references. The java implementers are the ones dealing with pointers, since the vm and api are implemented in c/c++.

    if you're actually interested in this, read the white papers on the java system.
    http://java.sun.com/docs/white/index.html

    of interest should be the Garbage Collection and the VM handling of references.

    anyway java has it's own purposes compared to C++ or whatever... if there was only need for one language, there would only be one language
     
  15. kevan

    Member kevan Imagination rules the world

    Joined:
    Dec 4, 2009
    Messages:
    1,378
    Location:
    Place
    Country:
    Australia
    There is one another plus for Java

    it is!

    Once your fluent go learn C# and you will learn it within a few days since they are so similar.

    And you can use C# for Xbox Indie Games.
     
  16. purplesludge

    Member purplesludge anyone have any ideas for this space

    Joined:
    Mar 2, 2009
    Messages:
    1,047
    Location:
    wv
    Country:
    United States
    Learning java helps create a better understanding of object oriented programming, well for me anyways. I like c/++/# better though.
    Edit:My professor said that when they used to start with c/++ that more students would drop because of the initial difficulty. Now its mostly math classes that cause students to switch majors.
     
  17. nano351

    Member nano351 GBAtemp Regular

    Joined:
    Jun 6, 2009
    Messages:
    259
    Country:
    United States
    The AP language switched from C++ to Java so that's why you are taught java in your high school classes. Java is actually quite a versatile language and not as slow and bloated as everyone makes it out to be (all remembering the early versions of java). It allows for rapid development of complicated applications. It can't be used for everything (specifically programming for embedded systems, etc) since it does compile to a special bytecode that is later dynamically recompiled to whatever assembly language the machine the VM is running on supports. It does however: allow for your code to take advantage cpu instructionse opcodes you don't even know exist (compile once, run everywhere), program from android platform (dalvik), and program for the web frontend (applets and gwt) and backend (servlets).
     
  18. DiscostewSM

    Member DiscostewSM GBAtemp Psycho!

    Joined:
    Feb 10, 2009
    Messages:
    4,799
    Location:
    Sacramento, California
    Country:
    United States
    Java has its uses. It is the primary language taught at Sac State (at least from what I've seen), and can use libraries like OpenGL (for which you require to use the library wrapper JOGL). This past semester, we were taught how to make a game using Java and JOGL in my game-architecture class. It was interesting experience. I still prefer C/C++, but Java isn't too bad.

    Just to let people know who don't know yet, Minecraft is made in Java.

    As far as pointers are concerned, Java doesn't allow you to handle them directly, but instead, it uses a lot of references (basically one copy of a set of data, and variables hold the reference to it). Anything not a primitive type is done this way, so when you have one non-primitive assigned to another non-primitive, it doesn't copy the contents, but just gives it the reference. When you want to make an actual duplicate, you use the general clone function that all objects have. Personally, I like pointers as it gives me direct access to what I want, and allows me to handle data the way I want.
     

Share This Page