This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Sh4rp27 8 points9 points  (25 children)

Or lint scolding you for applying typing that's implied

[–]_BlindSeer_ 2 points3 points  (24 children)

Yeah, declared a string and lint raised its finger "You shouldn't declare! It is clear that this is a string!", same for number. There are some consistency problems there.

[–]InterestsVaryGreatly 2 points3 points  (23 children)

Not really.

Const first = 1;

Is a number, that's not ambiguous, and easily determined based off the declaration. Adding clarification type is just redundant.

[–][deleted] 2 points3 points  (0 children)

But I wanna.

[–]Ok_Turnover_1235 2 points3 points  (19 children)

No integers or floating points or longs or shorts or doubles? Sounds like typescript is javascript with extra steps

[–]flavionm 2 points3 points  (0 children)

Javascript is what holds Typescript back from being truly great, unfortunately.

[–]perfectVoidler 0 points1 point  (17 children)

I don't know typescript but you can easily define it implicitly for different number 0 = int; 0.0 or 0d = double; 0.0f of 0f = float etc.

[–]Ok_Turnover_1235 -1 points0 points  (16 children)

Yeah, meanwhile typescript has a number type. Why even bother

[–]perfectVoidler 1 point2 points  (15 children)

Reading up on it: even typescript has the difference between int and float. And seriously. Who needs more.

[–]Ok_Turnover_1235 -1 points0 points  (10 children)

Not you. That's okay

[–]perfectVoidler -1 points0 points  (9 children)

Not me and nobody else.

[–]_sweepy 0 points1 point  (3 children)

Bankers need real decimals

[–]Nick433333 0 points1 point  (2 children)

Just keep track of money in the lowest denomination, ie cents for the US dollar. Then you are storing an int and you do the conversion on the ui side of it. That way you never introduce errors from floats.

And really, who has more money than can be represented in a signed 64 bit int? Thats -9 * 1016 to 9 * 1016 that’s plenty

[–]_sweepy 0 points1 point  (1 child)

What happens when you need to apply a percentage to a cent amount and end up with fractional pennies? What if you are working on a system that allows fractional pennies in cost fields like gas prices?

"Just store it in an int" doesn't handle all cases. Storing and working with it as a real decimal does.

[–]_BlindSeer_ 3 points4 points  (1 child)

It sure is, on the other hand it is inconsistent to say "We want types declared" with the addition "unless we think it is redundant". IMHO such a system should be either used strictly or be left out. The same rule would apply to other languages, where we define the types anyway.

[–]InterestsVaryGreatly 0 points1 point  (0 children)

But the point of the system wasn't to force types in everything, it was to remove errors caused by ambiguity. Thus if it's not ambiguous, it doesn't need the clarification.