Strongly Typed
In “Hackers and Painters“, one of my favorite essayists and modern day renaissance men, Paul Graham, states his disdain for strongly typed programming languages. The main reason is that he doesn’t like to be scolded by mindless compilers that handcuff his creativity by enforcing static type-checking rules. Being a C++ programmer, even though I love Paul and understand his point of view, I have to disagree. One of the reasons I like working in C++ is because of the language’s strong type checking rules, which are enforced on the source code during compilation. C++ compilers find and flag a lot of my programming mistakes prior to runtime <- where finding sources of error can be much more time consuming and frustrating.
Driven by “a fierce determination not to impose a specific one size fits all programming style” on programmers, Bjarne Stroustrup designed C++ to allow programmers to override the built-in type system if they consciously want to do so. By preserving the old C style casting syntax and introducing new, ugly C++ casting keywords (static_cast, dynamic_cast, etc) that purposefully make manual casts stick out like a sore thumb and easily findable in the code base, a programmer can legally subvert the type system.
C++ gets trashed a lot by other programming language zealots because it’s a powerful tool with a rich set of features and it supports multiple programming styles (procedural, abstract data types, object-oriented, generic) instead of just one “pure” style. Those attributes, along with Bjarne’s empathy with the common programmer, are exactly why I love using C++. How about you, what language(s) do and don’t you like? Why?
The more you try to handcuff a software developer the more they try to get around it. Mainly due to cost and schedule pressures.
Is it mainly due to cost and schedule pressure, or is it mainly because of ego?
Some ego, some experimentation but mostly people start cutting corners when the cost and schedule legs of the project start getting raddled.
Have you personally experienced many cases where “cost and schedule legs of the project don’t start getting raddled”?
I prefer working with strongly type language, explicitly mentioning type is much better. With the introduction of auto keyword, Visual Assist and modern IDEs the pain of making type agree is much reduced even before compiling. I remember Andrew Koenig in his book Accelerated C++ using vector::size_type, rather than using any other type as counter variable, and I like that.
Hi Raj,
I too like getting beat up by the compiler. I’m a glutton for punishment.
I use unsigned as the type of the looping variable for vector. It’s less verbose and I’m lazy ๐ .
Hi Tony, I agree I too use unsigned int, but Ideally we have to use the type as defined inside Allocator, that can be any thing, char or int or long or anything else but size_type is just type defined in allocator type.
At least with the introduction of auto keyword in C++OX things will be much better, we may not need to think about type itself ๐ .