The Revamp of Gioorgi.com

The English New Year Intro:

Hi all readers,
the last reports show the lack of articles was a major issue for Gioorgi.com

My time was heavily compressed by my forthcoming baby (I will dad in a few months guys!).

Also my Job as Senior Consultant required a lot of my energy.

Gioorgi is bi-lingual, so the English guys can expect articles on the following:

  • Software trends
  • RedScorpion Code snippet
  • A new look, which will slowly grows in the next months

And now the Italian intro:

Un caloroso e felice 2010 a tutti i lettori di Gioorgi.com.
Purtroppo a causa di motivi personali (un bimbo in arrivo a maggio) e del troppo lavoro, negli ultimi mesi non sono riuscito a dedicarmi a Gioorgi.com come dovevo.

Nel tentativo di conciliare le nuove esigenze, ecco quello che troverete sul sito nel 2010:

  • Articoli tecnici di informatica in inglese
    Mi dispiace ma “English is the king of IT” e per rendere più aperto il confronto con le miriade di sviluppatori su Internet, non posso usare l’italiano. RedScorpion è l’etichetta che raggruppa tutti questi aspetti.
  • Storie di follia, magia e simpatia, di cui già avete avuto un assaggio, molto apprezzato
  • Un pizzico di politica, ma a caso e quando serve.
  • Recensioni di libri, vecchi e nuovi
  • Un nuovo look, essenziale ma che sarà sempre più curato con il passare del tempo.

JQuery Debugger

UPDATE:: Please see also http://gioorgi.com/2010/jquery-trainer/ about JQuery Training

JQuery Debugger is a small debugger developed by Gio, for every day ajax development.
JQuery Debugger is very light and not-intrusive. It places a “view source” button.

The “View source” button pop up a window with the html source

It is still in beta stage, but you can try it out.

Speed Intro

  1. Grap the last JQuery, and include it in you pages
  2. Download the debugger.js script here [download id=”4″]
  3. Add the following lines to the footer of all your html pages:
    <script type=”text/javascript”>DEBUG = true;</script>
    <script src=”./debuggerBeta1.js” type=”text/javascript”></script>
    <div id=’debugger_bottom_bar’/>
  4. Give me your feedback with a comment below!

April 0.2 Application Performance Framework

April (Application Performance Framework) is a super-light application framework based on Spring, featuring:

  • An Aspect Oriennted Programing Performance Monitor, which try to increase performance on the fly
  • A super-light XML-RPC communication framework

April first commitment is “be lite, be pluggable” and do not re-invent the wheel.
I am happy to describe here how it works the Beta 0.2, called “Fat Cat” by friends.

Getting Started with April

April is a self-contained package, you can download here:

[download id=”3″]

April project has been developed under Eclipse Ganymede, which is higly recommended. Anyway an ant build script is provided.

The project binary results in a webapp (war) you can deploy under your preferred application server.

How it works

The april demo is composed of a FileMonitor utility used to monitor file changes across a file system.

The core of April is the PerformanceMonitor, which is an aspect configured via Spring: take a look to the aopMonitor.xml located under april/war/WEB-INF/spring/ folder.

The performance monitor will start measuring the performance of every methods defined in the pointcut. When one method is too slow, the Performance Monitor will check if the method belongs to a class implementing the “AutoTune” interface.

If the AutoTune interface is implemented, the PerformanceMonitor will ask to the object if it can be opttimized via a call to

public boolean canBeOptimized();

If the method returns true, Performance Monitor will begin the optimization phase.

The optimization phase

The Performance monitor will invoke the following method of the AutoTune interface

public Runnable split() throws Exception

Is up to the implementation to return a new runnable object, which will do a part of the work.
The returned object need not to be of the same type of the AutoTune implementor  (ATI).

The idea behind

The idea is to find bottleneck based on how much time a method takes to run. The monitor then asks to a slow instance to spawn another thread.

This approach cannot solve every issue, but it seems effective on some scenarios, because it can “follow”  the bottlenecks when they change position.

The call is performed before the return statement of the “slow” method, and a global lock is used to guarantee only one spawn request at the time.

The post-optimization phase (speculation)

This phase is fired via the AutoTune method

public void mergeWith(AutoTune candidate2);

but it is still unfinished and unstable, so it is disabled for the meantime.
I am evaluting different approaches, and every comment is welcome.

Do you like April? Do you have an idea for improving it? Leave a comment below!

Release History

  • April 0.2 is the first full english release.
  • April 0.1 was a “request for comments” release, published in this italian article. It was released on April 8th , 2009

JRuby and Jython: the easy way

This entry is part 5 of 19 in the series Programming Languages

The revamp of Jython 2.5, the python interpreter written in Java, is a very good news, because give us the chance to think of a new way of coding. Looking at Google trends,  JRuby and Jython are emerging as key  pieces of a new puzzle.

OOP revolution take years to become active, and Java success is based on about 15 years of trials, errors and refinements.

After some considerations, at Gioorgi.com we are evaluting a new approach to java  programming.
New methodology emerge slowly, and it is not easy to find what is userful to day-by-day programming. One of the true success of OOP is the reduced mantenance costs, because OOP has a stronger isolation of related concepts.

So let’s start from academic research, to see what can help us to reduce maintenance costs.

If you take a look to  Traits: Composable Units of Behaviour, published on 2003 by Nathanael Scharli, Stephane Ducasse, Oscar Nierstrasz, and Andrew P. Black, you read:

[…]A trait is essentially a group of pure methods that serves as a building block for classes and is a primitive unit of code reuse. In this model, classes are composed from a set of traits by specifying glue code that connects the traits together and accesses the necessary state. We demonstrate how traits overcome the problems arising from the different variants of inheritance[…]

Traits differ from classes in that they do not define any kind of state,
and that they can be composed using mechanisms other than inheritance.

Building dynamic traits is an interesting approach to programming, similar to Aspect Oriented Programming (AOP).

Anyway both ideas (traits and AOP) have been proved a bit unsuccessful in the day-by-day programming. After looking at the implementations,   a small peak on google shows only experimental projects.

A web framework based on dynamically service composition, can be an interesting step for shortening Java coding time.

In this context, the Java-Python bridge (Jython) a dynamic interpreter, is a better solution then a compiler, because give us more freedom. Also JRuby shares a similar approach.

Let’s see the key point of this idea:

  • There is no need of learning a new library, but it is possible reusing as much as possible JDK know-how.
  • Python offers lambda functions, a powerful way of defining scoped and parametric functions. This is impossible in Java, and similar approach (based on CGLIB or Spring for instance) are  slow to set up, understand and debug. Teams need to be trained a lot, and this can increase development costs.
  • The ability to extend Java classes via  python code gives you a strong flexibility
  • The dynamic aspect of python simplify coding of prototype parts and mock objects
  • Python has several advantages on its own:
    • Python is older then similar dynamic scripting languages.
      Python was created in the early 1990s by Guido van Rossum at Stichting Mathematisch Centrum.  Also Ruby has a similar born date, but it has grown slowly.
    • Python code is easy to understand compared to more mature scripting languages (like perl)
    • Python library is rich
    • Python community process (PEPS) is well established, and live
  • The security model of Java protect us from abuse. This has been a problem in python. For instance a web framework written in pyton (called Zope) suffers from this lack of security and isolation. This issue is common also to Ruby as a dynamic language.
  • Java memory management  is stronger then the Python one.
  • Java multi-processing abilities can leverage python lacks on this area
  • Java is slowly moving toward scripting languages. JSR 223 is an example. At the moment, there are the following scripting engines:

For these reason, Jython/JRuby look promising for prototyping and developing.

References

Creare pdf da pagine web attraverso Internet Explorer

Tempo fa (Ottobre 2008) ho dovuto valutare la fattibilità di una soluzione “save as pdf” basata sull’automazione di Internet Explorer. Il risultato finale è stato soddisfacente, soprattutto per quanto riguarda il rapporto risultato/effort. Vediamo quindi come creare una funzionalità universale “Save as PDF” in meno di un giorno…

Continue reading “Creare pdf da pagine web attraverso Internet Explorer”