b_murphy@fennel.cc.uwa.oz.au (10/17/90)
Keywords: Pascal, C Summery : How does one learn to program in C after Pascal? Hello, So, lets say your a wiz-bang programmer in Pascal. You've been writing heaps of code for your companion (something with an apple on the front I beleive.:-) and your new boss (due to economics) decides that you are to create code in C or C++ for Windows 3 on I*M (I *didn't* say it, I _Just_ hinted a few letters :-) What do you recommend for reading. (I speak PASCAL, 6502, Clipper BASIC :-(, English and Dutch :-)) Also as of 23 Oct I'll be on a new address, but I'll tell you that when I've got it. -- -o (short for On-no) ()/)/)() can be r e a c h e d at B_MURPHY@VAXA.UWA.OZ.AU _T_H_I_S___I_S___V_A_L_I_D___U_N_T_I_L___2_3___O_C_T_O_B_E_R___1_9_9_0_ The net never sleeps, come to think of it, do I ever? ----> Thinking is dangerous, subversive and leads you astray. <----
casseres@apple.com (David Casseres) (10/17/90)
In article <1990Oct17.151226.2449@fennel.cc.uwa.oz.au> b_murphy@fennel.cc.uwa.oz.au writes: > So, lets say your a wiz-bang programmer in Pascal ... and your new boss (due to economics) > decides that you are to create code in C or C++ for Windows 3 on > I*M (I *didn't* say it, I _Just_ hinted a few letters :-) > > What do you recommend for reading. (I speak PASCAL, 6502, Clipper > BASIC :-(, English and Dutch :-)) I recommend reading a lot of C code, with Kernighan and Ritchie's "The C Programming Language" at hand to help you figure out what it means. Read stuff like the sample code that comes with MPW or Think C. Forcing yourself to understand examples is the only way you will ever learn this "language." After you have a reasonable grasp on C (like your typedef's compile two times out of three, and you laugh bitterly when people talk about C's "portability"), you are ready for C++. It is really much better than C. However, it is still based on C, so a good deal of it doesn't make sense except in a very obscure way. TAKE A COURSE. You don't want to be alone when you're learning C++. Read Stroustrup's "The C++ Programming Language." Read it when it's time for you to get some sleep, but you can't because you're so terrified by what they tried to teach you in the class. Reading Stroustrup is just like getting whacked between the eyes with a 2x4. When you're awake again, read the "Unofficial C++ Style Guide" by David Goldsmith and Jack Palevitch, in issue #2 of Apple's "develop" magazine. Everything in it is extremely good advice and it will save you a good deal of grief. Get your hands on some example C++ code, such as what you get with MPW C++ or what gets handed out in the course you're taking. Read, study, force yourself to understand -- but much more important, start every C++ project by COPYING AN EXAMPLE, and then start changing things and adding your own stuff. This is a major key to successful C++ coding. Try to avoid reading most books on object-oriented programming. They will tend to make you hate C++. Write all your comments in Dutch ; ^ ) ; ^ ) ; ^ ) David Casseres Exclaimer: Hey!
wieser@cs-sun-fsd.cpsc.ucalgary.ca (Bernhard Wieser) (10/18/90)
I must disagree, the worst thing to do is read lots of C code. The best thing to do is sit down with K&R, and program all the examples. But remember, ANSI, Unix, and Mac C libraries are very different. Know that when you start reading.
pepke@gw.scri.fsu.edu (Eric Pepke) (10/18/90)
Pascal and C are almost identical. This no doubt explains why the flame wars over which is "better" and why are so bitter and vitriolic. Nothing starts a holy war like a tiny difference in interpretation of doctrine. They are almost identical because they started off nearly so, as ALGOL-type block-structured procedural languages. Also, over the years, people have been working to put C-like features such as loop breaks and type casts into PASCAL and PASCAL-like features such as strong typing in functions into C. The remaining differences tend to be mostly syntactic or obscure and avoidable. It is too bad you haven't yet had languages like APL, SNOBOL, PROLOG, and LISP, which would help you appreciate just how really small the difference is. But you can still get the same result by thinking about BASIC all the time. The following is a list of about 90% of the real differences between PASCAL and C. In most cases there's, near enough, a one-to-one correspondence, in others there is quite a bit of difference in the details. Warning! The mere possesion of such a list can still get you burned as a heretic in many parts of the world. On the other hand, it might help you get your job done. This list, plus a copy of Kernhigan & Ritchie, should enable you to convert sample programs from PASCAL to C, and after a few tries, you will know C. Pascal C ------ - BEGIN ... END { ... } IF foo THEN bar [ ELSE moo ] IF (foo) bar; [ ELSE moo ] ; between statements ; at end of statement := = = == <> != NOT ! PROGRAM ... END . main() { ... } RECORD struct variant RECORD union REAL float, double INTEGER short, long, int WHILE foo DO bar while (foo) bar REPEAT foo UNTIL bar do { foo } while (!bar) bork; (proc or function call) bork(); FUNCTION toad : type; type toad() toad := 3; return 3; CASE foo of switch (foo) 1: case 1: (remember break at end) ARRAY glop[0..9] of integer int glop[10] TYPE section typedef foo . bar foo . bar foo ^. bar foo -> bar foo^ *foo WITH no such animal OTHERWISE (nonstandard) default: declared, numeric labels undeclared, nonnumeric labels FOR k := 0 TO 9 DO bork for (k = 0; k < 10; ++k) bork CYCLE (nonstandard) continue LEAVE (nonstandard) break a AND b (a and b evaluated first) a && b (b only evaluated if a) a OR b (a and b evaluated first) a || b (b only evaluated if not a) nested procedures and functions no such animal CHAR is not a number, use ORD() char is a number as well as a character type(foo) (nonstandard) (type) foo Eric Pepke INTERNET: pepke@gw.scri.fsu.edu Supercomputer Computations Research Institute MFENET: pepke@fsu Florida State University SPAN: scri::pepke Tallahassee, FL 32306-4052 BITNET: pepke@fsu Disclaimer: My employers seldom even LISTEN to my opinions. Meta-disclaimer: Any society that needs disclaimers has too many lawyers.