Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

To me, the use of the keyword static in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different things.

In C static means, that the function or variable is only accessible via functions inside the same source file, comparable to private functions and members in C++, Java and C#.

In C++, Java and C# static means, that the methods are not members of a class instance, but effectively are more or less like C functions plus namespace.

IMHO these two concepts are quite different, so why did the designers of C++ and later Java and C# choose the static keyword for that behaviour? Is there a logical connection that I miss?

EDIT I know, that static in C does not govern accessability in a way similar to private in C++, but can be used in that way, see http://stackoverflow.com/a/1479639/124983https://stackoverflow.com/a/1479639/124983

To me, the use of the keyword static in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different things.

In C static means, that the function or variable is only accessible via functions inside the same source file, comparable to private functions and members in C++, Java and C#.

In C++, Java and C# static means, that the methods are not members of a class instance, but effectively are more or less like C functions plus namespace.

IMHO these two concepts are quite different, so why did the designers of C++ and later Java and C# choose the static keyword for that behaviour? Is there a logical connection that I miss?

EDIT I know, that static in C does not govern accessability in a way similar to private in C++, but can be used in that way, see http://stackoverflow.com/a/1479639/124983

To me, the use of the keyword static in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different things.

In C static means, that the function or variable is only accessible via functions inside the same source file, comparable to private functions and members in C++, Java and C#.

In C++, Java and C# static means, that the methods are not members of a class instance, but effectively are more or less like C functions plus namespace.

IMHO these two concepts are quite different, so why did the designers of C++ and later Java and C# choose the static keyword for that behaviour? Is there a logical connection that I miss?

EDIT I know, that static in C does not govern accessability in a way similar to private in C++, but can be used in that way, see https://stackoverflow.com/a/1479639/124983

Clarification
Source Link
Residuum
  • 3.3k
  • 1
  • 31
  • 31

To me, the use of the keyword static in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different things.

In C static means, that the function or variable is only accessible via functions inside the same source file, comparable to private functions and members in C++, Java and C#.

In C++, Java and C# static means, that the methods are not members of a class instance, but effectively are more or less like C functions plus namespace.

IMHO these two concepts are quite different, so why did the designers of C++ and later Java and C# choose the static keyword for that behaviour? Is there a logical connection that I miss?

EDIT I know, that static in C does not govern accessability in a way similar to private in C++, but can be used in that way, see http://stackoverflow.com/a/1479639/124983

To me, the use of the keyword static in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different things.

In C static means, that the function or variable is only accessible via functions inside the same source file, comparable to private functions and members in C++, Java and C#.

In C++, Java and C# static means, that the methods are not members of a class instance, but effectively are more or less like C functions plus namespace.

IMHO these two concepts are quite different, so why did the designers of C++ and later Java and C# choose the static keyword for that behaviour? Is there a logical connection that I miss?

To me, the use of the keyword static in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different things.

In C static means, that the function or variable is only accessible via functions inside the same source file, comparable to private functions and members in C++, Java and C#.

In C++, Java and C# static means, that the methods are not members of a class instance, but effectively are more or less like C functions plus namespace.

IMHO these two concepts are quite different, so why did the designers of C++ and later Java and C# choose the static keyword for that behaviour? Is there a logical connection that I miss?

EDIT I know, that static in C does not govern accessability in a way similar to private in C++, but can be used in that way, see http://stackoverflow.com/a/1479639/124983

Source Link
Residuum
  • 3.3k
  • 1
  • 31
  • 31

False friends? Keyword "static" in C compared to C++, C# and Java

To me, the use of the keyword static in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different things.

In C static means, that the function or variable is only accessible via functions inside the same source file, comparable to private functions and members in C++, Java and C#.

In C++, Java and C# static means, that the methods are not members of a class instance, but effectively are more or less like C functions plus namespace.

IMHO these two concepts are quite different, so why did the designers of C++ and later Java and C# choose the static keyword for that behaviour? Is there a logical connection that I miss?