Hi all,

I just wanted to run some ideas by the people on this mailing list. 
These ideas concern the fundamental architecture of Inline.pm. If you 
are interested, I would appreciate your consideration and thoughts 
regarding these issues.

The major objectives of Inline.pm are:
1) To lower the barriers that prevent people from using other 
programming languages (especially C) with Perl.
2) To create a general environment/syntax for gluing any functional or 
object oriented language to Perl.
3) To provide a fully functional replacement for XS. Actually an 
abstraction 'over' XS, exposing the best and eschewing the rest.

Much success has already been achieved towards the first objective. 
Inline lets you write C extensions as simple as Perl one-liners, or as 
complex as inlined yacc grammars :)

Version 0.30 went a long ways towards accomplishing the second 
objective. Inline is now a general framework that provides a base syntax 
and support for modules like Inline::C, Inline::CPP and Inline::Python. 
It has been abstracted in such a way as to allow the binding of both 
compiled and interpreted languages.

The only work left to be done here, is to implement the Inline support 
modules for things like Java, Ruby, Lisp, Fortran, Bash, CORBA, SOAP, 
XSLT.... The definition of 'language' can blurred using this framework. 
Just think in these terms: "I have something that I want to make work 
with Perl. It is normally (or abnormally) expressed in its own syntax 
and coded in separate files. I want to put it right inside my Perl code 
and have it do the right thing at the right time." That's the Inline 
spirit.

If you are interested in implementing any of these 'languages', please 
speak up. I think they are all doable projects. You will find lots of 
help on this mailing list. At least from me and Neil. :) I am interested 
in seeing all of these happen but I don't have the time or even desire 
to create and maintain them. I'd like to just concentrate on Inline::C 
and the core Inline module.

That brings me back to the original reason I'm writing this. Objective 
3. In order for Inline to become a widely accepted replacement for XS, I 
think a few things need to change. The most important are:

1) A formalized way to build and install 'CPAN' modules that use Inline 
extensions.

        Currently, the suggested manner for creating and distributing extension 
modules is adhoc, and a little flaky. The C code gets compiled at 'make 
test' time, and the 'make install' does not remove/replace the existing 
shared objects. This can be solved my providing tools that go in the 
Makefile.PL to generate a Makefile that does the right thing.

2) The second problem is a little stickier and is the real subject of 
this tome :) I think that the MD5 keys (the long hex numbers) that are 
currently mangled in the shared object names, should be removed and 
placed elsewhere. This would allow a script called 'beebop.pl' to have a 
shared object called 'beebop.so' instead of 
'main_C_beebop_pl_6e7142e1724ddd37c76e8d76925ff60a.so' and it would be 
installed as './blib_I/lib/auto/beebop/beebop.so' instead of 
'./blib_I/lib/perl5/site_perl/5.005/i586-linux/auto/main_C_beebop_pl_6e7142e1724ddd37c76e8d76925ff60a/main_C_beebop_pl_6e7142e1724ddd37c76e8d76925ff60a.so'
My idea is to put all the extra verification information in a sister 
file called './blib_I/lib/auto/beebop/beebop.inline'.

To address the finer points of the issue, I'll describe the current 
implementation and its pros and cons. Currently, Inline creates a name 
for the shared object by mangling together the following items 
(separated by underscores):

1) The package name (eq main, Foo, Foo::Bar)
2) The programming language like 'C' or 'Python'.
3) The following:
    A) The script name if the above package is 'main'. All of the non 
word characters like '-' and '.' are changed to '_'.
    B) The variable $Foo::VERSION if the package is 'Foo'. This is to 
identify the shared object of a distributed extension module.
4) The MIME Base16 encoding of the MD5 digest of the source code.

The main advantages of this method are:
   A) Is easy to implement
   B) Provides a unique name for any possible object.
   C) Allows many shared abject to be associated with one Perl file.
   D) Easy to recognize the meta-data parts. (Language, namespace, version)
   E) Works fine (most of the time) if you never need to see the names.

The disadvantages are:
   A) Very long names. Noisy and ugly.
   B) Hard to read and impossible to type. Adds complexity to debugging.
   C) Names don't look like 'normal' ones produced by XS. Non-Perlish.
   D) Full path names too long for many 'tar' implementations. This has 
ramifications for distributing precompiled objects.
   E) No good way to determine which objects are current and which are 
artifacts of old builds. No way to automatically remove old objects. 
Especially important if module is permanently installed in Perl site 
libraries.


I would like to propose a new implementation. It is not without problems 
and obstacles. But I think it is in the spirit of Inline and Perl: It 
makes easy things easier and hard things still possible.

Here is a list of the ideas:

1) Shorten the shared object name to one of the following forms:
    A) Script name if the package is 'main'. ragtime.pl => ragtime.so 
(drop .xxx extensions like .pl and .cgi)
    B) Package name if not 'main'. Jazz::Swing => Jazz/Swing.so
    C) 'e' plus first few chars of MD5 if script is a command line form.
-e => e_2cf5.dll (use AUTONAME feature below)
    D) Use a user specified name as a config option.
OBJ_NAME=Soul => Soul.so
2) Put all of the other info that used to be in the name (including MD5) 
into a sister '.inline' file. Check that file at load time to see if a 
compile is needed. Jazz/Swing.pm => Jazz/Swing.so => Jazz/Swing.inline
3) Require the user to specify an object name if more than one Inline 
section is used in the same file.
4) Provide an AUTONAME feature if user doesn't want to make up the names 
of multiple extensions. Names would use as much of the MD5 key needed to 
make them unique. Foo.pl => Foo.33e4.so, Foo.49.so, Foo.33e0.so. These 
have a disadvantage of not being replaced/removed on recompile.
5) Don't allow AUTONAME for extension modules. Thus ensuring that older 
versions get replaced.


I guess that's about it. Maybe not as painful as I thought. Am I missing 
anything here. I know there are a lot of creative ways to use Inline, 
and I don't want to exclude any of them. Please think about this 
arrangement and let me know your thoughts.

Thanks, Brian

Reply via email to