Sunday, May 16, 2010

C++

Lately I've been moving my programming focus from Python to C++, simply because I wanted to experience a compiled language, and compare it with the "slower" scripting languages I often use (perl, bash, python, etc.). Slower insofar as they require libraries to be loaded at runtime. My first step was to create a recursive directory traversal function, since I planned on re-writing a "music catalogue" program I wrote in Python (basically a program that compiles a list of songs) in C++. I also want to add functionality, like specifying if you only want a list of artists, albums, etc. And also specify how it is printed out (i.e. comma-separated for "About Me" type forms, or a normal list).

I ran into a bit of a snag getting the recursion working properly at first, but asking in the ArchLinux Forums gave me the advice I needed, and the method works now without a problem. During that time though, another forum member mentioned that recursion is best avoided (with which I wholeheartedly agree), and who has prompted me now to look into re-writing my method as an iterative method instead of a recursive one. However, I'm still trying to wrap my head around the changes I'd need to create an iterative directory traversal function from the method I've already written. If anyone feels like taking a shot at explaining the differences I'd need to make in my recursive function to make it iterative to me, feel free to leave me a comment. Or, if you'd like to see the code I've written, I've paste-binned it here. If you re-write it into an iterative function, I'd be grateful if you posted a link to it here, in order to spur my thinking processes along.

Besides that, I haven't been up to all too much. Mainly organizing my life. Once I finish the music catalogue program, I'll probably post it up here. Also, I plan to update my blog more regularly once things have settled down here a bit.

2 comments:

Nick Banasihan said...

Still fixed this yet? I've read a book that discusses conversion from recursive to iterative, so I might take a shot at it if I have the time.

If you are curious as to what book it is, it's Sedgewick's Algorithms in C++. :P

Lswest said...

Well, I haven't fixed this particular program, but I've gotten the hang of iterative to recursive conversions.