Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Which is a better fit for C++: “static typing” or “dynamic typing”?

fit static typing
0
Posted

Which is a better fit for C++: “static typing” or “dynamic typing”?

0

If you want to use C++ most effectively, use it as a statically typed language. C++ is flexible enough that you can (via ptr casts, unions, and #defines) make it “look” like Smalltalk. But don’t. Which reminds me: try to avoid #define. There are places where ptr casts and unions are necessary and even wholesome, but they should be used carefully and sparingly. A ptr cast tells the compiler to believe you. An incorrect ptr cast might corrupt your heap, scribble into memory owned by other objects, call nonexistent ethods, and cause general failures. It’s not a pretty sight. If you avoid these and related constructs, you can make your C++ code both safer and faster, since anything that can be checked at compile time is something that doesn’t have to be done at run-time. Even if you’re in love with dynamic typing, please avoid it in C++, or else please consider using another language that better supports your desire to defer typing decisions to run-time. C++ performs 100% of its type check

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123