Learning C#?

Started by
15 comments, last by moneal2001 11 years, 3 months ago

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.
Advertisement

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.

This is true. But in C often your compiler/IDE will give you warnings about uninitialized variables.

I'm going to stick with C#, for one because Unity supports it and not Python, I plan on sticking with unity :D.

My Project info: My Dev Journal: http://www.gamedev.net/blog/1571-the-life-of-a-unity-developer/
I update this more: http://forum.unity3d.com/threads/158344-Not-Dead-Enough-a-zombie-apocalypse-simulator-now-in-production!

I started learning C# a few months ago using Rob Miles' C# Yellow Book. It's a free download and it helped me get up to speed pretty quickly with C#.

Here's the link again ...

Just scroll down the page until you find the 2012 edition.

Hope it helps.

Roy

Northwest Arkansas Game Developer Group
Live in Fayetteville, Springdale, Bentonville, or Rogers?
Interested in making video games and having fun?
Check us out on Meetup.

Thanks guys!

My Project info: My Dev Journal: http://www.gamedev.net/blog/1571-the-life-of-a-unity-developer/
I update this more: http://forum.unity3d.com/threads/158344-Not-Dead-Enough-a-zombie-apocalypse-simulator-now-in-production!

I'll just throw a recommendation in for the "Illustrated C#" series. I found them very approachable, moved on to the "Accelerated C#" version and keep that one around for more in-depth reference. I refer to them as series because there keep being new printings as the language spec continues to grow, but just grab the latest and you should be good.

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)

OP Check out RBWhitiker's site rbwhitaker.wikidot.com . it has online written tutorials on c# and xna. its where i started learning c# and xna. he also has a book on c# written for beginners as well. it is advertized on his site.

This topic is closed to new replies.

Advertisement