tricks to make things faster

Are there tricks to make things faster. I mean, if i wanted to write code fast i would just use Python. The reason i am dabbing into c/c++ is to get a glimpse of the speed increase. So far i have only gotten a headache from the syntax, and use massive amount of code to do such simple things.

Faster like: is using an iterator in a for loop faster than lets say looping indices of the container?

i am trying to maintain interest in c++, but its quite hard knowing that it takes in c++ 10 times what it does in python. The syntax is insanely difficult, complex, and drawn out long. I am also use to the "method" of simple is better rather than crazy long drawn out complex but faster "method". But so far i dont really even see the speed increase. C++'s syntax seems even crazier than C's.

And then everyone tries to learn c++ using high level programming such as directories (apparently listing directories is high level?), making http requests, etc. Where exactly is the line between low level and high level programming?

I program in python and can do the task 1 in about 15 minutes. In c++ the same task may take 3 days. I find it hard to program in C++ knowing that there is a much simpler solution out there, that being python.

So i keep reading and things say that c++ is much better at low level programming than in python. Where? What low level programaming? That i could write a program for linux specific that goes 1.5 seconds faster than the same program in python, but python's program can also run in windows and python's program also took 10 times faster to write. I dont see the advantage here? Is that 1.5 seconds execution time really worth it?

OK so you cant write a well 3D engine (probably) in python, but how many do we already have, that we can already use? That doesnt mean you cannot write a 3d game in python. Why would i want to even reinvent the wheel?

Maybe i am just a high level programmer that does not like low level stuff? Or i could just be going on a rave from stress of learning c/c++.
Last edited on
closed account (Dy7SLyTq)
Are there tricks to make things faster.

write better code

if i wanted to write code fast i would just use Python

python itself isnt neccesarily fast. no language is guaranteed to be faster than another. its how you write it.

but its quite hard knowing that it takes in c++ 10 times what it does in python.

that probably means your trying to use c++ like python. it doesnt usually take 10 times longer to write

The syntax is insanely difficult, complex, and drawn out long[quote]
actually c++ has a very simple syntax. pythons is just incredibly simple

[quote] (apparently listing directories is high level?)
not really its platform dependent, (unles you use boost)

So i keep reading and things say that c++ is much better at low level programming than in python. Where? What low level programaming?
it is, that just means that you havent done much lower level stuff

That i could write a program for linux specific that goes 1.5 seconds faster than the same program in python, but python's program can also run in windows and python's program also took 10 times faster to write. I dont see the advantage here? Is that 1.5 seconds execution time really worth it?
your programs havent been that big then. the bigger the program the more speed is neccesary. and your python script only works if they have python installed. the exe only works on linux but you can recompile for windows and its guaranteed to work even if they dont have a c++ compiler (assuming the account has the rights to run exes)
python itself isnt neccesarily fast. no language is guaranteed to be faster than another. its how you write it.

i meant the speed at which to write the program

that probably means your trying to use c++ like python. it doesnt usually take 10 times longer to write

it takes 10X longer because there is 10X more syntax than python

your programs havent been that big then
The most of which i wrote in python was 4-5 thousand lines of code, within modules and modules. The program runs as it should, with no decrease in performance

the only part i disagree with is:
and your python script only works if they have python installed.

where for windows users, py2exe, and linux/windows can use cx_Freeze http://cx-freeze.sourceforge.net/
well linux doesnt matter anyways, because python is on pretty much every one by default
In which both do not require python to be installed on the users computer and creates an executable
Last edited on
closed account (Dy7SLyTq)
actually your are wrong. they make it an exe so your not running the script your running an exe. idk about cx-freeze (nvr heard of it before) but i have only seen bad reviews about py2*
closed account (Dy7SLyTq)
it takes 10X longer because there is 10X more syntax than python
no theres not. and its not that difficult to write c++ code. in python it may be quicker to write small little programs, but when you write major stuff c++ is easier imo
actually your are wrong. they make it an exe so your not running the script your running an exe

regardless, python does not need to be installed on the clients computer, which was the root of that conversation
closed account (Dy7SLyTq)
yes, but that exe wont be as fast, which as i said it might only be 1.5 seconds right now, but if you were to right a lets say new language, (assuming both people optimize it to the max of their languages) c++ will be faster to write, less of a headache, and be faster as an end product
what about maintainability? Ive often heard c++ programmers say that c++ can be optimised, but then at that point makes it unreadable, and hence hard to maintain.
Last edited on
closed account (Dy7SLyTq)
thats not true well at least not 100% of the time. it depends on the coder. if they are a bad coder they will say that, but there are plenty of projects maintained in c++. webkit, ubuntu (i think thats made in c++), python (well c but still) blizzard games, etc
Topic archived. No new replies allowed.