Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 17th, 2006, 1:36 PM   #1
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Smile 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?
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote
Old Sep 17th, 2006, 1:57 PM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
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
Arevos is offline   Reply With Quote
Old Sep 17th, 2006, 2:38 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 17th, 2006, 2:53 PM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
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.
Arevos is offline   Reply With Quote
Old Sep 17th, 2006, 3:06 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Sep 17th, 2006, 4:33 PM   #6
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4 Jessehk is on a distinguished road
There is also Boost.Python, but I just know of it; I haven't used it.

http://boost.org/libs/python/doc/index.html
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!
Jessehk is offline   Reply With Quote
Old Oct 11th, 2006, 12:45 AM   #7
Game_Ender
Professional Programmer
 
Game_Ender's Avatar
 
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3 Game_Ender is on a distinguished road
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);
}
Game_Ender is offline   Reply With Quote
Old Jan 3rd, 2007, 1:43 PM   #8
jazzychic18
Newbie
 
Join Date: Jan 2007
Posts: 3
Rep Power: 0 jazzychic18 is an unknown quantity at this point
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.
jazzychic18 is offline   Reply With Quote
Old Jan 3rd, 2007, 2:30 PM   #9
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
You might want to look here
Arevos is offline   Reply With Quote
Old Jan 3rd, 2007, 2:33 PM   #10
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
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
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[tutorial] Python for programming beginners coldDeath Python 30 Dec 14th, 2005 11:35 AM
If you want to learn Python or improve your Python skills coldDeath Python 2 Nov 23rd, 2005 12:27 AM
Convert Python script to C++ code clanotheduck Python 17 Sep 25th, 2005 8:55 AM
Advanced Python Tricks Arevos Python 19 Sep 24th, 2005 7:39 AM
Python - A Programmers Introduction coldDeath Python 17 Aug 19th, 2005 12:41 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:08 PM.

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