1 Broken Scooter, 4 Iron Cots, 1 Used Ford, 3 Cats, and 1 Small Room


About
Yet Another Self-Important Blog.



Rohit Singh
Email Me



Blogs
Use as directed or at your own risk.



Links
These are a few of my favourite links.




       

[Sun, 13 Jun 2004]

The Great Language Debate

Slashdot is carrying yet another story comparing various programming languages. In this case, it is just scripting languages but there are other studies that do compare even more languages. It has taken me a long time to settle down on my everyday languages. For quite a while, I'd fiddle with any new language I came across. ML and Clean were the most tempting. There's something to be said for writing in a functional language. All that funky "everything is an expression" stuff is pretty cool. But I/O and data-structures are just a pain in the neck. Writing real ML code turned out to be enormously painful the last time I tried it. It didn't help that I was using it for an assignment and the assignment was due the next day and I had forgotten most of CS350. Still, they say OCaml, a variant of ML, is really fast and has good libraries. Until I get around to that one, I'll keep fiddling with Python's lambda and map statements.

I always liked Python more than Perl. The conversion is now complete. The only Perl code I now write are one-liners. Python can't be used to write one-liners but its verbosity and forced indentation and intuitive function names make it easy to read. And the final time to write the program isn't that much anyway. Now that I've gotten used to its modules, its gotten easier for me to write scripts that do lots of pipes and program-running business. These days, during the course of work, a hairy command line will typically pull in many different languages:

cat test3_${j}_${i%.policy}.ct | perl -ne '{chomp; print "echo ",$_," | addZero | chainbuild --param '${j}.prm' --fixomega --pdb > test3_decoy_'${j}_${i%.policy}'_",$.,".gly \n ./nbEasy test3_decoy_'${j}_${i%.policy}'_",$.,".gly | grep neighbouring \n"; }' > test3_${j}_${i%.policy}.1

ls ${j}/test3_runs/$i| GetStructParamsAll.py | tail -1 | perl -pe 's/\s+/\n/g;' | sed '1 d'| perl -ne '{chomp; if ($.%3==2) {print;} if ($.%3==0) {print " ", $_, "\n";}}'| perl -ne '{ if (/\S+\s+\S+/) {print;}}' > ${j}/test4_runs/${i%.gly}.tors

chainbuild is a C++ program, with 3rd-party Fortran libraries. I use awk/sed usually, and call in Perl's regexes if awk would get too unwieldy. Perl's -pe/-ne flags are really handy. Shell scripting is useful for running simulations and any script that is permanent enough to go into a file is almost always Python.

Sometimes I wonder if I go overboard with this scripting business. But, then again, its pretty useful.

[/misc] permanent link