Back in Germany

Posted by Daniel on August 15, 2009
Miscellaneous / 4 Comments

After more than a month out of the country, I am now back in Germany. Where have I been the last month and a half? Well, I got married at the end of June and my wife and I went to Venezuela for a honey moon and to meet the family. We saw Angel Falls, the Guacharo Cave, lots of beautiful beaches, thermal waters, hadcrafts and more. The trip was spectacular, and I’m pleased that my wife got to meet my whole family. Now I’m glad to be back and I’m eager to get back into the world of Perl and open source. I hope to have an interesting post next week.

Embedding Parrot in Perl 6

Posted by Daniel on June 20, 2009
Perl 6, Programming / No Comments

One of the interesting things about Rakudo is that you can embed Parrot assembly code (PIR to be exact) into Perl 6 code. With this you can optimize critical parts of the code and you can expose additional Parrot features to Perl 6. Let’s start with a hello-world example:

Q:PIR {
	say "Hello world"
};

Though it is not obvious right now, the stuff inside the Q:PIR { ... }; is parrot code.

Parameters

Of course, embedded Parrot code would be pretty useless if you couldn’t send parameters in and get results out. Here is a simple Parrot routine that takes two parameters, adds then and returns the result:

sub ($a,$a) = (3,4);
sub $result = Q:PIR {
	# Input.
	$P0 = find_lex '$a'
	$P1 = find_lex '$b'

	# Compute the sum.
	$I0 = $P0
	$I1 = $P1
	$I2 = $I0 + $I1

	# Return it.
	%r = box $I2
};
say $result;

Yes, that’s quite verbose. PIR is not much higher level than an assembly language. The $P0, $P1, … are Parrot registers. The $P* registers hold Parrot objects, and the $I* registers hold integers. A more interesting example would be a factorial function:

sub factorial(Int $n where {$n >= 0}) {
	return 1 if $n == 0;
	return Q:PIR {
		# Define variables.
		.local int ans, n

		# Input.
		$P0 = find_lex '$n'
		n = $P0

		# Compute the answer.
		ans = 1
		LOOP:
			ans *= n
			n -= 1
			if n > 1 goto LOOP

		# Return it.
		%r = box ans
	};
}
say "5! = " ~ factorial(5);

Exposing Parrot libraries to Perl

A specially neat feature of embedded Parrot is that you can expose Parrot libraries to Perl. For example, Parrot comes with support for the MD5 digest function, which itself comes from the OpenSSL library:

sub md5(Str $text) {
	my $binary = Q:PIR {
		.local string text
		.local pmc digest

		# Input.
		$P0 = find_lex '$text'
		text = $P0

		# Load digest library.
		$P1 = loadlib 'digest_group'
		digest = new 'MD5'

		# Calculate the digest.
		digest.'Init'()
		digest.'Update'(text)
		$S0 = digest.'Final'()

		%r = box $S0
	};
	# Convert to hex.
	return join '', map {sprintf '%02x', (ord $^a)}, $binary.comb;
}
say md5("The quick brown fox jumps over the lazy dog");

The resulting library is of course much simpler and runs much faster than anything we could code in pure Perl. And this will run wherever Rakudo is available, without the need for a separate compilation step.

Perl 6 and the Josephus problem

Posted by Daniel on June 12, 2009
Perl 6, Programming / 6 Comments

The Josephus problem in Perl 6, Python and Ruby

In today’s post, I would like to compare the OOP syntax of Perl 6, Python and Ruby. To this effect, I decided to show you an implementation of the Josephus problem in each language. Wikipedia describes the Josephus problem:

There are people standing in a circle waiting to be executed. After the first man is executed, certain number of people are skipped and one man is executed. Then again, people are skipped and a man is executed. The elimination proceeds around the circle (which is becoming smaller and smaller as the executed people are removed), until only the last man remains, who is given freedom. The task is to choose the place in the initial circle so that you survive (are the last one remaining).

The problem is named after Flavius Josephus, a Jewish historian living in the 1st century. As the legend goes, he and his 40 comrade soldiers were trapped in a cave, surrounded by Romans. They chose suicide over capture and decided that they would form a circle and start killing themselves using a step of three. As Josephus did not want to die, he was able to find the safe place, and stayed alive.

Acknowledgement

The idea to use the Josephus problem to compare these languages is not my own. The idea comes from danvk.org who used it to compare Perl 5, Python and Ruby. I have copied his Python and Ruby code and I added the Perl 6 code of my own.

A quick note

I have tried to normalize the code as much as possible, so that you can get a better impression of the OOP syntax in each language. I will not benchmark the code, and I will keep my commentary to a minimum. The idea is that you see the OOP syntax of each language, with minimum influence from me.

Writing the class

Perl 6 (tested with Rakudo)

class Person {
	# $. means "public", "is rw" means it is writable.
	has ($.position, $.succ is rw);
	has $.alive is rw = True;

	# Stringify
	method Str() {
		"Person $.position, " ~ ($.alive ?? "alive" !! "dead")
	}
	# Create a linked chain of people.
	method createChain($n) {
		return self unless $n > 0;
		$.succ = Person.new(position => $.position + 1);
		$.succ.createChain($n-1);
	}
	# Kill every nth person. Stop killing if I'm the last one.
	method kill($pos is rw, $n, $remaining is rw) {
		return $.succ.kill($pos, $n, $remaining) if !$.alive;
		return self if $remaining == 1;

		if $pos == $n {
			$.alive = False;
			$pos = 0;
			$remaining -= 1;
		}
		$.succ.kill($pos+1,$n, $remaining);
	}
}

Python (tested with 2.5.2)

class Person:
	# Initialize
	def __init__(self,pos):
		self.position = pos
		self.alive = True

	# Stringify
	def __str__(self):
		status = "alive" if self.alive else "dead"
		return "Person #%d, %s" % (self.position, status)

	# Create a linked chain of people.
	def createChain(self,n):
		if n > 0:
			self.succ = Person(self.position+1)
			return self.succ.createChain(n-1)
		else:
			return self

	# Kill every nth person. Stop killing if I'm the last one.
	def kill(self,pos,n,remaining):
		if not self.alive:
			return self.succ.kill(pos,n,remaining)
		if remaining == 1:
			return self
		if pos == n:
			self.alive = False
			pos = 0
			remaining -= 1
		return self.succ.kill(pos+1,n,remaining)

Ruby (tested with 1.8.7)

class Person
	# Accessor and mutator methods
	attr_reader :position, :succ, :alive
	attr_writer :position, :succ, :alive

	# Initialize
	def initialize(pos)
		@position = pos
		@alive = true
	end
	# Stringify
	def to_s
		"Person \##@position, #{@alive ? 'alive' : 'dead'}"
	end
	# Create a linked chain of people.
	def createChain(n)
		return self unless n > 0
		@succ = Person.new(@position + 1)
		@succ.createChain(n-1)
	end
	# Kill every nth person. Stop killing if I'm the last one.
	def kill(pos,n,remaining)
		return @succ.kill(pos,n,remaining) if !@alive
		return self if (remaining == 1)

		if pos == n
			@alive = false
			pos = 0
			remaining -= 1
		end
		@succ.kill(pos+1,n,remaining)
	end
end

Comments

All three classes are straight forward, and almost exactly the same size. Perl 6 is a bit shorter, but the differences are insignificant:

Perl 6 Python Ruby
Lines of code* 23 25 27
Characters* 546 578 549

* Not including comments.

Note: A reader mentioned that a better way to do Ruby is to replace “attr_reader” and “attr_writer” by a single “attr_accessor”. With this change, Ruby is the shortest by character count.

There are things I could have done to make each language shorter, but my goal was to make each code sample clear and legible. Besides, you shouldn’t pick a language because you can save 3 lines of code. It makes more sense to see if you like the syntax and the over-all “feel” of the language, and that is a much more personal decision.

On a personal note, I don’t like the Python syntax as much… passing “self” explicitly, double underscores… it feels a bit hackish, but that’s just me. In turn, I like the Ruby and Perl 6 syntax. I can’t decide which I like better. Both look very clean and very clear.

Using the classes

Finally, this is how you would use these classes:

Perl 6

my $orig = 40;
my $nth = 3;

my $first = Person.new(position => 1);
my $last = $first.createChain($orig-1);
$last.succ = $first;

my $winner = $first.kill(1,$nth,$orig);
say "Winner: ", $winner;

Python

orig = 40
nth = 3

first = Person(1)
last = first.createChain(orig-1)
last.succ = first

winner = first.kill(1,nth,orig)
print "Winner: ", winner

Ruby

orig = 40
nth = 3

first = Person.new(1)
last  = first.createChain(orig-1)
last.succ = first

winner = first.kill(1,nth,orig)
puts "Winner: " + winner.to_s

RPN calculator in Perl 6

Posted by Daniel on June 06, 2009
Perl 6, Programming / 5 Comments

Here is something fun. Let’s make a full RPN calculator in Perl 6. In the process we’ll learn a lot about Perl 6’s cool grammar features.

Regexes on steroids

Perl 6 extends Perl 5’s regular expressions to make a full grammar language. Btw, we no longer say “regular expression”, we just say “regex”. The first feature I’ll introduce is the token. A token is basically a regex with a name so you can refer to it later. For example:

token Op {'/' || '*' || '+' || '-'};
token Value { \d+[\.\d+]? };

The first token matches the arithmetic operators + – * /. The second token matches numeric values. You can use these tokens inside a regex. For example, the following matches one or more Ops:

$str ~~ / <Op> + /

Changes compared to Perl 5:

  • Space is not significant in a P6 regex. You can space things out to make the regex more readable.
  • If you put single quotes around any text, the regex matches that text literally. So instead of writing \* you can write ‘*’
  • Now we use ~~ instead of =~

An RPN grammar

We can write tokens that refer to other tokens in order to build more complex grammars. A RPN calculator is basically a list of values and operators. Thus, we can complete the RPN grammar with:

# An "item" is either a value or an operator.
token Item { <Value> || <Op> };

# An "expression" is one or more items separated by white space.
token Expr { [<ws> <Item> <ws>]+ };

The <ws> token is provided by Perl 6. It is similar to \s* but it does not match the inside of a word. For example, the string “hello” does not match <ws> but the string “2+2″ does. Using tokens that refer to other tokens (including recursive definitions) you can build very complex grammars with Perl 6. In fact, the reference grammar of Perl 6 itself is written in Perl 6.

Procedures and control flow

At some point we’ll need a function to compute the result of two values and an operator. In Perl 6 you write procedure parameters explicitly, as you do in other languages:

sub do_op($lhs, $rhs, $op) {
	given $op {
		when '*' { $lhs * $rhs }
		when '+' { $lhs + $rhs }
		when '-' { $lhs - $rhs }
		when '/' { $lhs / $rhs }
	}
}

And here you can see Perl 6’s brand new switch statement. The keywords given and when may be less familiar than switch and case, but they are more natural and read better.

This would be a good time to see the new syntax for for loops:

for @array -> $elem {
	say $elem;
}

Here you can also see the say keyword which is very much like print except that it automatically adds the \n character at the end of the string.

Main program

Now we are ready for the main program logic. Start with an skeleton:

# Read from the command line.
my $str = @*ARGS[0];

if $str ~~ /^ <Expr> $/ {
	# Do something.
} else {
	say "This is not an RPN expression.";
}

A few things merit mention:

  • The array @*ARGS contains the command arguments.
  • In Perl 6, when you get a value of an array, you keep the @ symbol. So the first command argument is @*ARGS[0].
  • The round brackets in an if-statement are now optional.

After a successful match, the match result is put in the $/ variable. This variable is similar to Perl 5’s $1, $2, … but more powerful. In particular, you can refer to token matches by name:

if $str ~~ /^ <Expr> $/ {
	$/<Expr>;            # <-- The Expr matched.
	$/<Expr><Item>;      # <-- A list of Item tokens.
	$/<Expr><Item>[0];   # <-- The first Item token.
}

We saw earlier how to step through an array using a for loop. We can use $/<Expr><Item> the same way:

if $str ~~ /^ <Expr> $/ {
	for $/<Expr><Item> -> $item {
		# Do something with $item.
	}
}

Now we know enough Perl 6 syntax to finish the program:

if $str ~~ /^ <Expr> $/ {
	my @stack;
	for $/<Expr><Item> -> $item {
		if $item<Value> {
			@stack.push($item<Value>);
		} else {
			my $v1 = @stack.pop;
			my $v0 = @stack.pop;
			@stack.push(do_op($v0,$v1,$item<Op>));
		}
	}
	say @stack[0];
}

I trust that you can follow the algorithm. If not, see the Wikipedia page on RPN.

The full program

Now we are ready to see the entire program together.

token Op {'/' || '*' || '+' || '-'};
token Value { \d+[\.\d+]? };
token Item { <Value> || <Op> };
token Expr { [<ws> <Item> <ws>]+ };

# Read from the command line.
my $str = @*ARGS[0];

if $str ~~ /^ <Expr> $/ {
	my @stack;
	for $/<Expr><Item> -> $item {
		if $item<Value> {
			@stack.push($item<Value>);
		} else {
			my $v1 = @stack.pop;
			my $v0 = @stack.pop;
			@stack.push(do_op($v0,$v1,$item<Op>));
		}
	}
	say @stack[0];
} else {
	say "This is not an RPN expression.";
}

sub do_op($lhs, $rhs, $op) {
	given $op {
		when '*' { $lhs * $rhs }
		when '+' { $lhs + $rhs }
		when '-' { $lhs - $rhs }
		when '/' { $lhs / $rhs }
	}
}

Now you can save this to a file (RPN.pl) and run it with:

perl6 RPN.pl  "5 4 + 3 / 5 3 - *"

Exercise

Modify the program to add error checking: Check that @stack has size at least 2 before running an operator and that it has size 1 before returning a result. Use +@array to get the size of an array.

Perl 6 First Steps

Posted by Daniel on June 05, 2009
Perl 6, Programming / No Comments

I have been working more with Perl 6 / Rakudo. I have contributed a few bug reports, and I have now ported six of the Debian shootout benchmarks to Perl 6. I’m adding all the benchmarks to the perl6-examples git repository:

git clone git://github.com/perl6/perl6-examples.git

The benchmarks are located in the ’shootout’ directory. The benchmarks implemented include Fasta, Regex-DNA, K-Nucleotide, N-Body and Reverse-Complement.

Performance

Since I mentioned benchmarks, I guess I have to mention performance…

As you might expect for a project at this stage, Rakudo is very slow. Most benchmarks run about 500 times slower than Perl 5. But that’s normal. There has been no optimization work on Rakudo, since the focus is to get the functionality done (and premature optimization is the root of all evil). In the long term, there is no reason why Perl 6 couldn’t be faster than Perl 5, thanks to its simpler grammar and its type system.

Personally I wouldn’t worry about the performance of Rakudo at this point. Besides, Rakudo is more than fast enough for a lot of simple tasks like admin scripts. I plan to rewrite my backup script in Perl 6 and run it on Rakudo.

The Perl 6 experience

So far, the experience of writing Perl 6 code has been quite pleasant. I really like the Perl 6 syntax. When I convert Perl 5 code to Perl 6 I find that the result is always clearer, always easier to read, usually shorter, never longer. The syntax is more regular (a traditional problem with Perl) and yet it is more succinct and flexible (Perl’s traditional strengths). I feel that with Perl 6 it is easier to just say what I mean. I’m impressed.

Brainfuck interpreter in Perl 6

Posted by Daniel on May 30, 2009
Perl 6, Programming / No Comments

I wrote a Brainfuck interpreter in Perl 6 (largely inspired by Acme::Brainfuck). Here it is in its entirety:

# Read the program.
my $program = $*IN.slurp;

# Compile to Perl 6.
$program .= subst(/\$/, 'P; };', :g);
$program .= subst(/(\++)/, { 'P += ' ~ $0.chars ~ ';' }, :g);
$program .= subst(/(\-+)/, { 'P -= ' ~ $0.chars ~ ';' }, :g);
$program .= subst(/(\>+)/, { '$ptr += ' ~ $0.chars ~ ';' }, :g);
$program .= subst(/(\<+)/, { '$ptr -= ' ~ $0.chars ~ ';' }, :g);
$program .= subst(/\./, 'print chr P;', :g);
$program .= subst(/\,/, 'P = ord getc;', :g);
$program .= subst(/\[/, 'while (P) {', :g);
$program .= subst(/\]/, '};', :g);
$program .= subst(/P/, '@P[$ptr]', :g);
$program  = 'my @P = (); my $ptr = 0;' ~ $program;

# Run
eval $program;

Here is “Hello world” in Brainfuck (taken from Wikipedia):

++++++++++    initializes cell zero to 10
[
   >+++++++>++++++++++>+++>+<<<<-
]             loop sets the next four cells to 70/100/30/10
>++.          print   'H'
>+.           print   'e'
+++++++.              'l'
.                     'l'
+++.                  'o'
>++.                  space
<<+++++++++++++++.    'W'
>.                    'o'
+++.                  'r'
------.               'l'
--------.             'd'
>+.                   '!'
>.                    newline

To run the program, just do: perl6 brainfuck.pl < hello.bf

Perl 6

Posted by Daniel on May 27, 2009
Perl 6, Programming / No Comments

This week I’ve been experimenting a little with Perl 6. It began as a quick question on IRC and somehow I ended up writing sample scripts in Perl 6. This week I ported the regex-dna benchmark to Perl 6, and I intend to port a few others. You can download it here.

One thing that’s new about Perl 6 is that it is a specification, similar to C, C++ and Java. Any product that meets the spec and passes the test suite can be called Perl 6 (there are many C compilers, and none of them is “the official C compiler”).

The implementation I have been experimenting with is Rakudo (compiler written in Perl 6 and Parrot assembly language) which seems to be the most active and the most complete. You can already write some Perl 6 programs with the Rakudo compiler. There is a wiki called November, a board game called druid, and a few others. Other notable implementations include Pugs (interpreter written in Haskell) and SMOP (interpreter written in C).

Why are plants green?

Posted by Daniel on April 27, 2009
Miscellaneous / 1 Comment

Have you ever wonder why plants are green?

And no, the answer I’m looking for is not “stuff is green because it reflects green light and absorbs red and blue”. What I mean is, why in the world would plants choose to reflect green, when most of the sun light is in the green spectrum? Wouldn’t it make more sense or plants to absorb green?

Well, today I found a web page explaining this. I thought it was very interesting and wanted to share the link. In summary:

Why are plants green?
Because they appeared late, after a different organism had already developed green photosynthesis. The first plants (algae) lived in the water, below the non-green plants, so all they had available was red and blue.
Then why did green plants come to dominate the planet?
Because this new kind of plant also had the ability to use CO2 from the atmosphere to make sugars. So although they were disadvantaged when it came to the light spectrum, they were superior over-all.

It is also interesting that plants have evolved to minimize the disadvantage of being stuck with the non-green spectrum. Plant leaves have a complex structure that makes light bounce around inside the leaves, so that each photon has multiple chances of being absorbed. For this reason, although chlorophyll only absorbs about 2% of incident green light, a leaf as a whole can absorb as much as 50%. For more on that point, see this page.

Ammonia based life

Posted by Daniel on April 20, 2009
Open Source / Open Standards / No Comments

A very interesting page on ammonia-based life. I didn’t realize that ammonia was such a good alternative to water as a basis for biology.

Personal Finance Software

Posted by Daniel on February 05, 2009
Miscellaneous, Open Source / Open Standards / 4 Comments

Updated: 3 Nov 2009.
This is a list of eight “Personal Finance” (accounting-type) programs that are entirely free, open source and mostly cross-platform. KMyMoney is not cross-platform but in the future it will be. The programs are listed in approximate order of simplicity and features.

Main Links:

SummaryOther SoftwareSend Your Suggestions

Summary

Platforms [1] Ease of use Basic finance QIF import QIF export GnuCash import Investments Multiple currencies Scheduled transactions Reports Small business
Buddi LinuxWin32 Mac **** Yes No No No No No No * No
HomeBank LinuxWin32 **** Yes Yes Yes No No No No * No
iFreeBudget LinuxWin32 [3] ** Yes No No No Basic No Yes ** No
Grisbi LinuxWin32 Mac ** Yes Yes Yes Yes No No Yes ** No
Money Manager EX LinuxWin32 [4] *** Yes Yes No No Basic OK Yes *** No
jGnash LinuxWin32 [5] *** Yes Poor No No Good Good Yes *** No
KMyMoney Linux [6] *** Yes Yes Yes Yes Good Good Yes **** No
GnuCash LinuxWin32 ** Yes Yes No Yes OK OK Yes **** Yes



[1] I only list platforms where the program can be installed by non-technical users.
[2] Multiple currencies means that you can have different accounts in different currencies. Some programs advertise “multiple” currencies and what they mean is that you can pick any currency as long as all your accounts have the same one.
[3] This is a Java program, so in principle it should be possible to run it on a Mac. But the program has not been tested on Mac and personally I could not get it to run on my Intel Mac.
[4] There is an experimental version for Mac.
[5] Runs on PPC Macs, but not on the new Intel Macs unless the user is fairly technical.
[6] When KMyMoney is ported to KDE4 it will run on Windows and possibly Mac. As of Feb 2009 the port to KDE4 has not started.

Buddi Linux Win32 Mac

“Buddi is a personal finance and budgeting program, aimed at those who have little or no financial background.”

Buddi may be a good choice for people who simply wish to track their income and expenses. It is very simple and very easy to use. There are only three tabs: My Accounts, My Budget and My Reports. In My Accounts you put your assets (bank accounts, cash) and liabilities (credit card, student loans, mortgage). In My Budget you put income and expenses. In My Reports you see various reports like “show me my income and expenses for last month”.

I got a good impression of Buddi. It doesn’t have any advanced features, but for people who are just starting to track their personal finances it might be a good fit. The only issue I have with it is that it can’t export to QIF. So when you outgrow this package, you’ll have a hard time moving your data to a different application. If you think you might be in this situation, I recommend you look at HomeBank.

Missing features:

  • Does not support QIF import.
  • Does not support stocks.
  • Does not support multiple currencies (all accounts have the same currency).
  • Does not have any reports besides budget.

HomeBank Linux Win32

A very small and simple finance package. Suitable for keeping track of your expenses or making a budget. Like most personal finance software, it organizes things into accounts, payees and categories. Features include: QIF import/export, OFX and CVS import, scheduled transactions, simple annual budget and car cost.

If your needs are simple or if you are just starting to track your finances, HomeBank is for you. A very important feature that it has is QIF export. This will allow you to migrate to another application later when your needs change. As you gain experience managing your finances you will gradually outgrow HomeBank and it is important to know that you can migrate.

Missing features:

  • Does not support stocks.
  • Does not support multiple currencies (all accounts have the same currency).
  • Does not have any reports besides budget.

iFreeBudget Linux Win32

The main feature that iFreeBudget provides compared to HomeBank is support for scheduled transactions, some support for investments and a somewhat wider range of reports. In exchange for that you give up QIF import and export as well as some ease of use. However, it does offer OFX import.

Special features: iFreeBudget can download your transactions on-line, directly from your bank. I wish more programs had this feature (btw, I did not test this feature). Another feature is that your account data is encrypted, so you have to enter a password to access it.

I am concerned about the lack of QIF export. If you decide to move to a different package you will have a hard time migrating.

Support for stocks and investments is very basic, but it may be appropriate for some users. iFreeBudget does not actually track money flowing between your bank and your stocks. It simply records the fact that you have certain stocks and gives you the current market value.

The main reason I give it a low score on ease of use is transactions. The wizard is certainly “easy”, but it’s a lot of clicks just to enter your groceries. You can go to File > New > Transaction. The problem here was that iFreeBudget kept saying “Invalid account” but didn’t tell me which account was invalid or why. It took me a while to find the problem.

If you are considering iFreeBudget, I would recommend that you also look at Money Manager EX. It has a similar feature set, somewhat better, and I find it easier to use.

Missing features:

  • Does not support QIF import and export.
  • Does not support multiple currencies.
  • Support for stocks and investments is weak.
  • Support for reports is a little weak.

Grisbi Linux Win32 Mac

This is still a low-end product. Grisbi supports all the features I listed for HomeBank, plus it supports multiple currencies (go to Edit > Preferences). It also has income/expense reports. Grisbi can import QIF and GnuCash files, and it can export QIF and CSV files.

I was not particularly impressed with Grisbi. It is not a bad program at all, but I felt that jGnash and KMyMoney have an easier user interface even though they have more features. So why would I use Grisbi? Still, I am sure that some people will prefer Grisbi and the program definitely deserves to be mentioned.

Grisbi offers QIF export and that’s important. It means that you have the option of migrating to a different package later when your needs change.

Missing features:

  • Does not support stocks.
  • Support for multiple currencies is weak (e.g. no price editor).
  • Support for reports is weak.
  • I don’t like the UI as much as the other programs.

Money Manager EX Linux Win32

This is a nice program, I like it. It has a similar but somewhat better set of features than iFreeBudget and I like the user interface better.

Money Manager EX has only basic support for stocks. It can track what stocks you have, but it does not track money flowing between your bank account and your stocks. MMEX has support for multiple currencies. The system is basic (e.g. there is no “price editor”) but I suspect that it is perfectly adequate for a lot of people. MMEX also has a pretty decent collection of reports (e.g. cash flow forecasting) which should be more than enough for most people.

If you need a program that supports stocks or multiple currencies but you want something simple and basic, you should definitely try Money Manager EX.

MMEX can import QIF files, but it cannot export to QIF. This is my main concern with this program. It may be perfectly suitable for you today, but if your needs change and decide you want a different package, you may have trouble migrating. MMEX does support CSV export and I guess that’s better than nothing, but realistically, that’s not enough to migrate to a different application.

Unique features: MMEX supports encrypting the database with the account data.

Missing features:

  • Does not support QIF export.
  • Support for multiple currencies is weak.
  • Support for stocks and investments is weak.

jGnash Linux Win32 Mac and KMyMoney Linux

These are my favourites. Both programs have a very similar feature set, but very different user interface. IMHO both have a good UI, they are just different. So definitely try both. That said, please note that jGnash has poor QIF support.

Both programs support stocks and investments including stock splits, and both have strong support for multiple currencies. That includes automatic online updates of stock prices and currency exchange rates.

Although these programs have a lot more features than Grisbi, I find the user interface easier to understand. If you are used to thinking in terms of asset and liability “accounts” vs income and expense “categories”, KMyMoney will be more familiar. If you learnt double-entry bookkeeping, either will feel comfortable – both programs include income and expense in the “accounts” section.

Reports: Both have a more complete set of reports than either HomeBank or Grisbi. They include net worth, balance sheet, portfolio, investment performance, etc. KMyMoney has better reports than jGnash. KMyMoney includes more reports (e.g. tax and forecast) and its reports are more flexible (e.g. monthly or yearly net worth, net worth by institution, etc).

Importing data: jGnash can import QIF and OFX. KMyMoney can import QIF and GnuCash. A reader (Ron Price) has reported that jGnash does a poor job at importing QIF files. Ron tested QIF import on several programs on this page and jGnash was the worst. jGnash lost his categories and accounts. If you are migrating from another program, be sure to test.

Exporting data: KMyMoney can export to QIF, but jGnash cannot. This is important. It is hard to migrate away from jGnash because it doesn’t support QIF export. jGnash has a good feature set, but you might want to switch to a different program later, and this is difficult without QIF export.

Other: Both support scheduled transactions and secure file encryption.

Unique features: jGnash can export reports to PDF and it has an interesting client/server architecture. KMyMoney supports VAT, it has better documentation and a much more active community (so it’s easier to get help).

GnuCash Linux Windows

Probably the best known accounting package for Linux. GnuCash is a step up in the complexity/features scale. Besides “personal finance”, it provides small business accounting features like invoicing, billing, accounts payable and accounts receivable. You can setup customers, vendors and employees. I can’t say much about the business features because I don’t use them.

GnuCash supports multiple currencies and stocks, but honestly, jGnash and KMyMoney both handles those better. For this reason, I am planning to migrate from GnuCash to jGnash or KMyMoney.

GnuCash supports QIF, OFX, and HBCI import. It also has the most complete set of reports from any program in this list (cash flow, employee report, etc). It includes a financial calculation (e.g. for annuities or present value calculations).

GnuCash does not support QIF export, bug KMyMoney supports GnuCash import and QIF export, so it’s not a big problem to migrate away from GnuCash. I recently migrated from GnuCash to KMyMoney and I didn’t have any significant problems.

GnuCash doesn’t try to hide the details of double-entry bookkeeping to the same extent that the other programs do. If you have studied accounting, you might like this, but people who never learnt accounting might need some time to get used to thinking of income and expenses as “accounts”. You don’t need to know the difference between debit and credit to use GnuCash.

Other Software

Before we begin, I’d like to suggest other great resources which are not strictly “Personal Finance Applications” but should be very useful to anyone wanting to mange their finances.

Send Your Suggestions

Is there a great program or feature that you think I should cover? Let me know! I do want to focus on free (no cost), cross-platform, open source software with an active community.

- Why free? Because there are many great free tools that people don’t hear about.
- Why open source? Because it’s the easiest way to make sure that the program isn’t cripple-ware, ad-ware or trial-ware.
- Why active community? Because it helps ensure over-all quality, regular updates, documentation and support.
- Why cross platform? Because that way more people can use it, and because it sucks when an application limits your choice of operating system.

purchase software