views:

60

answers:

4

I've always put languages into 2 types... ones that let you refer to "undefined" (uninitialized, freed, etc.) memory, such as C, C++, COBOL (?), Assembly, etc. and ones that you can't such as Java, Perl, C#, and Basic. Is there a "computer science" term for this distinction? While we're at it, is there a computer science term to what I call "undefined memory"?

A: 

Are you thinking about dynamic memory allocation and the heap?

thedz
Good job bringing those words into this thread, but C, C++, Java and C# all do similar things when it comes to memory, it's just that Java and C# abstract the management of it away from the user.
TahoeWolverine
A: 

Can you define "refer to"? If you simply mean that you can get at garbage memory without warnings or errors, I don't think that there is really a formal distinction there. The distinction I can think of that might be pertinent is "High Level" and "Low Level". High Level (further abstracted from assembly) languages like Java and C# generally abstract away the ability to start referencing garbage for obvious reasons. Lower level (close to assembly) languages don't simply for the sake of leaving it open to the developer (this is similar to memory management). Undefined memory is normally referred to as unused, garbage, or freed memory.

TahoeWolverine
OK, but I want to add "uninitialized" memory this classification... it is allocated but just not initialized
JoelFan
I believe Falaina beat you to that punch...
TahoeWolverine
+4  A: 

Pointer Safety.

I apologize for not being able to attribute the original author. I know I've seen Erik Meijer mention and define it though.

Pointer safety (or memory safety) is the attribute of a program, or all programs in a particular language or other constraint, where the program cannot address memory other than that it explictly allocated and owns, or through an intermediary, such as OS.

Type safety is also such an attribute, but is generally stricter -- if something is typesafe, it's generally pointer-safe as well. In this attribute, memory is referred to as "objects" that have a type, and the program never manipulates that memory except through operations on that type. I'll leave the various conflicting definitions of type alone for now, as that can also be a big question.

These attributes apply generally, and can apply to various memory management strategies -- dynamic heap allocations, arena allocators, stacks, and 'static' or 'global' storage. It's not just about heaps.

Wikipedia on pointer safety and type safety.

Aaron
Are you sure "pointer safety" refers to the issue of unitialized local variables?
JoelFan
I didn't say anything about "uninitialized locals" in particular, but a "pointer safe" language would necessarily address use of uninitialized memory when that memory is to be interpreted as a pointer.
Aaron
Ok, but what I'm looking for would include making sure that it's not possible to refer to uninitialized memory AT ALL, regardless of whether it's a pointer
JoelFan
+4  A: 

You know, I've always used the term Memory Safety when discussing these topics. And I consider C/C++ "Memory Unsafe" languages. I don't actually know if this is the accepted terminology, so I'll be interested in seeing other answers.

As for terms for "undefined memory", I believe that term would be a combination of 2 other terms:

Unallocated memory: Memory which has not been set aside for use by a program.

Uninitialized memory: Memory which has been allocated, but has not been given a meaningful value by the program.

Falaina