Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I use 'ruby-units' with ruby's 'irb' in order to do complex unit calculations. It's an excellent library and with some helpers one can write:

    (U('45 mi') / U('1.20095 gal')) >> 'km/l'
It doesn't come with an imperial gallon, but it could be added. It's also fun to do stuff like:

    (U('3.99e33 ergs/s') / (4 * Math::PI * U('1 AU')**2)) >> 'W/m^2'
To get the potential available solar energy output at earth's average orbital distance from the sun usefully expressed as Watts per Square Meter.

Anyways, what I really got from unit analysis was a more useful and fundamental understanding of electronics. Getting an intuition for how Tesla's relate to Weber's relate to Volts and Ohms and how the Coloumb relates to the Ampere and Siemen and how they all combine into Henry's and Farad's both to ultimately lead you right into Joule's and Watt's. I really wish I was taught the material that way.



Similar library for Julia is Unitful.jl (https://github.com/PainterQubits/Unitful.jl).




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: