News for hackers. Stuff that matters.
Re:The Norway Problem by _kdhr on Saturday April 03, 2021 @05:26AM (#26679514)
That’s a shrewd observation. Static types help with this somewhat. E.g. in Inflex, if I import some CSV and the string “00.10” as 0.1, then later when you try to do work on it like

x == “00.10”

You’ll get a type error that x is a decimal and the string literal is a string. So then you know you have to reimport it in the right way. So the type system told you that an assumption was violated.

This won’t always happen, though. E.g. sort by this field will happily do a decimal sort instead of the string 00.10.

The best approach is to ask the user at import time “here is my guess, feel free to correct me”. Excel/Inflex have this opportunity, but YAML doesn’t.

That is, aside from explicit schemas. Mostly, we don’t have a schema.

Re:The Norway Problem by dalbasal on Saturday April 03, 2021 @08:36AM (#26680558)
If we're talking about general problems, then I don't think we can be satisfied with "sometimes it's a problem with types and sometimes it's a UI bug." That's not general.
Re:The Norway Problem by alpaca128 on Saturday April 03, 2021 @09:37AM (#26680931)
> E.g. sort by this field will happily do a decimal sort instead of the string 00.10.

So that system is not consistent with type checking? How is this not considered a bug?

Re:The Norway Problem by _kdhr on Saturday April 03, 2021 @04:15PM (#26684355)
I mean if the value is imported as a decimal, then a sort by that field will sort as decimal. This might not be obvious if a system imports 23.53, 53.98 etc - a user would think it looks good. It only becomes clear that it was an error to import as a decimal when we consider cases like “00.10”. E.g, package versions: 10.10 is a newer version than 10.1.

Types only help if you pick the right ones.

Re:The Norway Problem by jhugo on Saturday April 03, 2021 @10:38PM (#26686477)
Sure. In most static type systems though, you would be importing the data into structures that you defined, with defined types. So you wouldn’t suddenly get a Decimal in place of a String just because the data was different. You’d get a type error on import.
Re:The Norway Problem by BlueTemplar on Sunday April 04, 2021 @09:14AM (#26689164)
And of course the plague that is CSV when your decimal delimiter is ,