Recommend me a programming book.

GEC: Discuss gaming, computers and electronics and venture into the bizarre world of STGODs.

Moderator: Thanas

Darmalus
Jedi Master
Posts: 1131
Joined: 2007-06-16 09:28am
Location: Mountain View, California

Recommend me a programming book.

Post by Darmalus »

I was recently introduced to programming, and I think I kind of enjoy it. I was wondering if anyone could recommend a good programming guide to get me started. I'm only a few weeks past "Hello World" in C, so I don't have much idea what is out there. A quick Google seems to indicate that C++ or C# is what I would do for simple games.

Sorry if I have overlooked a more relevant thread, a quick search didn't seem to pull up any threads younger than 2009.
User avatar
TronPaul
Padawan Learner
Posts: 232
Joined: 2011-12-05 12:12pm

Re: Recommend me a programming book.

Post by TronPaul »

I haven't found a good physical programming book before, but I can recommend an online tutorial, An Informal Introduction to Python. I find Python to be a easy language to read and write code in, and it's my preferred language.

What are you looking for in a language/guide? From your post you seem to want to be a video game programmer, do you want to work on the front or graphical end of games or the backend heavy math or multiplayer systems of games. Python is a language that is mostly used for non-graphical tasks (though the image libraries are amazing). We'd to know what you want to accomplish by learning programming.
If it waddles like a duck and it quacks like a duck, it's a KV-5.
Vote Electron Standard, vote Tron Paul 2012
User avatar
Brother-Captain Gaius
Emperor's Hand
Posts: 6859
Joined: 2002-10-22 12:00am
Location: \m/

Re: Recommend me a programming book.

Post by Brother-Captain Gaius »

Malik. The Holy Bible of learning programming from the ground up.

http://books.google.com/books?id=NXH_fb ... navlinks_s

The focus on C++ here really is ideal, because it gives you a greater breadth (and potentially depth) of understanding. It doesn't try to ram object-oriented programming down your throat while at the same time offering a lot on the subject if that's the way you want to go. C++ bridges the gap between lower-level stuff like C and "so buried under abstraction layers you don't know wtf is going on" languages like C# and Java, so you can more easily see both ends of the spectrum. I run into a lot of programmers who only learn Java/C# well, and have absolutely no idea how to build a fundamental data structure, because those language abstract it into oblivion and let idiots skate by.
Agitated asshole | (Ex)40K Nut | Metalhead
The vision never dies; life's a never-ending wheel
1337 posts as of 16:34 GMT-7 June 2nd, 2003

"'He or she' is an agenderphobic microaggression, Sharon. You are a bigot." ― Randy Marsh
Darmalus
Jedi Master
Posts: 1131
Joined: 2007-06-16 09:28am
Location: Mountain View, California

Re: Recommend me a programming book.

Post by Darmalus »

Sorry if I'm getting this across poorly. This would be entirely for personal projects, my major doesn't have a lot of programming in it, just enough to make me interested. When it comes to programming, my mind is basically an empty vessel at this point.

Right now, my sights aren't set any higher than, say, a rogue-like or Dwarf Fortress. I guess that would be math heavy.
User avatar
Terralthra
Requiescat in Pace
Posts: 4741
Joined: 2007-10-05 09:55pm
Location: San Francisco, California, United States

Re: Recommend me a programming book.

Post by Terralthra »

The Head First series is quite good.
User avatar
TronPaul
Padawan Learner
Posts: 232
Joined: 2011-12-05 12:12pm

Re: Recommend me a programming book.

Post by TronPaul »

Brother-Captain Gaius wrote:I run into a lot of programmers who only learn Java/C# well, and have absolutely no idea how to build a fundamental data structure, because those language abstract it into oblivion and let idiots skate by.
For some programmers this isn't really needed, but it's a good concept to have. A programming teacher at my university was complaining about teaching data structures in Java and decided he would allow students to also use Clojure and show them that it would take only a few lines of code for a linked list.
Darmalus wrote:Right now, my sights aren't set any higher than, say, a rogue-like or Dwarf Fortress. I guess that would be math heavy.
I wouldn't start with graphics though that's just me. I would try and make a simple text based game first and then add graphics to it. You probably don't want to use Python for game programming, but it's still one of the nicest languages to read (it looks like pseudocode).

Also if you want fiction to keep your programming interest piqued read Cryptonomicon and Snow Crash, both by Neal Stephenson. If you have questions about programming forums feel free to PM me. I really enjoy helping people out and even when you have an amazing programming book, some concepts are a bit difficult if they don't click right away (arrays and loops come to mind).
If it waddles like a duck and it quacks like a duck, it's a KV-5.
Vote Electron Standard, vote Tron Paul 2012
User avatar
Brother-Captain Gaius
Emperor's Hand
Posts: 6859
Joined: 2002-10-22 12:00am
Location: \m/

Re: Recommend me a programming book.

Post by Brother-Captain Gaius »

TronPaul wrote:For some programmers this isn't really needed, but it's a good concept to have. A programming teacher at my university was complaining about teaching data structures in Java and decided he would allow students to also use Clojure and show them that it would take only a few lines of code for a linked list.
This is precisely the problem. Introducing programming via Java/C# means teaching data structures later is a mess (plus, those languages do ram OOP down your throat), so those programmers end up skating by using pre-existing libraries which they don't understand. Doing a linked list in a few lines of code is great... if you understand what a linked list is actually doing.

I remember taking an AI class where we focused on A* pathfinding (which is pretty important for a lot of game genres). Problem: to do it properly, you need to understand linked lists on a pretty fundamental level, and half the class had no idea how to use or manipulate linked lists. The corollary to this is that this sort of thing is a symptom rather than the disease itself; if you can't figure out how to use basic data structures properly, how are you going to figure out which AI algorithms you're going to use in the right situations? Which in turn begs the question, are you training a programmer to think, or training a programmer to write code by rote?

I guess it comes down to whether you want a programmer to be a technician or an engineer, and Java/C#-oriented programs seem geared toward the former.
Agitated asshole | (Ex)40K Nut | Metalhead
The vision never dies; life's a never-ending wheel
1337 posts as of 16:34 GMT-7 June 2nd, 2003

"'He or she' is an agenderphobic microaggression, Sharon. You are a bigot." ― Randy Marsh
User avatar
The Grim Squeaker
Emperor's Hand
Posts: 10319
Joined: 2005-06-01 01:44am
Location: A different time-space Continuum
Contact:

Re: Recommend me a programming book.

Post by The Grim Squeaker »

Really easy/fun 101 course/site is Code academy. (Well, more like 100.1, it's pretty easy, but fun!)

http://www.codecademy.com/#!/exercises/0
Photography
Genius is always allowed some leeway, once the hammer has been pried from its hands and the blood has been cleaned up.
To improve is to change; to be perfect is to change often.
User avatar
TronPaul
Padawan Learner
Posts: 232
Joined: 2011-12-05 12:12pm

Re: Recommend me a programming book.

Post by TronPaul »

Brother-Captain Gaius wrote:I guess it comes down to whether you want a programmer to be a technician or an engineer, and Java/C#-oriented programs seem geared toward the former.
It's not the language at fault, it's the teachers and the students. Many of the intro professors at my school are very poor teachers (I need to reteach a friend for him to unlearn bad conceptions) and many of the students don't try to learn or go outside the box (needed for learning thoroughly). I use Java for undergrad research and don't write custom data structures, but need to do a lot of smart thinking with lists, sets, and dictionaries to get things to run properly.

I'd say a better indicator of knowledge is if someone knows only one language, then you know they don't have an in depth understanding of computer science.

Also Darmalus, if you start to like programming, get Linux or another Unix system. I can't code without vim and git now.
If it waddles like a duck and it quacks like a duck, it's a KV-5.
Vote Electron Standard, vote Tron Paul 2012
User avatar
The Grim Squeaker
Emperor's Hand
Posts: 10319
Joined: 2005-06-01 01:44am
Location: A different time-space Continuum
Contact:

Re: Recommend me a programming book.

Post by The Grim Squeaker »

)EDIT ran out):

Ooops, sorry, didn't see that he asked for a book.

What are your goals in what you want to learn? Games? Work skills? Intellectual challenge?

(I'd be happy for any recs for anything applicable to scientific research in Biology, Neuroscience, Psychology, Economics personally - The Java class for the sciences I'm taking now is a JOKE. [3 weeks in until they hit For, While, Do, :P])
Photography
Genius is always allowed some leeway, once the hammer has been pried from its hands and the blood has been cleaned up.
To improve is to change; to be perfect is to change often.
User avatar
Brother-Captain Gaius
Emperor's Hand
Posts: 6859
Joined: 2002-10-22 12:00am
Location: \m/

Re: Recommend me a programming book.

Post by Brother-Captain Gaius »

TronPaul wrote:It's not the language at fault, it's the teachers and the students. Many of the intro professors at my school are very poor teachers (I need to reteach a friend for him to unlearn bad conceptions) and many of the students don't try to learn or go outside the box (needed for learning thoroughly). I use Java for undergrad research and don't write custom data structures, but need to do a lot of smart thinking with lists, sets, and dictionaries to get things to run properly.

I'd say a better indicator of knowledge is if someone knows only one language, then you know they don't have an in depth understanding of computer science.

Also Darmalus, if you start to like programming, get Linux or another Unix system. I can't code without vim and git now.
Don't get me wrong, I use a fair amount of C# myself. There's nothing wrong with the language at all. The problem is starting with it and learning programming via it (or a similar language like Java). It's like learning to sing with AutoTune. It's a crutch which provides great ease of use for a programmer who knows what he's doing, and instils a massive disability in a beginning programmer who doesn't.

edit: and rubbish to the Linux stuff, unless Darmalus is already using Linux. If you're on Windows, there is no finer IDE than MS Visual Studio, which you can usually get the full version of for free if you have a student email.
Agitated asshole | (Ex)40K Nut | Metalhead
The vision never dies; life's a never-ending wheel
1337 posts as of 16:34 GMT-7 June 2nd, 2003

"'He or she' is an agenderphobic microaggression, Sharon. You are a bigot." ― Randy Marsh
Darmalus
Jedi Master
Posts: 1131
Joined: 2007-06-16 09:28am
Location: Mountain View, California

Re: Recommend me a programming book.

Post by Darmalus »

Our intro to programming class started us off on C (C89, according to the textbook). I'm not sure what you mean by basic data structures, we need to know arrays, do while for loops, 1s & 2s comp, functions and a few other things. Is that it, or do you mean even lower level stuff? Pointers still gives me trouble. I don't really know much about libraries, other than the most basic theory, the standard one fulfilled all our needs for this class. I have visual studio.

From the sounds of it, I should start with C++, then move on to Java and C# as I get a bit better?
User avatar
Brother-Captain Gaius
Emperor's Hand
Posts: 6859
Joined: 2002-10-22 12:00am
Location: \m/

Re: Recommend me a programming book.

Post by Brother-Captain Gaius »

An array could be considered a very basic form of data structure. Generally, the term refers to linked lists, stacks, queues, trees, etc. All various forms of storing and manipulating large amounts of data, each with different trade-offs and advantages.
Pointers still gives me trouble.
Exactly what I'm talking about ITT. To understand linked lists, you need to understand pointers. If you play with C#/Java, you will never, ever see a single pointer... and you can see where I'm going with that, I'm sure. C# et al is the Dark Side easy path - you don't have to learn pointers, you don't have to learn how to structure a program outside of a rigid object-oriented environment, you don't have to learn how to manage memory... so you never will, which causes problems later on.
From the sounds of it, I should start with C++, then move on to Java and C# as I get a bit better?
C or C++, both are fine, although the latter is a bit more relevant. C is just antiquated. Understanding things like null-terminated C-strings and such is nice, but not strictly necessary. If you're working in a MS/Visual Studio environment, C# is a natural next step after you understand C/C++. On other platforms, Java probably makes more sense.
Agitated asshole | (Ex)40K Nut | Metalhead
The vision never dies; life's a never-ending wheel
1337 posts as of 16:34 GMT-7 June 2nd, 2003

"'He or she' is an agenderphobic microaggression, Sharon. You are a bigot." ― Randy Marsh
Darmalus
Jedi Master
Posts: 1131
Joined: 2007-06-16 09:28am
Location: Mountain View, California

Re: Recommend me a programming book.

Post by Darmalus »

Brother-Captain Gaius wrote:
Pointers still gives me trouble.
Exactly what I'm talking about ITT. To understand linked lists, you need to understand pointers.
I want to understand pointers (really want to, finals are next week). I think my problem is that, so far, nothing has been done to differentiate a pointer from a normal variable (know what it does, but how does that do anything but add an extra step?). I can probably muddle through that part of the test by rote, but actually knowing what I'm doing is always better. www.cplusplus.com has the same problem as my class notes and textbook, it looks like they are using pointers like a regular variable.
User avatar
TronPaul
Padawan Learner
Posts: 232
Joined: 2011-12-05 12:12pm

Re: Recommend me a programming book.

Post by TronPaul »

Darmalus wrote:Our intro to programming class started us off on C (C89, according to the textbook). I'm not sure what you mean by basic data structures, we need to know arrays, do while for loops, 1s & 2s comp, functions and a few other things. Is that it, or do you mean even lower level stuff? Pointers still gives me trouble. I don't really know much about libraries, other than the most basic theory, the standard one fulfilled all our needs for this class. I have visual studio.

From the sounds of it, I should start with C++, then move on to Java and C# as I get a bit better?
The data structure thing isn't really relevant to game programming. I'd say start off on Java, C#, or Python and set goals for yourself. Pointers are nice to understand, but very bad to touch directly (unless writing low level code), bad heap error, bad!
If it waddles like a duck and it quacks like a duck, it's a KV-5.
Vote Electron Standard, vote Tron Paul 2012
User avatar
Brother-Captain Gaius
Emperor's Hand
Posts: 6859
Joined: 2002-10-22 12:00am
Location: \m/

Re: Recommend me a programming book.

Post by Brother-Captain Gaius »

Their utility becomes more apparent as you moved into more advanced topics. Like arrays and classes, they seem silly and unnecessary at first, but then you hit bigger and better stuff and go "ooooh, so that's why you need them".

Interesting factoid: An array isn't really a thing unto itself, it's just a glorified pointer. Likewise, passing a variable by reference is just a sugar-coated pointer. If you want to do anything of interest with a local variable, chances are you will need to use a pointer in some way to do it, even if you don't realize you're using one. The explicit pointers of C++ just let you do that with more precision.

It's difficult to give an example of an important usage of pointers without dumping a huge pile of complicated code that won't make any sense to a beginner. Unfortunately, pointers are just one of those things you have to "trust" the teacher on until later when you see them actually in action.

Linked lists are a reasonably salient example: Lists store data by "linking" (hence the name) one block of data sequentially to the next in a row, like a string of Christmas lights. Node A contains a datum, and a link to Node B. Node B contains another datum, and a link to Node C, and so on. Guess what you have to use to link the nodes? Pointers. How else will Node A know how to get to Node B? You need to point at the memory location where the next node is physically located, even if it's logically located right next to Node A. And that's what pointers do, they point to physical locations of data.
Agitated asshole | (Ex)40K Nut | Metalhead
The vision never dies; life's a never-ending wheel
1337 posts as of 16:34 GMT-7 June 2nd, 2003

"'He or she' is an agenderphobic microaggression, Sharon. You are a bigot." ― Randy Marsh
User avatar
Brother-Captain Gaius
Emperor's Hand
Posts: 6859
Joined: 2002-10-22 12:00am
Location: \m/

Re: Recommend me a programming book.

Post by Brother-Captain Gaius »

TronPaul wrote:The data structure thing isn't really relevant to game programming.
picard.jpg

Heaven forbid you should want AI in your game, then. Or a magazine/bullet counter, or a grid-based inventory, or a zillion other fundamental game systems.
Agitated asshole | (Ex)40K Nut | Metalhead
The vision never dies; life's a never-ending wheel
1337 posts as of 16:34 GMT-7 June 2nd, 2003

"'He or she' is an agenderphobic microaggression, Sharon. You are a bigot." ― Randy Marsh
User avatar
TronPaul
Padawan Learner
Posts: 232
Joined: 2011-12-05 12:12pm

Re: Recommend me a programming book.

Post by TronPaul »

Yes in an actual highly developed game it is (not the ones he might make at first). However, I don't think he needs to dive in so heavily if he's just starting out. Easing in with Java or C# is more likely to start him off programming. Yes he might not know the underlying operations of the language or objects, but for an introduction it's not important. This is a intro to programming thread right? :wink:
If it waddles like a duck and it quacks like a duck, it's a KV-5.
Vote Electron Standard, vote Tron Paul 2012
User avatar
Brother-Captain Gaius
Emperor's Hand
Posts: 6859
Joined: 2002-10-22 12:00am
Location: \m/

Re: Recommend me a programming book.

Post by Brother-Captain Gaius »

TronPaul wrote:Yes in an actual highly developed game it is (not the ones he might make at first). However, I don't think he needs to dive in so heavily if he's just starting out. Easing in with Java or C# is more likely to start him off programming. Yes he might not know the underlying operations of the language or objects, but for an introduction it's not important. This is a intro to programming thread right? :wink:
The entire point of my previous posts in this thread is that using a more abstract language like C# is a terrible way to introduce programming. It immediately forms bad habits and doesn't teach the fundamental concepts. True, you don't need to know every detail of an internal combustion engine to drive a car (hence why we don't start by teaching Assembly and machine code)... but who's the better driver, the one who learns on an automatic transmission, or the one who learns on a manual transmission? You can get by on just learning the "easy" automatic, but you'll never be a professional driver. And if you start on auto and go to manual later, you'll have already learned bad habits that are fine on an automatic but won't fly on a manual, which then necessitates unlearning a bunch of shit you could have just learned properly from the get-go.

Yes, it's more challenging to learn C/C++ from the ground up. It's also the better way to learn.
Agitated asshole | (Ex)40K Nut | Metalhead
The vision never dies; life's a never-ending wheel
1337 posts as of 16:34 GMT-7 June 2nd, 2003

"'He or she' is an agenderphobic microaggression, Sharon. You are a bigot." ― Randy Marsh
User avatar
TronPaul
Padawan Learner
Posts: 232
Joined: 2011-12-05 12:12pm

Re: Recommend me a programming book.

Post by TronPaul »

Brother-Captain Gaius wrote: The entire point of my previous posts in this thread is that using a more abstract language like C# is a terrible way to introduce programming. It immediately forms bad habits and doesn't teach the fundamental concepts. True, you don't need to know every detail of an internal combustion engine to drive a car (hence why we don't start by teaching Assembly and machine code)... but who's the better driver, the one who learns on an automatic transmission, or the one who learns on a manual transmission? You can get by on just learning the "easy" automatic, but you'll never be a professional driver. And if you start on auto and go to manual later, you'll have already learned bad habits that are fine on an automatic but won't fly on a manual, which then necessitates unlearning a bunch of shit you could have just learned properly from the get-go.

Yes, it's more challenging to learn C/C++ from the ground up. It's also the better way to learn.
I don't agree with you. Yes there is a place for direct usage of pointers, but they are a small case. All the data structures mentioned in this thread can be implemented in the "abstract" languages with minimal effort. In regards to bad habits, a self taught programmer will have bad habits no matter what language they start in. Unless their code is critiqued they won't know if their code is O(n^2) when it should be O(n) or an otherwise lesser value. Using pointers and pointer manipulation are not a fundamental concept, understanding in general how memory works and that variable reference parts of memory is (which can be taught with "abstract languages"). Honestly most programmers shouldn't need to (and shouldn't at all) touch pointers except when working on systems, low-level programs, and extreme optimization.

If you want to learn a language that will teach you programming concepts learn Haskell, OCaml, or (god forbid) Lisp.
If it waddles like a duck and it quacks like a duck, it's a KV-5.
Vote Electron Standard, vote Tron Paul 2012
Psawhn
Youngling
Posts: 63
Joined: 2010-08-25 01:33am
Location: Alberta, Canada

Re: Recommend me a programming book.

Post by Psawhn »

Darmalus wrote:Sorry if I'm getting this across poorly. This would be entirely for personal projects, my major doesn't have a lot of programming in it, just enough to make me interested. When it comes to programming, my mind is basically an empty vessel at this point.

Right now, my sights aren't set any higher than, say, a rogue-like or Dwarf Fortress. I guess that would be math heavy.
Personally, I won't recommend a specific language, but instead I'll recommend that you come up with some projects or tasks to do. They could be a series of exercises from the programming book for whichever language you decide upon, or things you dream up in your head.

In my experience, programming languages are tools just like anything else you might find in a garage. Woodworking tools shape and transform wood, and computer code shapes and transforms information. Implicit in defining code as a tool is that it needs to perform a role in creating or doing something, no matter if your goal is "build a bed" or "build a game." Does this mean you should have a 'driving ambition to build this next great game?' No. I really like that you're interested in programming. I love the process of programming, myself, and the kind of thinking you have to do to proceduralize an abstract concept into lines of deliberate, logical code. But you have to ride a bike to learn how to do so, and that means travelling somewhere with it.

My own introduction to programming was by making simple programs and games on my TI-83+ in high school. Some of them were simple little math things like adding up the numbers from 1 to 100 to double-check that I have the generalized formula working right. I wrote a program to do synthetic polynomial division (which meant that I forgot how to do it in the final exam). I also wrote a 2-player Tron light-cycle type game, and a single-player racetrack type game, and a very limited MUD-style fighting game against a dimwitted AI. Over my undergraduate degree as a geomatics engineer, I've had dozens and dozens of programming assignments that were "use C++ to use a least-squares adjustment to perform a GPS positioning solution" or "use c++ to use a least-squares adjustment to perform a photogrammetric intersection" or "use any language of your choice (which means I get to use matlab :)) to do this other assignment," or "use VBA to write an ArcMap program to do this"... and now it's "use C# to write an embedded application to position and navigate and fly a small UAV"

So do the examples in the textbook or programming book. Look online for coding challenges and try them out. Come up with your own ideas for simple, little programs, or medium-sized programs. Buy a netduino and some extra attachments from Sparkfun and try to build something neat. The process of writing code to solve a problem is what I love about programming, and I think the best way to learn programming is, well, writing code to solve problems.
Darmalus wrote:
Brother-Captain Gaius wrote:
Pointers still gives me trouble.
Exactly what I'm talking about ITT. To understand linked lists, you need to understand pointers.
I want to understand pointers (really want to, finals are next week). I think my problem is that, so far, nothing has been done to differentiate a pointer from a normal variable (know what it does, but how does that do anything but add an extra step?). I can probably muddle through that part of the test by rote, but actually knowing what I'm doing is always better. http://www.cplusplus.com has the same problem as my class notes and textbook, it looks like they are using pointers like a regular variable.
In some way of looking at it, pointers really are just "adding an extra step." They still have a value stored, in them, which is just the address of the variable they're targeting.

You can very easily see what a pointer looks like. I'm probably doing this wrong (and I'm supposed to be doing other homework right now), but I think you can basically

Code: Select all

int num = 1234; /*simple variable to point to */
int *c; /*our pointer*/
c = #
printf("%d \n",c);
and you should see some odd number. (You could also see the number in hexadecimal by using "%x" or "%X" but that doesn't matter.) Whenever you use a pointer, the compiled code knows how to use that odd number as a memory address.
Pointers come in handy when you're iterating through arrays, but you have to keep in mind that the type of pointer depends on the target data type. A char and int have different sizes, so an increment operator on a char pointer only increments the memory address it points to by the size of a char (1 byte), rather than the size of a bit (4 or 8 bytes). Again, to see it in action, printf() the pointer and see how it changes in a loop incrementing or decrementing it.

Maybe a way to think of it is with the idea of a bunch of mailboxes in the wall, like you get at an apartment building. Different mailboxes can store different things (like only a letter, or a big parcel), and you can refer to a mailbox by name ("Bill's mailbox") or by address (which is what a pointer does). The advantage of a pointer is that it lets you iterate through variables in an array, just like if you were putting a flyer in every tenant's mailbox. You just iterate the pointer up and down, so it basically turns into "Mailbox 44, mailbox 45, mailbox 46, etc". The type of a pointer matters because different data types have different sizes because of how they're stored in memory. You can have an array of chars or ints or even an array of complex data types like a struct of your own definition, which like is the difference between a row of mailboxes and a row of houses.
User avatar
Skgoa
Jedi Master
Posts: 1389
Joined: 2007-08-02 01:39pm
Location: Dresden, valley of the clueless

Re: Recommend me a programming book.

Post by Skgoa »

I am getting into the thread late and have not read every post, so this might have been mentioned before:
If you want to start making games fast, download Microsoft's XNA framework. It's C# and it's just so fucking easy to get things going. Here is a good book for that: http://www.amazon.com/dp/0596521952 but there are thousands of great tutorials out there.
http://www.politicalcompass.org/test
Economic Left/Right: -7.12
Social Libertarian/Authoritarian: -7.74

This is pre-WWII. You can sort of tell from the sketch style, from thee way it refers to Japan (Japan in the 1950s was still rebuilding from WWII), the spelling of Tokyo, lots of details. Nothing obvious... except that the upper right hand corner of the page reads "November 1931." --- Simon_Jester
User avatar
Purple
Sith Acolyte
Posts: 5233
Joined: 2010-04-20 08:31am
Location: In a purple cube orbiting this planet. Hijacking satellites for an internet connection.

Re: Recommend me a programming book.

Post by Purple »

Brother-Captain Gaius wrote:It's difficult to give an example of an important usage of pointers without dumping a huge pile of complicated code that won't make any sense to a beginner. Unfortunately, pointers are just one of those things you have to "trust" the teacher on until later when you see them actually in action.
How about a simple, high school grade example. Let's say you have a function that needs to swap the values of two variables, any two variables. It can be two numbers or two diffrent guns held in the hand of a player in a shooter game or anything else that needs swaping. That is the most commonly used one. The only thing the user has to know is what a function is. That is to say, a piece of code given a name so that the programmer can call it by name and not have to type it all over again a billion times over. And that's why I have seen it used in every beginners course I ever heard off. The code for that would look like this:

Code: Select all

void Swap(object a, object b)
{
    object c = a;
    a = b
    b = c;
}
Now, ask the other guy what this program does. He will tell you that it swaps the values of a and b. Well that is true. Now ask him to write it down in code and than call it from main and print out the results. What will happen than? (question for everyone)

And that is why you need pointers.

*Note: key word object is used here as a reference to some generic variable value and not to the C#/Java object class.
It has become clear to me in the previous days that any attempts at reconciliation and explanation with the community here has failed. I have tried my best. I really have. I pored my heart out trying. But it was all for nothing.

You win. There, I have said it.

Now there is only one thing left to do. Let us see if I can sum up the strength needed to end things once and for all.
User avatar
TronPaul
Padawan Learner
Posts: 232
Joined: 2011-12-05 12:12pm

Re: Recommend me a programming book.

Post by TronPaul »

Purple wrote: And that is why you need pointers.
That is not a good enough reason to need to use pointers especially when in good code you wouldn't write a method for swapping variable values. After taking a class in C and reading Unix V6 for another, I think pointers are much more dangerous to use than their alternatives. There's a reason there are only a handful of languages that allow the programmer to use pointers. The memory dangers pointers cause can be removed by abstracting them away from the programmer.

There's a place for pointers, but unless you really need to write low level code the abstracted languages are much less of a pain and safer.
If it waddles like a duck and it quacks like a duck, it's a KV-5.
Vote Electron Standard, vote Tron Paul 2012
User avatar
phongn
Rebel Leader
Posts: 18487
Joined: 2002-07-03 11:11pm

Re: Recommend me a programming book.

Post by phongn »

If you really want something from the very basics you can look at SICP. A good primer on C++ is Accelerated C++
Post Reply