Live data from Hacker News

Twenty five thousand dollars of funny money

rachelbythebay.com

1–10 of 175 posts

Re: Twenty five thousand dollars of funny money

#2
I'm confused how this was able to give out money before the new code was submitted to production. The author claims that both she and her coworker tested it before the code was submitted and they ended up with the extra $25k. Was this code only executed on the front end? Were there no checks in the backend to prevent employees from just pulling out whatever money they wanted?

Re: Twenty five thousand dollars of funny money

#4

Scalars like this are so dangerous. A New Type would help here, but this is much easier to say in hindsight.

One of the benefits of learning to program with Ada as the teaching language at University was the instinct to sub_type all the things. IF you're using a raw int you are probably doing it wrong.

Re: Twenty five thousand dollars of funny money

#5
> This is yet another reason why I say bare numbers can be poison in a sufficiently complicated system.

In Racket, I tended to use keyword arguments, and include the units in the keyword argument. For example, one library used `:velocity-mm/s`. (The `/` character is an identifier constituent, not some special operator syntax.)

In Rust, I'm going to try out using language features for static checking of some units (with 0 runtime cost).

Re: Twenty five thousand dollars of funny money

#7
I think I like the duck typing in TypeScript more than I dislike it.

But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”

Re: Twenty five thousand dollars of funny money

#8

I'm confused how this was able to give out money before the new code was submitted to production. The author claims that both she and her coworker tested it before the code was submitted and they ended up with the extra $25k. Was this code only executed on the front end? Were there no checks in the backend to prevent employees from just pulling out whatever money they wanted?

The way she said it ‘crashed’ and you could just reload the page, and that it was frontend work also points to browser js code?

So yeah I’m curious how that worked too.

Re: Twenty five thousand dollars of funny money

#9

I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”

type RobotName = string;

function foo(r: RobotName) {}

?

Re: Twenty five thousand dollars of funny money

#10

I think I like the duck typing in TypeScript more than I dislike it. But I still wish I could say “this function accepts a type called RobotName. It’s a string, but so is RobotUuid, and we don’t want that. So only accept, strictly, objects typed as RobotName.”

You can kind of do it:

  interface RobotName {
    value: string;
    type: "RobotName";
  }
Or if you don't want to make an extra wrapper around every object:

  interface RobotName {
      _phantomType: "RobotName";
  }
  
  function makeRobotName(name: string): RobotName {
      return name as any as RobotName;
  }
  
  function getRobotName(robotName: RobotName): string {
      return robotName as any as string;
  }
Presumably V8 is smart enough to inline the wrapper functions.
Post reply on HN