Python Forum
Reasons to choose Python over C++?
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reasons to choose Python over C++?
#1
What are the reasons to choose python over c++?
>Is it because of the simplicity and shortness of the Scripts in Python?


Confused Confused Confused
Reply
#2
They exist for very different problem domains. Depending on what you're doing, maybe c++ is the right choice.

If execution speed or memory usage are critical (they normally aren't), then c++ is the right choice.
If prototype speed or legibility is more important, python is probably the better choice.

If you're building a website, python is 100% always the right choice, although if speed becomes an issue, you could write a backend service in c++ to speed it up, and even then python would be a better frontend (although caching would probably give a greater benefit anyway).

If you're building a device driver for a refrigerator, c++ would be a better choice, if available (you might only have access to c, though).

If you're working on a video game, then... it depends on what kind. But c++ would probably be better. Even then, I'd say Java/C#/Lua would be better than either, unless execution speed was an issue as before.
Reply
#3
Thanks Nilamo
 you are so helpful.

 But C++ is complex and it has multiple types of functions and headers.its not easy to remember them all.
 I was trying to study it for the past  1 month.i could not learn much.And there are lot of bugs in all compilers,i could not even run my helloworld cpp properly.
 So i moved on to python,its easy
 But there is not enough Beginner friendly tutors
Reply
#4
I started with C++. And found everything i wanted to do in C++ i was able to do in python. I dont think I ever really went back. Even my game dev itch was scratched by python instead of C++. 

(Apr-26-2017, 04:32 PM)RandoomDude Wrote: But C++ is complex and it has multiple types of functions and headers.its not easy to remember them all.
Any programming language takes years of practice to become fluent in it. More so with C++ than a language like python. But they all take time. One month is not enough even for python, let alone C++.

(Apr-26-2017, 04:32 PM)RandoomDude Wrote: But there is not enough Beginner friendly tutors
Where are you looking? There are a lot if you google a speciifc activity.

We have our own tutorials
https://python-forum.io/Forum-Tutorials

and there references to other tutorials
https://python-forum.io/Thread-A-List-of...-Resources

If you have trouble finding a tutorial anywhere we take requests (though its at our own timeframe)
https://python-forum.io/Thread-Tutorial-Requests

(Apr-26-2017, 04:22 PM)nilamo Wrote: If you're working on a video game, then... it depends on what kind. But c++ would probably be better. Even then, I'd say Java/C#/Lua would be better than either, unless execution speed was an issue as before.
You can do quite a bit with Python. It depends on what kind of game, how far advanced you want, etc. You can easily start in python and later be transfer if needed to c++. You can learn the same concepts, pitfalls, strategies, in c++ game dev that you do in python while making decent games in python. For example here are a list of games people compete with on pyweek. Note that they are created in a week. So most games dont have a lot of flare.

Quote:What are the reasons to choose python over c++?
I think the #1 for me is i enjoy more coding in python than i do with languages like C++, PHP, Java, etc. I stay away from Microsoft C#. I just have more fun doing it as i am not wresting with the language as much if at all. 

NOTE: sometimes you have to use different languages. You can always attempt to tweak a language to be like another language to try to use just 1 language (which is never ideal or recommended), but you end up fighting the language then. Its sometimes just easier to use multiple languages. Once you learn the concepts, you can easily transfer them to other languages. Most are just syntax changes. So once you learn the first language, the second or third is not as bad.

For example if you want to do Android, though python's Kivy does work, its actual easier to use java (in my opinion). Last i recall to make an Xbox game you have to write it in C# (if thats still valid?). This forum I would rather be in Python (we all would), but the software already exists in PHP and is maintained so we dont have to. If you need to create a driver for unknown hardware, you might be best with C++.

I can tell you one thing that will never be written in python. Video Card drivers. They need to be fast fast fast. 
Reply
#5
I admittedly don't know a whole lot about gamedev, though I've been dipping my toes in it during my free time, using c#/monogame.
Reply
#6
Quote:And there are lot of bugs in all compilers,i could not even run my helloworld cpp properly.
I used C++ for many years. I'm not sure I found a single bug during all that time.
Perhaps the problem was your code?
Or lack of knowledge on how to use the compiler.
Reply
#7
Here's a little long - but brilliant Python advocacy article. I haven't touched C++ since 2008 - and I don't miss it
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply
#8
(Apr-26-2017, 06:21 PM)volcano63 Wrote: Here's a little long - but brilliant Python advocacy article. I haven't touched C++ since 2008 - and I don't miss it
That is a really good read. I think everyone should read that.

Parts of that remind me of the pygame community 
Quote:Choosing a language for you application simply because its “fast” is the ultimate form of premature optimization.
when new people blame python/pygame for their slow game, when in reality it is them loading resources in the class' constructor every instance for example. Every time a creature gets spawned, their game loads all the images, sounds, fonts, etc. again and again and again. lol. They would find out when they switch to C++ that their bottlenecks still exists.
Reply
#9
I have stumbled several times in my career on cases when badly written Python code - or duplicated processing - were bottlenecks in data processing project - those infamous 3%.

In one case, analysis code running over hundreds of millions lines of text was comparing one-digit integer with threshold value. Removing conversion to integer speeded up comparison 11  Doh times. Those were microseconds, but still. Removing conversion was a simple matter.

In another case, graphical implementation was slowed down to a crawl due to duplicates in code, that was very WET - as opposed to DRY Wall . I suggested caching mechanism to solve the issue - I was patted on the shoulder, and majorly ignored.
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply
#10
(Apr-26-2017, 07:07 PM)metulburr Wrote: when new people blame python/pygame for their slow game
I blame pygame for my slow games.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Choose an element from multidimensional array quest_ 2 441 Nov-25-2020, 12:59 AM
Last Post: quest_
  Need help implmenting if/else or case statements for option to choose file format. samlee916 1 498 Jul-22-2020, 06:06 PM
Last Post: Larz60+
  Choose your own adventure game noahc2004 2 690 Jun-26-2020, 02:06 PM
Last Post: DPaul
  Please help a newbie choose which programming language to learn. yeto 2 1,246 Feb-25-2019, 12:56 AM
Last Post: yeto
  User Input to Choose from Dictionary anelliaf 9 17,170 Mar-27-2018, 02:22 PM
Last Post: anelliaf
  Need a little more help in a Choose Your Own Adventure Program Goldberg291 13 12,180 Jan-31-2017, 08:33 AM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020