Monday, May 6, 2024

Why Uniform Function Call Syntax matter

Uniform Function Call Syntax (UFCS) is a computer language pattern that allows commands/procedures/functions to be called in visually different ways.  Why is this important?  Why should any programmer care?

Readability.

90% of programming time is reading what somebody wrote in the past, not writing new code.
90% of programming is bug fixing and refactoring.

Oh, wait, what is refactoring?  Changing the code to make it more readable.  Not faster.  Not more efficient.  More readable.

UFCS allows code to be more readable.  That's all it does.  That's all it has to do.

Which of these is more readable to you?

                                                                                                 Listack
1 add 2        Swift                    operator / infix style                1 add 2
add 1 2        Haskell                prefix style                               add: 1 2
add(1, 2)      C                         procedure call style                  add(1, 2)
(add 1 2)      LISP                    Lisp style                                 (add: 1 2)
1 2 add        Forth                    method call / postfix style       1 2 .add

These are all valid program snippets from different languages.  They are all readable to varying degrees.  They are all in different styles.  They are all equivalent.

UFCS, especially as implemented in Listack, allows you to use whichever one is more appropriate at the time.  Want to us standard function call?  Do it.  Want to chain together a bunch of functions in a pipeline on a single piece of data?  Do it.

Function chaining example - which is more readable?  They all do the same thing, resulting in 3.  (There are more possible variations.)

1 5 3 .sub .add
(add: 1 (sub: 5 3))
add: 1 sub(5, 3)
add(1, sub(5, 3))
1 add sub(5, 3)
1 (5 sub 3) .add

Listack has the additional advantage that infix operators (+, -, etc.) are not special.  So you can use a simple '+' instead of 'add' when creating your own procedures.

1 + 2     --> 3
"Hello " + "there!"     --> "Hello there!"
myCustomThing1 + myCustomThing2        --> myCustomThing3

Monday, April 29, 2024

No, we are not all the same

2021 is probably the last year we have somewhat reliable crime data from the FBI.  We know that every year since then has had the data cooked, folded, spun and mutilated.  When, that is, the Leftist cities even bother to send the (mandatory) data to the FBI at all.  When, that is, they Leftist cities bother to record the crimes at all.  When, that is, the crimes get reported in the Leftist hives at all.

These are conviction numbers.




Black women are more likely to commit murder than white men.  By these statistics, 4.5% of all black men are convicted murderers.  It's true that some of them will acquire multiple convictions over their lifetimes, and that will skew the numbers a bit, but that's not a glowing endorsement of our "criminal justice" system, is it?

Wednesday, April 17, 2024

Commodore 64 beats quantum computer

A 40 year old Commodore-64 home computer beat out IBM's new, multi-million-dollar quantum computer at its own test.  It was just as accurate, faster, more energy efficient, and far cheaper, too.  And it doesn't need a cryogenic chamber to operate.

Quantum computing is analog computing.  It's not quite a scam, but it's almost indistinguishable from one.  You can accomplish the exact same things through hydraulics.  In fact, the hydro-economic simulator built in 1949 is still working, and is still a more accurate simulation of economic activity than most digital computer models.

New hydro-computers are still being built.  And they can outperform digital computers at specialized tasks.  Digital computers were built to excel at general tasks.  Their whole point is that they are programmable, where analog computers are specialists at single tasks.

Tuesday, April 16, 2024

Yet another task resolution system

Yes, I enjoy making up rules for fantasy combat games.  It's a weird hobby, but it's a hobby.

Basic premise:  Character skill and item quality are measured in size of dice:  d4 (low) to d12 (high).

Mechanism:  In any endeavor where chance plays a role, the active player rolls a skill die and an equipment die, and adds them together.  The target likewise rolls skill + equipment, but may be using different equipment.  Bonus add to the size of a die, penalties reduce the die size.  Bonuses beyond d12 add to the total.  Penalties below d4 subtract from the total.  Defender/target wins ties.

Say a dwarf (melee d8) swings an axe (melee d8) at an orc (skill d6) with a shield (d8) and sword (melee defense +1).  That ends up being d8+d8 versus d8+d8.

If the attacker rolls higher than the defender, damage is dealt.  For simplicity, let us say one point.  For every 5 points the attacker beats the defender's roll, additional damage is scored.

Say a dwarf (melee d8) swings his axe (melee d8) at an orc (skill d6) with a shield (d8) and sword (melee defense +1).  That ends up being d8+d8 versus d8+d8.  If the dwarf rolls a mighty 14 while the orc rolls a pathetic 3, the orc will take 3 damage (1 for success, an additional 2 for rolling 10 over), killing it.

Say a thief (skill d6) is using his second-hand tools (quality d4) to pick a double-locked door (quality d8, 2 successes needed).  That ends up being d6+d4 versus d8.    If the thief rolls well and gets a 7 versus the door's unlucky 2, the thief achieves 2 successes, freeing both latches during one action.

The advantage of this system is that even a kobold with pointy stick can hit a high level fighter in heavy armor with sword and shield.  It won't happen very often, of course, but it is always possible, since your minimum roll (with equipment) is a 2.  It also highlights the need to have both skill and equipment, as having only one or the other means you roll but a single die, putting you at a distinct disadvantage.

If you're using a large number of hit points, you can either subtract the defense from the attack, or consider the defense roll to be a threshold, and count the full damage of any attack that rolls above it.  Either way, you would generally ignore the "5 over" rule, unless you want to add in some sort of combat options like stunts and feats.

You can add in rules for critical failures (all 1's) as you see fit.  I use them to degrade equipment quality/durability.  You can add in a rule for critical successes (maximum possible die rolls), but this system rewards low skill/quality that way.  The "5 over" benefit fills that niche for me.

Magic equipment allows a static bonus to the die roll, raising the minimum possible roll, which is quite valuable.  Low quality gear uses a lower die type, while exceptional quality gear uses a higher.

Sunday, March 31, 2024

HE is risen!

And light and hope return to the world.  Happy Easter everyone!

(Except you, Pedo Joe Biden.  You're going to burn in Hell.)



Thursday, March 28, 2024

Demystifying h and h-bar

h was the beginning of quantum physics.  It represents the indivisible quanta of light.  To get a photon's energy, you multiply its frequency by h.  The frequency is, mathematically, the inverse of the wavelength.  In other words, h represents the circumference of a circle, the amount of ink you would use drawing one wavelength.


All images are as found on the internet.  Credit to whomever made the things in the first place.  I can't draw.

That's easy enough.  But what is h-bar (ħ)?  It is h divided by 2π.  That makes ħ the radius of the circle.  (The circumference of a circle is 2πr.)  In other words, ħ is the null-to-peak amplitude of a photon.  Which photon?  Every photon.  That was the insight that eventually led to quantum physics.

While we're here, the Heisenberg uncertainty theorem states that the uncertainty in the momentum of a particle, times the uncertainty in its position, cannot be less than ħ/2.  In other words, their product cannot be less than half the amplitude of a photon.  Which certainly makes sense, because you couldn't possibly measure anything less than that size by any means.  Notice that this distance is minuscule!  So when you hear people say that you can't know the position and momentum at the same time, they're talking nonsense.  Of course you can.  But there is an absolute limit to the ability to measure something of that ridiculously small scale of precision.  (Notice we're not talking about absolute size, we're talking about the precision of a measurement.)  Not just because of the tooling involved, but because it really doesn't make any sense to talk about distances smaller than ħ/2, because a circle smaller than that is less than the amplitude of a photon, and there is no such measurement.  Not with any tools.  Not even conceptually.  In addition, the minimum arises because when you work out the math, at the smallest scales, the uncertainties (precision) in position and momentum sort of end up being reciprocals, just like frequency and wavelength.  The less you have of one, the more you get of the other.

Contemplate and compare this relationship with the minimum sampling rate of digital audio, which must be at least twice the maximum frequency of the audio signal being sampled.  If you tried to sample at a lower rate, the result would have no relationship to the original signal.

Sunday, March 24, 2024

No, space is not curved

Space is flat.  What does this mean?  It means that the three familiar dimensions of space (x, y, z) obey the Pythagorean principle for Euclidean space.

0 ≤ (x2 + y2 + z2)  ≤ c2 

But what does this mean?  x, y, and z are not deformations, but velocities, so they have an intrinsic time element which we usually ignore.  No, it's not proper (subjective) time.  This is the home of true, objective time.  Yes, it exists, because it must.  After all, light propagates and changes over time, without experiencing any time itself.  But it is routinely ignored, for reasons which completely escape me.  (Note that the axes of a spacetime diagram are true distance and true time.  But we, for some reason, must pretend that these don't exist.  Possibly because we, being made of matter, can never actually experience them?)

It would be easier and more intuitive to replace the awkward x, y, z with a simple v for velocity, ignoring the actual direction, which is immaterial for this narrow purpose.  

0 ≤ v2 ≤ c2 

Of course, nothing with mass can travel at the speed of light.  By similar logic and a careful examination of the meaning of quanta, it cannot remain perfectly stationary, either.  To do so, the particle must give up that last bit or momentum.  But there is no way to drop that last bit, because it is less than the smallest quanta of energy transfer.  So we may simplify the expression slightly for normal matter.  (Notice that a photon either travels at the speed of light, or stops existing, but never anything in between.)

0 < v2 < c2

Spacetime, on the other hand, is not flat, but hyperbolic.  This is because proper (perceived, subjective) time is imaginary, and when you square it, out pops a minus one.

0 < (v2 - t2) < c2 

Oddly enough, you can negate the central term, and it still holds true.

0 < (t2 - v2) < c2