ProcAn 0.8

March 8th, 2008

I haven’t written about procan in a while but I have been quietly working on it in the background.   This release brings UI improvements, namely an ncurses interface as well as some other small performance improvements and optimizations.  If you are not aware of it, ProcAn is an adaptive process analysis tool meant to provide a cleaner and more interesting view of current system activities and users.   You can find more information about it along with the download link here: ProcAn project page

A lot of the algorithm improvements are still a work in progress and planned for version 0.9.

The Evolution of the Imperative Programmer

February 11th, 2008

Today I thought I would write a little about Haskell.  This year I decided to learn this language and revisit the world of functional programming.   After spending a month with it there are things that I understand much better, but I’d be lying if I said it was easy.

In order to learn Haskell, and functional programming in general, you really have to change the way you think about programming.   One thing that has been especially hard on me has been the type system where, in a non-strict language, types really can take on a whole new meaning.   Non-strict languages tend to have a little uncertainty about when expressions are evaluated so you end up defining functions which end up being totally different types than you expected take the problem of the IO() monad:

getAFile theFile = do
li <- readFile theFile
return (words li)

this function opens a file, breaks the file into a list of words and returns the list.   You might ask yourself why I didn’t do this:

getAFile theFile = words (readFile theFile)

afterall, it seems like the evaluation of readFile would happen immediately and it would return a String no?  Not quite… see, it actually has the type IO String.  As mentioned above, IO is a monad and monads extend the normal type system as well as storing function results and side-effects.   In light of this, however, the words function does not know how to evaluate.  but by doing this:

li <- readFile theFile

li will have the type that we really expact because it will contain the result of the evaluation. You should also know that return doesn’t do what you expect either… it has the net effect of converting the list of words into type: IO [String] which I do here because the next function that I will call will take this particular type.  return is a common and very useful thing to have when performing operations involving monads.

So as you can see… for an imperative programmer this can get pretty hairy.   I get the feeling that this will come a little easier as I understand more about the language.    I don’t want to give the impression that I don’t like Haskell, quite the contrary I think it is incredibly useful.  I set about thinking to use it as a prototyping tool for algorithms but  now I think it has a strong place in my repetoir.   Here’s a good example:

Computing the sum of a Geometric Series at a given itteration:  

Here’s something in C, just to have to compare against:

double gseries(double c, double r, int max)
{
int n;
double res = 0.0;
for (n = 0; n < max; n++)
{ res += (c * pow(r,n)); }
return res;
}

and now in Haskell:

gseries c r n = sum ( [(c*r^x) | x <- [0..n] ] )

Now lets look at something you can’t do in C:

gseries_inf c r = [(c*r^x) | x <- [0..] ]

This is basically an infinite list.   This is allowed because of Lazy Evaluation Haskell will only evaluate what it needs in order to give you the information:

*Main> (gseries_inf 1 1.9) !! 100
7.505162419825193e27
*Main> (gseries_inf 1 1.9) !! 1000
5.6702336219128545e278
*Main> (gseries_inf 5 1.9) !! 1000
2.8351168109564274e279

Haskell is well suited for a wide variety of tasks and has earned its own place in my toolbox.

Switching Hosts

February 2nd, 2008

I signed up for Dreamhost a little over a year ago.  When doing my initial research on value hosts this was, hands down, the best one.   I realized this last week while trying to set up a web interface to my Git repositories that I had outgrown them so I began looking for a new one.  One thing that I knew I wanted was to move from Shared Hosting to a VPS Host and the one I settled on was VPSLink.

I have been using them for a week now and my site responds noticably faster than with Dreamhost, which was sluggish at best… even during off-peak times.  The flexibility of managing my own server (albeit, a virtual one) is nice and I decided to offload mailhandling responsibilities to Google for my domain… which was also very easy.

The one thing you have to be carefull about with VPS Hosts is making sure you get enough memory for you needs.   I bought a plan with 256M of real memory and 512M of Swap.  After some tweaking of MySQL, Apache and a few other services my server has been running for a week without touching swap or coming close to exhausting the physical memory.

With an Ubuntu 7.10 Xen client I also ran into problems after upgrading and the system refusing to install the new libc6-xen.   If you experience this problem (some applications exhausting CPU resources and running at 100% inside of Xen client) you’ll need to download the libc6-xen package install it via dpkg…. hopefully this will be fixed soon, but it caused me several hours of headache.

Warfish.net

January 24th, 2008

Warfish.net is like a web-based version of Risk.  Completely turn based with email notifiers.   This is a shameless plug for this site… I don’t know the guy who runs it but it’s a hell of a lot of fun to play with friends.   If you’d like to try a game check out my recruitment page so I can invite you to a game:  http://warfish.net/networks/matburt

Multipurpose Gumstix Computer

November 9th, 2007

I’ve been working on this project for a little while now, it involves a couple of products from Gumstix.  A Connex 400xm-bt, a WifiStix-CF, and a GPSstix (which includes audio, lcd hookups, and gps).  This project is actually intended for multiple purposes including a wearable computer and a car computer.   I chose Gumstix because their hardware is pretty clever and includes schematics, plus they are geared around Linux.  I’ve completed part of my hardware set up by mounting all of the boards inside of a clear plastic case that I have cut to allow it to fit

With that out of the way I can focus more on the software side of things.   Gumstix has an interesting approach to their platform and development from the Linux side.   There are a few mailing lists, a sourceforge page, a Subversion repository, and a Wiki site.   In order to really make use of a gumstix device you have to be pretty familiar with Linux, and if you want to keep your system up-to-date with the Gumstix community you will need to set up a cross build environment for the ARM platform to rebuild the buildroot.  Gumstix makes this fairly easy and you can actually be up and going in a short time after you checkout the SVN repo and read up on how to do things on the Wiki site.  They utilize the menuconfig interface to set up what gets built in the buildroot (including target options), packaged applications, and the bootloader (U-Boot)

My only complaints are that development seems to be driven by  one individual with the help of a very loose community on the mailing lists.   The buildroot is horribly unpredictable on Subversion and nearly impossible to track, while stable releases are not very frequent.  Most people try to track the Subversion tree pretty closely and will post information about what is working in each buildroot revision.   Luckily there are some revisions that seem to get everything to work right… I had a great deal of trouble getting Bluetooth to work at first.   But I will say this… everything else has worked basically out of the box and I am satisfied.   I would love to see the project maintainers get a little better organized, the documentation is often out of date and somewhat misleading in places and I personally think they would benefit from having a more open and structured builtroot development process so that problems can be addressed more quickly and everyone can track the status of the hardware by buildroot revision to know what to expect when flashing a new filesystem and kernel to the device.

See my project page here for more information on this project.

After writing this, I noticed the following press release from Gumstix:  Press Release .  With someone  there to drive this we should see there software stability improve.

New Truck

October 11th, 2007

In sort-of the same vein as the last post, here’s the new ride:

Poor Car…

September 29th, 2007

… guess it’s time for a new one

.

Getting the Console Screen Dimensions Revisited

May 24th, 2007

Several months ago I posted a C function that will fetch the console screen dimensions for both Windows and Unix. Actually… there were two functions, one for the width and one for the height. I left it as an exercise for the reader to come up with the better implementation. I decided that I would post my revised version so that you can behold it in all its simplicity. When writing console programs I make heavy use of this function.


pair<int,int> getScreenDimensions()
{
pair<int,int> dims;
dims.first = 25;
dims.second = 80;
#if !defined (WIN32)
struct winsize screen;
if (ioctl(2,TIOCGWINSZ, &screen) == 0)
{
if (screen.ws_row > 0)
dims.first = screen.ws_row;
if (screen.ws_col > 0)
dims.second = screen.ws_col;
}
#else
CONSOLE_SCREEN_BUFFER_INFO screen;
if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &screen))
{
dims.first = (screen.srWindow.Bottom - screen.srWindow.Top)-1;
dims.second = (screen.srWindow.Right - screen.srWindow.Left)-1;
}
#endif
return dims;
}
...and there ya go. Beauty and Simplicity.

‘Getting Things Done’ and other tools

May 21st, 2007

Lately I have been so swamped with crap that I’m working on that I’m finding it difficult to prioritize what needs to be done, especially on the micro-scale.  As an engineer I like to break things down into small, easy to digest pieces that can be completed easily and whose existence can be combined with many other small pieces to make up the whole of the project or task that I’m working on.
This methodology has worked well  for me in the past when I have had a limited number of projects and tasks and I could easily keep track of them in my head or in a little notebook that I carry around with me everywhere.   Lately, however, I have realized that this is just too monumental of a task and things end up slipping through the cracks and never getting done… not a problem I’m used to having.

Enter Getting Things Done.  I completely dislike it when people (motivational speakers, psychologists, psychiatrists, etc) try to come up with the magical process that will make you more productive.  This is different, however, in fact… it’s so simple that it is beneath me why anyone would register a trademark on it… though I bet this guy is making a killing selling his books.  While he is probably the same kind of kook who stands up and gives motivational speeches at a local Holiday Inn his ideas are good ones.

The truth is that you do not really have to buy the book to get what he is saying and it is greatly dependant on you and potentially the tool you use to help you. Historically I’ve been a fan of my little notebook even if after a little while it starts to fall apart. I decided that if this process was going to help me I had better find something a little more durable.

I searched around for some simple software that was free, easy to use, and completely accessible. It seems that most software written for this concept is Mac based (I wonder what that says about Apple users?) which doesn’t work for me since I don’t plan on buying a Mac.  Even Linux and Windows software probably wasn’t going to be good enough since setting up my laptop would probably take longer than quickly entering something in, or checking something off my list.   I figured web based software was the way to go… that way I can just whip out my PDA, problem solved.  After looking at a few things I settled on Tracks.  Which is an outstanding application, and is very simple to use.  In fact, in the arena of web based GTD software… this one stands out as being the best, especially since I don’t want to pay for it, and I especially don’t want it hosted on someone else’s server.  This is an RoR project which I simply uploaded to a new subdomain on my webhost.  It’s brilliant and my wife can even post things she wants me to do, though I’m not sure if that’s a good thing just yet.

The one drawback right now is that the Ajaxiness does not play very well with Mobile IE or Opera. I think this will be resolved when Opera Mobile 9 is released, which I am eagerly awaiting. After having used this for the last two weeks it has done wonders for my productivity.

This also got me thinking… there are some other tools which I would love to have as web-based applications that would simply make my life easier. A notetaking application, for instance, something similar to MS OneNote which is, hands down, the best notetaking application I’ve ever used. Another good example is Personal Accounting Software. I have used GNUCash in the past, and it is actually pretty terrible as far as what it is designed to do, but then again…. Quicken and MS Money are not a whole lot better.

The major downside of most software like this is that it doesn’t work for me in the context of needing this functionality even while I’m not sitting at my primary workstation. It has to work better than GNUCash, and it has to be free, and I don’t want to have to sign up to some other on-line service to use it. I think these two applications would work well in this domain because they give you the ability to benefit from them without being tied to one computer and especially without being tied to one vendor.  All of the rest of the applications that I use are fine by me staying standalone. This is probably due to the nature of how we use computers today… there is a whole other discussion that needs to take place on the likelyhood that web-apps are the way of the future.

Thoughts on Ruby

May 12th, 2007

After having heard about it for a while from some very respected sources I decided to give Ruby a try.  I had heard that it had a very similar feel to Python.  After using it for a weekend I can really agree with that statement.  It really is no more or less powerfull than Python, nor can I say for certain that one would be easier to learn than the other.  I think Python and Ruby are excellent languages for the beginner programmer.

That is one of the things I have always loved about Python is that it is both easy and flexible.  Aside from being easy it is also quite capable of advanced tasks.  I think I would still favor using Python simply because I have used it for a long time and there is no compelling reason to switch entirely to Ruby though I would be more open to working on a project in Ruby.

I still find myself dropping back to C and C++ for some tasks.  I encountered a situation a few months ago, doing natural language parsing where the raw speed of C was needed to decrease the analysis time (by several orders of magnitude!).  The presence of tools like Swig allow you to write those time-critical pieces in C and use them in you Python (and Ruby).