Python vs. C++11

Discussion in 'Python' started by sturlamolden, Feb 13, 2012.

  1. sturlamolden

    sturlamolden Guest

    There are bigsimilarities between Python and the new C++ standard. Now
    we can actually use our experience as Python programmers to write
    fantastic C++ :)

    Here is a small list of similarities to consider:


    Iterate over any container, like Python's for loop:

    for (type& item: container)


    Pointer type with reference counting:
    std::shared_ptr


    Python-like datatypes:

    tuple std::tuple

    list std::vector
    std::list
    std::stack

    dict std::unordered_map
    set std::unordered_set

    complex std::complex

    deque std::deque

    lambda [name](params){body}

    heapq std::heap

    weakref weak_ptr

    str std::string -- unicode, raw strings, etc work as Python


    Other things of interest:

    std::regex, std::cmatch
    std::thread thread api versy similar to Python's
    std::atomic datatype for atomic operations
    std::mt19937 same prng as Python
     
    sturlamolden, Feb 13, 2012
    #1
    1. Advertising

  2. sturlamolden

    sturlamolden Guest

    On Feb 13, 4:21 am, sturlamolden <> wrote:
    > There are bigsimilarities between Python and the new C++ standard. Now
    > we can actually use our experience as Python programmers to write
    > fantastic C++ :)


    And of course the keyword 'auto', which means automatic type
    interence.
     
    sturlamolden, Feb 13, 2012
    #2
    1. Advertising

  3. sturlamolden

    Henrik Faber Guest

    On 15.02.2012 08:18, Tim Roberts wrote:
    > sturlamolden <> wrote:
    >>
    >> There are bigsimilarities between Python and the new C++ standard. Now
    >> we can actually use our experience as Python programmers to write
    >> fantastic C++ :)

    >
    > This is more true than you might think. For quite a few years now, I've
    > been able to do an almost line-for-line translation of my Python programs
    > to C++ programs. (Microsoft has had a "for each" extension for a while
    > that made this easier.)


    I disagree. Unicode support comes for free with Python3+ while C++ it
    still is a piece of crap (or something that you'll have to pass to
    external libraries). The C++ standard library is nowhere nearly as
    densely packed with features than Python's. For every little thing you
    need some external dependencies. Language semantics aren't enough to
    translate one language into another.

    Best regards,
    Henrik
     
    Henrik Faber, Feb 15, 2012
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    763
  2. Paul Moore
    Replies:
    0
    Views:
    639
    Paul Moore
    Mar 1, 2008
  3. Martin v. Löwis
    Replies:
    0
    Views:
    680
    Martin v. Löwis
    Mar 1, 2008
  4. Senthil Kumaran
    Replies:
    0
    Views:
    594
    Senthil Kumaran
    Jan 17, 2011
  5. R. David Murray
    Replies:
    0
    Views:
    782
    R. David Murray
    Jan 17, 2011
Loading...

Share This Page