2009-02-27

programming can be fun (polyglot introduction)

programming can be boring, especially when you hit deadlines, or when you have to track heisenbugs.

but it can (and should) be fun. it can also be seen as a form of art - don't laugh, i'm serious. i'll try to show this through the following posts, where i'm going to write a polyglot program, while explaining the tricks i'm using to get it working.

a polyglot program is a computer program that can be understood by different compilers / interpreters, performing the same operations independently of the programming language used. it's a single file, where one tries to stuff as many different programming languages as possible.

before you start grumbling that this is not useful in everyday life, let me state that i am aware of this fact. :-) those posts are only here to have some fun and show you what can be done with programming languages, in ways that were not really foreseen when the languages were being defined. repeat after me: those posts are not meant to be a programming guide.

so, why would i write such a beast? well, the simplest reason is because i can. because it's fun. and there's not much more to it... if you think it's a moronic thing to do, i'm not forcing you to read them. after all, you came in here! :-)

in order to spice up the game, this program will do more than just say hello to the world. yup, this program will be a real one, that computes the first 10 numbers of the fibonacci sequence and display them on the screen. i said "computes", which means following the real algorithm, not displaying a stored sequence...

here's the perl version for this algorithm. it will be our base upon which we build, adding more languages:

$i = 0;
$n1 = $n2 = 1;
print "$n1\n";
while ( $i < 9 ) {
($n1, $n2) = ($n2, $n1+$n2);
print "$n1\n";
$i++;
}


note: i know that it's not really perlish, but it will allow us for a better integration with c.

nothing fancy in this program, running under plain perl 5.10 - but without strict and warnings. i won't go into much details regarding the algorithm. once again, it's really a straightforward translation of the fibonacci algorithm.

this post was just an introduction, stay tuned for the next steps. following posts will be labelled polyglot, for easier reference to the complete story.

2009-02-17

cpan2pkg now interacts with upstream buildsystem

as you're reading those lines, app::cpan2pkg 0.5.0 is propagating on cpan.

the changes are quite interesting, since it allows cpan2pkg to go from local build to upstream buildsystem:
  • importing package upstream
  • submitting package upstream
  • waiting for user confirmation when package is available on upstream build system
warning, though: currently, it doesn't take the module requirements into account before submitting a module on upstream build system. this will be fixed in next version.

but it's quite an achievement... just running "cpan2pkg Foo::Bar" will build the package with all its prereqs, install them locally, import them in upstream repository, and submit them on upstream build system. (i know, i know, only mandriva is supported as of today.)

all in all, this means that i'm nearing v1.0.0. all the basic pieces are now in place, and it's just a matter of re-ordering things, adding a couple of conditions, some fixmes to deal with... and some cleaning. a lot in fact! :-) stay tuned.

2009-02-15

app::cpan2pkg 0.4.1 released

now that padre is working again on mandriva, i've been able to make some progress on cpan2pkg...

as explained in a previous post, version 0.4.0 of app::cpan2pkg was providing the basis to completely generate and install local packages.

so, the changelog for 0.4.1 is pretty straightforward:
  • storing when a module is complete
  • build module when all prereqs have been built & installed
  • better prereqs extraction
i had the, ahem, pleasure (for a given definition of pleasure) to discover that cpan2dist is pretty dumb in its arguments parsing.

option --nobuildprereqs does not work as one might think - it really means: "don't rebuild prereqs if they are at latest version, but rebuild anyway if we're not at latest version". yeah, right, i'm stuffing --nobuildprereqs but please rebuild them anyhow if you want...

so i cheated and wanted to use the --ignore option of cpan2dist, but somehow, using a regex with look-behind assertion such as /(?<!$name)$/ does not seem to work - while it is working as intended when testing it on various strings. sigh.

anyway, i've managed to go through this. and this means that the local part of cpan2pkg is complete!

so, now i can work on upstream package importing. and maybe on some mechanism to prevent 50+ processes to be launched at the same time, for modules with a lot of prereqs... but that's, as they say, refinment! :-)

spoiled by padre

a few revisions ago, padre (the perl ide) introduced unicode specificities in wxwidgets.

unfortunately, the perl wx bindings shipped by mandriva are not unicode-aware. in fact, even if the wxwidgets library shipped is unicode capable, the perl bindings were specifically building against the ansi version. the bug has been reported and should be fixed soon.

however, in the meantime, i'm back to using something else than padre... and this sucks! no easy module profiling, no on-the-fly syntaxic checking, etc.

sure, those things could be introduced in my replacement editor (vim). however, they do not feel as natural as those features are in padre.

sure, padre has still a long way to go before matching some features available elsewhere... but it already has features that i can't live without when coding perl. and this is quite incredible when you think how yound padre is...

boy, i wish my padre will be back soon! :-)

2009-02-14

audio::mpd 0.19.6 released

audio::mpd 0.19.6 is on its way to cpan.

changes:
so, even if i started this blog to try to spread the word about perl on outside world (not that my blog is high-profile - yet! :-) - and will change perl perception overnight), it is also proving useful for me as well...

note that bug reports are better sent to http://rt.cpan.org

2009-02-06

app::cpan2pkg 0.4.0 released

app::cpan2pkg 0.4.0 is live. packages are now being built (with cpan2dist from CPANPLUS) and installed - if there's no missing prereqs, of course.

note that not all the dependency updates are treated afterwards, since it needed to have the build-package-and-install-it-locally step completed first (obviously). that would be next on the agenda.

once this is done, everything related to package generation / install will be done. and i'll then work on submitting packages upstream...

2009-02-02

cpanplus::dist::mdv 1.0.0 released

cpanplus::dist::mdv, the cpanplus backend to create mandriva rpms, has now reached version 1: much rejoicing and all that...

it doesn't mean that there won't be any new features in the future, but it is now somehow complete - read that it can install generated rpms now.

there's also a minor bug fixed: previously, the -debug package was selected (over the regular one) for binary rpms.

note that this version is already available in cooker, the development mandriva version.

padre 0.26 released

on behalf of the padre developpers, i am happy to announce the release of v0.26 of padre, the perl ide!

it took a bit longer than previous releases, because of the complete configuration layer rewrite.

now that the config revamping has landed, and with the previous plugin api cleaning, padre should now be stable for the next months (famous last words, i know). this would be a perfect time to start contributing!

full list of changes can be found here:
http://svn.perlide.org/padre/trunk/Padre/Changes

wait till cpan catches up or install by

pip http://www.perlide.org/download/Padre-0.26.tar.gz

thank you to all padre committers and supporters.