comp.lang.ada
 help / color / mirror / Atom feed
* Learning C and C++
@ 1993-05-27 10:14 agate!howland.reston.ans.net!torn!nott!bnrgate!bnr.co.uk!zaphod.axion.bt.
  0 siblings, 0 replies; 9+ messages in thread
From: agate!howland.reston.ans.net!torn!nott!bnrgate!bnr.co.uk!zaphod.axion.bt. @ 1993-05-27 10:14 UTC (permalink / raw)


[Yes, I have got the right group -- read on]

For my next job, I'll be working in C and possibly C++ (no flames, please).
Can anyone recommend some good books on both for someone who has a Pascal
and Ada background?

I first programmed in BASIC, then 6809 assembler and then progressed via
Pascal and various other assemblers to Ada. I've done quite a lot of work
modifying a large C program, but I haven't actually *written* much C code.

I've looked at the second edition of K&R, but it seems rather expensive and
sparse. "A Book on C" by Kelly and Pohl bears a remarkable similarity to K&R
-- indeed, it looks like K&R with more words.

So, can any of you folks recommend anything for this Adaphile?

Mat

| Mathew Lodge             | "What's your name, boy?" "Kate." "Isn't that |
| mjl-b@minster.york.ac.uk |  a bit of a girl's name?" "It's short for... |
| University of York, UK   |  Bob." -- Blackadder II                      |

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Learning C and C++
@ 1993-05-28  9:00 Peter Hermann
  0 siblings, 0 replies; 9+ messages in thread
From: Peter Hermann @ 1993-05-28  9:00 UTC (permalink / raw)


In article <738497688.6331@minster.york.ac.uk> mjl-b@minster.york.ac.uk writes:

>For my next job, I'll be working in C and possibly C++ (no flames, please).
>Can anyone recommend some good books on both for someone who has a Pascal
>and Ada background?

There exists a pretty new book "Programmieren mit Ada und C" 1992
by Annette Weinert 147 pages , isbn 3-528-05240-6
The author is reachable via Alsys, Karlsruhe, Germany, support@alsys.de
maybe you convince her to translate it into english?
The book compares both languages with a lot of examples.
regards,
Peter Hermann

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Learning C and C++
@ 1993-05-28 18:20 Step he Leake
  0 siblings, 0 replies; 9+ messages in thread
From: Step he Leake @ 1993-05-28 18:20 UTC (permalink / raw)


In article <738497688.6331@minster.york.ac.uk> mjl-b@minster.york.ac.uk writes:

>For my next job, I'll be working in C and possibly C++ (no flames, please).
>Can anyone recommend some good books on both for someone who has a Pascal
>and Ada background?

I've found "C, A Reference Manual" by Harbison & Steele, Third Edition, to be a
s
good as the Ada LRM. That is, if you REALLY want to know what the syntax is 
supposed to mean (as defined by ANSI), you can find out here. It also goes 
into some of the history of why ANSI C still has some of the bad things C does;
at least you get some understanding, if not relief.

Stephen Leake	NASA Goddard Robotics Lab
internet : nbssal@robots.gsfc.nasa.gov

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Learning C and C++
@ 1993-05-28 20:22 Robert Dewar
  0 siblings, 0 replies; 9+ messages in thread
From: Robert Dewar @ 1993-05-28 20:22 UTC (permalink / raw)


One interesting point (for the fellow who is falling off the good ship USS
Ada and will have to fend for himself among the C and C++ reefs) is that
a good background in Ada is excellent preparation for C programming. As is
so often the case in moving from one language to another, you can carry
good habits from one place to another. Often we scorn people who write
language X in the style of Y, but actually I think this is an excellent idea
when X=C and Y=Ada. In particular, the discipline of careful design of package
specs can carry right over to a very disciplined approach to the design,
coding and documentation of C headers.

This certainly won't solve all your problems, and when you jump overboard
I strongly recommend grabbing onto the nearest debugger, you'll find yourself
living in it much more than you did in Ada!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* LEARNING C AND C++
@ 1993-05-29  0:12 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland.
  0 siblings, 0 replies; 9+ messages in thread
From: cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland. @ 1993-05-29  0:12 UTC (permalink / raw)


On 27 May 1993, Mjl-b@minster.york.ac.uk posted to All:

MJL-B. For my next job, I'll be working in C and possibly C++ (no flames,
     . please). Can anyone recommend some good books on both for someone who ha
s
     . a Pascal and Ada background?

>From Pascal to C, an Introduction to the C Programming Language, Douglas L.
Brown, Wadsworth Publishing, 1985, ISBN 0-534-04602-9.

Regards, Mikey <michael.hagerty@nitelog.com>
---
 . MR/2 1.50 #63 . Allopathy--The art of amusing the ill while nature cures.
     

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: LEARNING C AND C++
@ 1993-05-31 13:18 Bjarne Stroustrup
  0 siblings, 0 replies; 9+ messages in thread
From: Bjarne Stroustrup @ 1993-05-31 13:18 UTC (permalink / raw)


michael.hagerty@nitelog.com (Michael Hagerty @ Nitelog BBS - Monterey, CA - 408
-655-1096) writes

 > On 27 May 1993, Mjl-b@minster.york.ac.uk posted to All:
 > 
 > MJL-B. For my next job, I'll be working in C and possibly C++ (no flames,
 >      . please). Can anyone recommend some good books on both for someone who
 has
 >      . a Pascal and Ada background?
 > 
 > From Pascal to C, an Introduction to the C Programming Language, Douglas L.
 > Brown, Wadsworth Publishing, 1985, ISBN 0-534-04602-9.
 > 

A brief comment - I don't think anything else would be appropriate on comp.lang
.ada:

C and C++ are different languages. Learning C isn't learning C++; it is not eve
n a
prerequisite for learning C++. I am of the opinion - based on some experience -
 that
for Pascal and Ada programmers C++ is easier to learn than C, especially if the
Pascal or Ada programmer initially focus on a sub-set of C++ that corresponds t
o
his or her previous langugage. The difference between C and C++ in this context
 is
that C++ has much stronger type checking and (in the case ofthe Ada programmer)
provides direct support for data abstraction. This minimizes the culture shock.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Learning C and C++
@ 1993-06-01  6:15 Dag Bruck
  0 siblings, 0 replies; 9+ messages in thread
From: Dag Bruck @ 1993-06-01  6:15 UTC (permalink / raw)


In <comp.lang.ada> dewar@schonberg.NYU.EDU (Robert Dewar) writes:
>
>This certainly won't solve all your problems, and when you jump overboard
>I strongly recommend grabbing onto the nearest debugger, you'll find yourself
>living in it much more than you did in Ada!

Advice based on personal experience, no doubt...    :-)

More seriously, I would strongly recommend this book:

	Andrew Koenig: C Traps and Pitfalls, Addison-Wesley

It's a small book with a lot of substance.  It does a better job than
any other book at describing the unique relationship between pointers
and arrays in C, which is fundamental and not very well understood by
most people.  It has indeed lots of good advice to offer.

I think there are three idioms in C that are bewildering at first
sight but very common in C code:

1.  Assignment is an expression, as in

	x = y = z;		/* not too bad */
	while ((c = getchar()) != EOF) ...;
		/* assign to 'c' and then check what it is */

2.  Auto increment and decrement of pointers,

	while (*p != 0)
		*q++ = *p++;

3.  There is no boolean data type; any integral type may be used
instead.  Zero is false, anything else is true.

If you combine all of these you may write:

	while (*q++ = *p++) ;

which copies an array of some type up to and including the first zero
element.  This is a common way to copy strings.  Also note that it is
different from the example in (2).

With these three idioms, and in particular the last example, you have
enough amunition to keep you going through a five-week flame war on
Ada vs. C (:-).  There is in fact some truth to it; if you look at the
criticism of C, and more recently C++, you will notice that a great
deal is based on permutations of these three idioms.


				-- Dag Bruck

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Learning C and C++
@ 1993-06-02 19:08 Robert Kitzberger
  0 siblings, 0 replies; 9+ messages in thread
From: Robert Kitzberger @ 1993-06-02 19:08 UTC (permalink / raw)


dewar@schonberg.NYU.EDU (Robert Dewar) writes:

>Often we scorn people who write
>language X in the style of Y, but actually I think this is an excellent idea
>when X=C and Y=Ada. 

I agree, as long as accepted coding practices of the 'new' language aren't
abused.  For example, I've seen cases where the C preprocessor was used
to make C code look like Pascal:

#define BEGIN {
#define END }
...etc...

The resultant code is only attractive and maintainable to the person 
that wrote it.  

	.Bob.
--
------------------------------------------------------------------------
Bob Kitzberger                          Internet:   rlk@rational.com
Rational, Grass Valley, CA              CompuServe: 70743,1550
type Opinion is private; 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Learning C and C++
@ 1993-06-03 12:48 Robert Dewar
  0 siblings, 0 replies; 9+ messages in thread
From: Robert Dewar @ 1993-06-03 12:48 UTC (permalink / raw)


Of course I agree with Bob, the use of the C macro processor to distort the
syntax is a truly horrible practice. Indeed it is this kind of abuse of
macro processors that helped result in the rather draconian approach of
Steelman which required that Ada NOT have a macro processor.

When I talked of using Ada style in C, I was referring not to low level
syntactical stuff, where you are stuck (or blessed, depending on your
point of view, or perhaps whether you are a reader or writer) with the
C syntax, but rather to high level structuring approaches.

In particular, I think most C programming would benefit from a much more
disciplined view of header files, to elevate these to the same level of
importance, design and control as package specs in Ada. Of course in C one
has to depend on people's good behavior or the use of external tools where
in Ada the language provides the necessary control, but it's quite possible
to write C using the Ada package style.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1993-06-03 12:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-06-03 12:48 Learning C and C++ Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1993-06-02 19:08 Robert Kitzberger
1993-06-01  6:15 Dag Bruck
1993-05-31 13:18 LEARNING C AND C++ Bjarne Stroustrup
1993-05-29  0:12 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!howland.
1993-05-28 20:22 Learning C and C++ Robert Dewar
1993-05-28 18:20 Step he Leake
1993-05-28  9:00 Peter Hermann
1993-05-27 10:14 agate!howland.reston.ans.net!torn!nott!bnrgate!bnr.co.uk!zaphod.axion.bt.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox