Archive for February, 2009

Baby steps with Ioke

Wednesday, February 18th, 2009

I now am ready to take some first steps with Ioke. If you would like to install it for yourself and try it out too, you can follow the instructions or follow the Hitchhiker’s Guide. I used the instructions for a vanilla install, but it looks like the Hitchhiker’s Guide goes into far greater detail.

I’ve now installed basic Ioke on Windows and Linux and it was painless in both cases, which was an unexpected pleasure. Once installed, you can fire up the REPL with a simple ioke at the command line. What you are presented with will look something like this:

1
2
rubyyot@atlas:~$ ioke
iik>

You are now ready to play with Ioke. It is quite different from what I’m used to. I would recommend that you try out the interactive mode as well to get your feet wet. That way you will get immediate feedback.

A few things stand out immediately when playing around with the language. The first is that there is no dot notation. Second are the concepts of cells and Ground. Third is the that it is a prototype based language.

It’s not a dot, it is a period

Object oriented programming is supposed to be littered with dots, it’s part of the language. Without the dots how are we supposed to tell where one word stops and the next begins. This is insane!

Or is it. English doesn’t use dots to separate it’s words. Tell.me.does.this.look.like.a.natural.sentence.to.you? No, it really doesn’t to me either. Asthetically, it’s only slightly betterThanCamelCase. Ok, so I get it, the whitespace separates the words , or in this case they are called messages. You may ask, “What is a period good for?” Let’s go to the REPL and find out.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
iik>; "hello world" println
hello world
+>; nil
 
iik> "hello world" println. "hello ioke" println.
hello world
hello ioke
+> nil
 
iik> "hello world" println "hello ioke" println
hello world
hello ioke
+> nil
 
iik> "hello world". println
*** - couldn't find cell 'println' on 'Ground_0x17B4DFB' (Condition Error NoSuchCell)
 
 "hello world"                                    [<init>:1:15]
 
The following restarts are available:
 0: storeValue           (Store value for: println)
 1: useValue             (Use value for: println)
 2: abort                (restart: abort)
 3: quit                 (restart: quit)
 
 dbg:1>

Wow, so what’s all that? Well I evaluated 4 statements using the REPL. The first one simply told Ioke to print the string “hello world” on the screen followed by a new line. So far so good, I’m now past the obligatory Hello World command. The line beginning with +> displays the return value of the evaluated statement. In this case it was nil, which should be familiar to those who have used Ruby and for anyone else, it means the same thing as null.

The next expression that I evaluate is two println statements each followed by a period so that the compiler will know that I handed it two statements. Sure enough, we see that both lines are printed. So, the period can be used to separate statements. Or can it, the next experession yeilds the same results without a period in sight. This is an interesting development. Perhaps I had it wrong.

To test my theory I decided to try placing a period between the string and the println message. What happened was that I got an error saying that println is not valid for Ground. Even though I’m not entirely sure what ground is at this point, it’s fairly obvious that the placement of the period caused the println message to be called on something other than the string I passed it. As a side note, the error was nicely caught by the debugger which prompted me for an action to take.

Ground, Origin and cells

So let’s see what this Ground is that the debug message was talking about. According to the documentation:

Ground is the default ground/context for evaluation.

Meaning that Ground is a high level object that is the default context for evaluation of a message. For this to become a little clearer, a little background of the Evaluation Model helpe. Here is an excerpt from the wiki that helps sort it out. It takes the code foo bar(flux bar) quux and breaks down the evaluation into steps.

  1. The message foo is sent to Ground, which is the current ground and also the default receiver.
  2. The message bar is sent to the result of the foo message. The value returned will be activated.
  3. The cell bar contains a method in this case, and that method expects one argument, so that forces evaluation of the arguments.
  4. The message flux is sent to Ground, since it’s the ground and there is no prior message inside of an argument list.
  5. The message bar is sent to the result of the flux message.
  6. The result of the bar message is used as the argument value given to the outside bar method.
  7. The message quux is sent to the result of the initial bar message.
  8. The result of the quux message is thrown away, unless this code is part of a larger piece of code.

Here we see what it means when we say that Groud is the default context. The messages foo and flux have no receiver (there are no words preceding them in the execution model) so the receiver is defaulted to Ground.

Lets now take a closer look at objects in Ioke. Each object has an infinite (at least that is how I see it in my mind, there probably is some sort of limit on it) number of storage containers called cells. You can name these cells and fill them with stuff. You can fill them with data, and objects. These would be considered cells filled with content that is not activatable. Here are some examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
iik> foo = Origin mimic
+>  Origin_0x26FBCA:
 
iik> foo cheese = "Cheddar"
+> "Cheddar"
 
iik> foo answer = 42
+> 42
 
iik> foo
+>  Origin_0x26FBCA:
  answer                       = 42
  cheese                       = "Cheddar"
 
iik> bar = Origin mimic
+>  Origin_0x19A1925:
 
iik> bar size = "little fish"
+> "little fish"
 
iik> foo stomach = [ bar ]
+> [ Origin_0x19A1925:
  size                         = "little fish"
]
 
iik> foo
+>  Origin_0x26FBCA:
  answer                       = 42
  cheese                       = "Cheddar"
  stomach                      = [Origin_0x19A1925]
 
iik> foo stomach[0]
+>  Origin_0x19A1925:
  size                         = "little fish"

Here I’ve made two objects, each of these objects mimics Origin. Origin being an object designed to be the starting point for other objects. It seems to be a bit lower in the object hierarchy than Ground.

You can also put activatable content in the cells, these are methods (he behavior component of the object). Here is an example using the previous objects:

1
2
3
4
5
iik> foo ask = method(question, answer)
+> ask:method(question, answer)
 
iik> foo ask ("What is the meaning of life, the universe and everything?")
+> 42

Here, I’m simply creating a method that takes a parameter called question and always returns the value of the cell answer. Because a method is activatable it is executed when the cell is referenced.

Mimics and prototypes

Ioke is a prototype based language, this is a concept that I’m having the most difficulty with. I’ve spent so much time working out the relationship between classes and objects, and here is a language that does away with the concept of classes altogether. Instead of using a class as a template for a new object instance, the new object mimics an existing object. This means that the templating comes from an instance of an existing object. I’m going to have to get used to this one.

Well I’ve cracked the seal on Ioke and it’s been a pleasant experience that still seems a bit foreign. I’m going to work with it some more and hopefully post some interesting things that I find.

Ioke: Fear of a folding language

Tuesday, February 17th, 2009

Have you ever signed up tp do something because you knew it was something that you should do?  You are all charged and ready to go and you really don’t have to spend any effort in making the decision.  You know you want to do it.  Still, you don’t do it, at least not right away.

A couple weeks go by, and occasionally your internal alarm goes off, telling you that you need to stop procrastinating and get it started. Yeah, I know how that is.   It’s been a couple more weeks than that and I haven’t started learning Ioke.  Sure, I’ve been busy.  Not so busy that I couldn’t have done anything.  Just busy enough that it’s been a good enough excuse.

Well, I’ll be honest.  There’s another reason why I haven’t started working on learning Ioke yet.  Truth be told, Ioke scares me a little.

Now don’t get me wrong, it’s a very interesting language;  one that I am very much wanting to learn.  It’s just that it’s outside of my comfort zone.  It’s foreign, and it uses strange terminology like mimic and Ground and macros.  It knocks me down a few notches, tells me that I may have learned other languages, but it’s different, it won’t crack so easily.

Of course, that is optimal.  I wouldn’t want to attempt to expand my horizons with a year of  Python because I already know Ruby and while there would be some lessons and perspectives to learn, my time would be better spent with something further outside my comfort zone.   Java would be a similar issue, already knowing C#, eye opening moments would be minimal.

The very fact that Ioke both interests and pushes me out of my comfort zone makes it the perfect candidate for me to learn.  It presents a challenge which is just what I need.

Knowing this, it is just a matter now of powering through the initial learning curve and getting on with the benefits.  Yeah I know, I’m getting to it.  Meanwhile, are there any goals that you have set for yourself in 2009 that you have having a hard time starting?  What is holding you back?  Anything that is pulling you out of your comfort zone?

S.O.L.I.D. not that there is anything wrong with that

Friday, February 13th, 2009

Today, I’ve listened to the two podcasts that have been spawning cries of “heresey” and “zealot” from around the net. Those are of course the Hanselminutes interview of Uncle Bob and Stack Overflow Poscast #38.  These have stirred up a lot of commentary regarding S.O.L.I.D principles,  Star Trek races, semanticsgeology and construction and some general ranting.  Needless to say,  I’ve enjoyed it a great deal.  It’s great to see so many people in the .NET and the developer community at large getting so passionate and vocal about these topics.

Before I go on any further, I would like to say that I very much enjoyed reading Uncle Bob’s book Agile Software Development, Principles, Patterns and Practices.  It is one of the better technical books I’ve read.  So I have a great deal of respect for the man, he knows his stuff.  Personally, I would never say that he “doesn’t code very much”, unless I was being sensational.  Doing so would be both unprofessional and hypocritical on my part.

Apart from that, what seems to be under fire is how frequently to use SOLID principles, best practices, etc.   Are you, as a developer, being a greater asset by simply hacking out a solution of trivial to moderate complexity in the shortest amount of time, or are you a greater asset by remaining disciplined and sticking to SOLID principles most, if not all, of the time.

Underneath it all, there is an interesting question asked here.  One that I have struggled with and I am reasonably certain that you have too.

How much should you test, abstract and otherwise follow proven best coding practices?

  • When Bob says that each consumer of a service should have it’s own interface to it, does he really mean every consumer?  Isn’t that wasteful?
  • When your programming mentor mentions that you really shouldn’t write any code that doesn’t fix a failing test, does he really mean that all production code typed in should be the minimal possible to pass a test?  Does he realize how much test code that is?
  • When adhering to SOLID principles should you really confine all new keywords to your factories and place everything in your IoC container(s)?  Seriously?  Even the boring little classes?

I’m sure you have answers to all of these questions.  I’m also fairly certain that you could add at least a couple more questions to this list.  Regardless, I think that these are reasonable questions to ask.  Ones that every developer asks themselves at some point or other.

Of course, with these and so many other difficult and somewhat abstract questions there is no simple black or white answer.  My answer is “It depends.”

To answer these questions you will more than likely have to ask yourself a series of other questions.  Some of these may include:

  • What is the worst thing that will happen if this system blows up at any given time?
  • How will my actions affect developers (myself or otherwise) working with my code in the future?
  • What is the return of my investment of time, if I follow what I believe to be the best practices?
  • Do I know enough about this topic at all to make informed decisions at all?
  • If I follow what I perceive to be best practices against my “other (better?) judgement”, how likely am I remain disciplined on this project?

I’m sure there are a number of others that you see missing from this list as well.  What it boils down to, is that we want to produce great or perhaps simply good software in a timely manner, and enjoy it. If this wasn’t the case,  you wouldn’t care about practices, principles or pineapples.  The question isn’t if SOLID principles have their place, it is, “is this their place?”  It’s not a question of do I want quality, it’s “am I willing to go to this extent, when I don’t see a benefit?”  None of us like to write more code than necessary to achieve our goals.  Writing excess code can be frustrating.  So can learning.  But learning is what we are doing.  Your gut instincts as to what is or is not excessive use of principles and practices will likely change over time.  I can’t say if you will use them more or less with experience, but looking at the credentials of the folks out there teaching us, my guess is that you will find yourself using them more.

Follow as many best practices as you can maintain both your discipline and your enjoyment with.  After a little time, re-evaluate.  If something isn’t working out, tweak it.  If something is turning out to be a good thing, try adding some more.  This isn’t a formula driven profession and no two people will be happy coding in exactly the same way.   Use your best judgement, and remember that we don’t know everything, yet.

Introspection – February 2009

Thursday, February 12th, 2009

2009 is shaping up to be a year as full of change as 2008 was, if not more so.  The primary difference is that this year I’m ready for it, or at least ready-er(?).  It’s mostly a state of mind that I’m working to maintain.  This year my mantra is:

Change is good, it brings opportunity.  Be ready for anything.

Being ready for anything is not as easy as it sounds when you have spent a good part of your last ten years trying to settle into a comfortable routine.  This plan has, by the way, failed me in each of the last ten years.  It simply isn’t maintainable.  Life has had a way of shaking me up when I get too settled in.  Either that or I have an evil twin that is working diligently to make sure that I am constantly struggling.  Personally, I prefer to believe the first option since it makes me feel a bit less like a paranoid psychotic.

In the midst of my readiness, I have set a number of goals for myself to achieve in 2009.  These are generally in the category or personal improvement and more specifically intended to keep me from becoming a big, fat, coughing wannabe programmer sitting around all day wondering why life is passing him by.

So without further introduction, here are my goals for 2009 and how I am doing with achieving them.

  • Spend more family time - I’m continuing to fail here.  Need to improve quickly.
  • Quit smoking - Funny that this goal was the one I thought that I would ignore throughout the year, but I’ve done it.  It’s been over a month since I quit smoking cold turkey.
  • Continue learning in Ruby and .NET – While I went through a stretch of good growth here, the last week or two have brought a loss of momentum and motivation, hopefully this is a temporary bit of downtime.
  • Learn Erlang Learn Ioke – While I would still like to learn Erlang, I’ve officially jumped ship to Ioke on this one.   I have the ‘S’ release installed on my new laptop and I just need to start using it.
  • Exercise frequently – Quitting smoking has had me putting on the pounds, primarily because of energy drinks.  I’ve now switched to coffee and tea and, now that the weather is warming up a bit, I am walking on most days.
  • Stop trying to organize, and start simplifying – Completely derailed on this after a minor victory involving a trip to storage and the goodwill donation station.
  • Become financially stable – I’ve started an emergency fund, which is really not all that exciting.  Except for me, since I’ve never had one and in this case, my opinion is the one that counts.
  • Contribute – No progress as of yet.
  • Teach – No progress here either.
  • Enjoy the journey- A mindset that I need to continue to nurture, because I haven’t really done this, at all.

Next month I’ll check back in an see how I’m doing with these goals.  Good luck with all of yours.

Anathem – The book advertised to people who watch movies.

Thursday, February 12th, 2009

I make it no secret that my favorite author is Neal Stephenson.  Not only did I like The Baroque Cycle, I loved it.  In the Beginning was the Command Line was one of the reasons I took interest in Linux in the first place.  The fact that my wife named her computer Snowcrash is just a minor reason of the many reasons that makes her so cool.

I’ve been waiting anxiously for news of his next book, and a few weeks ago I  was delighted and surprised to find that he had not only announced a new book, he had released it as well.  So, without further ado, I fired up Amazon.com and ordered myself up a copy.

While I was still in surprise and shock about the new book announcement,  I noticed something out of the ordinary about the webpage Neal Stephenson posted for Anathem.  There is a trailer for the book on the page.  Yes, a video trailer for the book.  Upon first sight I thought it was sheer genius to promote your book with a video trailer like you would find for movies or even music in the form of music videos.

Well, I’ve now received the book and am about 130 or so pages into it.  One of the things that struck me about the book early on is that he paints a world where only a small percentage of people can read or even bother to be educated at all.  The majority of the world is illiterate, incapable of rational thought; spending much of their time recording and watching movies (he calls them speelys) and talking on cel phones.

I found it ironically funny that the first book I’ve ever seen with a trailer would have such a theme.  Yet it is a valid statement about the world we live in today.  Much of our entertainment comes from watching recorded media of one sort or another, and a good portion of the rest of our time is spent using a phone.

As you can tell, I am greatly enjoying this book and hope to have a chance to write some more about it by the time that I am done with it.  I would also be doing you a dis-service if I didn’t recommend that you read some of his writing, if you haven’t already.  Perhaps you could start with Cryptonomicon.