Learning to code in C

Status
Not open for further replies.

wb

Ars Legatus Legionis
25,208
Subscriptor
Two book recommendations:

The C Programming Language by Kernighan and Ritchie (a.k.a K&R C).

K&R C is *the* essential C reference.

The Practice of Programming by Kernighan and Pike.

An excellent book about programming style and practice. Ostensibly written about general programming, but I find most of the content is geared very strongly towards C.
 

Drutro

Ars Praetorian
461
Subscriptor++
Off the top of my head (or rather, my list of bookmarks), this page has a lot of information going from the basics all the way up to heavier stuff like semaphores. I'm sure there are other sites out there if you need more of the basics, but this should be managable if you have any programming background.

I think you should just break down and buy a book if you can. Overall it will be an easier and smoother experience than scouring the web for a page that explains everything you have a question about. I've found that many online sources will explain one aspect of a problem, but skimp on other parts, so you gotta look for more sources. Makes it hard to understand the whole sometimes. :)
 
The best way is to abandon any notion of learning C and learn C++ instead.
bleh.

Problem with C++ is there's so many different frameworks you can use to avoid ever really learning how to manually do some things you need to know how to do to be a programmer. For example, using a canned string class is easier than managing C-style strings....or using typesafe I/O(even with iomanip stuff) is usually easier than explicitly writing out a printf() to do what you want...same with new vs. malloc()...but by doing it the C way you learn what's going on at a more fundamental level...so actually implementing the base class itself(where you need the lower level knowledge) would never be a problem. Learning to program and writing programs are two different things. Abstraction and OO ain't the answer to everything.

The only detriment I can think to learning C instead of C++ is that you can fall into the trap of thinking as a structural programmer and unless you find a way to change your mode and get out of that, when you start writing C++ OO code you probably will have trouble thinking/devising OO approaches. But then, the opposite is true, too.
 
Problem with C++ is there's so many different frameworks you can use to avoid ever really learning how to manually do some things you need to know how to do to be a programmer. For example, using a canned string class is easier than managing C-style strings....
I don't think that manually managing C-style "strings" is either required to be a programmer, nor even something particularly desirable to learn.

or using typesafe I/O(even with iomanip stuff) is usually easier than explicitly writing out a printf() to do what you want...same with new vs. malloc()...but by doing it the C way you learn what's going on at a more fundamental level...so actually implementing the base class itself(where you need the lower level knowledge) would never be a problem.
I can't think of any occasions on which I've needed to write my own string (or I/O, or linked list, or set, or map, etc.) class. The classes I (and many others) write are much higher level than that. I'm hard-pressed to see why it's even useful to know. It teaches you more about the inadequacies of C than anything else.

That particular kind of low-level knowledge is a minority interest at best.

Of course, there's nothing to stop you from doing it in C++ if you really need to learn that kind of thing -- the point is, it doesn't make you deal with it unless you really need to. C, on the other hand, does.

Learning to program and writing programs are two different things. Abstraction and OO ain't the answer to everything.
You can learn to program without ever having to dick around with the annoyances of fixed-size null-terminated strings.

And even when learing to program, you should learn to not reinvent the wheel.
 

EtherealGoddess

Ars Tribunus Militum
2,782
Subscriptor++
DigitalFury said:

Problem with C++ is there's so many different frameworks you can use to avoid ever really learning how to manually do some things you need to know how to do to be a programmer. For example, using a canned string class is easier than managing C-style strings....or using typesafe I/O(even with iomanip stuff) is usually easier than explicitly writing out a printf() to do what you want...same with new vs. malloc()...but by doing it the C way you learn what's going on at a more fundamental level.

I'd be interested to know how malloc()/free() and printf() let you know what's going on at a more fundamental level versus their C++ counterparts. What do you mean by "fundamental"? Essentially, they're just function calls which don't expose much (if anything) more than their C++ counterparts.

Learning to program and writing programs are two different things. Abstraction and OO ain't the answer to everything.

That's why C++ is a multiparadigm language. You don't have to use OO if you don't want to. The language also does a good job of not penalizing (performance-wise) those who don't use all the features.

As far as datatypes and algorithms go, that's more of a computer science issue than a programming one. Programming doesn't necessarily require any knowledge of computer science and vice versa. The idea of a queue is independent of what language you implement it in, though your language choice may affect how you can implement one. I could program long before I took HS comp sci.

PeterB said:
And even when learing to program, you should learn to not reinvent the wheel.

Right. Once I learn what sorting is and how it works, having a generic algorithm to sort just about any collection of any types is great. It seems (in my experience) that most people using C++ neglect the great containers and algorithms in the standard library for some reason.
 
Well Peter, you and I do completely different types of programming. I also teach a different type of programming than you seem to do.

My point is that, it's always easier to go from knowing the intricacies UP the abstraction ladder, than it is to go from the top of the abstraction ladder down to the lowlevel if needbe. In fact, I'd wager that somebody that knows the intricacies would have an easier time using an abstract model than someone who knows the abstract model could go down.

Don't get me wrong, the stuff I do(interfacing and simulating hardware) is definitely a minority skill...but it's a skill that allows me to easily pick up abstract model hierarchies and platforms...for instance, learning GTK+ a couple years ago(my first GUI toolkit) and MFC were a breeze for me. As is using QStrings with Qt for every string I want to use. But, heck, even my own teaching staff (unfortunately) was just a bunch of C++ programmers(beyond my control), who couldn't for the life of them figure out how to do the C-string parsing for the assembler project that was assigned to the students.

Saying that knowing the lowlevel complexity is unimportant to know means about as much to me as someone telling me that they don't need to know how to add because they know how to use a calculator. And when there is no calculator?

It's not reinventing the wheel...it's making sure you're prepared. Like I said, nobody's saying you have to _use_ the lowlevel knowledge(and thus, you're not reinventing the wheel)...just have it just in case. But, to each his own, I'd guess.

I just wish they'd stop hiring C++ programmers in this department so I wouldn't have to deal with so many of them that don't have a clue how to do(let alone, teach) lowlevel structural programming. :mad:
 

wb

Ars Legatus Legionis
25,208
Subscriptor
I can't think of any occasions on which I've needed to write my own string (or I/O, or linked list, or set, or map, etc.) class. The classes I (and many others) write are much higher level than that. I'm hard-pressed to see why it's even useful to know. It teaches you more about the inadequacies of C than anything else.

You're too young, then. It was not very long ago that C++ didn't have any of this capability, and if you wanted good string handling, maps, vectors, hashes, etc., then you had to roll your own using the still-new templates. I've written more implementations of the STL classes than I care to remember.

We still use our own implementations in our company, since the base code was developed pre-STL. I'm glad we do. You never know, for example, when a stl::string won't suit your needs properly because of the kinds of manipulations you have to perform. For us, it was easy enough to modify our own internal string class to extend the functionality (say...add a mechanism to cache very large strings to disk) and optimize performance for our special cases.


EDIT:

One more thing. Try to keep in mind that you might be programming in an environment where you do not have access to all those fancy abstraction layers. As an example, I happen to have a PowerPC 403G board that comes with a very nice C++ compiler. If you want to do any kind of IO, however, I hope you're familiar with C stdio, because the C++ streams take up too many resources to fit on such a small-scale system. I've used this board on several different projects, usually to interface to other hardware I've developed (e.g. a plotter I bunged together, a microprocessor I've prototyped on a FPGA, etc.). Usually I will write essential blocks of code in assembly, and the rest in C++, as one might for a game with critical sections of code to optimize. As an experiment on my last project I tried to write everything in C++. Although I was successful, it was my understanding of how C++ worked at a lower level that allowed me to accomplish this feat.

[This message was edited by wb on December 23, 2001 at 11:56.]
 
"The OO design concept initially proved valuable in the design of graphics systems, graphical user interfaces, and certain kinds of simulation. To the surprise and gradual disillusionment of many, it has proved hard to demonstrate significant benefits of OO outside those areas. A decade later, inspection of open-source archives (in which choice of language reflects developers' judgements rather than corporate mandates) reveals that C++ is still very little used outside of GUI and multimedia toolkits. When all is said and done, C++ is basically just another conventional language. It confines the memory-management problem somewhat better than C does, but doesn't solve it. For many types of application its OO features are not significant, and simply add complexity to C without yielding much leverage. The world is not short of free C++ compilers; if C++ were unequivocally superior to C it would now dominate" - Eric S. Raymond, The Art of Unix Programming

"Those who claim 'C++ is a better C' are wrong" - Richard Heathfield, C Unleashed

As for actually learning C:

1) You MUST buy K&R2, even if you barely have a penny to your name. It is required reading. And it is mostly not dated; the only significant changes happened in 1999 with the introduction of a new C standard, but there are no fully C99 compilers yet, so don't worry about it.
2) I suppose you could look at my own introduction, though it may not be that useful.
3) Also think about buying _Expert C Programming: Deep C Secrets_ by Peter van der Linden and _C Unleashed_ by Richard Heathfield.
4) Remember always that main does not return void.
5) I recommend against the linked UK site above; it shows an example program with "main()"; obviously, the writer doesn't know that he's programming in a language which has been standardized. That sort of flaky, loose thinking (like "void main", but not quite as bad) just gets you into trouble later on - or worse, makes you into a code monkey.
--
Stephan T. Lavavej
 

wb

Ars Legatus Legionis
25,208
Subscriptor
Right. Once I learn what sorting is and how it works, having a generic algorithm to sort just about any collection of any types is great.

Wrong. What happens when the customer calls up and complains that the sorting takes way too long? Do you just say, "oh, I'm sorry...we're using the STL and that algorithm can't work any faster!" No, you make your own (or at least find a suitable) algorithm that's optimized for your case. Or, do you not have any customers?
 
You're too young, then. It was not very long ago that C++ didn't have any of this capability, and if you wanted good string handling, maps, vectors, hashes, etc., then you had to roll your own using the still-new templates. I've written more implementations of the STL classes than I care to remember.
I don't see how your having to write the STL because the STL didn't exist is a justification for anyone else doing the same. Yes, not long ago C++ didn't have such things. It does now. It seems pointless to ignore the facilities now on offer merely because they used not to exist.

We still use our own implementations in our company, since the base code was developed pre-STL. I'm glad we do. You never know, for example, when a stl::string won't suit your needs properly because of the kinds of manipulations you have to perform. For us, it was easy enough to modify our own internal string class to extend the functionality (say...add a mechanism to cache very large strings to disk) and optimize performance for our special cases.
I'm not sure that it'd be necessarily difficult to do the same with an STL string class anyway.

<hr>

The original post wasn't asking about how to be a computer scientist, he was asking how to code. If all he wants is to code, dicking about with C-strings isn't a valuable use of time. Perhaps I'm reading it wrong, but the initial post didn't suggest to me that he had any particular interest in coding for little embedded things with fuck all memory -- he would have access to creature comforts (STL, for instance), and as such he ought to use them.

<hr>

In fact, I'd wager that somebody that knows the intricacies would have an easier time using an abstract model than someone who knows the abstract model could go down.
I'd wager they'd get caught up in the details and ignore that the language they're using has a perfectly good set of standard libraries. There are too many STL-era C++ programmers who ignore the STL for no reason other than they apparently want to tackle everything from the lowest level, even if the extra detail is irrelevent to the task at hand. As far as I can see, those who learn the intricacies are not good at sitting back and saying, "I can just use this string class and it'll do what I need without having to get caught up in how it works".
 

EtherealGoddess

Ars Tribunus Militum
2,782
Subscriptor++
Or, do you not have any customers?
No, I don't have any customers. Does this render my experience invalid?

Wrong. What happens when the customer calls up and complains that the sorting takes way too long? Do you just say, "oh, I'm sorry...we're using the STL and that algorithm can't work any faster!" No, you make your own (or at least find a suitable) algorithm that's optimized for your case.

Obviously, if the requirements of the program called for faster than O(n log n * log n) performance, I wouldn't have used the standard library's stable_sort to begin with (or would change it if I found out after the fact). I was speaking generally of the sorts being useful for a variety of generic containers that is standard. No where did I say don't understand various sorting algorithms or be ignorant of computer science because you have all these cool standard library things to do it for you. What I believed I was saying was that these containers and libraries are useful to avoid everyone coding their own lists and queues and sorts from scratch. The performance is more than adequate for many general tasks.
 
Originally posted by wb:
Wrong. What happens when the customer calls up and complains that the sorting takes way too long? Do you just say, "oh, I'm sorry...we're using the STL and that algorithm can't work any faster!" No, you make your own (or at least find a suitable) algorithm that's optimized for your case. Or, do you not have any customers?
I have customers.

If they want better than O(nlogn), they'll have to constrain their data in some way; there isn't anything better without a priori information (in which case a radix sort might be usable with O(n) sort time).

If they're being very unfortunate, and having quicksort act as O(n<sup>2</sup>), I can offer heapsort (guaranteed O(nlogn)), with the proviso that the sorts will generally be slower (compared to a quicksort acting as O(nlogn)).

But better than that isn't possible.

I would imagine that this STL implementation's sort is pretty good; it quicksorts unless the quicksort would tend towards O(n<sup>2</sup>), in which case it heapsorts, or unless n is very small, in which case it insertion sorts. This will tend to be better than indiscriminate heapsorting, but if they need a guaranteed O(nlogn) sort time, I can do that too.
 

gumbo

Ars Tribunus Angusticlavius
6,107
I think that C++ would be better for your intended application - also, branching off into Perl or PHP would be different than C/C++, becuase those are scripting languages for the web, etc. IIRC Perl can be compiled, but it is a scripting language. Also, I think they are more object oriented than structued. However, I have never learned these languages, just looked at code for them several times, and noticed patterns/features. :p Take it w/ a grain of salt. :)

gubmo
 
D

Deleted member 5324

Guest
Originally posted by PeterB:
The best way is to abandon any notion of learning C and learn C++ instead.

If you're going to suggest learning a language other than, at least go all the way and recommend a real high level language. Something without the error-prone syntax of C or C++, possibly without weak (or easily-forced-to-be-weak, as in the case of C++) typing, and definitely without the need for memory management by hand.

If we're suggesting other languages, then C++ certainly can't outdo Python for ease of use, ease of programming, or clarity of intention. And C++ certainly can't outdo O'Caml for safety, both of syntax and of types. If someone wants to learn, there are far better languages with which to do so than C++.

If a man wants to learn C, let him learn C -- no other portable language will get him closer to the metal. If he wanted to learn to program, there are better languages, but from what I could read, he wanted to learn C, not programming in general.

(as a minor note, you'll almost always find that among assured O(n log n) sorting algorithms, merge sort is the fastest; in every case I've seen it's been faster than heapsort.)

Jeremy
 
(as a minor note, you'll almost always find that among assured O(n log n) sorting algorithms, merge sort is the fastest; in every case I've seen it's been faster than heapsort.)
I think merge sort needs extra memory proportional to the number of elements, and I've seen merge sorts that are slower than heapsorts in any case.

If a man wants to learn C, let him learn C -- no other portable language will get him closer to the metal.
C++ permits one to get just as "close to the metal" as C -- but, unlike C, doesn't require it.
 
I think merge sort needs extra memory proportional to the number of elements, and I've seen merge sorts that are slower than heapsorts in any case.
I does need extra memory (as much as your dataset) to be fully efficient. There are "in place" merge sorts, but they're slower. The version with extra memory is guaranteed O(n * log n) though, and that might be important in some cases. It has the advantage of being stable. Also, due to its sequential nature, it will probably have a significant advantage over other sorts on large data sets (ie. that don't fit into the cache). Just look at how DBs are sorted: they normally use a variation of merge sort, because it requires lots of bandwith but little random access. That matches what a HD can provide. More and more, processors also benefit from this kind of access to memory. Just something to keep in mind ;)
 
C++ permits one to get just as "close to the metal" as C -- but, unlike C, doesn't require it.

C is the chosen language (above assembly) for getting "down to the metal". And GNU is the compiler. At least for cross platform and embedded work. (Unless you have the money for the fancy stuff...)

A GNU Development Environment for the AVR Microcontroller

ColdFire GNU C

And so on from 8-bit micros to supercomputers...

Right now I'm hacking some bits of code for a Rabbit:

The BL1800 Jackrabbit is a high-performance C-programmable single-board computer with a compact form-factor.

As for learning C on Windows, Cygwin is free.

q
 

wb

Ars Legatus Legionis
25,208
Subscriptor
No where did I say don't understand various sorting algorithms or be ignorant of computer science because you have all these cool standard library things to do it for you. What I believed I was saying was that these containers and libraries are useful to avoid everyone coding their own lists and queues and sorts from scratch.

I apologize, I was under the impression you *were* saying that's all you needed, which I vehemently disagree with.


I don't see how your having to write the STL because the STL didn't exist is a justification for anyone else doing the same. Yes, not long ago C++ didn't have such things. It does now. It seems pointless to ignore the facilities now on offer merely because they used not to exist.

I'm not advocating ignoring the available facilities. I'm saying that not every platform with a C++ compiler happens to have the STL, or perhaps the STL container implementation on that platform has a nasty bug that renders it useless for your needs. There are also many situations where linking the STL into your code is not an option.

I have seen several otherwise excellent programmers come upon these situations and freeze up, not knowing what to do. They spend a lot more than "normal" time coding because they have to learn everything related almost from scratch. While I hold everyone here on Ars in high regard, I'd prefer not to instill the notion that you can just depend on the STL because you'll never need anything else.


My issue, I guess, is with this statement:

The classes I (and many others) write are much higher level than that. I'm hard-pressed to see why it's even useful to know.

Ignoring something because it seems inadequate to you is not particularly bright. At the very least, you will need to understand C-style strings given the plethora of library functions you must interface with that employ them.

There is a reason you learn the theory behind a derivative before learning the standard shortcut to differentiate polynomials. For that same reason, I feel it's wise to understand how STL containers are implemented if not before using them, at least in parallel to learning about them. It builds a base of fundamental knowledge upon which the abstraction makes more sense in context.
 
Originally posted by euzeka:
I does need extra memory (as much as your dataset) to be fully efficient. There are "in place" merge sorts, but they're slower. The version with extra memory is guaranteed O(n * log n) though, and that might be important in some cases. It has the advantage of being stable. Also, due to its sequential nature, it will probably have a significant advantage over other sorts on large data sets (ie. that don't fit into the cache). Just look at how DBs are sorted: they normally use a variation of merge sort, because it requires lots of bandwith but little random access. That matches what a HD can provide. More and more, processors also benefit from this kind of access to memory. Just something to keep in mind ;)
One compromise I've seen is to e.g. quicksort subsets of the data (as much as will fit in memory), write out that partially-sorted data to disk, then mergesort from disk.
 

javaseeds

Seniorius Lurkius
47
IMHO,
Since C is a subset of C++ anyhow, it couldn't hurt to learn C++. Although, I'm a Java programmer, sometimes, when I have a rare free moment[what are those again?], will try and port Java code snippets into C++ and visa versa to help keep the mind sharp.

To that end, here are some links I've found useful in my constant learning of the techonologies (most are freeware):

Windows:
http://www.borland.com/bcppbuilder/freecompiler/
although I don't really do the GUIs, mostly just play with algorithms
on the command prompt
Invaluable resource:
http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
Chapter 3 of Volume 1 spends some time on C.

I don't really spend too much time on Windows C/C++, though. I simply prefer Macintosh, although it doesn't hurt to review Win32 coding.

Macintosh:
Classic - http://developer.apple.com/tools/mpw-tools/compilers/index.html
MPW is an interesting bird. However, with the release of OS X, it's seeing it's sunset. There is a rather large learning curve, though.

OS X: (membership is free)
http://developer.apple.com/tools/projectbuilder/
also, comes free with OS X purchase, admittingly, the instructional materials for Project Builder are sort of scarce, but there are lots of helpful online info in various places.

helpful online book:
http://www.mactech.com/macintosh-c/online.html

Also for OS X and other 'nixes [or would that be 'nixii?], you have GCC and related materials, however, I've found the documentation to be fairly terse and require a lot of mental digesting, which goes with the territory of Unix programmers. :D ;)

and for a few pennies in material cost, you could look at:
http://www.codewarrioru.com/Classroom/Course/1,1168,70_26426__,00.html
which I've found to be good introduction/refresher classes

Lastly, I also would suggest taking a look at Java as an instructional tool. The compliers (javac and jikes) are free. I feel it's a good language that has a good developer base. Java and C/C++ are complimentary (in an academic sense) as their goals/philosophies are similiar, just different implementations.

Hope this helps...best wishes
 

javaseeds

Seniorius Lurkius
47
with all due respect:
With minor exceptions, C++ is a superset of C. Most differences stem from C++'s greater emphasis on type checking. Well-written C programs tend to be C++ programs as well. All differences between C++ and C can be diagnosed by a complier.
p.816, B.2, The C++ Programming Language, Third Edition, Stroustrup, Bjarne

B.2.2 does, however, discuss C code that isn't C++, but it's such a moot point with current compliers, that for all intents and purposes, C is a subset of C++

Sorry, I should have notated it before.

Have a Happy Holiday everyone!
 
If I had my _C Unleashed_, I'd bust out some quotations now. Unfortunately, I don't have it at home.

C++ is not a "superset" of C, nor any such nonsense. C89 itself is a different language from C++, and in any case, different styles are used when writing programs in the two languages. And as for C99, it is a very different language from C++; C99 is even farther away from being a "subset" of C++.

Five bucks says none of you C++ yokels has heard of restrict pointers, or variable-length arrays. (You don't get to look it up without forfeiting. :D ).
--
Stephan T. Lavavej
http://stl.caltech.edu
 

javaseeds

Seniorius Lurkius
47
Not intending to make this BF material, but I just go by what is printed and generally assumed to be known. Since day 1 of my CS classes in 1994, it was just said that C++ is a superset of C, and I've always identified that to also mean C is a subset of C++.
So maybe that's -1 for not following deductive reasoning....

Every C program I've ever written, though, compiles and runs when saved as a .cpp file.

That said, Stroustrup[the inventor of C++], does say:
In the strict mathematical sense, C isn't a subset of C++. There are programs that are valid C but not valid C++ and even a few ways of writing code that has a different meaning in C and C++. However, C++ supports every programming technique supported by C. Every C program can be written in essentially the same way in C++ with the same run-time and space efficiency. It is not uncommon to be able to convert tens of thousands of lines of ANSI C to C-style C++ in a few hours. Thus, C++ is as much a superset of ANSI C as ANSI C is a superset of K&R C and much as ISO C++ is a superset of C++ as it existed in 1985
http://www.research.att.com/~bs/bs_faq.html#C-is-subset

so I guess it's not strictly a true Venn subset, but it seems book writers either don't know or don't care, for example:
Stroustrup based C++ on C because of C's brevity, it's suitability to system programming, it's widespread availability, and it's close ties to the UNIX operating system. ... Stroustrup added OOP features to C without significantly changing the C component. Thus, C++ is a superset of C, meaning that any valid C program is also a valid C++ program, too. ... There are some minor descrepancies, but nothing crucial. C++ can use existing existing software libraries
p.6, C++ Primer Plus, Third Edition, Steven Prata, 1998 Sam's Publishing.

When I made my earlier post, this is why I made the claim to C being a subset of C++...because "C99" isn't differentiated from other forms of C in any of my books on hand. Maybe I'm just a little outdated, but not entirely inaccurate.
It is noted that:
Please note that "C" in the paragraphs above refers to Classic C and C89. C++ is not a descendant of C99; C++ and C99 are siblings. C99 introduces several novel opportunities for C/C++ incompatibilities.
http://www.research.att.com/~bs/bs_faq.html#difference

Which is probably what I should have started off with in the first place.

Happy Holidays!
 
I'll fight back with the comp.lang.c FAQ:

http://www.eskimo.com/~scs/C-faq/q20.27.html

"C++ was derived from C, and is largely based on it, but there are some legal C constructs which are not legal C++. Conversely, ANSI C inherited several features from C++, including prototypes and const, so neither language is really a subset or superset of the other. In spite of the differences, many C programs will compile correctly in a C++ environment, and many recent compilers offer both C and C++ compilation modes."

That's the final word on the matter. clc knows all. :D
--
Stephan T. Lavavej
http://stl.caltech.edu
 

Liam

Ars Scholae Palatinae
618
Alex: by all means prefer learning C first to C++. It's simpler. Or, learn C++, but don't worry so much about OOP, the STL, and all that just yet. You'll probably find, when you're a little more fluent, that what you've really accomplished (aside from the differences in I/O) is to learn C. After learning C (or your very small subset of C++), jump into OOP. You have a very real advantage that you won't have to unlearn all sorts of procedural mental wiring; you can just add OOP to it. Try out classes. See how they make life easier. See how they make it more complex. Check out inheritance. Then try out templates. See how they make life even easier, and even more complex. Then learn how to use the STL; learn what's available to you. Use it. For production work, prefer the standard containers to your home-built ones, but never, EVER say to yourself "I don't need to understand how that works; somebody did all the thinking for me." That's true, somebody DID do all the thinking for you, but that's a horrible reason not to learn (or try and figure out) why they did things the way they did. You'll appreciate it even more after you understand it.

You said you were low on fundage. As far as free compilers and development environments go, I have to plug Cygwin if you're using Windows. If you're using Linux, you've already got all the good stuff. If you absolutely have to have an IDE, well...I have no advice for you there. Maybe a student version of Visual C++.

If you're going to try C first, definitely get K&R's book. If you're going to try C++ first, get Stroustrup's book, but don't be afraid to skip around in it.

OOP and templates and the STL and exceptions and all that stuff is really great, but only really after you've done enough to see why. For me, having Bjarne (or my professor) telling me, "Oh, yeah, OOP/exceptions/templates/insert buzzword/feature here is REALLY SUPER! It makes life SOOOOO much easier" has about ZERO impact until I've learned enough to see the need that they fill. That's my argument for learning the basics first.

PeterB's comment about "coding versus being a computer scientist" is noted. If you're shooting for practicality, ignore the advice I gave about relying on others' thinking, to a certain extent. If you really want to know how it works, don't. One of the things you'll notice about either of those books is that their suggested exercises tend to involve writing stuff that's already in the standard libraries, and there's a reason for that. It's incredible practice.
 
Status
Not open for further replies.