# Today I Learned

Some of the things I've learned every day since Oct 10, 2016

## 132: PHP is Ugly

So I learned the basics of PHP today. My main takeaway was that it is a very, very ugly language.

I don’t really know what else there is to say about it. But I will try to illustrate.

$\texttt{for (item in iterable)}$

it’s

$\texttt{foreach (iterable as item)}$. A deliberate effort to make human readability less intuitive, I guess?

You have to start variable names with $\$??? Why.

$\texttt{strlen()}$$\texttt{strpos()}$$\texttt{strtolower()}$$\texttt{strtoupper()}$? Really?

Also, using $\texttt{.}$ for concatenation just so you can’t use standard dot notation.

How was all this syntax actually intentionally designed this way?

I just

## 131: Pierce’s Law

In classical logic, Pierce’s Law is the property that

$((P \rightarrow Q) \rightarrow P) \rightarrow P$.

Proof:

$(P \rightarrow Q) \rightarrow P$

$\Downarrow$

$\overline{P \rightarrow Q} \vee P$

$\Downarrow$

$\overline{\overline{P} \vee Q} \vee P$

$\Downarrow$

$(P \wedge \overline{Q}) \vee P$

$\Downarrow$

$(P \wedge \overline{Q}) \vee (P \wedge 1)$

$\Downarrow$

$P$

## 130: Consequentia Mirabilis

Consequentia Mirabilis, also known as Clavius’ Law (after the German mathematician) is the principal in classical logic

$(\neg X \rightarrow X) \rightarrow X$.

That is, it’s the principle that if a proposition’s negation implies the proposition, then the proposition must be true.

Its use is similar in form to that reductio ad absurdum. To use reductio ad absurdum, one assumes that a proposition is false, sees that a contradiction follows, and from this concludes that the proposition must be true. To use consequentia mirabilis, by contrast, one assumes that a proposition is false, sees that the proposition itself follows, and from this concludes that the proposition must be true.

## 129: UUIDs

Universally Unique Identifier (UUID) is a 128-bit number used to uniquely identify things, whatever those things might be, in computer systems. The way they are represented in text varies, but they typically look something like

123e4567-e89b-12d3-a456-426655440000

or

00112233-4455-6677-8899-aabbccddeeff,

with 32 hexadecimal digits being broken into 5 groups by hyphens. The usefulness of UUIDs comes from the sheer improbability of the same UUID being generated 2 different times.

To give an idea of the improbability: the number of Version 4 UUIDs you would have to generate to have at least a 50% probability of a collision would be around 2.7 quintillion. If a computer generated 1 billion UUIDs every second, it would take 85 years just to compute that many, and even then the amount of physical storage required would be around 45 exabytes, much larger than the largest databases currently in existence.

This is to say that for now, UUIDs are a very good way of uniquely identifying things with almost impossible collisions.

## 128: Git Commit Message Subject Conventions

Some conventions that should be followed when writing the subject of a commit message in Git:

• Separate the subject from the body (if it exists) with a blank line
• Keep the length at no more than 50 characters
• Capitalize the first letter, don’t end it with a period
• Use the imperative mood. For instance, “Update getting started information” instead of “Updated getting started information”, “Refactor X for readability” instead of “Making X more readable”.

Additionally, a commit message subject should convey information about not only what was done but also why.