Earlier quoted context omitted.
In the mid-2010s I worked at a company that switched from using raw ints to refer to database rows to using (in C# terms) "Id ". Across the entire codebase, we discovered an entire class of bugs that only never cause any issues because all the important rows in all the important tables had Id 1 (e.g. Currency 1 was USD and Country 1 was USA) - so in a few places where the ints got mixed up, the correct row was still…
Oh wow. Was there a “stomach sank to the floor” sudden feeling upon discovery?
Twenty five thousand dollars of funny money
171–175 of 175 posts
Re: Twenty five thousand dollars of funny money
#172Earlier quoted context omitted.
The way that things work at this particular company is that you typically test changes in this codebase on your dev machine, but usually the dev machine talks to a prod database. The prod database is too large to practically have a second copy sitting around for testing. Also, if you tested on some pristine small test database you're going to end up missing bugs that would only manifest with actual prod data.
I get it but that just seems really dangerous. I hope they have a lot of guard rails and roll back support or something.
Re: Twenty five thousand dollars of funny money
#173One of the first programming languages I learned was TI BASIC on the TI-89. It had an excellent units (refinement types) system: you could define an expression as a "unit" by prefixing a variable with an underscore, and it came with a bunch of built-in units. A unit expression could thereby automatically convert between types as needed, outputing the base unit. E.g. `5_dollars + 8_cents` would output `508_cents`. The…
Looks neat. Of course you can do this in c++.
F# has a refinement type system built in (which allows this), and of course Haskell and Idris are sufficiently capable in their type systems to trivially support it, but none of those are particularly mainstream general-purpose programming languages. Mainstream languages pretty much all need some sort of library for it, which is unfortunate since they're extremely useful in many common programming problems.
Re: Twenty five thousand dollars of funny money
#174Re: Twenty five thousand dollars of funny money
#175Earlier quoted context omitted.
Looks neat. Of course you can do this in c++.
Of course, templates are sufficiently complex metaprogramming to achieve this. But it's not a language built-in, or even part of the standard library. F# has a refinement type system built in (which allows this), and of course Haskell and Idris are sufficiently capable in their type systems to trivially support it, but none of those are particularly mainstream general-purpose programming languages. Mainstream languag…
One would have to make a library with various classes representing various units, plus the (implicit) conversion between them. It´s probably something that exists somewhere.