r/ruby • • 4h ago

What I learned 60 years ago

I just started to read "Elements of Programming Style" (Kernighan & Plauger). I was first taught FORTRAN 60 years ago. I guess you never forget. I understood the Newton's method and the commands on page 4 and think I might have a chance to rewrite it in Ruby. Too much to do at home right now. Probably won't get back to it until after the holidays.

All encouragement and guidance will be appreciated.

4 Upvotes

1 comment sorted by

1

u/Zestyclose-Turn-3576 2h ago

That'll be interesting.

I did something similar to the opposite. Having done FORTRAN77 many years ago, and since learned Ruby, I implemented a simple solar system model in modern object oriented Fortran.

So that was built out of objects like:

  • Coordinate, which could be created as cartesian or polar.
  • Vector: a pair of Coordinates
  • Body: Coordinate plus mass plus name
  • VelocityVector: Unit vector plus speed magnitude
  • ForceVector etc

It made the physics pretty simple, as you could take any pair of objects and ask the pair what the force vector was between them.

Do you think you'll be trying to make an object-oriented version of the code?