about
Blog: Object Models
11/26/2024
Blog: Object Models
native code, managed code
About
click to toggle Site Explorer
Initial Thoughts:
-
C++ Native Code
The C++ Programming Language was built, from the ground up, to support creation of user-defined value types. For this it supports copy construction
and copy assignment. If a class's members and bases all have value semantics, the compiler will generate default copy and assignment operations
that provide value semantics for the class, by doing member-wise copy and assignment. If a class composes reference types, then the class designer
overloads the class copy constructor and assignment operator to provide correct value semantics.
-
C# and Java Managed Code
- Javascript Javascript has value types, e.g., ints, bools, literal strings, and reference types which are instances that reside on a managed heap. Javascript uses a prototype object model. New instances are created by cloning a prototype and removed from memory by garbage collection when all references to them have been nulled or gone out of scope. Most applications of Javascript are hosted by browsers. However, in the Node.js framework, a host for the Chrome V8 Javascript engine has been developed for Windows, Linux, and Unix applications. Node supports TCP communication and uses a single-threaded message loop, similar to the loop used in virtually all GUI applications. Javascript objects are dynamically typed. They behave very like C Language structs that contain instances or references to data and pointers to functions. New functions and new data can be added to an instance at any time.
- A local object is defined inside some scope, e.g., function scope or control scope.
- Value types are, with one exception, blit-able, e.g., can be copied by copying memory. Structs are value types, but may not be blit-able since the languages, suprisingly, allow structs to hold references.
- Unmanaged resources are things like I/O streams, database connections, and socket handles.