admin管理员组

文章数量:1435208

I am new to puter programming and have some experience programming with python. I am thinking of developing a program that does physics simulations (projectiles, circular motion, damped simple harmonic motion systems etc.) as a hobby project. I would like to write the program that it could be run by a non-technical user(my fellow students) on a variety of platforms (mac, windows etc.) without any setup and python doesn’t seem to be a good option for building such a program so I am looking for an alternative. JavaScript has caught my attention, as it seems to be quite powerful on modern browsers, especially in conjunction with HTML5. I would like to know whether it is suitable to use JavaScript for this type application, and some information as to where I should start (I have no JavaScript knowledge) Thanks in advance!

Yes I did have a look at the similar threads on the site but I want write something by myself than using a 3rd party library (other than for the frontend, if possible) :)

I am new to puter programming and have some experience programming with python. I am thinking of developing a program that does physics simulations (projectiles, circular motion, damped simple harmonic motion systems etc.) as a hobby project. I would like to write the program that it could be run by a non-technical user(my fellow students) on a variety of platforms (mac, windows etc.) without any setup and python doesn’t seem to be a good option for building such a program so I am looking for an alternative. JavaScript has caught my attention, as it seems to be quite powerful on modern browsers, especially in conjunction with HTML5. I would like to know whether it is suitable to use JavaScript for this type application, and some information as to where I should start (I have no JavaScript knowledge) Thanks in advance!

Yes I did have a look at the similar threads on the site but I want write something by myself than using a 3rd party library (other than for the frontend, if possible) :)

Share Improve this question edited Nov 13, 2010 at 16:40 Tds asked Nov 13, 2010 at 16:02 TdsTds 11310 bronze badges 1
  • There's a decent amount of existing javascrpt on the web which uses physics behind the scenes, if you want to look at what others have done. – goat Commented Nov 13, 2010 at 16:50
Add a ment  | 

2 Answers 2

Reset to default 6

What is actually your question? :)

Can you write a physics simulation in Python?
Yes, of course.

Can you write a physics simulation in Javascript?
Yup.

Will it be useful?
Yes, probably.

Will it be efficient?
Not as efficient as an implementation with C, to be sure. But for small-scale simulations should you should have quite enough power with current JIT javascript interpreters. Tens or hundreds of objects on 30fps looks like a safe approximation, I think.

Can you make use of modern HTML when writing a physics simulation in JS?
The simulation and the display are two different things, but yes, if you want to make a graphics frontend to your simulation, the modern features of HTML and CSS could be certainly useful. But if you write it in any other language, you still have nice choices for visualization.

How to learn JavaScript?
There's plenty of tutorials online, but I don't know any particular one to remend; perhaps anyone else can fill for me here.

As mentioned by Kos languages that are as High Level as Python or Javascript might constrain you. But later on you can still move critical parts to C-Code. (-> Regular shared Library or even Browser-Plugin)

For JavaScript I remend you the Mozilla tutorials: https://developer.mozilla/en/javascript Check out the "JavaScript Guide" in particular and keep in mind that not every Browser supports JavaScript 1.7. By the way, you should also checkout jQuery. Actually it might be easier to start right off with jQuery because you need some highlevel library anyways.

By the way: You might also want to check out Processing. (www.processing) It might be perfect for you as you are new to programming and it has a lot of awesome vizualization features. It basically a simplified Java with a very easy to use library. You can checkout the pre-installed examples and start playing around. Be sure to check the Reference on the website / the forum if you are stuck with problems. Processing runs on the JVM and is therefore cross plattform. I remend Processing very much because you can directly see results and in any case it might be interesting for Prototyping even if you think of using another language in the future to suit your needs.

Actually there is even a JavaScript version of Processing though I never used it...

EDIT: If you plan to choose JavaScript, you should use Firefox in bination with Firebug. It makes life easier when debugging...

本文标签: javascriptWriting physics simulation appsStack Overflow