|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic Page: «« 1 2 3 4 5 6 7 8 »» |
Last Thread Next Thread ![]() |
| C is unnecessary |
|
![]() DerekSaw Member since: 11/26/1999 From: 5-Claw, Dragonland |
||||
|
|
||||
quote: A better C programmer will use snprintf(). |
||||
|
||||
![]() sjelkjd Member since: 3/15/2001 |
||||
|
|
||||
| Okay, and what if he didn't allocate a large enough buffer? Reallocate? Miss out on part of your input? Whatever the solution, it is empirically less optimal than the c++ solution. Even snprintf is still too low level. Now you have to worry about buffer size - and it still suffers from the same lack of type information that sprintf has. |
||||
|
||||
![]() kordova Member since: 10/10/2001 From: Global Citizen |
||||
|
|
||||
| Of course (responding to the title "C is unnecessary") one could argue that c++ isn't any more necessary. |
||||
|
||||
![]() Arild Fines Member since: 8/20/2001 From: Oslo, Norway |
||||
|
|
||||
quote: You officially disqualified yourself from this discussion right there. "To assert that the earth revolves around the sun is as erroneous as to claim that Jesus was not born of a virgin." -- Cardinal Bellarmine |
||||
|
||||
![]() Alpha_ProgDes Member since: 7/5/2002 From: Silver Spring, MD, United States |
||||
|
|
||||
"To assert that the earth revolves around the sun is as erroneous as to claim that Jesus was not born of a virgin." -- Cardinal Bellarmine OT: in defense of the Cardinal, it was the Middle Ages. There was alot of misconceptions in those days. So the quote is a little unsupporting to "your" point. And yes, I'm Catholic. but i can admit that the Church has f*cked up more times than it can count Back on topic: if you C++ can do "everything" that C can do, why use C (ignore the legacy code factor while answering this question)? |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
quote: Could you give me a concrete example? int f(); The above has a different meaning in C than in C++. A simple search and replace won't be sufficient. In C it is implicitly a variable arity function, while in C++ it is a zero-argument function.
struct A {
int foo;
};
struct A a;
int a;
The above used to be legal C code. I think it was changed in C99 (gcc is griping at me about it). This obviously isn't legal code in C++. Again, a search and replace won't be sufficient. |
||||
|
||||
![]() alnite Member since: 11/8/2002 From: Santa Ana, CA, United States |
||||
|
|
||||
![]() Enselic, just a reminder, IF you use WinAPI/OpenGL, you should not say that we can dump C and use C++ all the way. |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
quote: Actually, let me retract that statement. A regex based substitution should be sufficient to properly match and translate said forms. Although this would have to occur after the preprocessor has ran. Otherwise the matcher could attempt to translate: #define (void) FOO FOO f(); Which is a return-type cast, not a function declaration. Also working in function-pointers wouldn't be that bad. |
||||
|
||||
![]() sjelkjd Member since: 3/15/2001 |
||||
|
|
||||
quote: I do all my OpenGL coding in c++. And what little Win32 coding is also done in c++. |
||||
|
||||
![]() alnite Member since: 11/8/2002 From: Santa Ana, CA, United States |
||||
|
|
||||
| I am just saying that Win32 and OpenGL API use C, not C++. There is no such thing called OOP in Win32 and OpenGL API, they are all pure function calls. Current project: A puzzle game. % completed: ~10% Status: Active. |
||||
|
||||
![]() Anonymous Poster |
||||
|
||||
quote: Well there are such things as kernel objects... but I'll shutup about that. |
||||
|
||||
![]() RhoneRanger Member since: 12/17/2002 From: USA |
||||
|
|
||||
| Ensylic, Great question! Keep it up my friend! Strict C is probably faster than c++, but as long as you code smartly in c++, and take from C what is needed from C (example TYPEDEF), C++ will be almost, if not just as fast as C. |
||||
|
||||
![]() Bennettovia Member since: 5/4/2003 |
||||
|
|
||||
| when the C millisecond timer over flows in the 2030s or whenever its supposed to happen, then they'll be a reason to code in C, and I'll be makin' mega bux doin' it, so there. |
||||
|
||||
![]() Senses777 Member since: 1/23/2002 From: San Clemente, CA, United States |
||||
|
|
||||
quote: Thats the funniest think I'v heard in awhile, please provide a link. It will be the Y2K+~30 bug, (of coarse the news will have to think of a better name). Anyways, this is the way I see it, and it would be painfull if anyone posted after this without considering this: If all the C compilers in the world could be replaced by C++ compilers, (ALL OF THEM, even the ones running on some old linux machine that hasn't been used for years and may never be again), then why not do it? In its true form, isn't C++ completely backwards compatable with C? I was under the impression that it was, and I have not seen any evidence suggesting otherwise. Now I'm not saying that C++ compilers ARE C backwards compatable, I'm saying that those compilers would be made to be under the assumption that all C compilers would be made into C++ compilers. (obviously a few things could not be fixed, like if some c code used "class" as an identifier or whatnot, but shut up and don't argue about that, assume it would be fixed as well some how in a perfect way). So, why not change them all? No extra person would have to learn C++, they could keep using C, or whatnot. C++ and C arn't DIFFERENT languages, C++ is just an extended version of C. No one would be forcing anyone to use the extra feautures of C++ in this C removed world, so why not do it? |
||||
|
||||
![]() sjelkjd Member since: 3/15/2001 |
||||
|
|
||||
quote: Programming in c++ doesn't require you to use OOP. Purely procedural programming is acceptable in c++, when it is appropriate. Class heirarchies are good when you need dynamic dispatch on one object, code sharing between similar objects is natural, or you need to specify an interface for functionality that the user can implement. Innappropriate use of OOP is just as bad as the lack of OOP when it would be useful. |
||||
|
||||
![]() sjelkjd Member since: 3/15/2001 |
||||
|
|
||||
quote: People don't seem to understand one important point regarding performance. c++ is not slow. If you use a feature of c++ that has some overhead, you're going to pay for it. If you were using C and you needed that feature, it's not going to magically be faster because you are using C. It's going to be just as slow, if not slower, and a whole heck of a lot harder to understand, since the language is lacking the idioms needed to express what is going on. Furthermore, this C emulation of c++ features is going to be harder to developer, harder to maintain, and more prone to errors and bugs than the c++ equivalent. |
||||
|
||||
![]() Peter19852001 Member since: 2/2/2002 |
||||
|
|
||||
quote: Thats the funniest think I'v heard in awhile, please provide a link. It will be the Y2K+~30 bug, (of coarse the news will have to think of a better name). Anyways, this is the way I see it, and it would be painfull if anyone posted after this without considering this: If all the C compilers in the world could be replaced by C++ compilers, (ALL OF THEM, even the ones running on some old linux machine that hasn't been used for years and may never be again), then why not do it? In its true form, isn't C++ completely backwards compatable with C? I was under the impression that it was, and I have not seen any evidence suggesting otherwise. Now I'm not saying that C++ compilers ARE C backwards compatable, I'm saying that those compilers would be made to be under the assumption that all C compilers would be made into C++ compilers. (obviously a few things could not be fixed, like if some c code used "class" as an identifier or whatnot, but shut up and don't argue about that, assume it would be fixed as well some how in a perfect way). So, why not change them all? No extra person would have to learn C++, they could keep using C, or whatnot. C++ and C arn't DIFFERENT languages, C++ is just an extended version of C. No one would be forcing anyone to use the extra feautures of C++ in this C removed world, so why not do it? Take a look at this story. I used to use blue ball pens for all of my wirting. Then one day I found that there is a pen which can be used the same way as my blue ball pen. In addition, it gives me black colour too. If all blue ball pens could be replaced by this new pen, should the blue ball pen be abondoned and give the reason that there is nothing you can write using the blue pen that you cannot write using the new pen. Moreover, no one would force you to use the black colour even all the blue pens were replaced by the new pen. What do you think? My opinion is that if all I want is a blue pen because I do not need black colour for anthing of my writing, I do not have any reason to replace my blue pen with the new one even it gives something extra. It goes without saying that the new pen will be heavier because it contains more than the blue pen, namely the black pen. As for C and C++, it is similar. C++ provides something extra and does not force you to use it. However, it is very likely that a C++ compiler is larger than a C compiler and C++ compilers takes longer time to compile. So my conclusion is that C has its own use as someone has already pointed out. Therefore C is still necessary for someone who want to have smaller and faster compiler. |
||||
|
||||
![]() targhan Member since: 10/17/2001 From: Sweden |
||||
|
|
||||
| before 2030 the time_t structure will be extended with additional bits and won't overflow. also C is in fact a newer language then C++, the C standard was revised in 1999 and C++ in 1998, the new things in C99 gives C features that isn't available in C++. Also it's a lot easier to support a C implementation, so low spec systems will always have a C compiler, but not always a C++ compiler, as well as the CRT vs the C++ runtime library. For example my OS uses C because it's easier to make sure exactly how it works, because there is no vtables or rtti fields added to my structs, unless I add them myself. -------------------------------- "I'm a half time coder, full time Britney Spears addict" Targhan |
||||
|
||||
![]() Enselic Member since: 9/16/2002 From: Lund, Sweden |
||||
|
|
||||
*Enselic wakes up from a nice swedish sleep, perform some social activities and then read all the posts*quote: If you stick to C you will never even have the oppurtunity to use templates, classes and so on. If you move to C++ you have nothing to loose! quote: C is not necessary since we have C++! quote: Allow me to lol. Why the heck would you want to use the same name for an int as a struct? Bad programming if you ask me. quote: You can use C++ for those libaries too! Now could you leave? Yes you annoy me... quote: THAT is why C is not necessary and that is why I started this thread. ![]() ____________________ ____ ___ __ _ Enselic's Corner - My site. Go test my game Spatra and see if you can beat it onto the Official Spatra Top 10. CodeSampler.com - Great site with source for specific tasks in DirectX and OpenGL. [edited by - Enselic on May 4, 2003 9:27:46 AM] |
||||
|
||||
![]() alnite Member since: 11/8/2002 From: Santa Ana, CA, United States |
||||
|
|
||||
quote:So...what makes a code C++? and what makes a code C? How do we differentiate them? EDIT: other than function overloading. Win32 API uses extern "C"Current project: A puzzle game. % completed: ~10% Status: Active. [edited by - alnite on May 4, 2003 10:09:31 AM] |
||||
|
||||
![]() Ready4Dis Member since: 4/26/2002 From: USA |
||||
|
|
||||
quote: I highly doubt IE uses scanf, nore any other common program with a buffer over-run/flow error that could be used to gain access to your machine, or do something bad to it. All of that stuff is normally when working with winsocks, and reading in packets, etc. quote: I am using a C++ compiler, but I removed all parts of C++ from the raytracer core. I received a hefty 400% speed boost from doing so. That was using the EXACT same intersection code, so if that was the part taking the longest, and I got a 400% boost in speed... (yes, both were testing in release mode) that must really say something. My point was, if you have a problem with variable names in functions, you obviously have A.) bad variable naming techniques, and/or B.) to large of functions that you can't easily see what's happening. Bad planning will mean hard to read code. Using C code, it is easy enough to organize your code in a readable manner, place common functions into a seperate files, and give it a name that describes the commoness. I also wanted to state, that I DO use C++, and to a pretty large extent (more often than I use straight C), so I do know how usefull C++ is and can be, but in most cases, straight C code is faster than using the "advanced" features of C++. Same goes/went for my older 3d software engines... sure C++ was alright, but C was faster... and I wrote inline assembly for certain aspects because that was even faster than C. I haven't done much in the way of assembly & C/C++ in msvc (that was in the days of turbo c/c++), but I may re-write sections of my raytracer in assembly... try converting C -> assembly.. not that difficult... now trying converting C++ -> assembly.. omfg, we have to re-write it and re-plan it completely. --- Edit --- Stupid double qouteing doesn't work [edited by - Ready4Dis on May 4, 2003 9:59:49 AM] |
||||
|
||||
![]() alnite Member since: 11/8/2002 From: Santa Ana, CA, United States |
||||
|
|
||||
quote:I didn't claim you couldn't. Those libraries are written in C (at least the header files where functions structs etc are defined). If you use them, you use C. |
||||
|
||||
![]() kordova Member since: 10/10/2001 From: Global Citizen |
||||
|
|
||||
quote: Why/Who are you trying to prove this to? I'm sure several major games have been written in C so maybe you should speak with the Quake guys as I'm sure they would be fascinated by your _opinion_. |
||||
|
||||
![]() the Speed Bump Member since: 1/8/2001 From: BC, Canadia |
||||
|
|
||||
quote: He just wanted to get a megarant going. At least it's still on topic. Nobody's saying that C isn't useful, but C++ was made from the get-go to be "a better C." Anything you can do, I can do better, and all that. What's the harm in using C++ that way? Is there any downside to using C++ instead of C? The only ones I can think of are the availability of C++ compilers on weird platforms, and that C++ doesn't compile as fast. I'm hip because I say "M$" instead of "MS". |
||||
|
||||
![]() antareus Member since: 8/6/2002 From: Ashburn, VA, United States |
||||
|
|
||||
quote: Quake uses C++ virtual functions, which are quote: (sarcasm) but they're implemented in C. This argument is moot as I think Doom 3 is being written in C++. |
||||
|
||||
|
Page: «« 1 2 3 4 5 6 7 8 »» All times are ET (US) ![]() |
Last Thread Next Thread ![]() |
|