Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Dare I ask: c or c++ ?

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2002
    Location
    UK
    Posts
    4

    Dare I ask: c or c++ ?

    I see that its possible to use C for openGL development rather than C++ but would I be shooting myself in the foot using it?

    I'm learning C for OS development and want to work on openGL development too but I need to be able to get tuts and help and if 99% of people use c++ then I should go with that instead

    Thanks

    Craig

  2. #2
    Intern Contributor
    Join Date
    Apr 2002
    Location
    brooklyn, ny
    Posts
    65

    Re: Dare I ask: c or c++ ?

    I say C++ ..

    my bad... got to get back to programming .. Stayed away for too long I guess, starting to forget stuff

    [This message has been edited by jubei_GL (edited 12-16-2002).]

  3. #3
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Minnesota, US
    Posts
    180

    Re: Dare I ask: c or c++ ?

    Whoa wait...C has structures too. I think you mean classes. And yeah, use C++. It allows you to make things more organized into neat little modules. Also operator overloading and function overloading help. Templates are SUPER useful too. Plus who says you can't design a program like a C Application instead of a C++ application WHILE using C++. You can still use a procedural design.

    C++ is the way to go in my opinion!

    - Halcyon
    "Programming is an art form that fights back."

    - I forgot who said it!

  4. #4
    Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    292

    Re: Dare I ask: c or c++ ?

    Well, you are right C and C++ handle structs.

    But in C you dont put functions in a struct,
    whereas in C++ you can. I may be wrong, but last time I checked this was the case.

    You may find the link below useful.
    http://www.clarkson.edu/~jets/cs444/...o_c_guide.html


    Originally posted by Halcyon:
    Whoa wait...C has structures too. I think you mean classes. And yeah, use C++. It allows you to make things more organized into neat little modules. Also operator overloading and function overloading help. Templates are SUPER useful too. Plus who says you can't design a program like a C Application instead of a C++ application WHILE using C++. You can still use a procedural design.

    C++ is the way to go in my opinion!

    - Halcyon

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Nov 2002
    Location
    Latvia
    Posts
    626

    Re: Dare I ask: c or c++ ?

    If you're working with MSVS then there is no difference at all, create new workspace, add cpp file to it & write your code. If you're writing only C code it'll work just fine with no warnings, if you'll add some C++ features nothing changes. Think of that - C++ is C update, so the syntax stays the same, you only need new compiler, that can compile new features (it'll definately support old ones too).

    BTW, somwhere in this forum I saw comparison that showed C is in the 1st place and C++ in 4th in speed benchmarks. Although, I doubt because it depends highly on compiler you're using. Prove me wrong

    [This message has been edited by M/\dm/\n (edited 12-15-2002).]

  6. #6
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Minnesota, US
    Posts
    180

    Re: Dare I ask: c or c++ ?

    Mancha, you are totally right. C++ lets you put procedures inside a structure, but then it turns into a class basically .

    Anyways, i really thing that benchmark is in the way that the benchmark app was programmed for c and c++. I mean there are things that are slower in C++ but you can get around em. And i mean come on...In the day and age of 2+ gigahertz computers, i dont' think you will notice a difference unless you are the equivallent to superman in the programming world.

    Plus the advantages of program design in C++ beat the slowing down (if there is any). I mean I find it incredibly intuitive to create modules that handle a seperate task (texture loading module, opengl scene module, etc) than straight coding it in C. But that is my opinion.
    "Programming is an art form that fights back."

    - I forgot who said it!

  7. #7
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Vancouver, BC, Canada
    Posts
    118

    Re: Dare I ask: c or c++ ?

    Use C++. C++ has two things going for it, first has no technical merit;
    a) employers want new C++ programmers, not C programmers. You'll get interview questions using std::string instead of char * and std::vector instead of arrays and be expected to know them inside out. Whether C++ is better or not is not relevent. C++ is simply trendier.
    b) I think C++ is better. There is one simple thing it does that C can't; operator overloading. In C++ you can write a nice function called operator*(lhs, rhs) and then simply type C = A * B; to multiply vector A and B. This alone makes C++ better for programming 3D. It is just so much clearer to see that, as it would appear in real math, than the old C version of C = Mul( A, B );

    Classes vs structs, and all the other C vs C++ arguemnts are up to your preferrence, but I think you'll agree C++ is better simply for operator overloading. And if you want to be a professional programmer it is handy to know the language people want to hire you to use.

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Nov 2002
    Location
    Latvia
    Posts
    626

    Re: Dare I ask: c or c++ ?

    Yes, for 999999999...9999%

  9. #9
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Minnesota, US
    Posts
    180

    Re: Dare I ask: c or c++ ?

    Well other than just operator overloading, there are templates. I mean if those aren't helpful...what are!?!? With templates you have a class/procedure work on any data type. For example if you want to build a CStack class, then you need to make another structure or something so you can tell the procedures what data type to take. But with templates, you tell the CStack class what it's taking, and you have a class that can work on anything. It's REALLY useful.

    And yes...operator overloading IS awesome!!!!
    "Programming is an art form that fights back."

    - I forgot who said it!

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Nov 2002
    Location
    Latvia
    Posts
    626

    Re: Dare I ask: c or c++ ?

    Although there is lot of hidden stuff under it I mean mem allocation.

Posting Permissions

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