I’m asked about this all the time, and it’s in part because I am a software engineer, a developer with 30+ years experience.
My first real learning experience was on the TRS-80, using interpreted BASIC – a primitive, line oriented language which was as appropriate as available at the time.
My primary language of choice is C++. I know it extremely well, but I must say that it’s not the best language to start off in. It’s filled with potential pitfalls.
Now, the suggestion to consider assembler is interesting, but also not suitable for a beginning student unless that student is extremely dedicated, focused, determined and talented (but then, all possible avenues would be appropriate for that kind of person). One reason I don’t suggest C++ is because it’s basis is C, and C was originally intended as a pseudo assembler, and that’s why it was used to write the first version of Unix.
C# or Java are the appropriate starting points. C# has better overall performance and access to the Windows operating system, but Java has its own merits. Both are “safer” for students, but C# may have the edge if I had to choose should I teach a course. Most universities are using Java in that mode.
Now, if game development is your target, Java isn’t your primary language direction unless your games are on the Andriod phone. C++ will be the primary language there, with assembler as a rare secondary.
The concepts of code construction, the use of objects, the theories of computer science are all well illustrated in C# and Java, and that knowledge is transferrable to C++ and elsewhere. Even the syntax of these three languages share a common root.
Sorry, though, I haven’t been a student for decades, and thus I have no current references to suggest for a beginner. I can leave you with this one bit of help relative to your question:
In the early BASIC language, and indeed in primitive assembler, there is a single dimension of organization….a list of instructions. The list can loop, branch, even “return” from a branch, but it’s just a list of instructions. This is what the very earliest style of programming a computer was based upon.
C wasn’t the first, but probably the best example of the second dimension of organization; functions. A function is a collection of statements wrapped up in an identifier (a name). The primary unique feature of the function is a local set of variables unique to the local execution of the function, it involves the concept of a stack. The stack is a specialized area of memory that works like a stack of cards, which are used to remember what function the point of execution CAME FROM. It also includes any storage for local variables for that particular moment of execution of that function. Imaging if you were constantly interrupted with additional things to do, all day long. You might, if you’re a primitive thinker, need to write what you were doing just before you were interrupted on a card, and place it in a stack of cards, then proceed with what you were interrupted to do. During that time you may get another interruption, and another, and each time you put a card on top of the stack which recalls what you were doing, and any information about how far you had gotten while you were doing it…so that when you’re finally done with the current task, you toss the card for that task in the trash, pick up the top card on the stack, and CONTINUE. You can “unwind” this stack, and therefore never loose track of the interrupted tasks. Of course, these “interruptions” are really scheduled, expected tasks…they just put your current task into a “suspended” condition until the “sub task” is completed, and you return.
Programmers usually think of “being inside a function”. Within the function, that “card on the stack” contains all the local variables used during that function’s execution.
Imagine what happens if, while inside a function, you call….that same function again, and again, and again….the stack could grow indefinitely. Of course, there would be a “termination condition”…limiting how high the stack would get (what we usually think of as the DEPTH of this self calling…known as recursion).
Now, each time that happens, each sub-call (or recursion of the call as we name it) has it’s own local variables. Before you think that’s a useless notion, the fastest sorting algorithm (generally), called qsort, is written based on that very design.
Now, to objects.
Objects are a 3rd dimension to the organization of code. We view them as a collection of data and functions. Further, with clever structuring, the nature of objects creates multiple dimensions of organization, so it’s really well beyond just 3 dimensions.
Think of this analogy. First, there’s a list of instructions…consider them as rows in a spreadsheet. Next, there are functions..think of these as columns. Now you witness the 2D nature of that organization.
Now, the objects are pages.
Which, of course, can be organized in chapters, books, libraries…etc.
The purpose of the object is to take the feature of multiple dimensional organization and use it to create software that’s built more like a machine.
In C, which doesn’t have objects, we tended to create these groups of functions that worked as a family, all devoted to a particular subject. There are functions to handle string, others for math, others for files…etc.
It gets to be a mess, strictly organized only by the discipline of the programmers working on it.
With objects, we create components that work like parts of a machine, then fit those components together to create more complex machines. Those machines can, in turn, be turned into components in yet more complex machines, while still keeping the organization under control….and leveraged.
Instead of a bunch of functions that handle files, we create (or there is a library with) an object that represents an open file. We use the object to load and save data to the file it represents.
Objects become metaphors for the real world counterparts they model.
Note, when I say that, I’m not talking about games, though certainly they’re used for that…I’m talking about concepts – any concept. The object gives whatever concept it represents the features of reality, and makes development a lot more productive, and gives us leverage to produce applications of greater ambition with greater organization.
Best of luck….it’s a blast if its your kind of thing!
Edited by JVene - 6/9/10 at 6:51pm