A short essay on multitasking.
A poem for Japan
Healing
Two days ago, I stepped over a plank of wood
and walked past a barren tree.
My family and I hugged mugs of thin tea
and huddled around a kerosene heater set to low.
I almost wish it weren't so peaceful.
Yesterday, I watched a heron
glide along a riverbank.
It's whiteness a stark contrast
to the fragments of houses and overturned cars.
I almost wish I hadn't seen it.
Last night, I watched a crescent moon
in a cloudless sky.
The blackness of a city without power
produced stars unlike I have ever seen.
I almost wish I had just gone to bed.
Today, I stepped over a plank of wood
and noticed a lone cherry blossom on a branch.
Its pink petals fluttering in the moist wind
at once delicate and strong.
I almost wish life were not so beautiful
and so resilient.
Using RAII to simplify using the Lua stack when writing C++ code
I recently found myself doing a lot of this sort of thing.
bool lua_t::load(const std::string& filename)
{
lua_pushcfunction(state_, traceback_function);
if (luaL_loadfile(state_, filename.c_str()) != 0)
{
lua_pop(state_, 1);
return false;
}
if (lua_pcall(state_, 0, LUA_MULTRET, -2) != 0)
{
lua_pop(state_, 1);
return false;
}
lua_pop(state_, 1);
return true;
}
The “sort of thing” I’m referring to is restoring the state of the Lua stack at every exit point from a function which manipulates it. In the above case, I had to use three distinct calls to lua_pop to achieve this. Today, I found a new approach that can simplify dealing with the Lua stack from C++.
struct stack_bookmark_t
{
explicit stack_bookmark_t(lua_State& state_)
:
state_(&state),
top_(lua_gettop(state_))
{
}
~stack_bookmark_t()
{
lua_settop(state_, top_);
}
private:
lua_State* state_;
int top_;
};
The motivating example changes to this.
bool lua_t::load(const std::string& filename)
{
stack_bookmark_t bookmark(*state_);
lua_pushcfunction(state_, traceback_function);
if (luaL_loadfile(state_, filename.c_str()) != 0)
{
return false;
}
if (lua_pcall(state_, 0, LUA_MULTRET, -2) != 0)
{
return false;
}
return true;
}
At every exit from this function scope, the destructor of stack_bookmark_t ensures that the stack height is restored to its prior state.
On publishing
In this day of instant gratification publishing, traditional journals, who take their time to cultivate each issue by working with their authors and painstakingly formatting their content are starting to seem somewhat old fashioned. Nonetheless, I find their vetting process useful in collecting valuable content targeted at specific audiences.
I recently had an idea that I wanted to publish in a C++ trade magazine, any of them would do. I pitched my idea to Dr. Dobb’s, a rather prestigious computer programming publication and Overload Online, the free journal of ACCU, a community of programmers interested in things C and C++ related. Overload was interested in my idea and complimented me by reviewing a draft but they noted that another author, Martin Moene, had presented a very similar idea, and encouraged me to write a follow on article. I ultimately decided against writing the follow on article and, at first, I was crestfallen at being scooped. Martin’s idea and mine are nearly identical in spirit if a bit different in execution. But, more important than the individuals involved are the ideas and I’m glad these ideas are now firmly in the public domain where developers can benefit from them regardless of who presented them first. (I’m laughing at myself a little in writing this last sentence but I resonate with the sentiment.)
So it is with a great deal of satisfaction at both my personal triumph over my own ego and at the honor of being part of this discovery that I present to you my original draft of this technique.
I owe a debt of thanks to Scott Meyers who honored me by giving me feedback on an early draft and for teaching his course on Effective C++ in Embedded Systems which inspired me to look harder for a solution to the problem this technique aims to solve.
Jala neti
Slightly more familiarly, the humble neti pot is a centerpiece of my life. If it were a more well-known a part of our culture, I might display my neti pot as a centerpiece of my living room. St. Thomas Aquinas may have waxed poetic about wine. Let me, for a moment or two, attempt to do the same for my beloved neti pot.
For the uninitiated, jala neti is the practice of running a warm saline solution through the sinuses to remove debris, mucous, etc. It also has the side benefit of conditioning the tissue in the sinus and nasal cavities by applying slight osmotic pressure to the tissues and membranes thereby drawing some of the water from the cells. I’m sure future science will prove that this is a good thing. Personally, I think it feels dreamy.
I use my neti pot every day, sometimes twice, once in the morning and once at night. I am prone to environmental allergies and clearing the olfactory slate is an absolute necessity for me in order to breathe clearly through both nostrils.
You could say I’m obsessed with breathing. I work a job which is physically very sedate and my breathing suffers. This brought me to the neti pot and the neti pot brought me to yoga where I learned and continue to study breathing exercises. I firmly believe that if the breathing is smooth and clear, the mind is smooth and clear. Anything is possible with the proper breathing.
If you find that you are breathing only through one nostril or otherwise have an occasional or frequent impediment to continuous clear breathing, I suggest putting down the loratadine, cetirizine, or other antihistamine and pick up a neti pot. It’s cheap, natural and, to shamelessly use a contemporary buzzword, sustainable. After you get over the weirdness of purposefully putting saltwater in your nose, you’ll be a devotee forever.
Chado
Chado, as my teacher at Urasenke Seattle, Bonnie Mitchell encourages me to call it in English, or sado as my Japanese friends encourage me to call it when I speak Japanese, is the art of Japanese tea ceremony. Chado (茶道) literally translated means the way of tea: 茶=ちゃ=cha=tea, 道=どう=do=way=path. The do in chado is the same do as in kendo, the way of the sword, and bushido, the way of the warrior.
Chado is an ancient practice which originated in China and was imported to Korea and Japan. Chado was passed down through generations of Zen masters who dedicated their lives to perfecting the art of tea. Its roots in Zen inform the minimalist aesthetic of the tea room, the meditative nature of the ceremony, and basically every other aspect of the art.
The ceremony itself can appear subdued or affectedly formal on the surface but every person in the tea room from the host, to his guests, to the last object in the room plays an active role in creating the experience. The host must choose the objects in the room with a sensitivity to the environment, the season, and the occasion. The guests must learn and follow the established protocol of the tea room. The host imbues every motion with meaning and each guest gives purpose to the host by her participation. Like in tennis, or anything for that matter, there is duality in the tea room. Every query from either host or guest has a natural response. Every motion has a counter motion. Especially in this aspect, the Zen philosophy comes through. The art of tea is an expression of harmony. Yin and yang incarnate.