|
|
|
Language for Unix command line utilities?
|
|
6 points
by gn
5765 days ago
|
|
I code for a small biocomputing company. We download nucleotide sequence and taxonomy information in a number of unrelated formats from a number of public repositories and run various kinds of translation and analysis on it. Much of what we write are small command line tools that search, summarize, or transform certain types of (large trees of) text files. These programs look and feel a lot like traditional core Unix utilities; our most widely used programs are essentially just a specialized version of diff and a specialized version of grep, respectively. We used to prototype most of our utilities as shell scripts or in Perl; we redid shell scripts in Perl or C (or sometimes Java) if they became performance bottlenecks. Some years ago we decided to move from Perl to Python for new projects because Perl programs had a way of always ending up as maintainability nightmares and because Perl seemed on the way out anyway. It largely worked, but we were never really, truly happy with our Python code. I suspect part of the reason is that Python can be (or at least feel) less succinct than even C if you do lots of low-level file system stuff with close error checking. The true reason is probably largely aesthetic. We can't explain what's wrong, we're just vaguely uneasy. What other alternative to C should we be looking at? Ruby? Haskell? Is Go there yet? We have very open minds and are willing to consider pretty much anything that gives us reasonably easy and unmolested access to syscalls and their return values. |
|
OCaml would be a good choice too. Both of these languages work very naturally with tree-like structures. Profiling/code coverage in both is very easy. IMHO there's no need to go to C for any but the most performance-critical code (and remember that your I/O etc is already in C in the kernel). The C approach of checking the return value of every syscall (e.g. no exceptions) is very cumbersome.
Case in point today: rather than persuade our Unix guys to roll out Expect across a bunch of new machines, I rewrote a ~200 line Expect script I had in ~60 lines of Haskell and deployed a binary instead of a script.