Originally Posted by
Epy
Again, I'm smacking myself for not learning C++ sooner just for std::string alone. basically has all the spoils Python provides you with (I'm guessing Python actually took these from C++), but many many times faster as a compiled language.
That's not really the case, or no one would bother using anything but C++. I kind of agree with Yarin -- I find working in C++ more like working in C than perl.
Dynamic typing and garbage collection are a huge deal. If I had to be concerned with type conversion and safety for the tish I do in perl, it would take me 5x as long and cause 10x the headaches. It makes a lot of data structures much much simpler. Eg this:
Code:
std::unordered_map<std::string, int> adictionary;
From your first post only superficially looks like a python dictionary. It's way more limited -- the keys have to be strings and the values have to be ints. They can't be, eg, more dynamic dictionaries in a tree. And look at the freaking syntax -- it's almost painful. In perl:
The keys of which are stings which can type convert to numbers, and the values of which can be anything -- arrays of objects, code refs, more tree, etc. Now start to consider the code involved with putting something into a std::map. Then getting stuff out -- iterators are another very tedious, awkward C++ mechanism that has to do with strong typing.
GC is a little less significant IMO, but still saves a lot of hassles, esp. around closures and such.
I think if you take a reasonably complex, well written python program and re-write it in C++, you're going to end up with at least 3-5 times more code.