Moonside

Moonside wrote (edited )

I actually first stumbled into rational number data type when I was 12 or 13 and learning Lisp (but that story didn't end well and which totally gave me a misleading view of how principled programming languages were). I think all the major functional languages have them as it's not hard to implement as an abstract data type. A super basic is just a product type of two integers and call one the numerator and the other denominator and implement the operations accordingly.

Even Coq has them and if Coq has something implemented, it's probably pretty widespread in Haskell, Standard ML, OCaml, Scala and various Lisps and what have you.

If you really want some numeric nonsense:

  1. Bad implementations of complex numbers. The rectangular form a + bi is good for sums and re^(iθ) for multiplications. Ideally there should be one type for complex numbers and two classes like data Complex = Rectangular a b | Polar r θ in Haskell. This works ok if there are sum types, but apparently this is too avant garde for most languages.
  2. The Haskell numeric tower makes zero sense and is implemented with type classes, which isn't first class and is antimodular to the extent I recommend beginners only use library defined ones and not make your own like at all for a while at least. Like the Num class for numbers: you need to implement the operations (+), (*), abs, signum, fromInteger, (-) where abs and signum are total party poopers as basically what Num is is a mathematical ring with an extra operation. But, for example, complex numbers don't have a notion of absolute value defined for them so this turns sour quickly. I don't know what would make the situation better, however. They'll never fix this, probably.

Also if you want to read a rant about Booleans... this is pretty good. Every time I'm writing a function that takes a boolean parameter, I split it in two functions or somehow avoid testing for equality in the function. Thus pattern matching is bae and matching constructors is heaven sent. The author's piece on why dynamic languages aren't a thing at all is good too.

Phew, I'm glad that I got all that out of my system!

3

Moonside wrote

They represent real limitations for games (not really, but let's pretend)

They do, actually, if they're used for tracking time. If the game runs long enough (very possible in server-based online games), the physics increasingly start to go wonkier as the simulation becomes less and less fine-grained.

They're susceptible to flaws (different hardware might do different fast float maths - bad for speedruns, maybe? but also not a big deal at all)

It makes things more difficult for emulators, also in subtler ways like different kinds of conventions for rounding. I do wonder if these could be accounted for somehow, there are computations for which accuracy, reproducibility, making sense on a semantic level and so on are importanter than the pursuit of SPEED.

Other places we see floating points where fixed points could work just as well:

  • Anything dealing with percentages (likely bounded 0 to 1, or 0 to 100.)

I do wonder how well that actually works. While for probabilities it is always the case that for any event X, 0 ≤ P(X) ≤ 1, you can have steps in calculations that go out of these bounds. For example, 0 ≤ P(AB) = P(A) + P(B) - P(AB) ≤ 1, but if P(A) = P(B) = 1 then we'll have P(AB) = 1 + 1 - 1 = 2 - 1 = 1, where of course 2 > 1.

Also my shout out to humble rational numbers: the opportunities for using them are rare, too rare perhaps, but you feel clean like after having a bath when you do get to use them.

2

Moonside wrote

Reply to comment by toasthaste in Taco Bell has fries now by devtesla

Based on everything I know about Taco Bell not having ever the opportunity to eat there, it seems to me that it's mainly just that it's so greasy. Nothing has so far managed to convince me otherwise.

5

Moonside OP wrote

I can't avoid making up a conspiracy theory that QuickCheck library presently exists as an advert for QuviQ AB and this perhaps goes even further for the Erlang version. Good enough to become somewhat well-known and whet your appetite and then when you get serious, you need to bring consults in.

I was only testing simple mathematical properties (semigroup/monoid/group/Abelian group laws and involutivity) where generator specificity doesn't matter that much. The properties are so general that if a fault was discovered, it would taint a function for all inputs, even accidentally correct.

The one upshot of the whole shebang was that I got to reimplement some stuff as groups and I could just feel the power rushing through my veins ad hoc 'negation' functions into invert ones. Actually now I looked more into the docs and noticed that Haskell also has Abelian groups as a type class and I added them too to my types.

(It would be really nice if there was something that could automatize writing tests for common typeclasses. I have two types that have instances of semigroups, monoids, groups and Abelian groups and doing tests like I did means that testing their properties and a direct consequence of one took 14 tests which is kind of gross when you could write generic code.)

for what little its worth ive had an easier time using stack with haskell instead of cabal, but only because the book i was learning from used it. but googling for solutions to haskell problems has gotten more difficult now that there's two competing toolchains

I tried out Stack because there's some Emacs tooling around that, but the tooling was quite brittle which soured me a bit on that. There seems to be some amount of Stack related drama in the Haskell community and some people I've learned from have a strong distaste for Stack in favor of Cabal. I'm not in a place to know enough to switch and the problem wasn't really Cabal related. Rather it was, in the small, that the solution involved Template Haskell and sequencing IO actions both of which I haven't done before and, in the large, that no-one has bothered to write documentation or a tutorial on the bird's eye view of things. Or what a best practices could be, I'm not Haskell literate to just see what popular packages are doing.

2

Moonside wrote (edited )

this was always such a shit meme, but honestly Ugandan Knuckles has overtaken it in how it annoys me. Also the meme shits on Wakaliwood, which is actually some amazing film making if you're ask my opinion. Want everything be covered in lava? They'll make it happen, even if it doesn't quite work out. Everyone in an Ugandan village knows kungfu? Well yes, though they might lampshade it.

Also all the '& Knuckles' memeing I've done, I regret it so much now, has Heaven abandoned me????

2