Is C++ any better than BASIC?

Discussion in 'C++' started by Gerry Lintonice, Sep 14, 2005.

  1. I wonder if C++ is any better than a common BASIC, for example GW
    BASIC.

    What can you do with C++ that BASIC can't do?

    C++ seems so incredibly complicated, even more complicated than
    Assembler.Why bother with C++?
    Gerry Lintonice, Sep 14, 2005
    #1
    1. Advertising

  2. Gerry Lintonice

    Jim Langston Guest

    "Gerry Lintonice" <> wrote in message
    news:...
    >I wonder if C++ is any better than a common BASIC, for example GW
    > BASIC.
    >
    > What can you do with C++ that BASIC can't do?
    >
    > C++ seems so incredibly complicated, even more complicated than
    > Assembler.Why bother with C++?
    >


    Better is subjective, especially in this case when you didn't ask better for
    anything in particular.

    Languages are tools. If I'm working on an IBM AS/400 and I want to do a
    quick report, I'm going to use RPG not C++.

    Personally, I would always use C++ instead of any flavor of BASIC if I'm
    given the choice, but there may be cases where BASIC is preferred
    (especially on some platforms that it may be my only choice).
    Jim Langston, Sep 14, 2005
    #2
    1. Advertising

  3. Gerry Lintonice

    hacker++ Guest

    Gerry Lintonice wrote:
    > I wonder if C++ is any better than a common BASIC, for example GW
    > BASIC.
    >
    > What can you do with C++ that BASIC can't do?
    >
    > C++ seems so incredibly complicated, even more complicated than
    > Assembler.Why bother with C++?


    Well depends on what you want to do...
    Generic and type independent programming for instance:
    This is a simple _complete_ program in c++. It can accept 10 values of
    ANY type (including user defined types, provided certain conditions are
    met) and sort them. Try this in BASIC/Assembler!! And I haven't even
    mentioned polymorphism yet :)

    #include <iostream>
    #include <vector>
    #include <algorithm>

    using namespace std; // not recommended, only for illustration

    typedef int mytype; // substitute 'int' with almost any type

    int main()
    {
    vector<mytype> vec;
    cout << "Enter 10 values:\n";
    for(int i = 0; i < 10; ++i)
    {
    mytype num;
    cin >> num;
    vec.push_back(num);
    }

    cout << "The sorted list is :\n";
    sort(vec.begin(), vec.end());

    for(int i = 0; i < 10; ++i)
    {
    cout << vec << '\n';
    }

    return 0;
    }
    hacker++, Sep 14, 2005
    #3
  4. On 13 Sep 2005 18:22:42 -0700, "Gerry Lintonice" <>
    wrote:

    >I wonder if C++ is any better than a common BASIC, for example GW
    >BASIC.


    Define "better".


    >What can you do with C++ that BASIC can't do?


    Plenty.


    >C++ seems so incredibly complicated, even more complicated than
    >Assembler.Why bother with C++?


    Because each language represents a cost/benefit tradeoff. C++ has proven to be
    quite profitable to learn and use so far.

    -dr
    Dave Rahardja, Sep 14, 2005
    #4
  5. "hacker++" <> wrote in message
    news:...
    > Well depends on what you want to do...
    > Generic and type independent programming for instance:
    > This is a simple _complete_ program in c++. It can accept 10 values of
    > ANY type (including user defined types, provided certain conditions are
    > met) and sort them. Try this in BASIC/Assembler!! And I haven't even
    > mentioned polymorphism yet :)


    Just for fun I did the same with D, a little shorter and simpler:

    import std.cstream;
    import std.stdio;

    alias int myint;

    void main()
    {
    writefln("Enter 10 values:");
    myint[] vec;
    for (int i = 0; i < 10; i++)
    { myint j;
    din.readf(&j);
    vec ~= j;
    }
    vec.sort;
    writefln("The sorted list is: ", vec);
    }

    -Walter
    www.digitalmars.com C, C++, D compilers
    Walter Bright, Sep 14, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    14
    Views:
    523
  2. Peter Knoerrich
    Replies:
    9
    Views:
    286
    Peter Knoerrich
    Jul 1, 2004
  3. Peter Bencsik
    Replies:
    2
    Views:
    813
  4. Lucas J. Riesau

    BASIC is better than C++ !!!

    Lucas J. Riesau, Jun 17, 2007, in forum: C++
    Replies:
    14
    Views:
    489
    Patrick
    Jun 20, 2007
  5. Replies:
    2
    Views:
    44
    Mark H Harris
    May 13, 2014
Loading...

Share This Page