home *** CD-ROM | disk | FTP | other *** search
Wrap
Newsgroups: comp.lang.c Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!destroyer!cs.ubc.ca!newsserver.sfu.ca!darcys From: darcys@fraser.sfu.ca (Darcy Smith) Subject: Re: Newbie Wants Advice on C-Programming Message-ID: <1993Jan3.190002.2256@sfu.ca> Sender: darcys@sfu.ca (D'Arcy Smith) Organization: Simon Fraser University, Burnaby, B.C., Canada (sortof) References: <1993Jan2.163028.8829@netcom.com> <24538@alice.att.com> <4284@dozo.and.nl> Date: Sun, 3 Jan 1993 19:00:02 GMT Lines: 187 From newsserver.sfu.ca!cs.ubc.ca!destroyer!gatech!swrinde!zaphod.mps.ohio-state.edu!cs.utexas.edu!uunet!pipex!bnr.co.uk!uknet!mcsun!sun4nl!and!jos Sun Jan 3 09:27:40 PST 1993 Article: 34226 of comp.lang.c Xref: newsserver.sfu.ca comp.lang.c++:27833 comp.lang.c:34226 Path: newsserver.sfu.ca!cs.ubc.ca!destroyer!gatech!swrinde!zaphod.mps.ohio-state.edu!cs.utexas.edu!uunet!pipex!bnr.co.uk!uknet!mcsun!sun4nl!and!jos From: jos@and.nl (Jos Horsmeier) Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: Newbie Wants Advice on C-Programming Message-ID: <4284@dozo.and.nl> Date: 3 Jan 93 10:14:04 GMT References: <1992Dec24.172333.7339@grebyn.com> <1993Jan2.163028.8829@netcom.com> <24538@alice.att.com> Followup-To: comp.lang.c++ Organization: AND Software BV Rotterdam Lines: 57 >In article <24538@alice.att.com> bs@alice.att.com (Bjarne Stroustrup) writes: >| >|jimlynch@netcom.com (Jim Lynch @ Netcom Online Communications Services (408-241-9760 login: guest)) wrote >| >| > >You should always start out with the official books: >| > > >| > >For C, it is _The_C_Programming_Langauge_ 2nd ed. by Kernighan & Ritchie >| > >For C++, it is _The_C++_Programming_Language 2nd ed. by Stroustrup >| > >| > No no no no no no no no no no no no. These books are _unreadible_ to a >| > beginner. >| > However, they can be quite valuable as a reference (whenever you get >| > around to >| > learning how to read them...) > >|It is worth remembering that `beginner' means different things in different >|contexts and what `unreadable' means depends critically on what kind of >|beginner we are talking about. >| >|If by `beginner' you mean `someone who approaches programming for the first >|time,' you are almost certainly right (though I have heard of exceptions to >|that rule). If, on the other hand, `beginner' means `experienced programmer >|who just happens never to have encountered C or C++ before,' you are with >|a high propability wrong (though again I suspect a few exceptions could be >|found). >| >|The backgrounds and expectations of want-to-be C or C++ programmers seem >|infinitely varied and textbooks, approaches to teaching, and advise must >|try to take that diversity into account. No one approach or one book can >|cover all angles. > >I think there's a bit more to leaning C++ than there is in learning C. >C++ uses quite a different paradigm: the object oriented programming >approach. Here at my company, they made me volunteer (with a gun pointed >to my head ;-) to teach the programmers team the concept of object >oriented design and programming. My first attempt was using your book >along the line of explaining inheritance, polymorphism, data encapsulation >etc. etc. We ended up discussing the misty details of the C++ language. >I completely failed here. My second attempt was, not using any programming >language at all, but just a clear explanation of the object oriented >concepts and mechanisms. When all that was clear, we switched to C++. > >This approach was much more fruitful: the C++ language became just >a mechanism to express these object oriented mechanisms. I kept on >convincing these people that it doesn't matter _how_ you express these >concepts, as long as the language offers you the building blocks to >express them. IMHO there are tree types of `beginners': > >- First time programmers; >- Experienced programmers but still unaware of the OOD concepts; >- Experienced programmers aware of OOD concepts, but they don't know > anything about the C++ language. > >I think that one has to be a beginner of the third kind to be able >to learn the C++ language successfully. > >kind regards and happy new year, > >Jos aka jos@and.nl > I'd like to provide some exerpts from an "Interview with Bjarne Stroustrup" found invol. 1 no.3 1991 of "The C++ JOURNAL" - Bjarne please forgive me! Q) What do you recommend to people who want to learn C++ but have the idea of the learning curve hanging over their heads? I don't think that this is the case anymore but the idea of this huge learning curve still exists. A) ...Get a text book or two, at least two because you can never trust just one author. The problem is you can't know what are the view points and what are the facts. Q) At which point should they start learning object-oriented concepts. Is that something to be learned initially or something to be learned later on? A) It depends. It strongly depends. Q) ...when I teach...C++, I start with object-oriented concepts and then map them into C++ but there are others who go the other way. A) Lets talk about this because it is tricky. ...I invariably start with history amd background and aims of C++. ...I don't see how you can understand things, unless you understand thier background. ...These are the fundamental 3 ways to use C++: 1. as a better C 2. supporting data abstraction 3. supporting object-oriented programming ... Q) Have you incorporated these ideas into you new book? A) No, "The Annotated C++ Reference Manual" is a straight reference manual. You should not try to learn C++ from that. If you are more than a casual user, you should have it, though. There is a statement here in the book states the aim: "this book provides a complete language reference for the expert C++ user." It is not a tutorial. It has more about C++ than you ever wanted to know, because that is what a good reference manual has to have. ...[his first book] That book is not a manifesto for writing programs the way that I think you should write them. ...There are many ways of writing programs and "the best way" depends on the application, personality, and the background of the person writing. there is no one right way. There are so many people that write manifesto's saying, "Do thing my way!" If anything, my manifesto is, "Think very hard about rhat you are doing, then do it your way!" I am trying to provide tools for supporting such a view. ...If you have a lot of C code already and you need to do a change in some corner of it, then it is probably very wise to start up slowly. If you have to interface with a lot of C code, then the object oriented features are not going to fit in all that well. So what you do is to tool up first. You get used to your new tools. You use C++ as a better C, tighten the type system. You use type-safe linkage to make sure you don't have linkage problems. Start throwing in a little bit of data abstraction. We work that way in real production environments. We have found that you can't take just a bunch of programmers out of their productive lives for, say a year and a half to teach tham to "do everything right." Forget it. We have to deliver a product within a half a year, a year or whatever. Does that mean you can't go C++? No, you can. Can you go use C++ in a radically new style? Not really. So you can throw in the "better C" and a bit of data abstraction. Q) At which point does the object-oriented programming and design come into play? A) You can not do effective OOP if you already have a framework that is designed to prevent it. ...[the gist of this is try a new project OO when you are ready!]. Q) There are some people who feel if you are going to use C++, you should use it in a completely object-oriented manner. How would you respond to that? A) What does complete object-oriented mean? Some of the worst C++ programs that I have seen, were written Lisp and Smalltalk styles. C++ is not Smalltalk and Smalltalk is not C++. Same with Lisp. If you coded an imitation Smalltalk in C++, why would you expect it to run faster than Smalltalk? You are not as smart at implementing Smalltalk's basic notions as Peter Deutch. Simulating something is always less conveinient and less efficient than using the real thing. [Bjarne, didn't you write a simulator a part of your Ph.D.? - just kidding] If I had wanted to to build an imitatin Smalltalk, I would have built a good imitation. I was building a good C++. C++ is not a good Smalltalk amd Smalltalk is a lousy C++. OK - sorry that this is so big - and there is much much more - however I will stop here! - you welcome! So my point, so nicely expressed by Bjarne, is do not use C++ in a way that it shouldn't be used. If your project is suited to OO ideas and you are comfortable in useing tham - the USE them where APPROPRIATE. You do not ever have to use a Class, inheritence, polymorphism or any other OO idea if you don't know how [but mabey you should learn!] or if it is not applicable to your program. Fanaly here are two other C++ books: The C++ Programing Language - Bjarne Stroustrup C++ Primer - Stanley B. Lippman I'm gonna go play in the snow now [usualy it rains here] D'Arcy