Results 1 to 9 of 9

Thread: C++ or Java? Or somthing else...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    IZob's Avatar Citizen
    Join Date
    Aug 2009
    Location
    Australia
    Posts
    9,829

    Default C++ or Java? Or somthing else...

    Which programming language is your favourite?

    Personally for me its C++ because everything is structured in a sensible and logical way, generally speaking.

    Java on the other hand was designed to be more readable and easier to programme for the developer.

    Its easier to programme (I have yet to experience this part yet, but it is true since Java has plenty of libraries of pre-built programmes available to use), but IMO its not easier to read. In fact, it quiet the opposite. I am though a bit of a noob to Java...

    Your thoughts?

    Also ... partly decided to open this thread because there is more to computers then .. buying the hardware ("what iz da best $$$ value for HARDWarze item?)
    Contact me on Steam: steamcommunity.com/id/IZob/ or send a PM.

  2. #2
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,751
    Blog Entries
    3

    Default Re: C++ or Java? Or somthing else...

    Depends on what I'm trying to achieve. All the tools I've written for RTW/M2TW have been written in C# and with the exception of .Net not being portable to non-windows platform it combines most of the advantages of both Java and C++ without too many of the disadvantages.

    C++ is powerful, there literally isn't anything that cannot be done on a computer that you can't do with c++. You assertion that it is logical and structured is false. You can do pretty much anything you want in any you want, even if it makes no sense and it will generally compile. You have the ability to fine tune your code beyond anything that most other non-assembly languages can provide as you can make assembly language calls directly. The cost is c++ programs are not portable, every computer architecture you want to run it on needs its own compiler and hence multiple executables. Memory management is entirely up to the programmer as is garbage collection, which usually means memory leaks run amok in any serious or large c++ application. Most programmers no matter how good they are will make mistakes here, its a matter of if but of how many and how big the consequences are. Operator overrides are a god send, they make code more readable and I grumble about any language that doesn't have them. C++ (non .Net) does not really have any good/powerful IDE's to work with which is irritating.

    Java on the hand has the advantage being 100% portable there's no OS on which it can't run that is currently used by any serious number of people. It does garbage collection for you which means no memory leaks. Everything that isn't a primitive is an object the advantage to this is the common methods that all object then have, the disadvantage is that java passes all objects by reference which means that you need to add a lot of unnecessary code for object cloning to make sure that other methods don't accidentally change your objects, this isn't required if you can specify if a parameter should be passed by reference or by value. You can't choose to declare variable either on the stack or the heap. There's no operator overloading. There's no optional paramters, which means writing extra methods that just call other methods, and method calls all have overhead. Lots of IDE to choose from.

    Which I'd choose depends on what I'm trying to accomplish. If whatever it is needs to be super-efficient with a super-low memory overhead I'll likely choose C++, but aside from that I'm significantly more likely to choose C# or Java to write my code.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  3. #3
    IZob's Avatar Citizen
    Join Date
    Aug 2009
    Location
    Australia
    Posts
    9,829

    Default Re: C++ or Java? Or somthing else...

    You know your code I forgot that Java is very portiable, but that dosnt really benfit a student developing programms with the same OS all the time.
    C++ (non .Net) does not really have any good/powerful IDE's to work with which is irritating.
    Sorry whats an IDE?
    You can do pretty much anything you want in any you want, even if it makes no sense and it will generally compile.
    I meant, your capable of developing the code in a logical sense easier then other languages (at least imo). Of course you could always do the opposite and make the code unreadable. But thats unnecessary.
    Contact me on Steam: steamcommunity.com/id/IZob/ or send a PM.

  4. #4
    Dewy's Avatar Something Witty
    Join Date
    Jun 2008
    Location
    Australia
    Posts
    4,697

    Default Re: C++ or Java? Or somthing else...

    Programming languages are tools, you use tools for different needs. You wouldn't cut down a tree with a spade for example, just like you shouldn't be making a simple windows application in C++ when something like visual basic will get it done five times as fast.

    Quote Originally Posted by Squid View Post
    Java on the hand has the advantage being 100% portable there's no OS on which it can't run that is currently used by any serious number of people.
    What about game consoles?

    Quote Originally Posted by Squid View Post
    It does garbage collection for you which means no memory leaks.
    There is still memory leaks in Java programs. The GC doesn't free memory if there is still a reference to it. You can very easily run out of memory due to these memory leaks. I can't be sure but I swear there is hundreds of memory leaks in minecraft.

    Quote Originally Posted by IZob View Post
    Sorry whats an IDE?
    Integrated development environment.
    Oh no the picture of my dog disappeared!

  5. #5
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,751
    Blog Entries
    3

    Default Re: C++ or Java? Or somthing else...

    Quote Originally Posted by Dewy View Post
    What about game consoles?
    I'm sure someone could/would write a java interpreter for a game console if they wanted to and the console creator allowed it. (I'm sure the limiting factor is the later and not the former!)

    There is still memory leaks in Java programs. The GC doesn't free memory if there is still a reference to it. You can very easily run out of memory due to these memory leaks. I can't be sure but I swear there is hundreds of memory leaks in minecraft.
    Usually the result of people using global variables probably collections and not remembering to empty them, and technically that's not a memory leak as there are still references to the data. A memory leak is when you have allocated memory on the heap but have no way to de-allocate it because you've lost all references to the memory location. Not using memory efficiently is a different issue.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  6. #6

    Default Re: C++ or Java? Or somthing else...

    Quote Originally Posted by IZob View Post
    Sorry whats an IDE?
    Integrated development environment, if I remember correctly. Basically a program made for that language to help you code.

    I'd like to echo Squid's sentiments, except that C# is generally as efficient as C++. Languages like C# and Java have a clear advantage, in my opinion, over languages like C and C++ because of the JIT compiling. They really are just as fast as C++ unless you have some crazy-ass programmer spending months doing optimizations, but that can also be a bad thing because programs lose a lot of scope which leads to errors. So it's one of those things that just comes down to which one your prefer. In my case, C#. .NET is great, it's a great IDE, it has a simpler syntax, and has the fantastic XNA libraries.
    Under the Patronage of Leonidas the Lion|Patron of Imperator of Rome - Dewy - Crazyeyesreaper|American and Proud

  7. #7
    karamazovmm's Avatar スマトラ警備隊
    Join Date
    Aug 2009
    Location
    Brazil, São Paulo
    Posts
    9,639

    Default Re: C++ or Java? Or somthing else...

    I happen to like c# much more, and use the .net framework a lot.

    Im trying to learn objective c as of now, xcode is a good ide to use, so Im giving it a spin

    The very ugly forgive, but beauty is essential - Vinicius de Moraes

  8. #8
    karamazovmm's Avatar スマトラ警備隊
    Join Date
    Aug 2009
    Location
    Brazil, São Paulo
    Posts
    9,639

    Default Re: C++ or Java? Or somthing else...

    .net is a framework
    c# is a language
    visual studio 2010 is the IDE (also the boss when it comes to c#)

    Xcode is a great IDE c++ with it is a breeze

    The very ugly forgive, but beauty is essential - Vinicius de Moraes

  9. #9
    IZob's Avatar Citizen
    Join Date
    Aug 2009
    Location
    Australia
    Posts
    9,829

    Default Re: C++ or Java? Or somthing else...

    Just a test on your skillz:

    Imagen that this code has been compiled successfully, what then dose the program do?

    Edit: Try not to copy, compile and run the code.

    Spoiler Alert, click show to read: 

    Code:
    #include <iostream>
    #include <string>
    #include "bank.h"
    using namespace std;
    int main()
    {
     cout << "  --- main.cpp ---  " << endl;
     //Input data into account types (saving, credit, homeload ...) and calculate in bank.cpp.
                     //BSB,   account#, name,  address,      phone,  balance,  other...
     Saving Alice(123456, 12345678, "Alice", "1 Northfields Avenue, Wollongong", 1234567, 1000, "1234567890123456");
     Account Bob(123123, 12341234, "Bob", "20 Moore Street, North Wollongong", 12341234, -1000);
     Account Chris(123456, 87654321, "Chris", "1 Market Street, Wollongong", 42311234, -250000);
     Account David(123123, 11223344, "David", "100 Kings Street, Wollongong", 42112411, 20000);
     //display data.
     Alice.displayall_sav();
     Bob.displayall(); 
     Chris.displayall();
     David.displayall();
     return 0;
    }

    Spoiler Alert, click show to read: 

    Code:
    #include <iostream>
    #include "bank.h"
    using namespace std;
     
    Account::Account(int b, int accn, string name, string address, int phn, double bln)
    {
     BSB = b;
     AccountNum = accn;
     Name = name;
     Address = address;
     Phone = phn;
     Balance = bln;
    }
    void Account::displayall()
    {
     cout << "--- " << Name << "'s account. ---" << endl;
     cout << "BSB#: \t\t" << BSB << endl;
     cout << "Account#: \t" << AccountNum << endl;
     cout << "Name: \t\t" << Name << endl;
    }
    Saving::Saving(int b, int accn, string name, string address, int phn, double bln, string c):Account (b,accn,name,address,phn,bln)
    {
     card = c;
    }
    void Saving::displayall_sav()
    {
     Account::displayall();
     cout << "Card#: \t\t" << card << endl;
     cout << "Balance: \t" << Balance << endl;
     cout << "Interest paid: \t" << calculate_balance() << endl;
    }
    double Saving::calculate_balance()
    {
     int month=10;
     interest_paid=0.03/12*month;
     return interest_paid;
    }
    /*
    void Credit::creddata (long cardnum, int limit, int repay_due)
    {
    }
    void Homeloan::loandata(int interestrate, int term, int repay_schedule, int repay)
    {
    }
    void Termdeposit::depositdata(int interestrate, int term, int duedate)
    {
    }
    void Account::interests()
    {
     
     
    }*/

    Spoiler Alert, click show to read: 

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    //---------Classes----------//
    class Account
    {
    protected:
     int BSB;
     int AccountNum;
     string Name;
     string Address;
     int Phone;
     double Balance;
    public:
     Account(int, int, string, string, int, double);
     void interests();
     void displayall();
    };
    //-------------------//
    class Saving : public Account
    {
    private:
     string card;
     double interest_paid;
    public:
     Saving(int, int, string, string, int, double, string);
     double calculate_balance();
     void displayall_sav();
    };/*
    //-------------------//
    class Credit : public Account
    {
    private:
    public:
     void creddata (long, int, int);
     //void interests();
    };
    //-------------------//
    class Homeloan : public Account
    {
    private:
    public:
     void loandata(int, int, int, int);
     //void interests();
    };
    //-------------------//
    class Termdeposit : public Account
    {
    private:
     int Interestrate;
     int Term;
     int Duedate;
    public:
     void depositdata(int, int, int);
     //void interests();
    };*/
    Last edited by IZob; August 31, 2011 at 09:32 PM.
    Contact me on Steam: steamcommunity.com/id/IZob/ or send a 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
  •