[Previous] [Contents] [Next]

Value Types and Reference Types

Creating a language where everything is an object is not a new concept. Other languages have tried this, the most famous being SmallTalk. The biggest disadvantage to making everything an object has always been poor performance. For example, if you attempt to add two values of type double in SmallTalk, an object is actually allocated on the heap. Needless to say, the allocation of an object is extremely inefficient when all you wanted to do was sum two numbers.

The designers of the CTS were faced with the task of creating a type system in which everything is an object but the type system works in an efficient manner, when applicable. Their solution was to separate the CTS types into two categories: value types and reference types. These terms, as you'll soon see, reflect how variables are allocated and how they function internally.

[Previous] [Contents] [Next]