When is C really necessary?

Pages: 12
That would be a comparison between Java/C# and C/++. C++ doesn't sacrifice performance for safety because the safety is added at compile time.
+1 helios

C++ somehow got the reputation that it's slower than C, but it really isn't.
Of course not. But I'll bet it's damn hard to write a C++ compiler.
yeah i wonder how and what language use to write a compiler. could it be assembly? damn that's horrible. i can't forget that
mov   ah, 09
Of course not. But I'll bet it's damn hard to write a C++ compiler.


Is writing a C compiler supposed to be easy? Because it sure isn't.
I guess not, but I'd be willing to bet that a C++ compiler is much harder.
Yeah
so in simple words it's Reliability (C++) VS Performance (C) ?


Not really...It all depends on the skill of the person using the tool.

e.g. you can write a checked pointer to an array which checks array access in debug mode, but compiles out in release mode. So you get the same speed as C, with additional checks in debug mode.

I've never seen a hashmap implemented in C, so this in this respect C++ could be considered faster.

In theory a virtual function call is faster than C code littered with if statements because branches can stall the processor instruction pipeline.

so in simple words it's Reliability (C++) VS Performance (C) ?

No, it is type safety vs no type safety.

There are some pipeline performance hits you can take in C++. For example, iterators work using the overloaded operator>>s, so directly iterating over a byte stream using the standard stream iterators is slow in C++. You can overcome this easily enough, though, and work just as quickly and efficiently as in C.

Know your tools.
For example, iterators work using the overloaded operator>>s


I don't quite understand why using >>s would cause a pipeline performance hit.
I mostly worked on C.
and lil bit on C++.
As per my experience, i think, If you know your project deeply. You can implement it either language (C or C++) .
No much diff in performance and no much diff in Reliability, if you have deep knowledge of language ...
I also mostly work in C. I just find it simpler to write something quickly in C than C++ (although that's probably a matter of experience -- I have far less of it with C++).
It is always easiest to write in the languages you are most familiar with.

I don't quite understand why using >>s would cause a pipeline performance hit.
Me either, but alas, it seems to be the case. http://www.cplusplus.com/forum/beginner/11564/

The reason is actually that there are a lot of hooks in the pipeline for the ifstream::get() function (locale conversions, wide/narrow, etc), where there are none in C. The trick is to write yourself an istream iterator that works by getting bytes directly from the underlying filebuf, then the speed should jump back up. (I haven't tested this yet, though.)

So, whatever works...
:-)
Topic archived. No new replies allowed.
Pages: 12