Jump to content


I like C


52 replies to this topic

#21 rogerdv

    Member

  • Members
  • PipPip
  • 99 posts

Posted 28 July 2003 - 12:11 PM

baldurk said:

anubis: I think you may be missing the point. You don't have to use all of C++'s features to write OO code. Simply classes and most likely inheritance. That's all
I remember a fake interview to Bjorn Stroustrup a couple of years ago. The fake Bjorn said that most C++ programmers insist EVERY oop feature available, just because it was there and somebody told them in the C++ course that it was * a good programming practice*. Personally, I know one who respect those *good practices* as a Holy Bible. Produces a nice code, indeed, but mostly unreadable for mere mortals like me.

#22 UnknownStranger

    Valued Member

  • Members
  • PipPipPip
  • 139 posts

Posted 28 July 2003 - 12:30 PM

Hmm...just remembered this old joke about the programmer who renamed all his *.c files into *.cpp ones...

When he was asked, why he has done that, he said, that he wants to code OO... :lol:
M.E.
-----
"Human stupidity is something you can rely on." -- M.A.
"I didn't design life." -- J.G.
"It's almost finished..." -- EHD

#23 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 28 July 2003 - 12:42 PM

hehe:D


btw.. you know why they're called "good coding practises"?

because they help you to make the compiler detect your own errors when you forget them. because they help you to make your system not crash just because you made a logic error in your program. etc.

and mainly because they help saving repetitive typing.
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#24 rogerdv

    Member

  • Members
  • PipPip
  • 99 posts

Posted 28 July 2003 - 10:22 PM

Lets put it this way: what is the advantage of hiding all members and accessing them using functions? It is highly recommended, anyway I think the app will run keeping all member public and accessing directly like in the old structs.
Certainly, good programming practices helps a lot, but excesively good practices can make a clear sky become a storm day. Like Bjorn said: In C is easy to shot yourself in the foot. C++ makes it harder, but when you do it, you blow your whole leg.

#25 DrunkenCoder

    Member

  • Members
  • PipPip
  • 97 posts

Posted 30 July 2003 - 06:07 AM

Ok, nitpick but he's not named Bjorn but Bjarne don't belive me look here

as for the quote you can find his explenation here

also keep in mind that C++ isn't an OOP languate it's multiparadigm

hope that clearifies things a bit.

#26 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 30 July 2003 - 06:22 AM

as i stated on gamedev yesterday i think on the question "has C any use today?"

as always first: if its the only option (except for example asm) on a platform, use it (or the asm, if it fits your needs bether:D)..
what ever fits your needs

on every platform where there is a c++ compiler available (and thats about all the big ones today..), there is NO need to use C anymore.

the C language got a bit cleaned up in c++ (no stupid typedef struct _name {} name, and similar), and got a lot of additional features, the c++ part namely.

the C programming paradigms are still useful. functions, procedural programming. that all fits well into the c++ world as well.


but there is NO need to use straight C anymore. today c++ is "in", too, so you get much bether support and much faster c++ compilers, too :D
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#27 DrunkenCoder

    Member

  • Members
  • PipPip
  • 97 posts

Posted 30 July 2003 - 07:06 AM

And even if no "C++ Compiler" is availible for your platform you can always use the EDG C++ Frontend that can (among other things) translate C++ into C, the stuff that down your compilers throat and send angry e-mails to whoever is responsible for not giving you a proper compiler in the first place.

#28 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 30 July 2003 - 08:17 AM

good to know!
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#29 TheLionKing

    Valued Member

  • Members
  • PipPipPip
  • 143 posts

Posted 19 August 2003 - 03:19 AM

I love C++ :yes: .

I think C++ is like an addon to C. It just improves the features available in C.

I love C++ since it sounds a bit crazier then C.

I think lots of people use C++ :yes: .

As a matter of fact, :rolleyes: I think C++ is the standard language for game programming.
<span style='color:blue'>I can survive anything ... even NUKES!!!
The Lion King</span>

#30 starboarder2001

    Member

  • Members
  • PipPip
  • 35 posts

Posted 20 November 2003 - 11:59 PM

Anyone programmed in C#? I am going to try it pretty soon. I programmed in pure C until I completely understood OO programming. Pretty much anything I write from now on is going to be written in C++.... or maybe C#. ;7
1000
0100
0010
0001

#31 EvilSmile

    Member

  • Members
  • PipPip
  • 96 posts

Posted 21 November 2003 - 03:59 AM

I've only recently begun to learn cpp and I love it.
I find that it is far easier to produce cleaner code in cpp than in c.

as for teh speed issue- I really don't think it matters anymore. Unless you are *really* good you can't make sure that you put in all the features you want and also take care of OOPing your code and deliver on the same deadline using C. (but that could only be my opinion though...)

(in very simple words, my vote is for cpp)

#32 bladder

    DevMaster Staff

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 21 November 2003 - 04:01 AM

starboarder2001 said:

Anyone programmed in C#? I am going to try it pretty soon. I programmed in pure C until I completely understood OO programming. Pretty much anything I write from now on is going to be written in C++.... or maybe C#. ;7
yeah, Ive tried C#. Its pretty much like java, only....probably has a few more features and you get a really nice IDE :)

I think C# would be perfect for programming tools to use in your game. And the performance hit when using managed DirectX is not really that significant. It's supposed to be just a 5% performance hit at worst on average.

I say go for it. C# is great to work with, slick and clean.

#33 Mihail1212

    New Member

  • Members
  • Pip
  • 2 posts

Posted 21 November 2003 - 09:18 AM

I honestly like C more than CPP but i have reasons for that. First of all the code produced by CPP is NOT clean. Don't believe me? Disassemble the source and loop for yourself. It is also MUCH MUCH slower than C(look at the ASM again). Those compilers are wasting billions of ticks(costs a lot even on the DEL workstations with dual Opterons) while trying to resolve the class connections,parentness and all other things relative with CPP. Yes it makes the code easier to write but is it worth it? I think not!

#34 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 22 November 2003 - 01:20 AM

mihail. your statements about the performance are completely wrong, as every todays c compiler is actually just the c++ compiler as well. there is no difference. and c++ isn't slower normally at all.

and then again. why do all always first ask "is it fast?" if they compare languages? a language can not be fast. the produced code can. and it could be fast, or slow, for any language. it doesn't mather.
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#35 Mihail121

    Senior Member

  • Members
  • PipPipPipPip
  • 1059 posts

Posted 22 November 2003 - 10:33 AM

davepermen said:

mihail. your statements about the performance are completely wrong, as every todays c compiler is actually just the c++ compiler as well. there is no difference. and c++ isn't slower normally at all.

and then again. why do all always first ask "is it fast?" if they compare languages? a language can not be fast. the produced code can. and it could be fast, or slow, for any language. it doesn't mather.
True my friend! The speed of the code is important. And it does depend if the compiler is doing simple function call with 3 or with 3000. And by the way, there is no sence in using the C++ compiler for C code. I think that the C++ is based on C compiler. Anyway somethings are important. If u need something quick do it with C or better yet with ASM!

#36 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 22 November 2003 - 02:12 PM

mihail. you got me wrong: EVERY TODAYS C COMPILER IS THE SAME AS THE C++ COMPILER.

you run in debugmode if you have those issues. C is NOT faster at all than c++, because all C can can be done in c++ EQUALLY. just rename your file from .C to .CPP and you can compile it again, and the compiler will spit out the 100% exact same asm again.

and speed is never the main most important thing. its the LAST thing.
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#37 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 22 November 2003 - 05:58 PM

I'm pretty sure that gcc is a pure C compiler - ie. you'd need to use g++ to compile C++ code.
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.

#38 DrunkenCoder

    Member

  • Members
  • PipPip
  • 97 posts

Posted 23 November 2003 - 09:34 AM

Ok, really do you think they would write scientific compution programs in C++ (to increase speed over specialized FORTRAN compilers) if it was slower than C?
Nope they do it because it's faster.

Just because you can't use the language right doesn't mean it's slow.
Sure there are features in C++ that cost clock cycles but if that is a big concern then simply don't use them.

Equvivalent C and C++ code will be just as fast the C++ code being a bit more readable. You're simply talking out of your ass with really nothing that argues your point. You simply can't compare printf to cout and classes with virtual functions to calling a staticly bound function you'll have to simulate them in C to get a fair comparison. Heck calling member functions is SLOWER in C than in C++ because the C++ got native support for it. In MSVC++ this translates to that in C you have to manually push a pointer to the struct you're working on onto the stack wheras in C++ the same pointer is stored in a register.

Please grow up do some real research (no asking you'r 1337 h4x0r friends doesn't count)

#39 anubis

    Senior Member

  • Members
  • PipPipPipPip
  • 2225 posts

Posted 23 November 2003 - 02:40 PM

DrunkenCoder : relax :)

baldurk : nope... g++ is gcc. it's the same compiler :) g++ is just calling gcc with a few extra parameters.

oh boy i thought that this kind of discussion died out years ago. are we really still in the stone ages ? sure the whole industry codes in c++. of course they do that because it is slower and inferior to c.

i'm down with the casual inline assembly but i'm not going to make a fire using a flint when i have a lighter in my pocket ;)
If Prolog is the answer, what is the question ?

#40 DrunkenCoder

    Member

  • Members
  • PipPip
  • 97 posts

Posted 23 November 2003 - 03:16 PM

anubis said:

DrunkenCoder : relax :)
I guess I just have an issue with people not knowing what they're talking about posting crap as facts.

The key to writing efficent code in any language is understanding the underlying thoughts and design decisions built into the language. And that is simpler todo with C because it's basicly a highl level assembler (and that's actually one of its design goals) C++ is designed in quite a diffrent way and people not using it the right way end shooting themself in the foot constantly blame the language without even trying to understand how things work.

C++ is not a simple language but it's every bit as flexible and efficent as C.
Sometimes I actually wonder it it wouldn't have been better if the legacy from C hadn't been as strong :/ the language wouldn't been as widespread but maybe just maybe people that don't care about actually learning a new language wouldn't have migrated and then claimed C++ to be C with classes...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users