Unicode abuse

I was looking at doing a little bit of political activism on twitter, and as part of this, though about maximising the amount of information in each tweet a la Tweet Compressor which is an abuse of unicode to increase the 140 character (not byte!) limit for tweets.

Here's the implementation:


use utf8;
sub tweet_compress {
my $tweet = shift;
$tweet =~ s/\. ?$//; # we don't need no end of sentence punctuation
my @orig = ( qw/cc ms ns ps in ls fi fl ffl ffi iv ix vi oy ii xi nj/, ". " ,", ");
my @new = qw/㏄ ㎳ ㎱ ㎰ ㏌ ʪ fi fl ffl ffi ⅳ ⅸ ⅵ ѹ ⅱ ⅺ nj . ,/;
$tweet =~ s/\Q$orig[$_]\E/$new[$_]/g for 0 .. $#orig;
return $tweet;
}

Doing the rest of the right thing with unicode is a bit annoying (e.g.
binmode STDOUT, ':utf8';
to output the tweet correctly to stdout), and I really wish there were better unicode docs that didn't have high cognitive load .

Rakudo *'s Really Really Release Ready

How do you know when a new programming language is ready to be released? You try porting a real software framework to it. I recently completed a port of a Perl 5 framework to the Rakudo implementation of Perl 6, and guess what? It just works! This is my story...

After only a short ten year wait, a Perl 6 implementation is scheduled for release this month. Rakudo * (aka Rakudo Star) will be inaugurated on July 29th, 2010. Is it ready? That certainly depends on your expectations, but I am here to make the case that it is a usable programming language with at least one killer feature that will interest programming language addicts (like me).

I am an Acmeist Hacker, which is to say that I only like to work on projects that serve many programming languages. I have lots of these projects: YAML, TestML and JSYNC are three that I have been actively hacking on recently.

Following convention across language boundaries

I've been meaning to write this post for a while. I'd like your opinion on it.

In my last post [0] I touched on the question of following the Python ctypes API in the context of Type objects. The issue of how closely to stick to the Python API has come up a few times. There just bits and pieces I'm not wild keen on. The whole WINFUNCTYPE / CFUNCTYPE function prototype factory thing [1] for callbacks is a good example (in our implementation creating callbacks is as simple as my $cb = Ctypes::Callback->new(\&perl_func, <returntype>, <argtypes>);).

Who is the audience?

The argument for of course is the assumption that some of the first and most important users of Perl's Ctypes module will be C library authors or porters who already have a Python binding and will be interested in doing the same thing for Perl. Obviously if the Perl Ctypes implementation followed Python's 100% then the friction for those users would be low as possible and we might get more library bindings written sooner.

I've uploaded my Mastering Perl slides to the OSCON website.

I've uploaded my Mastering Perl tutorial slides to the OSCON website.

Introducing Catechesis

I love testing. I like to know, to the greatest degree manageable, that the code I have written does what I think it does. I love testing in Perl because there's a selection of tools available which is broad and deep. I wish the implementors of other languages would take a look at the Test:: and Devel:: sections of the CPAN and steal some ideas, really.

Recently I found myself designing a message-passing framework, and I decided that I wanted to at least have Perl 5, ObjC, Python, and Javascript implementations. The arguable sanity and hubris of this aside, it brought up an interesting problem in the domain of testing.

Monthly Meeting Report Of July

Yesterday, on Monday 19th of July we had our reoccuring Perl-mongers group meeting. Due to refurbishment we went to a different restaurant this time.

We were eight Perl programmers and every one of them primarly declared their participation on Doodle. Yes, we use Doodle to coordinate our meetings but we came up with the idea of implementing an online planner software by our self. Maybe this is the project one of us needed to get started with mojolicious.

We also spoke about who is going to YAPC, who is arriving when, and in which hotel do our fellow mongers stay. We also made some kind of plans for the 3rd of August when some of us want to do some site seeing in the afternoon until the preconference meeting starts. Maybe You want to come along with us to, we are looking forward to meet you.

And we also did some jibba jabba about our personal lifes, about physics, mechanics and electronics and other stuff more or less far from Perl. And we had quite some fun and a good meal.

Using magic hash key transformation

Since version 5.10, perl has the ability to magically transform keys on a hash. This feature was added to make fieldhashes possible, but has more uses. Here I'll show you how to do in using Class::Private as an example.

Loading the XS

package Class::Private;

use 5.010;
use strict;
use warnings;
use XSLoader;

our $VERSION = '0.05';

XSLoader::load('Class::Private', $VERSION);

1;

As you can see, there's not much to the Perl part of this module, it loads some pragma's (the 5.010 is important because this feature will not work on older versions) and then loads the XS.

Casting the magic

SV* new(class) SV* class; CODE: HV* hash = newHV(); sv_magic((SV*)hash, NULL, PERL_MAGIC_uvar, (const char*)&hash_filter, sizeof hash_filter); RETVAL = sv_bless(newRV_noinc((SV*)hash), gv_stashsv(class, GV_ADD)); OUTPUT: RETVAL

The joys of backtracking

I'm pleased to say that Parrotlog is now at a point where it can actually do stuff. It can call predicates and backtrack (more on that in a moment). Unification probably works as well.

Now, backtracking is tricky to get right. Currently Parrotlog has a problem with cuts. A cut is supposed to remove all choice points encountered after the currently executing predicate was invoked. Parrotlog's cut prunes all choice points since the invocation of the last predicate that matched successfully. Close, but no cigar.

YAPC::NA 2010 Survey : Final Week

For the last few weeks the YAPC::NA surveys have been running. In that time we've had received a total of 94 Conference Surveys submissions and 431 Talk & Tutorial Evaluations. While that is certainly a great response, we'd like more. Out of 298 attendees, that's only 31% of possible responses, while last year we managed 45%. So, if you haven't responded so far, please think about doing so. A mail has gone out to all those attendees who haven't responded yet, containing their personal keycode login, so please check your spam filters if you haven't received it. If can't find a copy of the email, and you definitely attended YAPC::NA in Columbus, please contact me directly (barbie [at] cpan.org).

Check SSH keys on your VPS

Today, during a routine check of a new server, a co-worker found an authorized_keys file that isn't ours. The keys in the file (two of them) were of the VPS company that provided the server. One of them is of a specific user there and the other is a generic one.

This grants them password-less access to our server. We have no idea if the private keys are shared between people and whether they are even password protected or not. If they aren't password protected and shared between users (which is likely), it means that we have a completely unknown number of people who can seamlessly access our server and if the key is stolen or ill-gotten somehow, it's much much worse.

Promoting Perl is fun

A year and a half ago, on the private mailing list of the White Camel recipients I was accused that I am trying to promote myself by promoting the White Camel award, that I am trying to turn it into a cheap marketing trick. It was done by someone I very much appreciated.

A few weeks ago, I was accused that I want to tax the funds of the Perl community.

Then in a private, "conversation" on IRC I was compared to some female body parts because I was "attacking" the above person. Apparently that happened, when I wrote that his words were offending me.

Most recently I have been accused that I am trying to use the Perl community to promote my business.

After every such event I spend hours, days, and sometimes even weeks wondering: Are they the few speaking the opinion of the majority? Is this what the Perl community thinks about me and my actions? If not, then why do I get these?

It takes ages to get in balance again.

Luckily there are many people who support the things I have been doing and express their support privately or publicly.
Thank you!

Thoughts on a Ctypes::Type object API

For the past few days I've been considering and experimenting with the design of simple Ctypes::Type objects. These are objects which, funnily enough, represent C data types for manipulation in Perl.

The reference implementation

Looking at the Python ctypes module, there were various things I didn't like. Python's simple types [0] can be summarized thusly:

>>> i = c_int(42)
>>> print i
c_long(42)
>>> print i.value
42
>>> i.value = -99
>>> print i.value
-99
>>>

Having to specify i.value seemed cumbersome for an object which essentially represents just that value and some rules for what kinds of values it can contain. So I started trying various things with tie'ing and overloading. Indeed, I was about to start a fourth project branch on types [1] before reigning in and having another think about fundamental behaviour.



Metaphor clash

Parallel programming with fork() and tail()ing logs

I' ve worked on a small freelance project recently. It was a log watcher and another tiny program watching it (watcher watcher). Basically, it's an extended `tail -f` watching over multiple logs generated by some persistent programs simultaneously and sending alerts based on configuration data. So there are two main problems before starting coding:

  1. Use threads or use fork()?
  2. Hand craft tailing code or check if there is already a module for that?

Kephra under Linux

Because of technical problems I was stuck to xp but recently using more and more my ubuntu boot partition. That was the main reason it was not on top of my priority list to to fix the remaining problems Kephra had. But finally, 0.4.2.33 is the first version that installs like a breeze. Of course its a dev release but a stable/testing release will come soon (1 blocker left).

But when you run Kephra, you will get a bag of GTK errors. That's not because i can't code. It's because i was too quick. I thought of features that in the end GTK considers as bugs. So i will rethink the autogenerated menu builder - event table - bridge. I have to do it anyway to speed up the pop velocitiy of the main menu under windows and to finalize some parts of the upcoming plugin API. But for now you can safely ignore the warnings, they're harmless. It should be also work for mac, but it's not tested, yet. (any volunteers? :) )

Put up or Shutup, part 1: Starting somewhere

My ranting and raving from the previous post, which I expected to only receive shun, flame and troll turned out to have a positive side effect: being told to actually do something about the things I was complaining about. So instead of disappearing into /dev/null or somewhere equally as stupid, and despite my own inabilities to do them all, the least I can do is something which is greater than being a clown on the internet.

The things I bitched about boil down to a few key bits:
  • Usability and experience on Perl related websites need significant improvement
  • Monitoring the effectiveness of the usability and reach along and iterating changes on the websites to improve usability for new comers and regular users
  • A greater effort to aggregate and supply high quality recordings of talks and screen casts.

Firefox/Chrome/Safari - Beautiful Examples of Objects

You may not have heard of Ralph Johnson and Joe Armstong, but they've been programming longer than most of us have, including OO programming longer than most of us have. It's fair to say that after you've been doing something a while, you tend to form opinions about it. Mssrs. Johnson and Armstrong have opinions and this interview with Ralph Johnson and Joe Armstrong is full of said opinions. It's brilliant. There's a great bit from Joe Armstrong where he explains what he thinks "OO" should be about. Though he doesn't use the Web browser as an example, I will. But first, it's important to quote him at length.

Albany.pm - Capdist, NY Perl Mongers meeting

There will be a Albany, NY Perl Mongers meeting the last week of July 2010 to get things rolling again after a very long hiatus. Sign up on the mailing list, or stop by on irc (irc.perl.org / #albany.pm) to find out more details!

Callbacks done, weird 64bit libffi issue?

The week has been frustrating, funny, yet ultimately fruitful.

Research, enhancing C function signatures

I had callbacks to Perl almost working at the start of the week, but couldn't seem to get variables updated 'in place'. The example function I was using to test callbacks, the C standard qsort, takes as its arguments a pointer to an array, the number of items in the array, the size in bytes of one item, and a reference to a function which will be passed two items from the array at a time and decide how to sort them. It returns void, and the original array ends up sorted.

I had the arguments passing to Perl and returning all right, but couldn't see how to update the array itself, so I spent a long time reading the C source for Python's ctypes to try and figure where or how it did so. I learned a lot, about Python internals in general and about its ctypes implementation.

The "M" word is the wrong word.

If you are offended, angered or feel I am mistaken, I welcome dialogue on this topic. No doubt what I will say might piss someone off.

BETA - An Example (of Failure)

The BETA project started in 1976, briefly escaped into the real world and was quickly beaten to death only to have its corpse revived in academia. It's one of quite a few languages which seems destined to never catch on. It's kind of a shame as it's an interesting language, but I'm certainly in no position to change this and, in any event, am not certain I would want to.

Yesterday I posted an example of OO in BETA. Prior to that, I posted an interesting quote from the BETA researchers. In the quote, they talked about how BETA was for modelling and they didn't like inheritance for code reuse. BETA is all about modelling things properly. They talk about this a lot.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.