Sunday, March 23, 2008

Gauche: yet another Scheme-a-tic diagram of programming (self-)education

I feel programmers in the 21th century prefer so-called dynamic, scripting or light-weight programming languages to the good-old static, compilation-based, and heavy-weight ones. In this sense, I belong to the old-style programmers, who like C, awk, and simple Bourne Shell. So far the most complex light-weight language I've used is Perl.

I like definitive or pre-defined syntax and keywords than those which may change the meanings by the programmer's definition, because the dynamic definition will make the program too complicated. Maybe my brain is losing flexibility, but I'd rather want to read something which can be easily decoded than the cryptic ones.

I didn't have a chance to formally learn programming, however, during my education. This is both good and bad: the good thing is that you don't have to spend time on learning subjects which you won't use throughout the rest of your life; and the bad thing is that you may have no chance to know the coding practice much efficient than what you usually write.

Some programming languages still irritate me. I should confess I don't like Prolog. I will be a very poor programmer if I have to write only rules between the objects than the way of moving around and cutting and pasting them. Thinking about the backtracking facility is a nightmare for me. I'm 99.9% (if not 100%) filled with the idea that every statement of a programming language will have a side effect, or may cause changes of the contents of the preallocated memory space. I still don't believe in the idea that no assignment is needed for a real-world computing.

I still think, however, the idea of functional languages which is focused on the relationship of data than copying and manipulating them back and forth, is an essential part of the modern computer programming. Abstraction work of data often simplifies the complex problems. Writing things in recursion than an arbitrary loop will simplify the code and often makes it efficient.

Recently I've learned many young programmers are learning a lot from LISP and Scheme, and I've heard some of them have learned Scheme in their formal education process. I welcome that trend and I hope it continues to grow, because in the real-world programming paradigm there's large room for optimization by introducing Scheme-style abstraction, such as describing an XML document in an S expression.

Gauche, an implementation of Scheme by Shiro Kawai and other developers, is a well-balanced mixture of the LISP-Scheme tradition of simplicity and a Perl-like feature, such as being able to handle Unicode, regular expressions, network sockets, and simple byte-aligned buffer structures which is essential for network programming.

Gauche is a viable alternative to scripting languages like Perl; and it's still a Scheme implementation, so an old-minded programmer like me has many things to learn and enjoy. Gauche has a lot of modules or external libraries to handle real-world problems, such as manipulating database engines and HTML/XML data structures. It took me only three hours to rewrite a Japanese input method server program in C by Gauche, thanks to the modules. Gauche and Scheme designers also know that programmers want to use assignments, so an old-headed guy like me didn't have to scratch the head forever.

In 1989, when I first met a Symbolics LISP machine, it didn't attract me much because the machine was something completely different from the UNIX workstations, which I wanted to use to communicate with my friends and gurus. I realize, however, things have changed a lot now; you can play around and even solve the real-world issues on a LISP-Scheme processing environment like Gauche. The vast increase of processing power including the CPU speed and the amount of main memory make this possible for everyone. And I think it's a new Scheme-a-tic diagram for a competitive programmer; you will become much more productive after learning practical data abstraction.

Monday, March 3, 2008

Gotchas, gotchas, gotchas

I've learned a lot of hard cold facts on how to deal with multimedia systems. Here are the examples:

  • White fungi can grow on a CD medium surface and even often render the media unreadable, though in most cases the medium can be rescued by wiping out the fungi. (Be careful not to damage the acrylic surface!)
  • Windows XP goes into an infinite loop (100% usage of a CPU core) to try to read an unreadable CD medium. If you don't have a multi-core machine, you'll be getting into a trouble. Why the CD/DVD drive cannot tell you that the media seems to have a problem, rather than just simply retry and wait for the timeout periods?
  • iPod 5G firmware Version 1.2.3 can crash and reboot forever, just because the album title field of an MP3 file contains an unreadable/irregular character. The iTunes 7.6.1 for Windows is running smoothly without any error message even with the MP3 file, so you can't tell what's really wrong until you try-and-fail the whole possible cases.
  • You cannot easily attach still pictures to an audio file without external software. And I realize that's the meaning of the word authoring of a streaming video.
  • You have to make a set of still pictures into motion pictures or a video stream first first, before syncing with an audio stream and make them a video stream, to be broadcast on the Internet, such as on YouTube. (A good news is that you can do this by a set of the open source software, such as mjpegtools and Avidemux.)
  • Gracenote CDDB has been broken for WinAmp, so I have to migrate into iTunes, just to pick up the metadata of each song I'm going to put into my lovely iPod. I like my iPod very much, but iTunes for Windows is really a big slow program and I hope it was a bit smaller and faster.

And I even learned some security and systems administration tips:

  • Many of PCI Serial-ATA cards cannot be used for operating systems other than Windows.
  • A 13-year old hard disk can spin up and is readable even if you once put it in your closet and left it unplugged for 10 years.
  • As of 2008, you can hardly find a SCSI interface card for a PC, at least in Osaka.

Then I remember the truth: your computer could be the number one device to consume your time and kill your productivity. So how many gotchas do you get every day? Ten? Or a hundred? And how many hours or even days do you lose?