I did.Guess you didn't see my post?
They are ... but didn't see that on here so far? ?I find those general anti-C/C++ - flame wars annoying.
I am fully aware of most of all that is brought up here, for and against the one or the other language, by you, cracauer, and others, of course - that's why there are more than one language.The risk can be reduced a lot with good design, good coding discipline
? I didn't know that one yet.case of featureitis.
I spent 10 years in that industry, and found myself building things for cars I would deny to drive or switch off all that stuff. As with languages, it tends to make you soft and depend on these features. Only to find out the border cases where it does not work, and then someone is gonna dieeee.? I didn't know that one yet.
(Currently it happens to cars.)
This is the common argument by classically trained Computer Scientist people. And of course you have a strong point here.The fastest code is the one using the best algorithm for the purpose. Using a simple language that compiles more and less directly to machine code won't help you with your O(2^n) algorithm.
Would be interesting to see examples where "casting to/fromCasting to/fromvoid *
is IMHO a bad code smell in C (although required in C++).
void *
is required in C++.I think the following C idiom does not compile without warnings in C++:Would be interesting to see examples where "casting to/fromvoid *
is required in C++.
int *data;
data = malloc(size * sizeof(int));
malloc
returns a void*
, which requires a cast in C++.Because this is a C-style idiom, in C++ they useI think the following C idiom does not compile without warnings in C++:
Code:int *data; data = malloc(size * sizeof(int));
malloc
returns avoid*
, which requires a cast in C++.
operator new
which uses the right types. No need to cast. And if you insist on using malloc
still no casting to void *
is involvedReally templates should avoid the need for a void* to be used in the first place in C++ (yes... not all C++ libraries are equalWould be interesting to see examples where "casting to/fromvoid *
is required in C++.
You didn't miss much. Borland C++Builder 6 was the pinnacle! (arguably 5 was). Now they feel terribly inelegant and cheap quality.I REALLY do not like the Visual Studio environment, so I don't write any more C/C++ code after Borland C went away.
The Embaracero environments are FAR too pricey so I ignore them.
Everywhere you actually want to use it as a different (data) pointer type? ?Would be interesting to see examples where "casting to/fromvoid *
is required in C++.
Exactly. Although this is just one classic example ... when doing anything "generic" in C, you'll quickly have a lot more uses ofI think the following C idiom does not compile without warnings in C++:
Code:int *data; data = malloc(size * sizeof(int));
malloc
returns avoid*
, which requires a cast in C++.
void *
.data = malloc(size * sizeof *data);
(so you don't repeat the type, which would be another source for bad bugs when ever changing it).So your argument is you don't needBecause this is a C-style idiom, in C++ they useoperator new
which uses the right types. No need to cast. And if you insist on usingmalloc
still no casting tovoid *
is involved
void *
much, if at all, in C++? Sure. True for sane C++ code and as long as you don't have to interface with C code. It still doesn't change the fact that you're required to cast to/from void *
in C++.An interesting web framework is,I have been playing with Crystal recently and enjoying it. It is inspired by Ruby in terms of syntax, standard library, and testing tools. It is statically typed with type inference; and provides exhaustive type handling, case statements, and error handling. It uses UTF-8 strings, but still includes a null-terminator for compatibility with C. I suspect it will be my go-to language for simple CLI utilities.
I use that, too
Nope. And I have reasons.
This is the common argument by classically trained Computer Scientist people. And of course you have a strong point here.
However: The Big-O-Notation – by definition – hides the constants. But constants matter: A factor of 2 can make the difference between 4 hours and 8 hours of computing time. Also, nifty algorithms are harder to implement, i.e. they are more prone to coding errors. So you always have to ask yourself: Does the complicated algorithm really pay off for the amount of data I am processing?
The fastest code is the one using the best algorithm for the purpose. Using a simple language that compiles more and less directly to machine code won't help you with your O(2^n) algorithm.
Why? We are grown adults here,bare we not? The oldNobody else has been brave [foolish?] enough to say so
It is more important to have the tools to find the performance bottlenecks and attack them. It is good if your IDE/compiler/whatever can help you there. And with assembler, that can be a challenge. With a high level language, the system can help a lot.Spot on.