Smalltalk Continues to Evolve

I have so many interests that I find myself rotating between them in order to give each some small share of my attention. I sometimes go for extended periods of time without spending any time at an activity. Then I rediscover it and am intensely engaged by it for a while. Then, as abruptly as I renewed my interest I am on to the next one.

This weekend I rediscovered my fascination for the Smalltalk language. There are a couple of popular free implementations of Smalltalk, Squeak and Pharo. Pharo announced a beta release of their new 64 bit implementation for Linux and MacOS. I downloaded it and had a look. I was impressed with the advances that have been made in the system utilities.

I am drawn to a language that uses a single paradigm throughout. In the case of small talk that paradigm is object orientation. The language is written in itself and although some of its primitives are often optimized to native implementations there are reference implementations in Smalltalk available for browsing.

Another attractive aspect of Smalltalk is the fact that the source code for the entire system is available for perusal in the built in code browser. This inspires developers to use existing implementations of features instead of reimplementing them. If there is a need to modify or extend their functionality it can easily be accomplished by subclassing the original implementation.

Smalltalk was the inspiration for the promise of code reusability that was associated with object orientation when it first became a popular programming paradigm. Other object oriented languages have fallen somewhat short of that promise. It is primarily because few other languages come with the source code for the entire system as an integral part of the delivery. Or if they do, the language is implemented in a different language other than itself. This places the burden of being conversant with two different languages to take understand the fundamental features of the language. Often the built in classes are closed so that if you want to modify or extend them you have to reimplement them yourself.

Often the benefits of a language go beyond just its syntactic structure. Fundamental issues of philosophy, community, central repository for libraries, and availability of free implementations with good documentation and lots of example code are often as important as the basic structure of the language.

Java, Perl, Python, Ruby, and PHP serve as examples of what I am talking about. Each have their strong points and weaknesses but all have received the widespread use that they have for reasons beyond any merits they might have as programming languages.

It is also true that the best of languages are often passed over if they are the proprietary vehicles of large corporations. Such languages are subject to the whim of their owners who have been known to change a language in a new release only to break existing code written by their customers. It doesn’t take more than once to learn that you are better off using an open source implementation of an industry standard language.

Sweet dreams, don’t forget to tell the ones you love that you love them, and most important of all, be kind.

Keeping Your Focus on the Task at Hand

A friend of mine commented on the post about fiddling with formats that I wrote several days ago. He said that he just used HTML when he wanted to get a page to look the way he wanted. I understand that I always have that option but I view it kind of like I do writing a program.

When it comes right down to it, I can always write my programs in machine language. Then I can get the machine to do exactly what I want. Only I can’t really do that any more. The programs that I want to write have become too complicated for me to write them in machine language. It would make a task that I would spend an hour on in a high level language take days. And tasks that I might spend a week on in Python might take months to get right in machine language.

Not only is there the issue of sheer effort but there is also the fact that because it takes so long to solve a problem at all in machine language, I would be way less likely to spend the time on tweaking it and refining it than I would if it were written in a higher level language.

And finally, there is the heart of the matter. I’m not really looking for the most efficient solution, I’m looking for an adequate solution. I want to think about the problem domain not the intricacies of mapping the problem domain onto the bare metal of the computer. I like my abstractions, thank you.

What this means when it comes to the analogy with WordPress is concerned is that WordPress gives me a consistent layout and lets me concentrate on writing. I am as adept with HTML and CSS and jQuery and JavaScript and all the various mechanisms used to render the incredible web content that we have all come to take for granted. But developing web content that way is hard work. And when I sit down to write a blog post, I want to expend the bulk of my effort on writing.

Hence, I use WordPress. I could embed raw html to achieve my layout goals within WordPress. But then I would have to remember how I did it every time and I would, in all likeliness, not achieve the consistence of layout that I am striving for. I’d rather find a consistent solution that someone else has written that is 80% of what I’m looking for than to have to implement it myself.

Sweet dreams, don’t forget to tell the ones you love that you love them, and most important of all, be kind.

There’s No Such Thing as Done

I used to think there was a right way and a wrong way to write a program. I found myself on a quest for the elusive right way to implement whatever program I was attempting to write. I wrote and rewrote the code. I read articles and books on techniques and disciplines. Nothing seemed to make programming any easier.

Slowly I began to suspect that maybe there was a continuum from good to bad and most programs fell somewhere in the middle. I hadn’t given up on the idea that there was an absolutely right way to do things and an absolutely wrong way. I just had plenty of evidence at hand that there were lots of ways that were neither absolutely right or absolutely wrong.

I don’t know why it took me so long but I have finally figured out that there are no absolutes. There are only criteria against which any given solution can be judged. The key fact that I had been missing was that there is almost never a single criteria by which a program can be judged.

I have become a dyed in the wool pragmatist. If a program achieves its intended purpose, it is good. If you discover there is another attribute that you would like it to exhibit, you have added a criteria. Now the program may fall short of adequately achieving its purpose. This will require some thought and perhaps a rewrite of the original program.

This activity of rewriting became so common that it has been given a name. It is called refactoring. Refactoring is done by first implementing a test suite that exercises the features that are implemented in the program as it is. It is also good to check the program in to a source code management system such as Git or Mercurial or even Subversion. There are plenty of others but these three are popular right now. With your test suite and backup copy of your original program you can now confidently start refactoring your program.

There are a number of ways that a program can be refactored. Each one solves a particular problem with the code as it is at present. For instance, you may have output to a particular type of output device hard coded in your program. In order to continue to support your current favorite device while setting the application up for supporting different kinds of output devices you might refactor your program so that it calls a print method on an output abstraction class. Initially you would concentrate on implementing an output abstraction class that supports outputting to you current favorite device. You aren’t going to want to quit using it.

When you have written that code and tested it against your existing test suite to ensure that you haven’t broken something in the process of changing the way it works, it is now time to implement the code to write to the new device. You will want to make sure that the current test suite still passes and that the code that supports the new device works properly. After that you need to write tests specific to your new code and ensure that it passes those new tests. When they work, check the new code and the new tests into your source code management system. You’ve implemented your new feature and you are ready to start on the next one.

Oh and don’t worry. Someone will want the program to do something more or differently before you know it. You have job security for as long as you want it.

Sweet dreams, don’t forget to tell the ones you love that you love them, and most important of all, be kind.

Memories of Grandmother and Granddaddy

I remember my maternal grandfather was a jolly fellow. He loved to joke and sing. Often, he would get up early in the morning and start a pot of soup before breakfast. Then he would cook a big breakfast for everyone. He was in the restaurant business for most of his life. He had a big family. My mother had a sister and three brothers. She told me about waitressing for my grandfather.

One time when I was thirteen I went on a trip with my grandparents. We went to Saint Louis to visit my grandmother’s sister, Helen.  We were sitting around the table after dinner. The conversation turned to which direction the Mississippi River flowed past a point where there was a crook in it so that it flowed north for a short stretch before it turned back to flow south. Aunt Helen had the idea that north was uphill and south was downhill. My grandmother was trying to explain that this wasn’t so.

Every time when she had just about convinced Aunt Helen that there was nothing untoward about the river flowing north for a bit and then curving back around to the south, my grandfather piped in and said something like, “but that would mean that it was flowing up hill.” This would get aunt Helen confused and she would start arguing with my grandmother and my grandfather would sit there and laugh quietly to himself. He did this three or four times before he got tired of it.

The next day we went to see the Gateway Arch. It was newly completed and we rode all the way to the top and looked out the windows. Later we stopped at a Radio Shack. Radio Shack didn’t have nearly as many stores in those days and I had never been in one of them. I got their catalogs in the mail all of the time though. I bought a small audio amplifier kit. When I got home I soldered it together but I must have overheated the transistor. It never worked.

My grandmother was a Superintendent of a school system in Tennessee. She always had text book samples. I loved to read them. I remember one time when I was on spring break and she let me go to work with her. I was impressed with her office.

I started thinking about my grandparents when I realized that I am as old now as they were when I knew them. I don’t feel old. I understand now that they probably didn’t feel old either. Time sneaks up on you. Of course I stand a good chance to live a good bit longer than they did. Our medical science is a good bit more advanced than it was back then. It still makes me ponder my mortality though.

Sweet dreams, don’t forget to tell the ones you love that you love them, and most important of all, be kind.

Fiddling with Blog Formatting

WARNING: This post is primarily an experiment in how to format code in-line in a blog post. If you don’t understand this post, it’s probably because I’m doing a lousy job of explaining myself. I am concentrating on form instead of content. Tune in tomorrow and I’ll probably be back to making some kind of sense. And now, back to your regularly scheduled blog post, already in progress.

I found that there is a style pulldown in WordPress that lets me put preformatted source code in a blog post. Surprisingly enough, it is called ‘Preformatted’.  There is an example of how it looks in the box below.

def hello():
    print('Hello, world!')

if __name__ == '__main__':

There are better looking ways to embed source code in a blog post but this is the simplest one. Some of the other ways provide syntax highlighting to make the keywords of the programming language stand out. Most of them provide line numbers to make it easier to talk about the various lines in the program. I will investigate those tools and report back on them as I learn how to use them.

Since I have a piece of Python code to talk about, I will attempt to explain what the program in the box above actually does. When loaded interactively into a Python interpreter, it defines a function called hello() that prints the string Hello,world! on the screen.

If the file containing this code is run from the command line, the variable name is given the value ‘main‘. The code after the if statement at the bottom of the box checks to see if name is equal to ‘main‘ and if so, the function hello() is called in the body of the if statement.

If the code is imported as a library, on the other hand, name will not be equal to ‘main‘, so the body of the if statement will not be executed. The code that imports the file can then call the hello() function at its own discretion.

If you know Python, this post has probably been boring. If you don’t know Python, it has probably been confusing. This post has been more of an exercise in how to format code in a blog post and less of an actual tutorial on Python.

If you are interested in a tutorial on Python, look here. I will probably write more about Python in the future. I will make the code prettier next time. I will make the prose more illuminating. But there is just so much time available to blog each night and I didn’t have time to experiment with formatting and write riveting content in the same post.

Sweet dreams, don’t forget to tell the ones you love that you love them, and most important of all, be kind.

A Pixie has Stolen My Heart

We have a little Maltipoo puppy. We named her Pixie Woo. I think she imprinted on me. When we were at the breeders to pick out a dog, she stood up on her hid legs and and begged me to pick her up. I did. She rode home on my lap and by the time we got home, I was her human.

My wife tells me that Pixie cries for half an hour every morning after I leave for work. When I get home in the evening, she barks with glee and dances around on her hind legs until I pick her up and give her a hug.

And the affection goes both ways. I have never had a pet that I loved like her. She is such a smart girl. She has a large vocabulary and it’s growing all the time. She knows steak, chicken, and fish. She knows carrot and greenie. She loves carrots and greenies.

My wife plays a game with her where she gets her nose while saying “Boop!” She decided to be the “booper” and jumps up and tags our nose when we are playing the game.

When I call my wife to make plans for dinner, she asks our dogs what they want to eat. She goes through a list of possibilities. When she says something that they want, they high-five her.

I have spent a good part of my life studying computer science with the goal of creating artificial intelligence. Part of the challenge is coming up with a test for determining whether a program is exhibiting intelligence behavior or is just doing what it has been programmed to do. By all criteria I can think of both my dogs are extremely intelligent. But Pixie more so than Belle our older Maltipoo. One thing is for sure, I am lucky to be the human of such an intelligent, affectionate little dog.

Sweet dreams, don’t forget to tell the ones you love that you love them, and most important of all, be kind.

Ode to British Television

The BBC makes such exquisite documentaries. For instance, tonight they are running a documentary on Paris of 1928. He has taken us to the places where people were meeting, where the artists lived, where the musicians played. They explore the reasons that people flocked there. The philosophical and artistic ideas that it inspired. I am a big fan of PBS but the BBC outshines it in almost every way.

There are a few PBS shows that can hold their own though. Ken Burns’ documentaries illuminate American History in a style uniquely his. And of course Austin City Limits showcases the best of our musical talent. There are others but those two stand out in my mind.

I think it is probably because American television entrepreneurs are more interested in broad popularity. Thus we have Seinfeld where they have The Office. They sometimes attempt to import some of their shows to American television with mixed success. On the other hand, they have produced such extremely popular shows as Dr. Who and Sherlock. But these are not the Crown Jewels of British television.

Such shows as Midsomer Murders, Poirot, and Jeeves are just a few examples of the highest standards of both production and story telling. I’m obviously a hopeless anglophile but I think even those not nearly as obsessed with all things British will agree that the British produce engaging television.

The documentaries are the hidden gems though. They are usually standalone offerings on a given topic. They rarely exceed an hour and a half duration. But they inspire enthusiasm whatever their topic.

Sweet dreams, don’t forget to tell the ones you love that you love them, and most important of all, be kind.