1. Home
  2. Explore
  3. Computer Science
  4. Bjarne Stroustrup Technology Lecture

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Bjarne Stroustrup Technology Lecture

  • 78Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Industry Context

How did the speaker characterize technology’s role at Morgan Stanley?

78 questions

  1. 1

    How did the speaker characterize technology’s role at Morgan Stanley?

    Model answer

    He described technology as fundamental to the business, not merely as support for it.

    Explanation

    His comparison was to companies whose core activities depend on technology.

  2. 2

    What relationship did the speaker draw between Morgan Stanley’s trading position and its technology?

    Model answer

    He said the firm’s leading position in equity trading was due in part to its belief that it builds superior technology.

    Explanation

    He connected the quality of its trading technology with its position in the market.

  3. 3

    What programming languages did the speaker mention as part of Morgan Stanley’s technology work?

    Model answer

    He mentioned C, C++, Java, and Scala.

    Explanation

    He described investment in C and C++ alongside more recent use of languages such as Java and Scala.

  4. 4

    What did the speaker say about Morgan Stanley’s technology team in Glasgow?

    Model answer

    He said it had reached about 100 programmers building sophisticated platforms.

    Explanation

    The Glasgow team worked alongside other development centers around the world.

  5. 5

    Which other development centers did the speaker name, and where were they located?

    Model answer

    He named Budapest in Europe, Shanghai in Asia, and Montreal in the Americas.

    Explanation

    He presented them as key development centers working alongside Glasgow.

  6. 6

    Why did the speaker say C++ should be able to work close to hardware?

    Model answer

    It should support systems work such as memory management and virtual machines while enabling programs to run efficiently.

    Explanation

    The language is intended to provide low-level control when applications require it.

  7. 7

    What does type safety mean in the speaker’s account of C++’s design goals?

    Model answer

    It means using types to help detect inappropriate operations and make programs safer.

    Explanation

    The speaker described increasing type safety as a goal he had pursued from the early development of C++.

  8. 8

    Why is resource safety important in systems programming?

    Model answer

    A program must not run out of resources such as memory, file handles, connections, or locks.

    Explanation

    The speaker emphasized that resource failures can be serious in systems such as spacecraft and phones.

  9. 9

    What does predictability require in hard real-time systems, according to the speaker?

    Model answer

    Operations must have predictable execution times, usually with a low maximum time.

    Explanation

    Operations without suitable timing guarantees may be unacceptable in real-time control systems.

  10. 10

    How did the speaker describe the relationship between task complexity and code complexity?

    Model answer

    Ideally, code complexity should be proportional to the complexity of the task.

    Explanation

    He presented this as a design ideal that is difficult to achieve in every domain.

  11. 11

    Why did the speaker say C++ should be both expert-friendly and novice-friendly?

    Model answer

    Expert power alone is insufficient if the language is hostile to new or casual users who could benefit from it.

    Explanation

    He argued that accessibility matters in addition to expressive power.

  12. 12

    Which kinds of applications did the speaker identify as central to C++’s intended domain?

    Model answer

    He identified systems software, embedded and resource-constrained applications, and large software systems.

    Explanation

    He contrasted these areas with applications such as simple web apps, which are not C++’s primary design target.

  13. 13

    What programming model did C inherit from its view of hardware?

    Model answer

    C provided a relatively direct model of operations, memory, and data laid out in sequences.

    Explanation

    The speaker described this model as effective for working close to the hardware.

  14. 14

    What contribution did Fortran make to programming language design?

    Model answer

    It raised programming from a machine-focused level to a problem-focused level for scientists and engineers.

    Explanation

    The speaker described Fortran as a language designed around the work of its intended users.

  15. 15

    How did the speaker connect higher-level programming with portability?

    Model answer

    He said that expressing programs at a more human and problem-focused level helped make programs portable across different machines.

    Explanation

    He used the movement of Fortran programs between machines as an example.

  16. 16

    What problem arose when different specialized languages were used for different tasks?

    Model answer

    Programs written in different languages could not easily combine capabilities, such as reading business records and then performing scientific calculations.

    Explanation

    Languages such as COBOL and Fortran were suited to different kinds of work, but combining them was difficult.

  17. 17

    What idea from Simula helped address the limitations of specialized built-in data types?

    Model answer

    Simula let programmers define their own abstractions, such as vectors, matrices, and records, using classes.

    Explanation

    The speaker described classes as a way for users to build the abstractions their applications need.

  18. 18

    How did the speaker summarize the origins of C++?

    Model answer

    C++ combined C’s close-to-hardware model with Simula’s support for classes and user-defined abstractions.

    Explanation

    The design aimed to retain direct access to hardware while making more complex abstractions possible.

  19. 19

    What problem do constructors and destructors help solve in C++?

    Model answer

    Constructors initialize objects, while destructors clean up resources associated with them.

    Explanation

    These features support the creation and orderly teardown of abstractions.

  20. 20

    Why does the speaker argue that C++ must preserve compatibility with existing code?

    Model answer

    Changing the language in ways that break large existing codebases is unacceptable to many users.

    Explanation

    Long-term stability is a constraint on adding or removing language features.

  21. 21

    What is a resource in the speaker’s explanation of resource management?

    Model answer

    A resource is something a program acquires and must eventually return or release.

    Explanation

    Examples include memory, files, sockets, connections, and locks.

  22. 22

    Why should a resource have a known owner?

    Model answer

    A known owner makes it clear which part of the program is responsible for releasing the resource.

    Explanation

    Unclear ownership can lead to leaks and other resource-management errors.

  23. 23

    How can unclear pointer ownership cause a resource leak?

    Model answer

    If responsibility for deleting or releasing the pointed-to object is unclear, no part of the program may clean it up.

    Explanation

    Passing a pointer between parts of a program can obscure who is responsible for the resource.

  24. 24

    What role should a handle play in resource management?

    Model answer

    A handle should represent a meaningful object or resource and manage access to it.

    Explanation

    Standard containers and other resource-managing objects use handles to represent the resources they manage.

  25. 25

    How do standard containers such as vectors, strings, and maps manage their resources?

    Model answer

    They manage their associated resources and clean them up when the container object goes out of scope.

    Explanation

    Their cleanup behavior is part of the resource-management model used throughout the standard library.

  26. 26

    What does it mean for cleanup to happen implicitly when an object goes out of scope?

    Model answer

    The object’s destructor runs automatically and releases the resources it manages.

    Explanation

    Programmers do not need to write a separate cleanup instruction for every exit from the scope.

  27. 27

    Why can manually pairing allocation with deletion be unreliable?

    Model answer

    Every return or exception path must perform the cleanup correctly, and programmers can miss one.

    Explanation

    The speaker warned that manually written cleanup code is easy to get wrong.

  28. 28

    Why is garbage collection not a complete solution to resource management?

    Model answer

    It primarily manages memory, while resources such as files, locks, and connections also need cleanup.

    Explanation

    The speaker emphasized that many important resources are not memory.

  29. 29

    How can a smart pointer help when an exception interrupts a function?

    Model answer

    Its destructor runs during stack unwinding and releases the resource it owns.

    Explanation

    This avoids relying on a later, manually written deletion statement.

  30. 30

    When is a unique pointer preferable to a shared pointer?

    Model answer

    A unique pointer is preferable when a resource has one owner and does not need shared ownership.

    Explanation

    It avoids the shared ownership bookkeeping required by a shared pointer.

  31. 31

    Why does a shared pointer maintain a use count?

    Model answer

    It tracks how many shared pointers own the object so the object can be cleaned up when the count reaches zero.

    Explanation

    The last owner releases the shared resource.

  32. 32

    What cost can shared ownership introduce?

    Model answer

    Maintaining the shared use count creates a shared resource and can add overhead, especially with concurrency.

    Explanation

    The speaker cautioned that shared state can cost more than expected.

  33. 33

    What is the central idea of resource acquisition is initialization?

    Model answer

    Acquire a resource in an object’s constructor and release it in the object’s destructor.

    Explanation

    The object’s lifetime then controls the lifetime of the resource it manages.

  34. 34

    How does resource acquisition is initialization support exception safety?

    Model answer

    If an exception exits a scope, destructors still run and release resources owned by local objects.

    Explanation

    This makes cleanup dependable across normal returns and exceptional exits.

  35. 35

    What should pointers generally represent in the speaker’s recommended approach?

    Model answer

    They should refer to objects owned elsewhere, rather than being used to obscure ownership.

    Explanation

    The speaker distinguished non-owning references and iterators from ownership handles.

  36. 36

    Why can returning a raw pointer from a function create ownership problems?

    Model answer

    The caller and function may not know which one owns the object and is responsible for deleting it.

    Explanation

    Sharing the pointer can make responsibility even less clear.

  37. 37

    Why is returning a pointer to a large matrix often an unattractive interface?

    Model answer

    It forces callers to deal with pointer ownership and dereferencing instead of working directly with a matrix value.

    Explanation

    The speaker wanted matrix operations to express matrix results, not pointer-management details.

  38. 38

    What ownership problem remains if a function returns a reference to a newly created object?

    Model answer

    The reference does not clarify who owns and deletes the object.

    Explanation

    Changing a pointer return to a reference can hide the ownership issue without solving it.

  39. 39

    Why did the speaker object to requiring callers to prepare a target object for a large result?

    Model answer

    It makes code less natural and gives up the direct expression of a result as a returned value.

    Explanation

    He argued that such a pattern can move programming away from concise mathematical notation.

  40. 40

    What does move semantics allow a program to do with a large object?

    Model answer

    It can transfer the object’s representation to a new object instead of copying all its elements.

    Explanation

    For a matrix, the representation can be transferred by moving its data pointer and leaving the original empty.

  41. 41

    What is the difference between a copy constructor and a move constructor?

    Model answer

    A copy constructor duplicates an object’s value, while a move constructor transfers its representation.

    Explanation

    Moving can avoid the cost of copying a large resource-owning object.

  42. 42

    How can a move constructor leave the original object safe to destroy?

    Model answer

    It transfers the resource representation and leaves the original with an empty or null representation.

    Explanation

    The original object’s destructor then has no transferred resource to release.

  43. 43

    When can the compiler generate copy and move operations for a class?

    Model answer

    When the class’s member types already know how to copy and move themselves, the compiler can generate the corresponding operations.

    Explanation

    A matrix containing a vector can rely on the vector’s own resource-management operations.

  44. 44

    Why does the speaker favor object-oriented inheritance for some domains but not all?

    Model answer

    Inheritance is useful when the domain contains genuine hierarchical relationships among concepts.

    Explanation

    The shape example illustrates a natural hierarchy, while other domains may not have one.

  45. 45

    What does interface inheritance provide in C++?

    Model answer

    It allows related types to share a common interface, often through an abstract base class.

    Explanation

    The speaker distinguished interface inheritance from implementation inheritance.

  46. 46

    What is an abstract class in the speaker’s description?

    Model answer

    It is a class that does not provide a complete implementation and can define an interface for derived classes.

    Explanation

    Abstract classes support runtime polymorphism through shared interfaces.

  47. 47

    What is a virtual function call, and what limitation did the speaker note about it?

    Model answer

    It is an indirect call through a polymorphic interface; it can be relatively inexpensive but may inhibit inlining.

    Explanation

    The inability to inline can matter when the operation being called is very small.

  48. 48

    Why can using protected data make a class hierarchy harder to maintain?

    Model answer

    Derived classes can modify that data, making it harder to preserve the class’s invariants.

    Explanation

    The speaker warned that exposing representation for modification can cause problems.

  49. 49

    Why is it incorrect to equate good programming with extensive use of object-oriented hierarchies?

    Model answer

    Good code can be written without object-oriented hierarchies, and object-oriented code can still be poor.

    Explanation

    The speaker rejected the idea that one programming style guarantees quality.

  50. 50

    What is generic programming intended to make reusable?

    Model answer

    It makes types and operations reusable across different element types or containers.

    Explanation

    For example, one sorting algorithm can work with vectors of different element types.

  51. 51

    Why did the speaker want a vector type parameterized by its element type?

    Model answer

    The same vector abstraction and its operations should work for different element types without being rewritten for each one.

    Explanation

    A vector of one type should be usable with algorithms suitable for that type.

  52. 52

    Why did the speaker consider macros inadequate for generic programming?

    Model answer

    Macros did not scale well as a way to express reusable, parameterized types and operations.

    Explanation

    He sought a more general and flexible mechanism, leading to templates.

  53. 53

    What is compile-time duck typing in template programming?

    Model answer

    A type is accepted if it supports the operations the template uses; otherwise, compilation fails.

    Explanation

    The template checks capabilities through attempted use rather than a separately declared interface.

  54. 54

    What is one advantage of template errors being reported at compile time?

    Model answer

    A mismatch can be found before the program is shipped or run.

    Explanation

    The compiler detects the problem when it tries to instantiate the template.

  55. 55

    What major usability problem can arise from template error messages?

    Model answer

    They can be extremely long and difficult to connect to the programmer’s original mistake.

    Explanation

    The speaker described compiler diagnostics that produced pages of confusing messages.

  56. 56

    What is template metaprogramming used for?

    Model answer

    It can perform computations at compile time, often to improve performance or express operations before runtime.

    Explanation

    The speaker noted that extensive compile-time programming can also become difficult to manage.

  57. 57

    How can a template function often infer its type parameter?

    Model answer

    The compiler can deduce the type from the type of the argument passed to the function.

    Explanation

    For example, a sorting function can infer its element or container type from its argument.

  58. 58

    What is a predicate in the generic algorithms discussed by the speaker?

    Model answer

    A predicate is an operation that tests a value or pair of values and returns a truth result.

    Explanation

    A sorting or searching algorithm can use a predicate to define its comparison or selection rule.

  59. 59

    What is a function object, and why can it be useful in an algorithm?

    Model answer

    It is an object that can be called like a function and can hold state used by the algorithm.

    Explanation

    The speaker used a comparison object that stored a string for its comparison operation.

  60. 60

    How can a lambda expression simplify the use of a custom predicate?

    Model answer

    It lets the programmer write the operation directly without defining a separate function-object class.

    Explanation

    The speaker showed a lambda as a shorter way to express a string comparison.

  61. 61

    Why do generic algorithms often take a range defined by a beginning and an end?

    Model answer

    A range lets an algorithm operate on all or part of a sequence.

    Explanation

    Using a range makes algorithms composable and supports operations on subsequences.

  62. 62

    What requirements does sorting impose on its input?

    Model answer

    The input must support the access pattern required by sorting, and its elements must be orderable by the chosen comparison.

    Explanation

    The speaker contrasted random-access containers, such as vectors, with lists that do not provide random access.

  63. 63

    Why is a list unsuitable for the sorting algorithm discussed in the lecture?

    Model answer

    That sorting algorithm requires random access, which a list does not provide.

    Explanation

    The compiler can report that the list fails the algorithm’s requirements.

  64. 64

    What do concepts add to template programming?

    Model answer

    They let programmers state the requirements that template arguments must satisfy.

    Explanation

    This makes the intended interface clearer than relying only on errors from attempted operations.

  65. 65

    How can concepts improve template diagnostics?

    Model answer

    They can identify which stated requirement a type fails to satisfy instead of producing pages of indirect errors.

    Explanation

    The speaker illustrated a concise error explaining that a list did not meet the sorting constraint.

  66. 66

    What did the speaker mean by saying generic programming is just programming?

    Model answer

    Generic code should use familiar programming ideas and should not require a separate, mysterious way of reasoning.

    Explanation

    He argued that clearer language support can make generic code resemble ordinary code.

  67. 67

    Why did the speaker discourage arguments that one programming paradigm must replace another?

    Model answer

    Different approaches remain useful for different problems, so newer techniques do not make older ones universally obsolete.

    Explanation

    He compared this to the continued usefulness of Newtonian mechanics alongside later physics.

  68. 68

    Why can C++ not simply discard older features that are considered problematic?

    Model answer

    Existing code and paying users depend on those features, so removing them can break compatibility.

    Explanation

    The speaker described compatibility as a constraint on improving the language.

  69. 69

    What role might code analysis and code transformation play in modernizing C++?

    Model answer

    They could help identify outdated or unsafe patterns and transform existing code into newer styles.

    Explanation

    The speaker saw these tools as a way to improve old code without requiring purely manual updates.

  70. 70

    How can using containers help reduce buffer-overflow risks?

    Model answer

    Containers retain their size, making it easier to write bounds-aware code than when using raw arrays that decay to pointers.

    Explanation

    The speaker recommended containers such as vectors for many uses instead of C-style arrays.

  71. 71

    Why did the speaker favor containers over C-style arrays for many tasks?

    Model answer

    Containers preserve useful information such as their size, while arrays can lose that information when they convert to pointers.

    Explanation

    The speaker still considered arrays useful when directly accessing hardware.

  72. 72

    What did the speaker expect hardware support for range checking to help prevent?

    Model answer

    It could detect and stop accesses outside an array’s bounds.

    Explanation

    He expected compilers to use such hardware support to enforce checks at runtime.

  73. 73

    Why can C++ compile times become long when headers are repeatedly included?

    Model answer

    A header included by many source files may be processed repeatedly during separate compilations.

    Explanation

    The speaker described module systems as a way to reduce this repeated work.

  74. 74

    How could a module system improve compilation?

    Model answer

    It could reduce repeated processing of header contents across source files.

    Explanation

    The speaker expected modules to help address a longstanding compilation-time problem.

  75. 75

    Why can organizations be slow to adopt newer C++ standards?

    Model answer

    Some need their codebases to remain compilable with older compilers and have large amounts of existing code.

    Explanation

    The speaker described compatibility requirements as an obstacle to upgrading.

  76. 76

    What benefits did the speaker say could support the adoption of modern C++ styles?

    Model answer

    Modern styles can be safer and can generate faster code.

    Explanation

    He argued that these claims should be supported with code analysis and transformation tools.

  77. 77

    Why is mixing code compiled by different C++ vendors difficult?

    Model answer

    C++ does not have a single standardized binary interface or linkage format shared by all compilers.

    Explanation

    Compiler vendors have tended to preserve compatibility with their own earlier compilers rather than one another’s.

  78. 78

    Why did the speaker reject building a new language as an easy replacement for C++?

    Model answer

    A new language would likely struggle without C++’s established community, code, and infrastructure.

    Explanation

    He said that creating a language with preferable properties would not by itself ensure its success.

1 of 78
Question 1 of 78

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent