Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Python (http://www.programmingforums.org/forum43.html)
-   -   Coding in Python or C++ (http://www.programmingforums.org/showthread.php?t=11344)

Dietrich Sep 17th, 2006 1:36 PM

Coding in Python or C++
 
If you would know Python and C++ equally well, what kind of programs would you use each of these languages for?

Why would C++ be preferred over Python?

Arevos Sep 17th, 2006 1:57 PM

I'd use C++ when Python isn't fast enough to accomplish what I want to do. Or if C++ has a vital library I need and Python doesn't.

So efficiency and libraries, really. Not that Python's particularly lacking for libraries :)

DaWei Sep 17th, 2006 2:38 PM

You will definitely find Python inferior to C++ when it comes to performance (I do find Pyton to be superior to PHP in that respect). That doesn't mean I'm not using the hell out of Python -- I am. Here's an example: generating my set of basic tic-tac-toe patterns takes a few seconds in Python. It takes so long in PHP that one can't write it as a server function because the script times out. In C++, the time is humanly indistinguishable from instantaneous.

Arevos Sep 17th, 2006 2:53 PM

Incidentally, tools like SWIG and Pyrex make integrating C++ with Python require very little effort indeed. Pyrex uses a Python-like syntax that translates directly into C, whilst SWIG automatically turns standard C functions into ones compatable with the Python C++ API. Psyco is also worth looking into as a way to speed up Python code.

DaWei Sep 17th, 2006 3:06 PM

I'll look into Swig and Pyrex, as I've been thinking about dinking with the C API. Psyco is indeed very useful, though not bullet-proof.

Jessehk Sep 17th, 2006 4:33 PM

There is also Boost.Python, but I just know of it; I haven't used it.

http://boost.org/libs/python/doc/index.html

Game_Ender Oct 11th, 2006 12:45 AM

I have played around with Boost.Python it provides a very nice python interface and wrapping system. Combined with Py++ you can even get SWIG like wrapper generation. The only downside is of course the compile time which will can get a little long due to the heavy use of templates. But you have to admit being able to do this is pretty cool:
:

object f(object x, object y) {
    if (y == "foo")
        x.slice(3,7) = "bar";
    else
        x.attr("items") += y(3, x);
    return x;
}
object getfunc() {
    return object(f);
}


jazzychic18 Jan 3rd, 2007 1:43 PM

I want to learn how to program and people say prthon is the easy to learn out of all programming language. can anyone tell me the easiest to learn just so i can get a feel for programming and can anyone suggest any books or free tutorial websites to recommend. Greatly appreciated for any recommendations or insight in the subject.

Arevos Jan 3rd, 2007 2:30 PM

You might want to look here

ReggaetonKing Jan 3rd, 2007 2:33 PM

I like how you just hijack this thread. Why not create your own?!

And For your quesrion, I would look into this FREE ebook. It is a beginner's level intro to programming book on Python. It very good and easy to read.

http://greenteapress.com/thinkpython/thinkCSpy.pdf


All times are GMT -5. The time now is 11:19 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC