Tuesday, October 31, 2006

Featherweight Wrap Java

Hurray! They accepted our paper "Featherweight Wrap Java" at SAC (The 22nd Annual ACM Symposium on Applied Computing), Special Track on Object-Oriented Programming Languages and Systems (OOPS), it will then appear on the proceedings of the conference (published by ACM press):

Featherweight Wrap Java
Lorenzo Bettini, Sara Capecchi, Elena Giachino.
Proc. of SAC (The 22nd Annual ACM Symposium on Applied Computing), Special Track on Object-Oriented Programming Languages and Systems (OOPS). ACM Press. 2007. To appear. abstract wrapjava.pdf bibtex


Abstract
We present an extension for a Java like language with a mechanism
for dynamically extending object behaviors. Our approach consists
in moving the addition of new features from class (static) level
to object (dynamic) level: the basic features of entities (representing
their structure) are separated from the additional ones (wrapper
classes whose instances represent run-time added behaviors). At
run-time, these entities can be dynamically composed by instantiating
wrapper objects which are attached to basic entities. We
formalize our extension by adding the new constructs to Featherweight
Java; the core language so extended (Featherweight Wrap
Java) is type safe.

Hopefully, this will become a Java extension (in the shape of a preprocessor) in order to have this "delegation-like" feature. The basic idea is to be able to extend object behaviors (methods) dynamically by wrapping objects. This reminds the Decorator pattern, and indeed this pattern was our main inspiration. (See the image representing the Decorator class diagram).

This way, you won't have to implement the pattern manually: you will simply use our proposed language extension.

Actually the language extension we propose is more powerful than what you get with decorator patterns, since it implements both consultation mechanisms and delegation mechanisms.

The theory of this extension is based on Featherweight Java.

Wednesday, October 25, 2006

I love Static Typing

I know it's a great debate: static typing vs dynamic typing. I definitely prefer statically typed languages. Lots of type errors in programs are detected during the compilation and not during the execution of programs. I think this way programs are far more reliable. It might be tedious to declare variables before using them, and specify their types, but the time you "waste" in this operation is surely repaid when you won't have to test your program thoroughly just to be sure that there are no situation where your program goes wrong because it misuses a variable. Even worse when the program silently uses a variable that is not defined.

Although I like PHP very much, I find it really irritating when your browser shows an error in your dynamic web site because you used a function that is not defined (probably just because you misspelled its name). Not to mention when your program silently misbehaves (without no sign of error) just because you used a variable that is not defined (and in that case it simply instantiates a variable with an empty value).

If a program is type-checked at compile time, it won't have to be re-checked (or at lease, completely rechecked) at each execution time (and I think you gain a lot in efficiency).

When I have to test my programs, I prefer to concentrate on the right implementation of the program logic, rather than to check whether I used the right types. That should be compiler's work.

Of course, dynamic typing is good under certain circumstances (dynamic loading of code); but for the other situations, I feel more comfortable and safe with static typing.

As you might have guessed, this post comes after some time spent on debugging a program that misbehaved just for this reason :-)

Just my opinion :-)

Friday, October 20, 2006

Eclipse & LaTeX: TeXlipse

I've been using this plugin, TeXlipse, http://texlipse.sourceforge.net, for few days and already love it! It's a plugin that adds Latex support to the Eclipse IDE. It is not a WYSIWG editor (which somehow is in contrast with the pilosophy of LaTeX, I think); however it has many great features that help you a lot when writing latex documents, e.g., syntax highlighting, code completion (especially for macros and bibtex, which is great!) and also shows the dvi with xdvi highlighting the part of the document where you're at in the sources. Give it a try! :-)

Thursday, October 12, 2006

Code2blog: Source-highlight frontend

Jim Storch, http://jimstorch.blogspot.com, wrote a frontend for Source-highlight, that can be used to highlight on-the-fly a program so that the formatted form (HTML) can be easily copied and then pasted in your blog. This frontend is written using Python (version 4) and pyGTK.

You can find it here http://code.google.com/p/code2blog.

I started to use it and like it very much!
Well done Jim! :-)

Monday, October 09, 2006

GNU Source-highlight 2.5

I've recently released the new version of GNU Source-highlight, http://www.gnu.org/software/src-highlite, which, given a source file, produces a document with syntax highlighting.

Source-highlight reads source language specifications
dynamically, thus it can be easily extended (without recompiling
the sources) for handling new languages.
It also reads output format specifications dynamically, and
thus it can be easily extended (without recompiling
the sources) for handling new output formats.
The syntax for these specifications is quite easy (take a look at the manual).


This way, instead of the colorless listings such as
/*
A simple hello program,
for http://tronprog.blogspot.com
*/

#include <iostream>

using namespace std;

int main()
{
cout << "Hello Blog!\n" << endl;
return 0;
}

You'll get the more nice looking one:
/*
A simple hello program,
for http://tronprog.blogspot.com
*/

#include <iostream>

using namespace std;

int main()
{
cout << "Hello Blog!\n" << endl;
return 0;
}

Notice that source-highlight can also be used as a formatter (i.e.,
without highlighting): you can, for instance, format a txt file in HTML (and it will take care of translating special characters, such as, <, >, &). In particular, the first (non colored) listing in this article was formatted with source-highlight without any highlighting but with the transformation of special characters.

Since version 2.2, source-highlight can also generate cross references; in order to do this it relies on
GNU Ctags, http://ctags.sourceforge.net.

These are the output formats already supported:
  • HTML
  • XHTML
  • LATEX
  • TEXINFO
  • ANSI color escape sequences (you can use this feature with less)
  • DocBook
These are the input languages (or input formats) already supported (in alphabetical order): C/C++, C#, Bib, Bison, Caml, Changelog, Diff, Flex, Fortran, Html, Java, Javascript, Latex, Logtalk, Log files, Lua, ML, Pascal, Perl, PHP, Postscript, Prolog, Python, Ruby, Shell, Sql, Tcl, XML.

Happy Highlighting! :-)

Thursday, October 05, 2006

PhpBibliography 0.3 - web based bibliography system

I've released version 0.3 of PhpBibliography, http://phpbibliography.sourceforge.net, a web based bibliography system.

PhpBibliography allows you to publish your bibliography online (and to edit it via web). It is implemented in Php and uses MySql. This is free software, open source, released under GPL.

The main features of the system are:

  • stores all papers details in a SQL database
  • handles uploads of files (e.g., .pdf of papers)
  • automatically generate bibitems
  • supports insertion of papers through existing bibitems
  • allows paper search and filter (e.g., authors, title, keywords, etc.) mechanisms
Papers are publicly visible but can be modified only via an authentication mechanism (based on users and passwords).

Papers are all stored in a common database, and can then later be filtered according to a specific authors so that each author can show his/her own papers in his/her own page (for instance at http://www.lorenzobettini.it/papers the papers shown are collected from two different phpbibliography installations; the papers are included in this webpage by using a remote URL inclusion mechanism by specifying, in URL the filter criteria -- in this case, the filter is to show only my papers).

Wednesday, October 04, 2006

Gentoo, Cups & Foomatic (stopped with status 22)

I've been using the Linux distribution Gentoo for a long while now and I've always enjoyed (and in spite of what I read on some web sites, I found it the most performant distribution). Packages are installed by compiling sources and thus it might take quite a long time to set up or upgrade a system, but then it's quite easy to maintain.

For some days I've been struggling with Cups when I was trying to install a Xerox printer, a Phaser 4500 DT (by using the drivers found on their website): everything is installed fine but when I tried to print something, nothing happened :-(

By taking a look at the log /var/log/cups/error_log, I found this line:

PID 7265 stopped with status 22
By searching on Google I didn't find much, but someone mentioned a similar problem due to missing footmatic packages...

Well, installing foomatic with
emerge foomatic
solved everything :-)

I hope this avoids some headache to other facing the same problem!

Monday, October 02, 2006

Compiling KDevelop from sources

Kdevelop is an IDE for KDE for various programming languages. I use it primarily for C++. It's very pleasant to use and it's also integrated with QDesigner for visually build graphical user interfaces.


Since I like to use the new features, I don't rely on the pre-built packages: I compile it from the svn sources, and in particular I'm using the currently developed 3.4 release. However, I also keep a working copy of the currently stable version 3.3.4; for this reason I install the version taken from svn in a different directory.

At first I had some problems in this process, so I report here my experience in successfully build and install kdevelop in a different directory. In particular, the following instructions assume that you want to install the compiled version in $HOME/usr/local. In case you want to install it in a different directory, all you need to change is this value.

First of all, I followed the instructions found at the web site (for downloading the sources from svn).

Then I run configure as follows (for $KDEDIR/share/doc/kde/HTML/en/kdelibs-apidocs/, please see the
instructions in the above web page):


./configure LD_LIBRARY_PATH=$HOME/usr/local/lib:$LD_LIBRARY_PATH
LIBRARY_PATH=$HOME/usr/local/lib:$LIBRARY_PATH --prefix=$HOME/usr/local
--with-kdelibsdoxy-dir=$KDEDIR/share/doc/kde/HTML/en/kdelibs-apidocs/
--disable-ada --disable-bash --disable-fortran --disable-haskell
--disable-java --disable-pascal --disable-perl

Of course, you can choose all the --disable options you like.

Then you can run make to compile the sources, and finally make install to install the compiled version (of course if you're installing in a system directory, then you might need to have the required privileges).

When you want to run this version of kdevelop you must use some environment variables. Here's how I run it (of course you can put this command line in a shell script):

LD_LIBRARY_PATH=$HOME/usr/local/lib:$LD_LIBRARY_PATH
LIBRARY_PATH=$HOME/usr/local/lib:$LIBRARY_PATH
KDEDIRS=$HOME/usr/local:$KDEDIRS
$HOME/usr/local/bin/kdevelop

Now you should be able to enjoy all the nice features of kdevelop :-)