r/programming • • Dec 23 '12

Simulating a solar system with Python

http://users.softlab.ntua.gr/~ttsiod/gravityRK4.html
244 Upvotes

72 comments sorted by

View all comments

Show parent comment

6

u/jjo241 Dec 23 '12 edited Dec 23 '12

Equations are yucky with long variables names:

ke = 0.5*m*v*v;

vs

kinetic_energy = 0.5*mass*velocity*velocity;

For longer equations its harder to keep lines to 80 columns e.g:

p = n * R * T / V;

pressure = moles * gas_constant * temperature / volume;

Anyone who would write a code like this will instantly know what each symbol stands for. The biggest ambiguity is the units used (but that's a different issue).

7

u/zokier Dec 24 '12

Actually I prefer the long forms in both cases. And even the ideal gas law one is just 56 characters, ie well below 80 character line. And for longer equations, I think breaking it down with descriptive temporary variables (or some other way) would be beneficial in either way.