The right language when you really needed it
(Integration between C language and high-level languages)

Software evaluation parameters

Performance vs productivity

Productivity vs quality

Hardware compatibility vs

performance

The right language when you really needed it
(Integration between C language and high-level languages)

Productivity

Illusions and smog-sellers

Performance

Wasteland

Hardware requirements

TCO

Hardaware compatibility

Hardware Abstract Layer

System Libraries and language libraries

Quality

Documentation taboo

The fast run to chaos

Control process degree

The possibility to have fast reactions

Software evaluation parameters

The right language when you relaly needed it
(Integration between C language and high-level languages)

Performance vs productivity

Power only where needed

The right language when you really needed it
(Integration between C language and high-level languages)

Productivity vs quality

How can I obtain more productivity?

Using obscure tools to improve

productivity deprives the possibility

to provide a complete support

The right language when you really needed it
(Integration between C language and high-level languages)

HW compatibility vs performance

Why should I use system libraies?

Is the software integrated with the system? (WxWidget)

The right language when you really needed it
(Integration between C language and high-level languages)

Different languages for

different philosophies

Tcl/Tk

Perl

Perl/XS/C vs Tcl/C

The right language when you really needed it
(Integration between C language and high-level languages)

Different languages for

different philosophies

Object Oriented

languages

Lambda function

languages

Procedural

languages

Data driven

languages

The right language when you really needed it
(Integration between C language and high-level languages)

Tcl/Tk

Introduction to Tcl/Tk:

Tcl programming examples:

Multyplatform structure (file join/file split ...)

Safe slave enviroments (interp)

Basic Tk overview

Tcl weakness:

Coherency (list commands)

Multitasking is performed just by thread

Tcl strengths:

Possibility to enhance the Tcl structures using Tcl

Tcl is easy and powerful

Tcl is available for many different platforms

Tcl and C:

Tcl_CreateCommand

The right language when you really needed it
(Integration between C language and high-level languages)

Tcl and C

C code

interface

destroyer

my C function

Tcl function name

Tcl pckg name

Check for parameters type

#include <tcl.h>

#include <stdio.h>

int cProc (ClientData cd, Tcl_Interp *interp, int argc, CONST char* argv[]) {

//

// Questa funzione esegue un addizione fra "a" e "b"

//

int out=0, a=0, b=0, e=0;

char outStr[20];

if (argc != 3) {

interp->result = "Error! Usage myAdd <int> <int>";

e=1;

} else {

if (Tcl_GetInt (interp, argv[1], &a) == TCL_OK && Tcl_GetInt (interp, argv[2], &b) == TCL_OK) {

out=a+b;

} else {

interp->result = "Error!The parameters must be integer numbers";

e=1;

}

}

if (e == 1) {

return TCL_ERROR;

} else {

sprintf (outStr, "%d", out);

Tcl_SetResult (interp, outStr, TCL_VOLATILE);

return TCL_OK;

}

}

int Myadd_Init (Tcl_Interp *interp) {

//

// Questa funzione registra la procedura scritta in C

//

Tcl_CreateCommand (interp, "myAdd", cProc, (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);

if (Tcl_PkgProvide (interp, "myAddPkg", "1.0") != TCL_OK) {

interp->result = "Error while I am registering the library";

return TCL_ERROR;

}

return TCL_OK;

}

Tcl library

The right language when you really needed it
(Integration between C language and high-level languages)

Perl

Introduction to Perl

Perl programming examples

Perl weakness:

The possibility to write a unreadable code

The trust contract with the user

Tcl strengths:

Coherency (oop)

A lot of existent libraries

Perl and C:

Inline::C

XS

The right language when you really needed it
(Integration between C language and high-level languages)

Perl and C (XS vs Inline)

Inline::C

Perl

myFile.pl

GCC

XS

GCC

myFile.xs

myLibFile.c

GCC

myFile.pm

myFile.c

myLibFile.so

ObjFile.so

Dynaloader.pm

Perl

XS vs Inline

The right language when you really needed it
(Integration between C language and high-level languages)

Perl Inline::C

#!/usr/bin/perl

use Inline C;

hello();

__END__

__C__

int hello () {

printf ("helloword\n");

return (0);

}

C

Perl

File: prova_inline-01.pl

The right language when you really needed it
(Integration between C language and high-level languages)

XS (h2xs standard model)

[]$ h2xs -n example -A

[]$ ll example

-rw-r--r-- 1 warlock 149 2006-09-29 15:13 Changes

-rw-r--r-- 1 warlock 83 2006-09-29 15:13 MANIFEST

-rw-r--r-- 1 warlock 832 2006-09-29 15:13 Makefile.PL

-rw-r--r-- 1 warlock 1166 2006-09-29 15:13 README

-rw-r--r-- 1 warlock 218 2006-09-29 15:30 example.xs

drwxr-xr-x 2 warlock 4096 2006-09-29 15:23 lib/

-rw-r--r-- 1 warlock 117049 2006-09-29 15:13 ppport.h

drwxr-xr-x 2 warlock 4096 2006-09-29 15:21 t/

[]$ cat example/example.xs

#include <stdio.h>

#include "EXTERN.h"

#include "perl.h"

#include "XSUB.h"

#include "ppport.h"

MODULE = example PACKAGE = example

int

helloword ()

CODE:

printf ("Helloword\n");

RETVAL=0;

OUTPUT:

RETVAL

[]# ln -l <example path>/example/blib/arch/../example.so <perl lib path>/.

[]$ perl -I<example path>/example/lib -e 'use example; &example::helloword()'

helloword

Created by h2xs files

Our XS file

The right language when you really needed it
(Integration between C language and high-level languages)

Perl/XS/C vs Tcl/C

The right language when you really needed it
(the package manager)

What should a software package

manager do?

Do you know the installation target?

Wpkg Framework

Wpkg package architecture

Examples

What should a software package

manager do?

The right language when you really needed it
(the package manager)

Installing

Checking for dependences

Installing files in their right positions

Update the system (es: manpage indexes, ldconfig...)

Uninstalling

Checking for broken dependence

Removing the previous installed files

Update the system

Quering

What about the package?

Which file by the pachage?

Which package have originally instelled the file?

Which softwares I have installed?

Verifing

Installed files status

The right language when you really needed it
(the package manager)

Do you know the installation target?

gtk-1

gtk-2

gtk-for-embedde

ARM

Intel

SPARC

pencil

mouse

no-pointer

The right language when you really needed it
(the package manager)

Wpkg Framework

pre_install.sh

post_install.sh

tests

settings

File installing

dynamic_path

extensions

extensions

The right language when you really needed it
(the package manager)

Wpkg package architecture

<app. name>-<ver>.wpkg

pkg.tar

pkg.tar.sign

application_files.tar

wpkg_infos.txt

pre_install.sh

post_install.sh

uninstall.sh

file1

file2

file3

file<n>

pre_install.sh

post_install.sh

uninstall.sh

wpkg_infos.txt

application_files.tar

pkg.tar.sign

<application name>-<version>.wpkg

pkg.tar

Linguaggio giusto al momento giusto
Licence

These slides and the all the example files are covered by GPL licence, you can redistribute it and/or modify it under the terms of the GNU General Public license as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the GNU General Public License for more details.

http://www.gnu.org/licenses/gpl.txt

Silvano Catinella

catinella@yahoo.com

+39 348 5631681

Licence

2006-09-23T10:09:36