Parsed Participle

The personal weblog of Faiz Kazi: Mostly oddities in programming, life in Japan, occasionally music.

[ Home | RSS 2.0 | ATOM 1.0 ]

Sun, 08 Mar 2009

Founder of NYU Computer Science passes away at 79

Jacob Schwartz, the founder of the Courant Institute's Computer Science Department, and designer of the SETL programming language passed away last week. He was behind the NYU Ultracomputer project.

SETL is incidentally one of the languages we will be studying as part of the 'Honors Programming Languages' course. SETL is said to have indirectly influenced Python. It is based on Set Theory and allows very succinct list-comprehension-like one-liners. At the start of the course (in January), we were told that it was decided to drop Python in SETL's favor since SETL would be more 'fun'.

posted: 16:20 | path: /programming | permanent link to this entry


Wed, 13 Aug 2008

Discovering xmonad

As someone who has maintained his set of 'dotfiles' faithfully for a few years now, window-manager choice and configuration has been of great importance. I used FVWM for a few years, finally switching to Sawfish somewhere in 2005. My sawfish configuration mimics what I had set up in my fvwm days rather closely, and sporadic periods of messing around with settings have been the only (enjoyable) disruption to my otherwise very productive computing life (as far as my Desktop environment is concerned).

I switched to Sawfish simply because it's scripting language, librep is a Lisp - one that I had been spending many commuting Zaurus hours on. Life has been very good with this the way it is.

Until I read yesterday's LTU article a post that talks about side-effects in imperative languages that cause closures to capture variables in less-than-desirable ways. It was not the actual post itself, but a link to a series, with one interesting post featuring a tour of Haskell and a rather fabulous example to use as a working demo program: XMonad, a really good window manager written in and extensible in Haskell:

  • Windows are automatically tiled
  • Mouseless
  • Configurable (even in real time), using Haskell

I'm tempted to try it; given todays large displays, arranging windows with your mouse just feels silly.

Imperative-style Iterations and closures don't mix well

The undesirable form of variable capture that Erik Meijer describes is, I think, a lot to do with supporting closures in languages where C-style iteration is still relatively a norm. The for (i = 0; i<10; i++){ /*..*/ } lets you use the i as a block scope variable while it remains a part of the mechanism of the iteration. It's easy to reproduce this in Perl (the language which is many things to many people), if you use the C iteration idiom:
my @arr = ();
for (my $i = 4; $i < 7; $i++) {
    push @arr, sub {
        return $i;
    };
}

for (my $i = 4; $i < @arr; $i++) {
    my $f = $arr[$i];
    print $f->(), "\n";
}
But the idiomatic way does away with this problem; and things are better now that we don't have to get distracted by the iteration mechanism: map and grep where one can:
my @arr = map {
    my $i = $_;
    sub {
        return $i;
    }
} (4..7);

print $_->(), "\n" foreach @arr;
Javascript may not have map/grep, but for Functional-style iterations, libraries do a great job of providing such utilities. Prototype.js comes to mind.
var delayedActions = [4,5,6,7].map(function (n) {
    return function (i) {
        return i;
    };
});
In fact this is where these closure-ish APIs shine - they overcome Javascript's problem (i.e., variables only have function scope) by expressing loops functionally.


Tue, 12 Aug 2008

OpenJDK in Debian/Unstable

I don't routinely need to write Java code these days, but it still feels good to know that the JDK is now available as Free Software in Debian:
$ apt-get install openjdk-6-jdk openjdk-6-source
# and then...
$ which java
/usr/bin/java
$ java -version
java version "1.6.0_0"
OpenJDK  Runtime Environment (build 1.6.0_0-b11)
OpenJDK 64-Bit Server VM (build 1.6.0_0-b11, mixed mode)
I don't use Java much (but that could have been because of it's non-free pain), and have so far managed with GCJ surprisingly well. However, having the official Sun JDK as packaged, Free software is really good.
posted: 12:12 | path: /programming | permanent link to this entry


Sat, 12 Jul 2008

Lisp's 50th Birthday Celebrations

The second oldest programming language still in widespread use is celebrating it's 50th birthday this year.

John McCarthy will be giving a talk about the history of Lisp, at OOPSLA 2008 (The ACM SIGPLAN Conference on Object Oriented Programming, Systems, Languages, and Applications), an event that I was already wishing I could attend. Is this the 'official' celebration, I wonder? Object-Oriented Programming owes a lot to Lisp, but then isn't Lisp so much more than just OO?

M.J.D (the author of Higher Order Perl) is apparently one of the keynote speakers. I'm beginning to wish I can still make it somehow.

posted: 09:10 | path: /programming | permanent link to this entry
Tags:


Sun, 18 May 2008

YAPC::Asia 2008

YAPC::Asia ( Yet Another Perl Conference, Asia) took place in Tokyo (where it has always been held since 2006) from May 14th through 16th.

I had missed the last conferences (in 2007, I was in Hiroshima working on yet another impossible-deadline project, which was memorable because it involved adventures in Javascript; in 2006, tickets were sold out too early), so this time I took no chances and bought my tickets well in advance (before my sabbatical even started).

I even submitted a few talk proposals, out of which a talk about multiprocessing/concurrency (entitled: "From POE To Erlang") was accepted for the 'advanced' track: There were three halls/tracks in all, and the scheduling and organization was really excellent: My talk on POE (The Perl Object Environment) was followed by a talk on XIRCD, which involved some POE code so that there seemed to be some continuity.

This was also the first time in some 5 years since I actually spoke to a live audience (if you exclude the odd presentation I sometimes make at work, in broken Japanese), since I live and work in Japan. The talk went OK, but suffered a hurried, insufficient preparation. Making slides isn't as easy as I remember. I was out of practice. A second talk was also accepted, not for the actual conference tracks, but for the arrival party, on the 14th. Surprisingly enough, a Javascript talk; turns out that YAPC::Asia and the Perl community in general is very Javascript friendly. This Talk ('The Little Javascripter / Higher-Order Javascript') did not go too well at all; I ran out of time half-way through my slides (which I feared were not really complete). It turned out to be an expensive trial run, but a good learning experience.

But I hope the main talk made up for it. Special thanks to Ishigaki-san for the translations. POE really has been amazingly useful to me in the last few months, and I thought that talking about it would be a nice way to introduce Erlang to the Camel-folks. A lot were already in the know though; one lightning talk was on exactly the same topic (a POE and Erlang success story in Amazon), and while some people made strange faces at the Prologesque syntax, a couple of Erlang fans were nodding excitedly.

The Camel Folks

The great thing about YAPC is that you get to meet so many people. They say that this was the biggest YAPC yet. Meeting Larry Wall early on the morning of the arrival party day was especially memorable: I had no idea he would be showing up for the Tsukiji 7AM-sushi eating expedition, so imagine my surprise when he appeared out of nowhere and greeted me saying "Hajimemashite! Larry desu. Yoroshiku!" (I was probably the only person there that morning who he'd not met before). He's as funny as I imagined: When we arrived to find all the sushi restaurants closed, he expressed some mild dismay that his pun on the expression "shimatta!" had gone unnoticed. ('Shimatta' is Japanese for 'closed', as well as an expression for 'darn it!')

Me and Thilo got to meet him and Gloria Wall again, when we bumped into them at lunch time in Matsuya's.

Jesse was exactly like I imagined; bubbly and resourceful; Leon Brocard was surprised (pleasantly bewildered?) to learn that I use Devel::ebug, his replacement for the original Perl debugger. I took the opportunity to bounce off a couple of ideas I had (and a hack that I'd made and had been using) on it. Jonathon Rockway's lightning talk on here documents were pretty useful, and Ingy's talks were the most fun. pQuery is a great idea.

The speakers were invited to Dan Kogai's (the Encode.pm guy!) house (now reknown for it's fabulous view) for a weekend Hackathon; I couldn't make it but did show up for a few hours on Sunday evening. I did not have anything planned to work on, so I started messing with Devel::ebug and (after the heads-up from Jesse's talk) Carp::REPL as well. I was hoping to re-implement my multiplexer hack (A way to allow Perl debugee processes to connect to a debug server so that ebug clients can debug them) without POE (which ought not to be a dependency for something like a debugger, though it was tremendously useful in prototyping the idea). Not much progress, but great fun. These people are nice.



Mon, 19 Nov 2007

Screen Scraping in this Day And Age

... of RSS, Web2.0 and whatnot. As much as I loved doing it back in old days, screen-scraping (parsing HTML off of web pages with a lot of guesswork) was (and is) yucky. I suppose I enjoyed it back then because I ended up learning a bit of Awk, and later Perl.

But since I've found no good way to avoid missing concerts, other than hope that there's a RSS feed with ticket/date information for bands/artists that I don't want to miss, I have to resort to such nonsense now and then:

use LWP::Simple 'get';
use HTML::TableExtract;
use Data::Dumper;

sub STATUS { 5 }  # The 5th column of table happens to be 'ticket status'

my $te = new HTML::TableExtract;
# slurp!
$te->parse(get 'https://tickets.thepolice.com/');

my ($table) = $te->tables;             # The first and only table in the 
                                       # page is a list of all gigs by city,
                                       # date, and ticket availability
my @tokyo_gigs = grep {                
                    grep /Tokyo/, @$_  # Rows with dates in Tokyo
                 } $table->rows;

# Look out for any changes; at this time, there are only 2 shows in Tokyo
die "Whoa! no gigs in Tokyo??"    unless @tokyo_gigs;
die "Whoa! *more* gigs in Tokyo??"    if @tokyo_gigs > 2;
die "Whoa! only *one* gig in Tokyo??" if @tokyo_gigs == 1;

# ... and if their status is anything other than 'Coming Soon',
# then either tickets sales have begun, or... are already sold out!
print "Whoa! somethings up!\n", Dumper @tokyo_gigs 
    if grep { ! /coming soon/i  }
       map { $_->[STATUS] } @tokyo_gigs;

This is just so I don't miss The Police live at the Tokyo Dome, scheduled in February, 2008.

So having to screen-scrape may suck, but at least there's Perl.
UPDATE:Nov 21, 21:00 JST: Looks like it worked! Well, sort of. I put the script in my crontab and this morning it sent me a mail with "Whoa! no gigs in Tokyo??" in the body; and sure enough, it seems that the presale Tokyo tickets status had changed - a link that said "Buy Tickets" is in it's place.
(Of course, it's a totally different issue that the site in question does not seem to let one purchase tickets for the Tokyo venues - how lame! Well, at least I am early enough to buy the 'general public' tickets on time.)
posted: 07:58 | path: /programming | permanent link to this entry
Tags:


Thu, 08 Nov 2007

What if Keruac were a Hacker?

I came across a programming language called 'Beatnik': http://www.cliff.biffle.org/esoterica/beatnik.html

I happened upon it while browsing CPAN, and found a module called Acme::Beatnik.

posted: 04:45 | path: /programming | permanent link to this entry


Sections

< March 2009 >
SuMoTuWeThFrSa
1 2 3 4 5 6 7
8 91011121314
15161718192021
22232425262728
293031    

[ Home | RSS 2.0 | ATOM 1.0 ]