Question

In: Computer Science

Describe some design trade-offs between efficiency and safety in some language you know.

Describe some design trade-offs between efficiency and safety in some language you know.

Solutions

Expert Solution

Some design trade-offs between efficiency and safety in C++ language can be written as follows:

  • The conflict between writability and reliability is a common one in language design.
  • The pointers of C++ can be manipulated in a variety of ways, which leads to highly flexible addressing of data. Because of the potential reliability problems with pointers, they are not included in java.

In general the pro's and con's can be written as follows:
C++

  • Extension of C with object-oriented programming, still able to run C code.
  • Compatible with C source code, except for a few corner cases.
  • Write once, compile anywhere (WOCA).
  • Allows procedural programming, functional programming,object-oriented programming, generic programming, andtemplate metaprogramming. Favors a mix of paradigms.
  • Runs as native executable machine code for the targetinstruction set(s).
  • Provides object types and type names. Allows reflection through RTTI.
  • Has multiple binary compatibility standards (commonly Microsoft (for MSVC compiler) and Itanium/GNU (for virtually all other compilers)).
  • Optional automated bounds checking (e.g., the at()method in vector and string containers).
  • Supports native unsigned arithmetic.
  • Standardized minimum limits for all numerical types, but the actual sizes are implementation-defined. Standardized types are available through the standard library<cstdint>.
  • Pointers, references, and pass-by-value are supported for all types (primitive or user-defined).
  • Memory management can be done manually through new / delete, automatically by scope, or by smart pointers. Supports deterministic destruction of objects. Garbage collection ABI standardized in C++11, though compilers are not required to implement garbage collection.
  • Resource management can be done manually or by automatic lifetime-based resource management (RAII).
  • Supports classes, structs (POD-types), and unions, and can allocate them on the heap or the stack.
  • Allows explicitly overriding types as well as some implicit narrowing conversions (for compatibility with C).
  • The C++ Standard Library was designed to have a limited scope and functionality but includes language support, diagnostics, general utilities, strings, locales, containers, algorithms, iterators, numerics, input/output, random number generators, regular expression parsing, threading facilities, type traits (for static type introspection) and Standard C Library. The Boost library offers more functionality including network I/O.
  • A rich amount of third-party libraries exist for GUI and other functionalities like: ACE, Crypto++, various XMPP Instant Messaging (IM) libraries,[3] OpenLDAP, Qt, gtkmm.
  • Operator overloading for most operators. Preserving meaning (semantics) is highly recommended.
  • Single and Multiple inheritance of classes, including virtual inheritance.
  • Compile-time templates. Allows for Turing complete meta-programming.
  • Function pointers, function objects, lambdas (in C++11), and interfaces.
  • No standard inline documentation mechanism. Third-party software (e.g. Doxygen) exists.
  • const keyword for defining immutable variables and member functions that do not change the object. Const-ness is propagated as a means to enforce, at compile-time, correctness of the code with respect to mutability of objects (see const-correctness).
  • Supports the goto statement.
  • Source code can be written to be platform-independent (can be compiled for Windows, BSD, Linux, Mac OS X,Solaris, etc., without modification) and written to take advantage of platform-specific features. Typically compiled into native machine code, must be re-compiled for each target platform.

Thank you.


Related Solutions

Question 1 Describe some of the trade-offs faced by each of the following: a. a family...
Question 1 Describe some of the trade-offs faced by each of the following: a. a family deciding whether to buy a new car b. a member of Congress deciding how much to spend on national parks c. a company president deciding whether to open a new factory d. a professor deciding how much to prepare for class e. a recent college graduate deciding whether to go to graduate school Question 2 i. The company that you manage has invested $5...
Each of the following situations require some trade-offs. You are supposed to analyze and discuss a...
Each of the following situations require some trade-offs. You are supposed to analyze and discuss a few trade-offs with respect to each of the given situation. a) A Parliamentarian has to make a decision whether to spend on Karachi’s sewerage system (1 Mark) b) President of a corporation wants to make a decision whether to start a new factory. (1 Mark) c) A middle income family wants to decide whether to buy a new Honda City. (1 Mark) d) A...
Explore the trade offs between centralized and decentralized international marketing research
Explore the trade offs between centralized and decentralized international marketing research
Since a society faces trade-offs, are there some ways out of the limitations imposed by the...
Since a society faces trade-offs, are there some ways out of the limitations imposed by the scarcity of resources? Use the Production possibility frontier model
With reference to a lens’s Numerical Aperture (N.A.) discuss the trade-offs between the diameter of the...
With reference to a lens’s Numerical Aperture (N.A.) discuss the trade-offs between the diameter of the front lens of an objective, the objective’s working distance, its optical resolution limit and the complexity of internal lenses.
What are the trade-offs in the process of creating a system that can distinguish between self...
What are the trade-offs in the process of creating a system that can distinguish between self and non-self? How do you think the system balances the need to maximize recognition of potential threats with the danger of autoimmunity? Give an example of a way the immune system might prevent autoimmune responses, and a way a microbe might exploit that system.
what are the main trade-offs in the theory of fiscal federalism? how can the tensions between...
what are the main trade-offs in the theory of fiscal federalism? how can the tensions between negative spillovers and diversity explain the european union only very limited harmonisation of social policies?
6. How are the trade-offs between in-house production and outsourcing affected by the business environment of...
6. How are the trade-offs between in-house production and outsourcing affected by the business environment of emerging economies such as China?
examine the trade-offs between the risks and the benefits of internal and external customers connecting from...
examine the trade-offs between the risks and the benefits of internal and external customers connecting from multiple locations on multiple devices to a banking computer, by addressing the following: identify and discuss the benefits for internal and external customers that might justify the risks. identify and discuss the benefits for the variety of locations that might justify the risks. identify and discuss the benefits for the various types of computing devices that might justify the risks. The initial posting should...
The concept of trade-offs is important to the economics discipline and to this course. Can you...
The concept of trade-offs is important to the economics discipline and to this course. Can you explain why economic investment ( investment in plant, equipment and machinery) represents a trade off between present and future consumption?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT