Wednesday, August 05, 2009

Perl 6 gets a release date!

Big news from the current Perl conference YAPC Europe 2009 here in Lisbon is that Rakudo * (star) will be released in spring 2010. Rakudo is Perl 6 on Parrot, which is an equivalent to the JVM or CLI.

Is that an official Perl 6 release? Well, it is the nearest to official that you will see. The Perl 6 team are keen to point out that there will be no such thing as a official version, just different implementations. I guess they are looking at Python for their inspiration there.

This could be make-or-break for Perl. It shouldn't be, Perl 5 will continue no matter what, but the new stuff is what will make Perl cool again in the eyes of the fashion conscious. We all know that fashion is fickle, illogical, and driven more by hormones than intellect. We also know how important it is in decision making. Much as it would like to, the Perl community cannot pretend that Perl 6/Rakudo is too far away to worry about. It is six months away.

My worry is that expectations will be high - the release will be incomplete and they are very open about that. The Rakudo "pumpking" (project manager), Patrick Michaud, sees this as a test release to encourage people to write applications to find bugs and feed back into the development. Trouble is that companies have been burned too often in the past to invest in applications on an incomplete and possibly flaky platform.

The dilemma is that if something is not released soon then Perl will have missed the boat - which is already upping anchor and about to steam away.

Update: read the comments from Pm - they are very good.

Wednesday, June 24, 2009

Perl 6 Questions and further information

This is following a recent Perl 6 seminar I gave.

Perl 5 style is still supported.

Named parameters go into %_
Unnamed parameters go into @_

Subroutines can be predefined with:
sub foo {…}

… is known as the "yadayadayada" operator.

Lexically scoped subroutines:
my sub mysub () is context { …}



Optional parameters: ? now comes after the parameter name.
sub mysub ($value, @harry, %ash, $opt?) {…} 


Named parameters: prefix is now : , instead of + and are optional unless they have a ! suffix.
sub named ($value, :@harry!, :%ash, :$other) {…}

...

named(42, other = 'fred', harry = @files);


Slurpy parameters, like perl 5 lists and arrays, are prefixed *

C style prototypes
Are not supported. It appears that when a subroutine is called before it is defined the parameter resolution still works correctly. However a runtime error is reported, not a compile time error (as it would with Perl 5 prototypes).

Dynamic types
These are called "traits". See Synopsis 12: Objects.

Zip operator
Has changed, it is now 'Z'. Behaviour with different length arrays has also changed between pugs and Rakudo, the result uses the shortest:


my @array = qw(The quick brown fox);
my @brray = qw(Now is the time for all);

my @all = @array Z @brray;
say @all.elems();
say @all[];

@all = @brray Z @array;
say @all.elems();
say @all[];

Gives:


8
TheNowquickisbrownthefoxtime
8
NowTheisquickthebrowntimefox




Important further change

When testing these changes in Rakudo I ran up against a change I had almost forgotten. When calling a subroutine, no whitespace is allowed between the sub name and the open parentheses. That slowed me up until I remembered. A backward step IMHO.

Tuesday, June 23, 2009

MySQL VARCHAR limits

A delegate recently queried the size limit on a VARCHAR field in MySQL. Our course documentation states a maximum of 255 characters: that is correct. For larger fields use TEXT.

Wednesday, June 17, 2009

Perl 6 Questions

I recently gave a short talk on Perl 6, and a number of questions arose. I will answer those questions as soon as I can, but unfortunately other fires need fighting right now.

One of the reasons for the delay is that the syntax for subroutines for Perl 6 has changed again, and in fact my slides are now out of date. That also means that pugs and Rakudo are incompatible in a major way - they have always been out of step to some extent.

Friday, April 24, 2009

Moving into the light?

A long time since my last post. Aside from bread-and-butter stuff, my activity has been on Python. There have been various upheavals in the business, and we aquired a Python 2 course. It wasn't too hot, and needed updating. Around the end of 2008 Python 3 was released, so I decided it would make sense to create a new course based on Python 3.

That is almost finished, but it turns out that it might have been premature, since no one seems to be in a particular hurry to move to Py3. That's a shame, because I am quite impressed. There have been issues, performance has been one of them (although I can't say I noticed any problems). In June 2009 a new version, 3.1, should be released, and that has a number of new features. So, having done all that work on a new course, I will have to hack it again come June. That's the problem with the bleading edge.

I have read of Python's ease of use, and never really believed it. After all, there are so many vested interests and religious wars that it is difficult to get a balanced view. I have to say that, after a little practice, Python is very easy to pickup. I have found myself just coding. The number of times I have to look something up gets less and less. I'm not sure I am fluent yet, but I'm close, and I reckon that is the fastest I have ever picked up another language.

Will Perl 6 be as easy?

Saturday, February 07, 2009

App::sh2p Version 0.05 now on CPAN

I always knew this would be a long project, although I'm heartened as to how far it has gone. It appears to have been useful to some people. It is a feature of Open Source that the only time I can be really sure it is being used is when I get bug reports - which could be rather off-putting to anyone without the skin of a rhino.

This latest release, version 0.05, fixes quite a few bugs, and adds support for things like trap (signal handling). In my defence, most of the bugs are missing support for certain features, and it is still in beta. I still have not got pipelines sorted out (that is a huge job), or $?, but they will come eventually. I only get to work on this in odd moments, evenings and so on, and it is difficult to find the time for development stints of more that two hours. I could really do with spending a couple of solid days on it.

One problem I had was in inserting a marker into a string which would indicate a token delimiter. Everything I tried clashed in someway with a real data item. I solved it eventually by using a gash reference, but I can't help thinking there must be a more elegant solution.

I have also started using OO techniques more - this product really does benefit from that.

I am now using the profiler and Coverage for my tests, but have not sorted out a good way to integrate my command-line tests. The "Perl Testing" book has ideas, but they require CPAN modules and I would rather not increase the number of dependencies. If you download this program and are dismayed at the tests (I basically check the thing will load) then be assured that I have a test suite of over 90 scripts, just one of which is my regression test script which currently has 55 test paragraphs within it. Each time I find a bug or add a feature I add a test, just like I should.

Friday, December 19, 2008

Shock! Horror!! A delegate ate my machine!

OK, he didn't actually eat it, but he did exploit a "feature" of CentOS I was unaware of. The halt, reboot, and poweroff programs can be called from an ordinary user if that user is logged on to the console at the time. Our classroom users have very simple passwords, but the point is that these can be called from a non-root user.

I found a fix (with thanks to Mr. Google) but I'm sure there is probably a better one. Right now this will do, since it appears to work, but I'll try and find an alternative.

In /etc/security/console.apps there is a config file for the programs mentioned (and others). Set each one to something like (for example):

USER=nobody
PROGRAM=/sbin/poweroff
SESSION=true

Of course having better passswords would help...