Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python vs. C++11

Reply
Thread Tools

Python vs. C++11

 
 
sturlamolden
Guest
Posts: n/a
 
      02-13-2012
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


 
Reply With Quote
 
 
 
 
sturlamolden
Guest
Posts: n/a
 
      02-13-2012
On Feb 13, 4:21*am, sturlamolden <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
 
Henrik Faber
Guest
Posts: n/a
 
      02-15-2012
On 15.02.2012 08:18, Tim Roberts wrote:
> sturlamolden <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 R. David Murray Python 0 01-17-2011 02:23 PM
Re: [Python-Dev] [python-committers] [RELEASED] Python 3.2 rc 1 Senthil Kumaran Python 0 01-17-2011 10:31 AM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Martin v. L÷wis Python 0 03-01-2008 10:51 PM
Re: [Python-Dev] [Python-3000] RELEASED Python 2.6a1 and 3.0a3 Paul Moore Python 0 03-01-2008 10:39 PM
Searching comp.lang.python/python-list@python.org (was: UTF-8) skip@pobox.com Python 0 03-10-2007 02:50 PM



Advertisments