Monday, December 3, 2012

Google Brain Search: A Science Fiction Story by MC Complete


As I walked into the stairwell, I suddenly realized that I didn’t remember where I had parked in the morning.  So I took out my Android phone and opened the application “Google Brain Search”.

Google Brain Search is like Google Search, but instead of searching the internet, it searches your memories.  I typed in “car” as my search term and clicked on the checkbox that said “Show most recent results first”.

The first result read: “Parking my car in the morning.”  Achievement unlocked!  I clicked on the link.  My phone showed a message that said, “Please wait while we load the memory.”

After a few seconds, it happened.  I flashed back to the morning, when I drove slowly through the fourth floor with no open spots, and then saw many open spots on the slope between the fourth and fifth floor.  On the left side, there were two open spots between the white pillars.  I maneuvered awkwardly into the spot on the left, narrowly managing to park between the lines.

As I walked down the stairs to the fourth floor, I thought to myself, “Google Brain Search.  How did we ever live without it?”

Tuesday, November 13, 2012

Our Bodies, Our Souls, Part 2: Body Language

As far as I can tell, there is no word for “body” in Biblical Hebrew.  The word for body in modern (and Rabbinic) Hebrew is “guf”.  The word “guf” appears only twice in the Tanach, in Divrei Hayamim, and it means “corpse”, which is not exactly the same thing.  (Maybe the Tanach has another word for body, but if it does, I’m not aware of it.)

Souls, on the other hand, are all over the place in Tanach.  (The Tanach has three words for soul: neshama, nefesh and ruach.)

Our Bodies, Our Souls, Part 1: The Real Slim Shady

Two of the first of the Jewish morning prayers are “Asher yatzar” and “Elokai neshama”.  Some prayer books place them one after the other, and some prayer books insert the the blessings of the Torah in between.

“Elokai neshama” is about the soul, and “asher yatzar” seems to be about the body.  “Asher yatzar” is ostensibly about Man: it begins “Blessed are You, Hashem our God, King of the universe, Who created Man with wisdom.”  The blessing is not about the wisdom that is or is not obtained by human beings, but rather the Divine wisdom showcased in the design of the human body.

There’s a funny thing about “Elokai neshama”.  “The soul that you gave me is pure...in the future, you will take it from me...later, you will return it to me...” the soul is a gift that God gave to me.  So who am I?  Apparently, “I” am a body that happens to possess a soul, not a soul that happens to possess a body.  The Real Slim Shady is Slim Shady’s body, not Slim Shady’s soul.

“Asher yatzar”, the blessing of the body, reinforces this point.  God created Man.  What is “Man”?  Man is a magnificent, organic machine--a body.  I am a human being; a human being is a body; I am a body.

Tuesday, October 23, 2012

MC Complete's Guide for the Perplexed, Part 1: Prayer

Daniel: I don’t get this whole prayer business.

Isaac: Prayer is praise, requests, and thanks.  What is there not to get?

Daniel: What about the requests?  What is the sense in asking Hashem to do things for me?  Doesn’t He already know what I want?

Isaac: Yes, he knows what you want.  But most of the time, you don’t ask for the things you want.

Daniel: I don’t?  What do you mean?

Isaac: Every Jew has his own specific set of desires.  But we all say the same Shmone Esrei.

Daniel: That may be, but how does that solve anything?  Doesn’t Hashem know what I’m going to say?

Isaac: Of course not.

Daniel: What?  What do you mean?

Isaac: Hashem knows the text of the Shmone Esrei very well.  He knows it by heart.  But he doesn’t know whether you are going to say it.

Daniel: Wait a minute.  Are you saying that God doesn’t know the future?

Isaac: No, it has nothing to do with that.  All I mean to say is that if you say the Shmoneh Esrei you say it, and if you don’t say it, you don’t say it.  God’s knowledge of the future, as well as His knowledge of the text, is irrelevant.

Daniel: Are you saying that Hashem want me to pray so that I focus on the needs of the community rather than my own?

Isaac: Exactly.  Better to pray for the needs of the community and take care of yourself, than to pray for your own needs and take care of the community.

Daniel: OK fine, let’s take one of the blessings of the Shmoneh Esrei.  Let’s take Refaenu.  In Refaenu, I ask Hashem -- we all ask Hashem -- to heal the sick Jews.

Isaac: Right.

Daniel: Does my prayer make it more likely that Hashem will heal the sick Jews?

Isaac: Hashem will heal the sick Jews.  We know that for certain.

Daniel: Well, I suppose we know (almost) for certain that He will heal some, but we also know for certain that He won’t heal them all, at least until the Moshiach comes.

Isaac: And maybe not even then.

Daniel: OK, so does my prayer make it more likely that a greater percentage of the sick Jews will be healed?

Isaac: We don’t know.

Daniel: I mean, on what basis does Hashem decide what percent will be healed?  What factors enter into these kinds of decisions?  What motivates Hashem?  What is He trying to achieve?  Why did he make people sick in the first place?

Isaac: We don’t know.

Daniel: So what is the significance of my prayer?

Isaac: Hashem cares about you.  You are asking Him to heal the sick Jews.  He will decide what percentage, based on His own calculations.  That’s all we know, and all we need to know.

Daniel: OK, I don’t know if you answered my question, but you certainly confused me enough that I no longer remember what my question was.

Tuesday, October 16, 2012

Mocks: A Guest Post by Zach Lloyd

So, you wrote a test that uses mocks where you could have used real dependencies...

I have a few major issues with this style of test:

  • It tests implementation, not behavior.  Why should a test care what methods are called within a function being tested so long as the function behaves in accordance with its contract?  With these kinds of tests it’s often possible to change a function to use a completely equivalent implementation, and yet the test fails after the change.  In the extreme, test cases like this end up purely mimicking the implementation of the method under test (e.g. if the method being tested calls x(), y(), z() on its dependency, then you will see that exact same sequence of calls in the mock setup).  This ends up testing nothing at all.
  • You can't even write a test with mocks like this without looking into the implementation of the class under test, which adds a lot of complexity to test writing and maintenance.
  • It takes me a non-trivial amount of mental effort to read one of these test cases with mocks -- much more than reading regular code.
  • I've never believed the argument that it's somehow bad to test real code.  Unless the dependency is truly on something that's hard to test reliably (like a network), I think you absolutely should be testing the real dependency by default.  I know the testing people disagree with this, but I don't particularly care.  The tests should be on an environment as similar to the real application as possible IMO.

I do feel pretty strongly that tests that use mocks like this are bad, but I'll leave it up to you whether you want to change it.

Wednesday, September 5, 2012

Quantum Theology

IMAO, the biggest philosophical problem of Quantum Mechanics is the “measurement problem”.  According to Quantum Mechanics, “measurement”, or “observation”, collapses the wavefunction of a particle.  Particles behave one way when we are looking, and a very different way as soon as we divert our gaze.

(For more background on the quantum measurement problem, see my blog post  http://mccomplete.blogspot.de/2012/07/decoherence-and-flying-fish.html .)

It’s almost as if there are two worlds: the visible world and the hidden world.

I want to call attention to two differences between the visible world and the hidden world:

In the visible world, any given particle at any given time is in one, and only one, place.  But in the hidden world, at any given time, any given particle can be in more than one place.

The behavior of the hidden world is almost absurd.  If a particle is in two places at the same time, it shouldn’t be one particle anymore.  It should be two particles.  But it isn’t, it’s still only one.

In my arrogant opinion, this is a kind of miracle.  In conventional miracles, isolated events defy the laws of nature.  But in the quantum miracle, the laws of nature defy the laws of logic.

The hidden world is absurd and miraculous.  The visible world, on the other hand, is coherent.

There are miracles happening constantly all around us, but we can’t see them.  They’re hidden from us.

Now for the second difference between the visible world and the hidden world:

The hidden world is deterministic and the visible world is nondeterministic.  The hidden world is entirely governed by natural law; the visible world is influenced probabilitsically by natural law, but it is, in a sense, chaotic, lawless.  So the world behaves lawfully, but the lawfulness is hidden from us.  When we look, all we see is lawlessness.

Maybe Divine Providence is like this.  Maybe the world is lawful and just, but the lawfulness is hidden.  Maybe behind the veil of coherence, good things happen to good people, but when we look, all we see is lawlessness, chance, indifference.

Shiluach Haken, Part 2: The Reward for Mitzvot

In the end of Masechet Chullin, the Gemara tells the tragic story of a father who told his young son to climb up a tree and get some eggs.  The boy climbed up the tree, sent away the mother bird, lost his footing, and fell to his death.

The boy had performed two mitzvot: honoring his father, and sending away the mother bird.   The Torah promises a long life as a reward for both mitzvot.

Elisha ben Abuya declared, “There is no justice and no Judge,” and went off the derech.

Rebbe Akiva declared, “There is no reward for mitzvot in this world, but in the next world, there is reward.”

On the other hand, every morning after the blessings of the Torah, we recite the Mishna of Elu Devarim.  Elu devarim says that there are mitzvot that bear fruit in this world, while the principal is saved for us in the next world.  (One of the mitzvot listed in Elu Devarim is honoring parents.)

I think that the mitzvot have a component of prudence.  Following the mitzvot is often the most responsible way to act.  Sometimes the mitzvot good advice about how to act wisely and achieve our own self-interest.  For instance, if you do acts of chessed, the recipients will sometimes return the favor, and the members of the community will like you and give you honor and support.  The study of Torah pays off in thinking skills and self-control.

But the mitzvot are not all about prudence.  The mitzvot have a component that transcends prudence.  They have a component of compassion, of honesty, of humility, of yirat Hashem.

Sometimes all these core values overlap with rational self-interest.  But since they are distinct values, there is also a set difference, where following the mitzvot is not the best way to optimize for self interest.  Thus, burial of the dead is called “chessed shel emet”, because the recipient can never repay you.

When the mitzvot call for self-sacrifice, the reward may be in the next world.  When the mitzvot call for prudence, the reward may be(partly) in this world.

Prudence is probabilistic.  Statistically speaking, on average, people who honor their parents do better than those who neglect to do so.  But prudence gives no guarantees.  Tragically, there are those who honor their parents and get hurt nonetheless.  Rebbe Akiva teaches us that these people will be rewarded in the world to come.