c++ for python programmers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nicola Musatti

    #16
    Re: c++ for python programmers

    On Feb 14, 2:41 pm, Neil Cerutti <horp...@yahoo. comwrote:
    [...]
    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

    Comment

    • Aahz

      #17
      Re: c++ for python programmers

      In article <1171303251.796 306.79520@p10g2 000cwp.googlegr oups.com>,
      Thomas Nelson <thn@mail.utexa s.eduwrote:
      >
      >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 (aahz@pythoncra ft.com) <* http://www.pythoncraft.com/

      "I disrespectfully agree." --SJM

      Comment

      • Neil Cerutti

        #18
        Re: c++ for python programmers

        On 2007-02-14, Aahz <aahz@pythoncra ft.comwrote:
        In article <1171303251.796 306.79520@p10g2 000cwp.googlegr oups.com>,
        Thomas Nelson <thn@mail.utexa s.eduwrote:
        >>I realize I'm approaching this backwards from the direction
        >>most people go, but does anyone know of a good c/c++
        >>introductio n 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

        Comment

        • Anders Arnholm

          #19
          Re: c++ for python programmers

          Nicola Musatti <nicola.musatti @gmail.comskriv er:
          On Feb 14, 2:41 pm, Neil Cerutti <horp...@yahoo. comwrote:
          [...]
          >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

          Comment

          • Steve Holden

            #20
            Re: c++ for python programmers

            Anders Arnholm wrote:
            Sam <free.condiment s@gmail.comskri ver:
            >On 13 Feb 2007 17:51:00 GMT, Jorgen Grahn
            ><grahn+nntp@sn ipabacken.dyndn s.orgwrote:
            >>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

            Comment

            • Michael

              #21
              Re: c++ for python programmers

              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.

              Comment

              Working...