Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is F# suitable for Physics applications?

Tags:

.net

physics

f#

I hate Physics, but I love software development. When I go back to school after Thanksgiving, I'll be taking two more quarters of Physics before I'm done with the horrid thing. I am currently reading postings on the F# units of measurement feature, but I've never used a language like F#. Would it be suitable to write applications so I can perhaps learn something about Physics while doing something I like?

I'm interested in command-line applications (even those that I can just execute and have spit out an answer without needing inputs) for things like kinematics, planar motion, Newton's Laws, gravitation, work, energy, momentum and impulse, systems of particles, rotational kinematics and dynamics, angular momentum, static equilibrium, oscillatory motion, wave motion, sound, physical optics, electrostatics, Gauss' law, electric field and potential, capacitance, resistance, DC circuits, magnetic field, Ampere's law, and inductance.

The reason I'm interested in F# is because of the units of measure functionality that the language provides.

like image 401
Thomas Owens Avatar asked Nov 30 '22 07:11

Thomas Owens


1 Answers

In my biased opinion, F# is ideal for physics. It has a feature called Units of Measure which does dimensional analysis for you, providing errors if you get it wrong. For example if you write:

let distance : float<meters> = gravity * 3.0<seconds>

That would yield a compile-error, since gravity is < meters/seconds^2 > and not < meters >. This prevents a great deal of physics-related programming errors.

For more information check out Andrew Kennedy's blog.

like image 176
Chris Smith Avatar answered Dec 04 '22 13:12

Chris Smith