Re: c++ for python programmers

2007-02-18 Thread Michael
Thomas Nelson wrote:

> I realize I'm approaching this backwards from the direction most
> people go, but does anyone know of a good c/c++ introduction for
> python programmers?

There's been lots of answers, but no-one's mentioned the book I like:
   * Accelerated C++ by Koenig & Moo

It dives straight into C++ - rather than attempting to say "look, C++ is
built ontop of C, so I'll teach you C first, I'll recognise that the idioms
for developing in C++ are different and start from there instead".

It's in my opinion by far and away one of the best intros I've read. (I'm
not saying that lightly either - I rank it as good/language relevant an
introduction as Learning Perl used to be, and the K&R book can be for many
C developers).

In many respects it'll also show you some of the similarities between python
and C++, and the differences.


Michael.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-15 Thread Steve Holden
Anders Arnholm wrote:
> Sam <[EMAIL PROTECTED]> skriver:
>> On 13 Feb 2007 17:51:00 GMT, Jorgen Grahn
>> <[EMAIL PROTECTED]> wrote:
>>> Well, C++ is a better language than C in many ways. So, if he needs to learn
>>> one of them, why does it have to be C?
>>>
>>> Another reason some people choose C++ over Python for some tasks is that
>>> they feel that larger programs benefit from strong, static type checking.
>>> I like both ways, but depending on the task, one or the other is better.
>> C++ is -not- strongly typed. You can cast anything to void *, and
>> manipulate it in ways unimaginable. Plus there's the whole mess that
>> is pointer arithmetic and a weak typesystem...
> 
> 
> C++ can be both, The type systenm is as fragila as you like it to be.
> I mainlty use c++ when i the need stronger typing that Python och C
> can't give me. In some ways it's even stronger types than languanges
> as Java and ObjectiveC. C++ it however at least four different
> languanges, in one ball of soupe.
> 
Presuming "when i the need" is a typo for "when I need the" rather than 
"when i feel the need for", when do you actually *need* strong typing?

By which I presume you to mean status typing, since Python is already a 
strongly-types language.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Blog of Note:  http://holdenweb.blogspot.com
See you at PyCon? http://us.pycon.org/TX2007

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-15 Thread Anders Arnholm
Nicola Musatti <[EMAIL PROTECTED]> skriver:
> On Feb 14, 2:41 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
> [...]
>> Don't forget the lack of standard garbage collection.
> memory related problems. I'm aware that most is not the same as all,
> but on the other hand garbage collection has it's problems too:

And that garbabe collection is only good for memory, garbage
collecting open files and network connections work much less
well. Giving the need to add a maonual "delete" function to be called
before the object is destroed when you need the life time controll.
And this having to be reflected in application depenednt way to figure
out how it works in each application.

/ Balp
-- 
http://anders.arnholm.nu/Keep on Balping
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-14 Thread Neil Cerutti
On 2007-02-14, Aahz <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>,
> Thomas Nelson <[EMAIL PROTECTED]> wrote:
>>I realize I'm approaching this backwards from the direction
>>most people go, but does anyone know of a good c/c++
>>introduction for python programmers?
>
> This isn't an introduction, but you should probably also pick
> up _Effective C++_ (and possibly _More Effective C++_, though
> that seems less useful to me).

I did enjoy _Effective C++_ very much, but in fact there's
nothing in there that's not already stated in _The C++
Programming Language_. Granted, TCPL is so dense that it wasn't
until *after* reading _Effective C++_ (Scott Meyers), that I
noticed this.

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-14 Thread Aahz
In article <[EMAIL PROTECTED]>,
Thomas Nelson <[EMAIL PROTECTED]> wrote:
>
>I realize I'm approaching this backwards from the direction most
>people go, but does anyone know of a good c/c++ introduction for
>python programmers?

This isn't an introduction, but you should probably also pick up
_Effective C++_ (and possibly _More Effective C++_, though that seems
less useful to me).
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

"I disrespectfully agree."  --SJM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-14 Thread Nicola Musatti
On Feb 14, 2:41 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote:
[...]
> Don't forget the lack of standard garbage collection.

Optional garbage collection is highly likely to be included in the
next C++ standard, due out in a couple of years.

> Also there's the hell known as exception safety.
>
> Python conceptually has many of the same issues with exception
> safety, but at least memory leaks aren't one of the consequences.
> I imagine most Python programmers don't even think about
> exception safety, but probably should be. We just happily raise
> exceptions willy-nilly, without worrying about our objects
> remaining in a reasonable state. Or do we? Maybe it's better not
> to think about it. ;-)

On the other hand having everything dynamically allocated prevents the
adoption of deterministic destruction, which is a far better clean up
mechanism than try/finally clauses.

In modern C++ standard containers and smart pointers help solve most
memory related problems. I'm aware that most is not the same as all,
but on the other hand garbage collection has it's problems too:
depending on the algorithm it may not be able to reclaim all the
unreachable memory and forgetting to explicitly reset variables may
lead to hanging to memory that is really not needed anymore.

Cheers,
Nicola Musatti

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-14 Thread Neil Cerutti
On 2007-02-13, Sam <[EMAIL PROTECTED]> wrote:
> On 13 Feb 2007 17:51:00 GMT, Jorgen Grahn
><[EMAIL PROTECTED]> wrote:
>> Well, C++ is a better language than C in many ways. So, if he
>> needs to learn one of them, why does it have to be C?
>>
>> Another reason some people choose C++ over Python for some
>> tasks is that they feel that larger programs benefit from
>> strong, static type checking. I like both ways, but depending
>> on the task, one or the other is better.
>
> C++ is -not- strongly typed. You can cast anything to void *,
> and manipulate it in ways unimaginable. Plus there's the whole
> mess that is pointer arithmetic and a weak typesystem...

Don't forget the lack of standard garbage collection. 

Also there's the hell known as exception safety.

Python conceptually has many of the same issues with exception
safety, but at least memory leaks aren't one of the consequences.
I imagine most Python programmers don't even think about
exception safety, but probably should be. We just happily raise
exceptions willy-nilly, without worrying about our objects
remaining in a reasonable state. Or do we? Maybe it's better not
to think about it. ;-)

> Disclaimer: I am unashamedly in the "C++ Is Evil" camp, and
> wholly believe that if you want proper strong, static type
> checking, use Haskell, or if you want proper, complete
> object-orientation (C++'s primitive types compromise its object
> system's integrity, and I believe I've already discussed
> casting and pointers), use Python, and if you want
> under-the-hood pointer-fu, use C.

C++'s standard library seems such a huge win over the C library,
that I'd hate to switch back. Of course it has its warts and
cancers, but it's an awesome accomplishment. And you *can* get
harder-to-use C versions that are basically portable.

-- 
Neil Cerutti
A billion here, a billion there, sooner or later it adds up to real money.
--Everett Dirksen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-14 Thread jkn
Hi Thomas

On Feb 12, 6:00 pm, "Thomas Nelson" <[EMAIL PROTECTED]> wrote:
> I realize I'm approaching this backwards from the direction most
> people go, but does anyone know of a good c/c++ introduction for
> python programmers?
>

They are not particularly aimed at Python programmers, but Bruce
Eckel's "Thinking in C++" books are (a) excellent, and (b) freely
downloadable, as well as purchasable in book form:

http://www.mindview.net/

Bruce is a python fan FWIW ;-)

HTH
Jon N

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-14 Thread Nicola Musatti
On Feb 14, 12:26 am, Sam <[EMAIL PROTECTED]> wrote:
[...]
> C++ is -not- strongly typed. You can cast anything to void *, and
> manipulate it in ways unimaginable. Plus there's the whole mess that
> is pointer arithmetic and a weak typesystem...

The previous poster wrote "strongly typed", not "a straight jacket".
The fact that you may do certain things doesn't mean that you have to
nor that they are going to be done to you against your will.

> Disclaimer: I am unashamedly in the "C++ Is Evil" camp, and wholly
> believe that if you want proper strong, static type checking, use
> Haskell, or if you want proper, complete object-orientation (C++'s
> primitive types compromise its object system's integrity, and I
> believe I've already discussed casting and pointers), use Python, and
> if you want under-the-hood pointer-fu, use C.

The trouble is that in addition to proper, strong, static type
checking people often also want their daily bread, fancy that. As to
the merits of complete object orientation, I'd like to hear about
them, because nobody managed to explain them to me in a satisfactory
way yet.

There are many valid reasons to dislike C++ and to prefer Python to
it, but dismissing it as "C++ Is Evil" is just plain stupid. Moreover,
C might be a valid competitor for small projects and it probably
covers most Pythonistas' needs for "closeness to the metal", but it
just doesn't scale.

Cheers,
Nicola Musatti

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-14 Thread Anders Arnholm
Sam <[EMAIL PROTECTED]> skriver:
> On 13 Feb 2007 17:51:00 GMT, Jorgen Grahn
><[EMAIL PROTECTED]> wrote:
>> Well, C++ is a better language than C in many ways. So, if he needs to learn
>> one of them, why does it have to be C?
>>
>> Another reason some people choose C++ over Python for some tasks is that
>> they feel that larger programs benefit from strong, static type checking.
>> I like both ways, but depending on the task, one or the other is better.
>
> C++ is -not- strongly typed. You can cast anything to void *, and
> manipulate it in ways unimaginable. Plus there's the whole mess that
> is pointer arithmetic and a weak typesystem...


C++ can be both, The type systenm is as fragila as you like it to be.
I mainlty use c++ when i the need stronger typing that Python och C
can't give me. In some ways it's even stronger types than languanges
as Java and ObjectiveC. C++ it however at least four different
languanges, in one ball of soupe.

And yes you can do it, that doesn't mean you have to dio it. As
_functions in python or __, you can use them from anyware, you don't
have to.

/ Balp


-- 
http://anders.arnholm.nu/Keep on Balping
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-13 Thread Sam
On 13 Feb 2007 17:51:00 GMT, Jorgen Grahn
<[EMAIL PROTECTED]> wrote:
> Well, C++ is a better language than C in many ways. So, if he needs to learn
> one of them, why does it have to be C?
>
> Another reason some people choose C++ over Python for some tasks is that
> they feel that larger programs benefit from strong, static type checking.
> I like both ways, but depending on the task, one or the other is better.

C++ is -not- strongly typed. You can cast anything to void *, and
manipulate it in ways unimaginable. Plus there's the whole mess that
is pointer arithmetic and a weak typesystem...

Disclaimer: I am unashamedly in the "C++ Is Evil" camp, and wholly
believe that if you want proper strong, static type checking, use
Haskell, or if you want proper, complete object-orientation (C++'s
primitive types compromise its object system's integrity, and I
believe I've already discussed casting and pointers), use Python, and
if you want under-the-hood pointer-fu, use C.

--Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-13 Thread Jorgen Grahn
On Mon, 12 Feb 2007 19:10:02 +0100, Maël Benjamin Mettler <[EMAIL PROTECTED]> 
wrote:
> Thomas Nelson schrieb:

[top posting fixed]

>> I realize I'm approaching this backwards from the direction most
>> people go, but does anyone know of a good c/c++ introduction for
>> python programmers?

> Learning C++ is not worth is in my opinion, since you can get the OOP
> power from Python and use C if you need speed...

Well, C++ is a better language than C in many ways. So, if he needs to learn
one of them, why does it have to be C?

Another reason some people choose C++ over Python for some tasks is that
they feel that larger programs benefit from strong, static type checking.
I like both ways, but depending on the task, one or the other is better.

And then there's always the "my boss told me" reason, which seems to apply
to the OP.

/Jorgen

-- 
  // Jorgen Grahn   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-13 Thread Jorgen Grahn
On Tue, 13 Feb 2007 06:35:36 +1100, andrew clarke <[EMAIL PROTECTED]> wrote:
> On Mon, Feb 12, 2007 at 10:00:51AM -0800, Thomas Nelson wrote:
>
>> I realize I'm approaching this backwards from the direction most
>> people go, but does anyone know of a good c/c++ introduction for
>> python programmers?
>
> Thomas, I sent you a message off-list but it bounced due to your mailbox
> being full.
>
> Short answer: Subscribe to the c-prog@yahoogroups.com mailing list and
> ask your C/C++ questions there.

Why on earth should he do that, seeing that he seems to post here over
Usenet? There are plenty of Usenet groups for both languages. For C++, there
are comp.lang.c++ and comp.lang.c++.moderated. Reading the second one has
been both useful and enjoyable for me.

And to echo what someone else wrote: please don't use the term "C/C++". It
makes about the same sense as "Perl/Python" (or "Python/Perl").

/Jorgen

-- 
  // Jorgen Grahn   R'lyeh wgah'nagl fhtagn!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-13 Thread Neil Cerutti
On 2007-02-12, Thomas Nelson <[EMAIL PROTECTED]> wrote:
> I realize I'm approaching this backwards from the direction
> most people go, but does anyone know of a good c/c++
> introduction for python programmers?

To become productive in C++ in a short time, especially with a
Python background, I highly recommend Koenig & Moo _Accelerated
C++_.

It's not enough C++ to join a C++ team at a professional
development house (of course no book can provide that), but it's
all the best bits.

If you get through that, then proceed directly to the source,
Stroustrup _The C++ Programming language_.

-- 
Neil Cerutti
You only get a once-in-a-lifetime opportunity so many times. --Ike Taylor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-13 Thread Nicola Musatti
On Feb 12, 7:00 pm, "Thomas Nelson" <[EMAIL PROTECTED]> wrote:
> I realize I'm approaching this backwards from the direction most
> people go, but does anyone know of a good c/c++ introduction for
> python programmers?

I don't think there's any book catering specifically for people coming
from dynamically typed languages. If you want a crash course try
"Accelerated C++", by Koenig & Moo; if you want something more gentle,
that may also serve as a reference, go for "C++ Primer", by Lippman,
Lajoie & Moo. Both books from Addison Wesley.

As for something freely available people speak well of Bruce Eckel's
"Thinking in C++", but I haven't read it: http://www.mindview.net/
Books/TICPP/ThinkingInCPP2e.html

Cheers,
Nicola Musatti


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-12 Thread Andy Terrel
On Feb 12, 4:11 pm, "Thomas Nelson" <[EMAIL PROTECTED]> wrote:
> On Feb 12, 1:35 pm, andrew clarke <[EMAIL PROTECTED]> wrote:
>
> > Thomas, I sent you a message off-list but it bounced due to your mailbox
> > being full.
>
> > Short answer: Subscribe to the [EMAIL PROTECTED] mailing list and
> > ask your C/C++ questions there.
>
> > Regards
> > Andrew
>
> I have to edit a large C++ project written by someone else.  My email
> address
> above is incorrect; replace mail with cs.  Thanks for the help.
>
> Thomas

To learn C I recommend K&R (Kernigahn and Richie), for C++ I like
Savitch's book, Absolute C++. I too learned python then c/c++.  Also I
would disagree with the people saying never to use C++, it will run
much faster for computationally intensive programs.  It will make you
a better python programmer, you get to see how things are done "under
the hood".

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-12 Thread Thomas Nelson
On Feb 12, 1:35 pm, andrew clarke <[EMAIL PROTECTED]> wrote:

> Thomas, I sent you a message off-list but it bounced due to your mailbox
> being full.
>
> Short answer: Subscribe to the c-prog@yahoogroups.com mailing list and
> ask your C/C++ questions there.
>
> Regards
> Andrew

I have to edit a large C++ project written by someone else.  My email
address
above is incorrect; replace mail with cs.  Thanks for the help.

Thomas

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-12 Thread andrew clarke
On Mon, Feb 12, 2007 at 10:00:51AM -0800, Thomas Nelson wrote:

> I realize I'm approaching this backwards from the direction most
> people go, but does anyone know of a good c/c++ introduction for
> python programmers?

Thomas, I sent you a message off-list but it bounced due to your mailbox
being full.

Short answer: Subscribe to the c-prog@yahoogroups.com mailing list and
ask your C/C++ questions there.

Regards
Andrew
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-12 Thread [EMAIL PROTECTED]
Thomas Nelson wrote:
> I realize I'm approaching this backwards from the direction most
> people go, but does anyone know of a good c/c++ introduction for
> python programmers?

I would stick with C unless you need to edit C++ code.  (Calling them
C/C++ doesn't make much sense as they're separate languages).

The biggest sticking points aren't going to be helped much by a Python
background, so I'd just use one of the tutorials recommended over in
comp.lang.c (Richard Heathfield had a useful link at one point).

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: c++ for python programmers

2007-02-12 Thread Maël Benjamin Mettler
SAMS "Teach yourself C in 21 days" by Bradley L. Jones and Peter Aitken

Learning C++ is not worth is in my opinion, since you can get the OOP
power from Python and use C if you need speed...

Thomas Nelson schrieb:
> I realize I'm approaching this backwards from the direction most
> people go, but does anyone know of a good c/c++ introduction for
> python programmers?
> 
> Thanks,
> 
> Thomas
> 

-- 
http://mail.python.org/mailman/listinfo/python-list


c++ for python programmers

2007-02-12 Thread Thomas Nelson
I realize I'm approaching this backwards from the direction most
people go, but does anyone know of a good c/c++ introduction for
python programmers?

Thanks,

Thomas

-- 
http://mail.python.org/mailman/listinfo/python-list