Hacker News new | ask | show | jobs
by hmaarrfk 1547 days ago
I typically stick to "SI" units.

Then, somebody asks me to code in the temperature of a system. And I have to think: "Is now really the time that I want to teach people the difference a kelvins and celsius?"

So my rule becomes, SI "except" temperature. Sigh...

8 comments

We also strictly stick to SI however we usually say kilograms in var names to be clear.

Haven't come across temperature however we would probably stick with kelvin.

We use a strict set of units in databases and while processing, conversions are localized if necessary only at the view layer.

We also only use UTC for date/times.

We only use E164 format (without spaces etc) for phone numbers: e.g. +12345678901 for an example number in OH, US. see National format https://libphonenumber.appspot.com/phonenumberparser?number=...

We only use iso3166-1 country codes and iso3166-2 region codes and translate on view.

This, one million times this. Use SI units. Don't measure distance in hotdogs, time in fortnights and speed in hotdogs per fortnight! It is as stupid as it sounds.

If you do, be explicit about it either in parameter or function name. I'm not going to put you on my shitlist if you're naming your function `microsleep`, but if I have to go look into implementation to see that you count timeout on your database in microseconds (looking at you, couchbase, like you ever could return something from a larger dataset in microseconds, lol) or, even worse, cache expiry time in minutes (hello unknown developer), I am going to go on the internet and complain about you.

This is actually an issue with thermal imaging cameras. Typically you'll get calibrated readings back in Kelvin, not in Celsius. Usually it's well documented by the camera manufacturer, but if you're providing an API to users you need to make them aware what the units are and make a decision on what you're going to return. For example this crops up if the sensor only provides counts which you need to convert into a temperature.

From a hardware perspective it makes sense to use K because you can encode the image directly using unsigned numbers plus some gain to allow for fractional measurements.

But you're still including the units in your identifier names (or encoded in type system), right?
No. Typically SI is implicit. Everything else is explicit.
SI doesn't prescribe that you have to use a single unit for all measurements. Are distance in meters or kilometers? Weights in kilograms or grams?

I assume you always just use the base units? kg, m, s, etc.? (I always think it odd that kilogram is the base.) I feel like could get weighty for some applications of a different scales when milligrams, millimeters, kilometers, days, etc. could be clearer. And even if you use "standard" units, if you aren't clear about what standard you use and what that makes that units, people won't always guess the correct option.

which is great when you're writing from scratch, but as soon as you have to start calling a library with functions based in non-SI units then you've got some ambiguity.
There should be a exception in every code standard that says SI units are OK where otherwise all lower case is enforced. Example to use mega (M) vs milli (m).
MKS or CGS?
CGS is so the sixties!
I'm confused, because one delta degree Celsius is exactly the same as one delta degree Kelvin. And you can convert with an offset.
In thermodynamic calculations you likely need absolute (Kelvin) values. But in many calculations where only temperature difference is used, either unit works equally well.
That sounds like a case for Kelvin. I still don't see why Celsius is the one exception that isn't SI.
I'll take a survey tomorrow to see how many people know what kelvin to C conversion is off the top of their head.

The other issue is when you get to Candelas!

How often are you doing the conversion manually? It seems like the sort of thing that should happen in the presentation layer so people never see the actual Kelvin amount. If you have a system where you always use SI then it's strange the have a single exception for temperature.
Hm, is it wrong to dream of a world, where this along with other basic science, would be considered basic knowlege?

Not blaming anyone who does not know it, but I would argue for more and better science education ..