Join 118,692 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 1,184 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
In my embryonic quest to understand C, I'm presentntly immersed in "The Absolute Beginner's Guide to C" by Greg Perry, which is suiting my basic needs. The problem is not with the text but with the way I best learn: through imagery and metaphor.
Bear with me and look for a moment at this Wiki site on object-oriented programming. It carries an allegory to the TV show, "Lassie" to briefly but elegantly explain object-oriented programming (don't worry, I do know that C is not an object-oriented programming language).
I understood the fundamentals of object-oriented programming in about ten minutes.
To point: is anyone aware of a text on C programming (tutorial text as opposed to reference text) that employs metaphor and allegory in the manner of the above hyperlink?
This post has been edited by LowWaterMatk: 8 Aug, 2008 - 03:59 AM
Within the sphere of OOP I can think of a few books that take what one might call an "anthropomorphic" approach (the Java Head First books come to mind). This is easy since Object often model real world Objects -- so while it may seem metaphorical that is actually much of the intent of OOP.
You will find many metaphorical discussions in computer science. Trees look like trees (if you do a hand stand and squint your eyes). Stacks do resemble stacks of plates. Queues are much like waiting in a British queue. Machines do actually sorta kinda resemble machines... I guess.
Although I believe that you will find lots of metaphorical discussion of the concepts in CS, I am unaware of any specifically in C.
I suppose you will find attempts to discuss programming in terms of a particular type of program which is almost metaphorical. Check out my unfortunately aborted attempt at a tutorial on data modeling (for games in C). This tries to introduce the concepts of programming data models in C. Since it is talking about modeling it takes a "metaphorical" approach.
Looks like NickDMax beat me to it, but yeah, most things, if you look at them, are kinda metaphorical anyway.
Let's take a dog class, for example. It would have a hunger level, thirst level, etc.
Then, it would have functions to bark, sit, lie down, etc.
I know it's not specifically what you're looking for, but I know a good book is "Beginning C++ Game Programming" ~ published by Thomson.
It may be a little below you, but the final few chapters about OOP are about making a (text-based) virtual pet. It has hunger levels, etc, and it has functions such as eat() sleep() etc.
If you like, I'll write you up a C++ class for an animal, which I would say would be most metaphoric.
As NickDMax mentioned, one of the philosophies of OOP is to allow the programmer to think at a high level, without worrying over the minor detail of how the computer does things - There's plenty of opportunities for analogies to creep into the OO world. the C language is very different, in that its far closer in nature to the way which the computer 'thinks' - the key to understanding C programming is to understand the finer detail of what's going on under the hood at the most primitive level (Beneath any software or operating system features which are presented to you).
If you're a fan of analogies (I truly despise analogies personally, since they're always flawed) - Imagine programming like assembling furniture. In the Java world, you go down to Ikea and pick up some ready cut, ready drilled flatpack furniture, and all you need to do is screw it all together without needing to worry about the dimensions or the design of the individual pieces (Because someone else has already done all this hard work for you). You might find that the manufacturing process has some very slight anomalies, and doesn't fit together 100% perfectly, or maybe the design doesn't suit your needs exactly, but it does the job very well otherwise.
In the Low-level world, you start out with a solid tree trunk and a workshop full of powertools, where you will handcraft the furniture. You'll need to spend alot more time recreating bits which Ikea would have made for you, though you can finetune each minor detail, you need to understand the resilience of the material, and the way in which stresses and strains work at the joints (Though with handcrafted furniture you will probably have less joints), but you need a detailed understanding of precisely what you're doing so that the furniture you build at the end doesn't collapse.
People, thank you so much for taking the time to reply. Lest anyone be confused, at this point in time I'm endeavoring to learn C, not OOP. I'm not looking for the C language to be more abstract, just the educational materials.
Any teaching material or book for that matter is an abstraction or as they say in philosophical circles, "a map of the territory". When I read "Pride and Prejudice" I'm not actually transported back to Jane Austen's genteel and unruffled English countryside of the early 19th century. I'm reading a book about it. Likewise, any programming language is but an abstraction of a functioning computer. Even machine language, being language, is abstract. Ones and zeros are not the presence and absence of electrical current through a circuit. They represent it.
Where I need help is in learning C, my language of choice. I need a great book about a language, hence an abstraction of an abstraction. Trolling about for an allegorical resource is but a trivial extension of my already abstracted reality.
NickDMax, why did you abort the tutorial? I read it and it reads wonderfully. I may not know how to program but I am a literary critic in my spare time and you write very well.
gabehabe, your virtual pet analogy in "Beginning C++ Game Programming" was almost certainly excerpted into that WIKI article on OOP that I hyperlinked in my original post. It's too close to be accidentally the same.
bench, your furniture analogy was wonderful and the precise reason I chose to learn C first. I hope I made the right call. I wanted to see stuff first from the machine's perspective, as best I could. I actually want to learn C++ but starting with C made sense to me for the reason mentioned. I hope that C++ being a superset of C is true in structural terms. I hope that learning C (it being a lower level language) helps me to see the machine's vantage point and that balances out any bad programming habits I might pick up that could hamper me in the learning of C++ (such as not instinctively using OOP principles). BTW, may I with respect take issue with you re analogies being flawed? You are of course correct. They by definition are not that to which they refer. They are vehicles to understanding that to which they refer and as such (in my mind) range along a continuum from grand to poor. They let people conceptualize things that they cannot understand literally. For instance, suppose the UNIVAC had failed to accurately predict Eisenhower's 1952 presidential victory, an intellectual event, a mere example that spread like wildfire throughout the global imagination. Would I be writing this? Noone outside of the University of Pennsylvania's Moore School of Electrical Engineering understood the UNIVAC, a black box in a lab somewhere, but within a month the planet saw with fear and awe its potential. I see the capacity to wrap our minds around analogies as one of the key reasons we aren't running around the hillsides braining each other to death with rocks and fighting for scraps of meat down by the sea. Analogies and opposable thumbs.
Good god, I'm adrift.
This post has been edited by LowWaterMatk: 9 Aug, 2008 - 03:16 AM
Given that my goal is to learn C as a stepping stone to harder drugs, wait, as a stepping stone to learning C++, would y'all suggest I spend a good deal of time developing expertise in C before branching outward to C++?
Suppose that I feel fundamentally grounded in C having used "The Absolute Beginners Guide to C" by Greg Perry. What would be a good C++ text to expand my mind with?
This post has been edited by LowWaterMatk: 9 Aug, 2008 - 12:04 AM
NickDMax, why did you abort the tutorial? I read it and it reads wonderfully. I may not know how to program but I am a literary critic in my spare time and you write very well.
Inspiration, motivation, and time.
The tutorial began due to one of my more base instincts -- to be didactic (though I LIKE to think of it as wanting to help others). However without feedback on the tutorial I lost sight of a clear direction. I wanted to implement a simple game, but didn't really have a good idea for a game to implement. All in all -- I lost the inspiration, resulting in a lack of motivation.
So I asked in the game programming forum if anyone was willing to help me. I figured if I could get a clear picture of the game I wanted to implement then I could fight my way though. But that post went unresponded to (actually most of my topics here on DIC do not generate responses... ) so eventually I lost all motivation, and now I really don't have the time anymore (at least not without inspiration and motivation).
Then again, I also began to think that I bit off more than I could chew. The following was my rough outline:
Enumerations Pointers/Arrays Structures/Unions Abstract Data types -- Mostly Linked Lists, Trees, Graphs, and maybe a hash table (the meat of game modeling ADTs). Data Modeling -- pulling it all together to form a model Example Game
One could write a book with such an outline -- and who wants to waste that much time and effort on a C tutorial.