Aharoni in Unicode, ya mama

Treacle tarts for great justice

Archive for the ‘Perl’ Category

People Speaking – Programming Perl

Posted by aharoni on 2009-06-03

— “Hey, what are you doing?! Do you want to program in Perl?” (Hadar, to our cat, when she saw him jumping on her laptop keyboard.)

Posted in Perl, people speaking, programming | Tagged: | Leave a Comment »

Regular expressions

Posted by aharoni on 2009-04-06

I love regular expressions. I cannot live without regular expressions. I cannot understand how people can go on with their lives without using at least one regular expression every couple of hours. I don’t understand why schools teach algebra instead of regular expressions. I didn’t use any algebra in my life, ever. I used a lot of regular expressions and it is not less mathematical.

Posted in Perl, education, philosophy, programming | Leave a Comment »

Rakudo

Posted by aharoni on 2009-03-20

I just compiled Perl 6, currently known as Rakudo. It actually works.

Posted in Perl | 3 Comments »

Made Me Cry – Hague

Posted by aharoni on 2008-05-17

A guy called Ian Hague gave US$200,000 to The Perl Foundation to help the development of Perl 6.

Well, it didn’t make me weep like Misha or The Walkabouts. But i did shed a tear.

Maybe it’s a tax writeoff and maybe he could give the money to the victims of the bad weather in Burma.

But he gave it to one of the geekiest and weirdest causes possible—development of a programming that possibly no-one will ever use seriously. But it could also happen that it will be the best programming language ever. And for whatever reasons he gave his money to it. It is almost a religious story: At least three of the leading developers of Perl 6 have been struck by bad health problems. And then an angel came, so this undertaking won’t perish.

The world is not lost.

Posted in Perl, made me cry, making the world a better place | Leave a Comment »

is perl still worth learning

Posted by aharoni on 2008-01-17

Someone entered “is perl still worth learning” into a search engine and found my blog.

The answer is Yes.

Python and Ruby are not inherently bad, but Perl is at least as useful and modern as them, it has – arguably – a wonderful community of programmers, it has an amazing library of reusable modules called CPAN.

My wife Hadar is starting serious work on her PhD in physics in the Technion. The guys in the lab in which she will be working wrote some calculations software in Fortran on Windows. The first thing that Hadar is doing is deciphering this Fortran code. She asked me for some help, and i couldn’t provide much, because i don’t really know Fortran. I suggested that she will advise those lab guys to consider porting their software, at least for the future, to Perl, because it is portable and because it is quite possible that it has the same capabilities for mathematical and scientific work as Fortran has. She told it to one of the researchers there and he replied that it should not be done, because “Perl is just a language for network servers.”

Saying that “Perl is just a language for network servers” is pretty much like saying that all Russian women are prostitutes. It’s a sad and silly prejudice. Here’s an article that dispels it: Ten Perl Myths.

So Hadar learned a little Perl and PDL – the Perl library for advanced mathematics. She picked up the basics very quickly. I was pleasantly surprised that she found that Perl’s main data types are scalars ($drug = 'caffeine') and arrays (@drugs = ('marijuana', 'quaalude', 'paracetamol')), because in math it works the same way (we didn’t discuss hashes yet). I was even more surprised to learn that it seemed perfectly fine to her that @drugs is an array, but to access ‘quaalude’ you need to write $drugs[2] and not @drugs[2]. We tried searching CPAN for various mathematical functions, such as eigenvalue, matrix diagonal and linear algebra, and found everything.

So she’s gonna try that.

If she can’t convince them to migrate to Perl, i’ll have to learn Fortran and try to help them migrate from a Windows version of Fortran to GNU Fortran.

Posted in Free Software, Perl, education, programming | Tagged: | 3 Comments »

Binary

Posted by aharoni on 2008-01-09

I program for living, but i’ve never received proper formal education in serious algorithms.

Here’s a very simple problem: Take an array of length n and fill it with zeros. Every array member represents a binary digit. Now, using this array and not using the usual math for binary conversion, print all binary digits from zero to the maximum binary number with n digits. For example, with n == 3 this should be printed:

0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

Here’s what i wrote. Is it OK or is it an embarrassment?

use strict;
use warnings;

# That's right, upgrade to Perl 5.10.
# If you can't, comment out this line.
use 5.010;

my $digits = $ARGV[0] // 3;

# /If you don't have Perl 5.10, use this:
# my $digits = defined $ARGV[0] ? $ARGV[0] : 3;

my @matrix = ();
my @number = map { 0 } (1 .. $digits);
my $last = 0;

NUMBER:
while (not $last) {
    push @matrix, [ @number ];

    my $digit_index = $digits;
    DIGIT:
    while ($digit_index) {
        $digit_index--;
        $last = 1;

        if ($number[$digit_index]) {
            $number[$digit_index] = 0;
        }
        else {
            $last = 0;
            $number[$digit_index] = 1;
          next NUMBER;
        }
    }
}

foreach my $number (@matrix) {
    print "@{$number}\n";
}

Oh (edit): The real embarrassment – in WordPress the sourcecode presentation cannot display Perl properly. But if i put ‘ruby’ instead of ‘perl’ in the language attribute, it works mostly fine …

Posted in Perl, education, programming | Tagged: , | Leave a Comment »

Big Girl Perl

Posted by aharoni on 2007-12-18

Love is so simple, to quote a phrase,
You’ve known it all the time, I’m learnin’ it these days.
Oh, I know where I can find you, oh, oh,
In somebody’s room.
It’s a price I have to pay
You’re a big girl all the way.

Happy birthday, Perl.

Posted in Perl | Tagged: | Leave a Comment »

Hard is not Impossible

Posted by aharoni on 2007-05-10

I did a talk at Jerusalem Perl Mongers meeting.

I showed a little script that i wrote two years ago when i wrote a paper about Lithuanian grammar. The script searches a text for uses of the nearly extinct Illative case. In the paper i tried to understand why do authors still use even though there are other ways to describe motion in Lithuanian. The paper was surprisingly well-received back then. (See also discussion about it in Debesėlis forum.)

Anyway, the script is not too clever in any special way. Scanning a text for words with illative endings is almost the same as scanning a log on a server for errors. (I once heard a co-worker using the phrase “perling through the logs”. He said that it’s his own invention!) Except that human language is much more complicated.

Now i say that clever analysis of a text in a natural human language is not impossible. I am thinking of a unified way to translate grammar books and dictionaries to machine-readable representation – to describe English, Lithuanian and Hebrew in the same way. I tried to search for other projects that did something like that, but found only theories without implementations or implementations which were too language-specific (Hebrew-only, English-only, etc.) After thinking about it for a few weeks i also started to truly understand a lot of concepts that i learned have been taught in the five years of studying for a Linguistics degree.

With modern tools such as Google, Perl 6 grammars, Semantic Web-related technologies, and some older ones, such as Prolog, building such a system seems technically feasible, just a question of man-years. At the Perl Mongers one of the participants also turned my attention to WordNet, which is mostly English-specific, but seems promising.

A lot of my friends want to establish a start-up company. If i shall ever do that, that’s what my company would do.

Posted in Perl, linguistics | Tagged: , , | Leave a Comment »

Grapes of Wrath 2007

Posted by aharoni on 2007-04-30

Winograd committee (standard!) which investigated the Second Lebanon War published its first official report today.

It is generating a lot media attention, but i wanted to point out two little things.

First – Retired Justice Eliyahu Winograd is the head of the committee. Winograd means grape in Russian. Thought you’d like to know.

Second – i like epigraphs and opening phrases. Great opening phrases, such as “In the beginning God created the heaven and the earth” (which is probably an incorrect translation, but who cares), “On the twelfth of June, 1812, the forces of Western Europe crossed the Russian frontier and war began, that is, an event took place opposed to human reason and to human nature”, “We hold these truths to be self-evident, that all men are created equal”, “The history of all hitherto existing society is the history of class struggles”, “Perl is a language for getting your job done”.

The Winograd report doesn’t have a great opening line.

But it does have an epigraph: “Weep sore for him that goeth away: for he shall return no more, nor see his native country” (Jeremiah 22:10). And the explanation: “This report is dedicated to the memory of beautiful flowers, the soldiers of IDF, that were cut down before their time in the second Lebanon war. They left after them a crying mother, a worrying father, a sad brother and a baby”.

The epigraph is taken out of context. The verse is incomplete. The full verse is “Weep ye not for the dead, neither bemoan him: but weep sore for him that goeth away: for he shall return no more, nor see his native country.”

As far as i understand the passage in the Bible refers to captive people. It is related to the war, because it started after soldiers were captured; but the explanation to the epigraph refers to soldiers who died in the war itself.

Israeli judges usually seem to write very good Hebrew in their reports and verdicts. I think that they slipped a little this time.

Posted in Bible, Hebrew, Israel, Perl, literature, politics | Leave a Comment »

Get It

Posted by aharoni on 2007-04-07

I was looking for a way to write down our songs in a way that the whole band will easily understand. Musical notation would be overkill – i needed a simple “map” of every song that will describe it as song parts – intro, bridge, verse, chorus, coda, etc., and instrument parts – guitar, piano, drums, and comments such as play slower here, play louder there etc. MIDI is good for describing music to computers, not people. Cubase is good for recording, but not for printing – except maybe notation scores, but i don’t need that. I tried writing it as a table in a word processor and found out that it was bad at the middle of the intro to the first song.

So i thought about making up some XML format and writing a Perl script that will convert it to PDF, HTML or some other printable and readable representation. And then i found out that what i really need is XSLT which does just that – transforms XML to other formats.

I kept hearing about XSLT everywhere, so i thought that now would be a good time to finally start using it. I read some articles and tutorials about it and most of them said that XSLT works like Lisp. So i recalled Eric Raymond’s article about becoming a hacker:

“Other languages of particular importance to hackers include Perl and LISP. Perl is worth learning for practical reasons; it’s very widely used [...]

LISP is worth learning for a different reason – the profound enlightenment experience you will have when you finally get it.”

(I think that there are more and better reasons to learn Perl, but i shall put that aside now.)

I tried to follow Raymond’s advice and study Lisp since about 1998. Yesterday i started getting it for the first time, with the help of Cygwin, Guile and this fine tutorial by Dorai Sitaram. The experience is enlightening indeed.

If you ever tried studying functional programming and gave up – try it again. It took me nine years to get it, and chances are that you are smarter than i am.

Posted in Miron Tzabari, Perl, music | Tagged: , , , , | Leave a Comment »

Like braille to the night

Posted by aharoni on 2007-03-14

You don’t need to understand anything about computers to read this entry. It’s a cultural observation.

For a long time – since about 1999 – Perl has been my favorite programming language. Formally i studied Pascal, C, C++, Java, DCL and SQL, but i haven’t used them much outside the studies. I’ve done almost all of my real work in Perl and i’m quite proud of it.

Lately i started to think about it. There are other programming languages which can compete with Perl. Perl’s best known strengths are price (zero), freedom (“open source”), dynamism (no need to worry about memory allocation) and portability (ability to run on almost any computer). But the same can be said about Python and Ruby and a significant number of people are sure that those two are even better. Java and the .NET family of languages have lovely and colorful tools and rich and robust libraries of reusable code. Yet i’ve never really came to love any other language as much as Perl, which still remains my absolute favorite. And then i understood why.

It’s the Perl culture that fits me so well. Yair Garbuz, a well-known representative of the current Israeli intelligentsia, said once: “I don’t speak to anyone in his language; If I have to speak to him in his language, it means that I don’t respect him enough to think that he’ll understand me if i speak my own.” The Perl culture doesn’t try to speak to me in my language. It considers me smart enough to learn to understand it.


Oh (edit): Stupid, stupid. I did use a lot of DCL for work.

Posted in Perl, philosophy, programming | Tagged: | Leave a Comment »

Keep it Gangsta!!

Posted by aharoni on 2006-08-24

A. E. Aharoni and L. Wall, OSDC 2006, Netanya

From an email from Larry Wall to the Perl 6 mailing list:

Reduce operators only turn infix into list operators. What you really
want here is a hyper-fatarrow:

    my %h = @k »=>« @v;

No, i’m not going to post every single Larry Wall quote from his every email.

I just like the word “hyper-fatarrow”, which refers to the fat arrow (=>) inside those angle quotes (»«), which you probably don’t have on your keyboard. Larry is quite brave to introduce Unicode characters as operators in a general purpose programming language. So he’s allowed to give them funny names too.

Posted in Perl | Tagged: | 1 Comment »

The cages and the cages

Posted by aharoni on 2006-08-21

I submitted a patch for Parrot and it was even accepted.

Parrot is the codename for the central part of the next version of the Perl language, Perl 6 (it’s a dynamic registered-based virtual machine, if you’re technically inclined). Because it is called Parrot, there’s a role in the development team called “cage cleaners” – the people who do all the little work without diving deeply into the magick algorithms. So i am one of them.

This patch doesn’t do much except aligning some spacing and indentation in a Perl file. But i’m still insanely excited. It is not functional for Parrot, but it helps developers write code without bugs.

More to come … i hope.

Posted in Perl | Tagged: | 3 Comments »