Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualNypyren

Posted 15 January 2013 - 11:20 PM

A C program is nondeterministic if you forget to initialize a single variable. This alone is sufficient reason to avoid recommending it as a first programming language.

 
 
I think you have your definition of nondeterministic wrong. C is very deterministic. The same thing will happen every time you run your program.

No. An uninitialized variable will have whatever value that previously existed in the memory address it gets assigned to. Memory is not initialized beforehand, which is one of the (minor) ways C can produce faster code than languages which initialize everything to zero.

Each time a program starts, memory is effectively random, since it has been altered by other things running on the system. If you don't initialize a variable, it starts with what is effectively random, and this may cause your program to do something TOTALLY different from the last time you ran it.

The value of the uninitialized variable comes from other processes in the same way that a threading race condition can set the value of a variable nondeterministically. A race condition is one of the textbook definitions of nondeterminism in algorithms.

C# is the complete opposite. It initializes all member variables to null/false/zero and produces compiler errors if you try to read from any uninitialized local variables.

#3Nypyren

Posted 15 January 2013 - 11:19 PM

A C program is nondeterministic if you forget to initialize a single variable. This alone is sufficient reason to avoid recommending it as a first programming language.

 
 
I think you have your definition of nondeterministic wrong. C is very deterministic. The same thing will happen every time you run your program.

No. An uninitialized variable will have whatever value that previously existed in the memory address it gets assigned to. Memory is not initialized beforehand, which is one of the (minor) ways C can produce faster code than languages which initialize everything to zero.

Each time a program starts, memory is effectively random, since it has been altered by other things running on the system. If you don't initialize a variable, it starts with what is effectively random, and this may cause your program to do something TOTALLY different from the last time you ran it.

The value of the uninitialized variable comes from other processes in the same way that a threading race condition can set the value of a variable nondeterministically. A race condition is one of the textbook definitions of nondeterminism in algorithms.

C# is the total opposite. It initializes all member variables to null/false/zero and produces compiler errors if you try to read from any uninitialized local variables.

#2Nypyren

Posted 15 January 2013 - 11:07 PM

A C program is nondeterministic if you forget to initialize a single variable. This alone is sufficient reason to avoid recommending it as a first programming language.

 
 
I think you have your definition of nondeterministic wrong. C is very deterministic. The same thing will happen every time you run your program.

No. An uninitialized variable will have whatever value that previously existed in the memory address it gets assigned to. Memory is not initialized beforehand, which is one of the (minor) ways C can produce faster code than languages which initialize everything to zero.

Each time a program starts, memory is effectively random, since it has been altered by other things running on the system. If you don't initialize a variable, it starts with what is effectively random, and this may cause your program to do something TOTALLY different from the last time you ran it.

The value of the uninitialized variable comes from other processes in the same way that a threading race condition can set the value of a variable nondeterministically. A race condition is one of the textbook definitions of nondeterminism in algorithms.

#1Nypyren

Posted 15 January 2013 - 10:58 PM

A C program is nondeterministic if you forget to initialize a single variable. This alone is sufficient reason to avoid recommending it as a first programming language.

 
 
I think you have your definition of nondeterministic wrong. C is very deterministic. The same thing will happen every time you run your program.

No. An uninitialized variable will have whatever value that previously existed in the memory address it gets assigned to. Memory is not initialized beforehand, which is one of the (minor) ways C can produce faster code than languages which initialize everything to zero.

Each time a program starts, memory is effectively random, since it has been altered by other things running on the system. If you don't initialize a variable, it starts with what is effectively random, and this may cause your program to do something TOTALLY different from the last time you ran it.

PARTNERS