Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Welcome Guest | Log In | Register | Benefits
Channels ▼
RSS

C/C++

Testing Complex C++ Systems



Related Reading


More Insights




Andrew Binstock

You're quite right. Sorry about that. We should have broken that up a bit during the editing process.

reanimator

I wish the style of the article was more reader friendly somehow.
The sentence as below is a brain hammer.

"I created plugins that reused the logic inside the fixed algorithm nodes and then constructed experiments that used the same networks with the same algorithm types and connectivity except that on one network the nodes used were the concrete (old) sub-classes of the runtime engine, and on another network all the nodes were PluginNode hosting the same algorithmic code"

RM1948

A quick web search indicates that strong vs weak typing is neither well defined nor objective.

Zenju

> it's just a technical term with a well-defined and objective meaning

Now I'm interested where you got your "sources" from. Or did you just make this up?

Zenju

> asked before speaking
And in order to "ask" I would "speak" I guess?

> what you *can* do with the language

That's not true. In this vague sense you can do anything with every language. C++ is commonly seen as a strongly typed language. There is no discussion about it.

jcanizales

A language is weakly or strongly typed depending on what you can do with the language, not what uses are considered bad. It has no pejorative connotation; it's just a technical term with a well-defined and objective meaning. C++ is weakly typed.

jcanizales

You should have asked before speaking. The weakness or strength of the type system of a programming language is a technical concept, without any pejorative connotation. It doesn't mean bad (nor good), and talks about what you *can* do with the language (not what you *should* do).

Andrew Binstock

I agree with most of your points. The terminology has taken on a bit of a political aspect within the C++ community. There is no doubt that by using the modern features in C++ with discipline, type safety can be assured. The "weak" part (an unfortunate descriptor, perhaps mutable and fixed would have been more neutral terms) comes in large part, but not exclusively, from the legacy of C. In this article, the author is discussing testing legacy codebases, so in that context, the challenges faced by testers due to the use of weak typing features seems appropriate to me. Zenju is right in his implication that developers who use the features are doing the linguistic equivalent of swearing. But the author's discussion of this is certainly not an attack on the language. It's simply a reflection of the reality of legacy codebases.

AnonymousNoNick

C++ is not weakly typed by most people's definition of what weakly typed means: that all class instances would be stored in an "object" type at compile-time, like C#'s ArrayList elements. On the other hand, a strongly typed language, by most people's definition, would have the types written out explicitly in the code; you could then perform compile-time error checking. The analogous C# collection in my example would be List<int>. C++ has always been a strongly typed language.

I think there has been an (unfortunate) conflation in recent years of weakly typed typed systems and type systems which happen to not have excellent security guarantees. Programming terms, jargon, motivations, concerns, etc. don't revolve around a type system's security guarantees; it's usually not the most important thing. I think many of us know that this specific denigration of the C++ language is basically propaganda by people who are promoting other languages with big security features.

Andrew Binstock

Zenju: I can't tell if you're trolling or not, but 1) C++ is weakly typed. Do you really need a link for this? 2) C++ does take a long time to build. The article provides a link to Walter Bright's explanation of why C++ compiles slowly. Bright has written three commercial C++ compilers.3) Fast tight code is precisely the reason most C++ developers I know use the language. And given my line of work, I speak to a lot of C++ developers.

I'm not quite sure what you're so upset about. The author's claims seem reasonable to me and not inconsistent with my experience.

Zenju

I do not see where the author makes a distinction between the language and code. Quite contrary he mixes it all together producing a number of statements that are wrong in their generality:

"C++ is a statically typed language, but its type system is very weak."
"Build speed is slow"
"C++ arguably poses the most difficult challenges for testing"
"C++ programmers love twisting code"
"C++ programmers [...] justifiably focus more than anything on generating fast and tight code"

By making these dubious statements without any reasoning right at the beginning of the article the author loses credibility and the reader interest to go on.

RM1948

I'll support Zenju's comment. Saying C++ is weakly typed - regardless of the context, i.e. legacy systems - because a developer misused reinterpret_cast is a very misleading statement. This is an abuse of the statement, not the fault of the language. The casting operators are there for a purpose and useful when appropriate. They were introduced to provide control over the casting of C specifically to keep C++ a strongly typed system.

Regardless of how large the system is it might behoove the company to grep for reinterpret_casts and fix them.

Andrew Binstock

Not sure I understand your comment or your recommendation. It's perfectly clear that the author is discussing code bases that already exist.

Deirdre Blake

Of course, you are right about C++. But the author is pointing out some of the common problems you run up against when prepping tests on large, complicated systems -- and naughty usage is certainly common enough.

Zenju

> type system is very weak. You can freely cast any pointer to any other pointer using reinterpret_cast.

"the english language is bad - you can swear a lot in it!". The author doesn't seem to be able to distinguish between what you can and what you should do. It's the common fallacy of confusing the code of some bad C++ programmers with the C++ language in general. I would suggest he read some new books on how C++ is used today, especially C++11.