Friday, February 27, 2009

I also cleaned up the library a bit. Reading up on POSIX signals I decided that it is wrong for the daemonize library to mess with them beyond blocking HUP. Also, now it has two functions, daemonize :: IO () -> IO () which does the bare minimum, and serviced :: Program -> IO () that does that and more, for example writing a PID file, handling start/stop/restart, catching and logging exceptions to syslog.

Coercions

> NULL == FALSE
logical(0)

If you are wondering what happened here, FALSE, which is a
logical vector of length 1, was compared for equality with NULL,
which is an empty list. To proceed with the comparison, R coerced
the list to a vector of length 0. Then, two logical vectors were
compared elementwise for equality, to yield the resulting vector of
length 0.

Equational reasoning is not a good starting point to make sense
of this:

Thursday, February 26, 2009

To re-post a message from the LtU-Kiev maililng list, there will be a screening of Simon P. Jones' video tutorial A Taste of Haskell together with slides.
Free entrance for up to 20 people, RSVP at the LtU-Kiev mailing list.
Saturday, Feb 28, 2009. 13:00-15:00. Ukrainian Education Center, Kyiv, Ukraine.
More about the venue here (eng).

Haskell users in Kiev, Ukraine, wanted to start a user group (HUG), but it turns out there are not too many practicioners yet, so the group ended up being open to all who love and use functional languages. The common denominator is Lambda the Ultimate readership! Hence the name: LtU-Kiev.

R language (or S) is something I occasionally deal with. It is known for good libraries for statistics, but its core is a rather general programming language; it is far from being as specialized as advertised. R had even been mentioned on LtU a couple of times.
R has a lot of Lisp hidden behind a C-like syntax. Lexical scoping, lambdas, lists.
Something I learned today is Recall and call. The latter is not unlike a (quote)..

fac
The downside is that the implementation is very slow. Since most operations vectorized, the argument is that it does not matter. Realistically, nobody is going to do anything about it.
In terms of inter-op with libraries, would it not have been much better to have it (and its wonderful libraries) run on top of a more widely accepted runtime, or even a Scheme or CL..
UPDATE: here is a nice blog on function argument handling semantics in R, which turns out to be pretty complicated.
UPDATE: I finally found the draft of the R Language Definition. The section on evaluation and argument matching is particularly interesting.

Next PHP is coming with closures and a functional programming library.
Will it help?
That may make it a slightly better compilation target.
It is unlikely that it will change the way
experienced PHP developers program.

Does Visual Studio Rot the Mind?
Rather a lengthy talk, barely worth a look, but some valid points there. IntelliSense affects the way people program and design programs. In a negative way, I grant you.
One more reason to use Emacs.

Wednesday, February 25, 2009

These are expression closures in JavaScript 1.8. return is gone, good riddance.
Now if only we could write fun or \ instead of function!
The code would work in R, and my wish applies to that language as well.

Roman Cheplyaka pointed me to a good book (Foundations for Programming Languages) by John C. Mitchell. As a side effect, my eye was caught by the author's mention of object-oriented language foundations and record calculi.
Record calculi? Really?
A few more googles, yes indeed, there are ways to mathematically formalize operations on labeled records, providing for object-oriented languages what lambda calculus provides for functional.
First hit on Google Scholar is a 1995 paper by Atsushi Ohori, "Polymorphic record calculus and its compilation"; Ohori in fact has plenty of interesting and publicly available papers.
Apparently one use case of this lore is polymorphic type inference for record types in the ML family.

Tuesday, February 24, 2009

I (heart) MS SQL. To take a fair random sample of a view or a table, you need a fair amount of SQL acrobatics. Not only that, you'd want to index the views if you do not want to wait forever for your sample. Indexed views come at a cost, last but not least of explaining to your client that the databasse schema needs to be changed.
Please, RDBMSs of all kind, die. It is 2009, not 1989.

PLT/mzscheme has been my number one choice. Reasonably fast (like naively written Haskell), with a very friendly community, runs on a VM, cross-platform, incredibly easy to install librares (PlaneT), fully dynamic FFI to C, does R6RS, has its own very nice extensions. I just could not figure out how to do ODBC - is it still supported?
Now I am looking for alternatives for the compiled use case, for example for producing small binaries, or plugins to C systems. Bigloo and Chicken seem attractive. It is hard to choose, both seem very good.
Please, no Common Lisp.
UPDATE: I went for Chicken and I am really impressed! C integration is tight, binaries are very small (shared runtime), user libraries are as easy to install as Linux packages, it is easy to compile shared libraries. Bigloo must have its advantages too but for now I am sticking to Chicken.

Saturday, February 21, 2009

Writing little programs that stay live and do work, should not be hard, right?
Well, on the UNIX platform it is not quite so! Just search the net for "LINUX Daemon Writing HOWTO.."
hdaemonize collects all the cruft daemons do into a library, so that you can do this:

This little program writes into /tmp/counter the number of seconds since its start, and reports its events to daemons.log; it is also ready to be deployed to /etc/init.d or /etc/rc.d; started by root, it will drop priviledges to the daemon user, or, if you name the program 'foo' and user foo exists, to user foo.
Far from being a UNIX guru, I am almost certain that I did some mistakes in the library, so I release it open-soure and welcome corrections.
hdaemonize home:
http://github.com/toyvo/hdaemonize/tree/master
inspiration for the code:
http://sneakymustard.com/2008/12/11/haskell-daemons

Tuesday, February 17, 2009

I gave up on self hosting and host the blog with Google. Reasons? To speed up the long-awaited death of PHP, make sure I don't lose the data, make it easier for people to comment. What I regret with moving to Blogspot is the ability to transform the text. Code and formula snippets are bound to get messed up. But thankfully, for publishing code and formulas there is a Gitit copy available.