
In the last year I’ve spent six months digging into a PostgreSQL project. PostgreSQL is one of the most interesting and fast developed database management systems. However it is still a little bit behind the major commercial competitors, it is without any doubt, the most advanced OpenSource and Free DBMS. On the great features of PostgreSQL is the documentation of its architecture, that is maintained updated constantly by its vivid and active community. Although this community provides one of the best (the fastest that I’ve every experienced as a single user) developer on-line support system, at that time (and still now!) I had serious difficulties to find out information about on of the most used and useful coding extensions: custom types. Some of you may had to work with PostgreSQL extensions like PostGIS (the simplest and most effective spatial extension that integrates spatial information into PostgreSQL) and wanted to extend or to provide similar functionalities so easy to use and comfortable. I was mentioning the user-friendly constructors for spatial objects. Custom Types for defining spatial objects are defined in the SQL language like that
POINT('37','-97');
(for more information, take a look to this link)
This type of syntax is only possible (as far as I know) if the type is defined using a C function, and for instance compiled into a .so shared object library provided to PostgreSQL. C PostgreSQL custom types are defined by two functions that translate the low level description of the type into SQL usable constructors. Here it follows the code to define constructors for a Currency type, and attached into this file, there is the source code for other operations like equals, greater and exchange rate calculation (the source of this piece of code is PostgreSQL C Reference Documentation).
/*
** Name: fcur_in()
**
** Converts an fcur value from external form
** to internal form.
*/
PG_FUNCTION_INFO_V1(fcur_in);
Datum fcur_in(PG_FUNCTION_ARGS)
{
char * src = PG_GETARG_CSTRING(0);
char * workStr = (char *)palloc( strlen( src ));
char * units = NULL;
char * name = NULL;
char * xrate = NULL;
fcur * result = NULL;
char * endPtr = NULL;
strcpy( workStr, src );
units = strtok( workStr, "(" );
xrate = strtok( NULL, "/)" );
name = strtok( NULL, ")" );
result = (fcur *)palloc( sizeof( fcur ));
memset( result, 0x00, sizeof( fcur ));
result->fcur_units = strtod( units, &endPtr );
if( xrate )
{
result->fcur_xrate = strtod( xrate, &endPtr );
}
else
{
result->fcur_xrate = 1.0;
}
if( name )
{
strncpy( result->fcur_name,
name,
sizeof( result->fcur_name ));
}
else
{
strncpy( result->fcur_name,
unknownCurrencyName,
sizeof( result->fcur_name ));
}
PG_RETURN_POINTER( result );
}
/*
** Name: fcur_out()
**
** Converts an fcur value from internal form
** to external form.
*/
PG_FUNCTION_INFO_V1(fcur_out);
Datum fcur_out(PG_FUNCTION_ARGS)
{
fcur * src = (fcur *)PG_GETARG_POINTER( 0 );
char * result;
char work[16+1+sizeof(src->fcur_name)+16];
sprintf( work, "%g(%g/%s)",
src->fcur_units,
src->fcur_xrate,
src->fcur_name );
result = (char *)palloc( strlen( work ) + 1 );
strcpy( result, work );
PG_RETURN_CSTRING( result );
}

I was reading the New York Times, where I discovered an interesting article standing out again from the crowd of tech reviews. I’m always attracted by the searticles that describe Italians and Italian researches, since the objectivity of NY Times journalists make easier to understand the real value of that piece of work. In this case the article was digging some years ago (nine to be precise) into “La Repubblica’s” archive which explained why the @ symbol was firstly used by italian merchants. A Florentine merchant named Francesco Lapi used the symbol @ in a letter written 473 years ago today, on May 4, 1536. As prof. Giorgio Stabile (Full professor of Science’s history at “La Sapienza” university, Rome) explained to The Guardian in 2000, Francesco Lapi’s letter was sent from Seville to Rome and described the cargo on three ships that had just returned to Spain from Latin America:
“There, an amphora of wine, which is one thirtieth of a barrel, is worth 70 or 80 ducats,” Mr. Lapi informs his correspondent, representing the amphora with the now familiar symbol of an “a” wrapped in its own tail.The Spanish word for amphora was “arroba,” and the Oxford English
Dictionary explains that the unit was approximately 25 pounds of a solid or about 3 gallons of a liquid. In modern Spanish, the @ symbol on keyboards is still called an arroba — as a Google image search illustrates. The word “arroba” itself was a Spanish corruption of an older Arabic word.
(src)

When approaching a new design of a rich content web application, the same questions always come out: which is the best framework for the purpose?
Well.. depending on your definition of “rich” and also to the complexity of the interactions within the platform that you want to built up, a few approaches exist to solve this problem. The first possible I will call it the “Javascript” approach. Thanks to the affirmed level of the Javascript technology, there are a lot of interesting libraries (such as JQuery or Dojo) that can provide the developer of a powerful toolkit for building fancy interactions and ready to go components. Especially if paired up with other strong Ajax frameworks (like Zend Framework), it can create a spicy mixture that boosts the development process. But what about the “after”? Usually independent programmers don’t care that much about the maintenance of the code… and more generally about the application development process, since the majority of software project failures are registered in the development phase.
But what if the project results successful? Code maintenance could be as much harmful as software development! In such situation I would personally have preferred to have chosen the second approach, that I will call “the Flash approach”. Nowadays flash players are installed in every PC, and a web browser without flash player support… has more than a half of the websites unavailable for its users. Flash movies are embedded everywhere (for Video streaming, Audio streaming, Slideshows…) but the power of flash movies is not only on the easy interface and interfacing power (i.e. a .swf movie can be considered as a small, fast web embedded application). A lot of programming languages have moved forward to match that standard and provide different languages to create complex flash compiled web applications . Those ones built in flash are not only fast to develop, but also to maintain. Opposing to their javascript competitors, websites built in flash (e.g. the famous French music website Deezer) take both positive aspects from website applications and standalone ones. Hence from a developer point of view, those websites are nothing more than a set of compiled applications, merged together in a light fashion to be served by the Internet community.
Just to have a taste of what is outside for the Flash development, I listed some swf generators APIs:
- Flex: obviously the mastered languages from Adobe to create flash applications, it provides an XML based language as support to the Actionscript interactions
- OpenLaszlo: a direct competitor of Flex. It provides a similar XML based syntax to build .swf web applications
- Ming: a C , C++, PHP, Python, Ruby, and Perl (yes you have understood…) library to generate SWF files
hi there! as you can see those pages have been cleaned again, since Wordpress platform seems to hate me and my writing skills…
Sorry for this issue but I promise I will refill my pages with the whole old content!
stay in touch!