Sunday, August 22, 2010

encrypt(3) example usage

A while back I had someone ask about how to use the encrypt() function under Linux. He had tried the man page, encrypt(3), which even contains an example usage. Unfortunately for him, the example given was terribly broken. I managed to find a post by Jens Thoms Törring which contained a working sample (though there was an off-by-one error which Mr. Törring later brought to my attention).  Since the current man page at the time had a broken example, I thought I would send a patch in to have it fixed.  That was a little over a year ago, but guess what?  Still the same broken code!  I don't know why the patch was not applied.  Perhaps it was a crappy patch (I don't normally do patches, so I might have done it wrong).  Or maybe the maintainer of the man pages was too busy.  I don't really know what happened. Since speculation is pretty much useless, I thought I might post the code here, for anyone else searching for a useful example of encrypt usage.

Saturday, August 21, 2010

The easy way out

I was just reading an article by Andrei Alexandrescu called, The Case for D.  In it he compares the traditional C "hello world" program to its D counterpart. Consider the following example:
#include <stdio.h>

main()
{
    printf("Hello, world\n");
}
If I compile this with gcc -o hello hello.c, I get an executable (without any warnings from the compiler).  It runs, and the return value is 13.  Wha-what?  Return value?  I didn't return anything.  But printf() did.

Google Go, or Digital Mars D?

Recently I learned of the Go programming language.  It is, according to the header on the main golang web page, an expressive, concurrent, garbage-collected, systems programming language. It looks kind of cool.  There is a compiler (6g) which works on my system.  I would prefer to use the gcc  front-end (gccgo), but at this point I cannot get it running.

Then there is the D programming language.  It is, according to the D main page, also a systems programming language.  It looks appealing as well.  D comes with its own compiler, dmd, and a front end for gcc (gdc).

Apparently, it kind of seems that these two languages have some overlap in their audience/goals.  This thread has some discussion about that from a primarily pro D perspective.  This is another thread, but more from a pro Go perspective.

My dilemma is that I want to learn a new language.  I am a hobby programmer, with a pretty good handle on C.  I have made stabs at C++ before, and while I think it is a wonderful language (string handling and memory management are so much easier than C) it is also a lot more to learn than C.  I am wondering if D or Go might be more suitable.  Ultimately, I might have to dive into both to make my decision.  I am hoping not to have to do that though.  One thing that will help make my decision is the documentation available.  I cannot learn a new language without some help.  So I will have to look into that aspect as well.  If you are a Go programmer, or a D programmer, (or both) and you feel like offering any suggestions as to what path I should take, please leave a comment.  I would appreciate any sound advice.