Tool Command Language: il papa’ di Java

E’ notizia fresca di stampa il rilascio di Tcl 8.6, che introduce parecchie novità a dispetto del fatto che sia una “minor” release.


In particolatre Tcl 8.6 introduce un motore “stackless”, integra nel linguaggio le estensioni OOP, ed aggiunge le coroutine.

Parliamo quindi diffusamente di Tcl, un linuaggio che ho sempre trascurato perché mi sembrava macchinoso e un po’ brutto/fatto  male…ma mi sono dovuto ricredere.

Continue reading “Tool Command Language: il papa’ di Java”

I hate XML, but now less then before thanks to SimpleXMLParser

I admit it: I hate xml square brackets dancing orgy, even in Java.

Anyway, all is xml-ized around me. So in 2006 I developed a small XML parser based on SAX. It was a shitty dirty code for JDK 1.4 which let you parse xml stuff defining a method and forgetting about selectors, XPath,  XWing, Tie fighters and so on…

I called it UltraSmartParser, a shitty name too.
Now I have revivied it from the tomb of darkness, and dressed with fancy super powers. It is on github:

To give you a tast of its power, let look at this code:

public class WordPressExportReader extends SimpleXMLParser {
	public static void main(String[] args) throws SAXException, IOException {

		XMLReader sax2Parser = XMLReaderFactory.createXMLReader();
		SimpleXMLParser parser = new WordPressExportReader();
		File f = new File("c:/jjsoft/gioorgicom.wordpress.2012-08-07.xml");
		FileInputStream is = new FileInputStream(f);
		InputSource s = new InputSource(is);

	private String currentTitle,pid;

	public void do_RSS_CHANNEL_ITEM_TITLE(String title) {
		this.currentTitle = title;

	// Catch <wp:post_id>1551</wp:post_id>
	public void do_RSS_CHANNEL_ITEM_POST_ID(String idz){

	// Catch stuff like
	// <category domain="category"
	// nicename="software"><![CDATA[Software]]></category>
	// <category domain="series" nicename="version-control"><![CDATA[Version
	// Control]]></category>
	public void do_RSS_CHANNEL_ITEM_CATEGORY(Map catAttribs, String cdata) {
			getLog().info(" POST:"+ pid+":"+ currentTitle+":" + cdata+ ":"+catAttribs.get("nicename"));


The orginal code targeted JDK 1.4, so it is a bit “vintage”.
The revamped revision you found on github spots:

  1. Support for attributes, missed in the original version
  2. Optimized algorithm
  3. Stored on Github, for sharing with you
  4. Better logging & class/method naming

The first version is called “karmak” because will be your path to enlightment…


JavaScript Wars: Xtend

And so Java, the old old King is still alive.

After Scala, Clojure, NodeJS, and Dart, a new hero is knocking to its castle: Eclipse Xtend

Will he succeed? Hard to Say, but Xtend is very similar to CoffeScript: Xtend simplifies writing Java code, but it doesn’t aim take the grab the crown with a night ambush to the King’s IDE.

At the moment Xtend do not spot a strong IDE, but its simplicity could give it a plus.  Xtend gives us less stuff then Scala, and mimics a lot C# feature like extension method and lambda function. But it is still a baby in a world of fighters, so keep an eye on it but do not write too much code with it, for the meantime…

The Javascript world bring to us a deadly news: the planet Flex has been attacked by the Html5 rebels. Adobe seems to retire from the Flex development, and also flash mobile has having a bad day (try to find it on moder android devices!).

And if Flex&Flash are dying, Silverlight is even less lucky!…he is riding in the black forest, during a bad storm.

So it is hard to say what the fucture deserve us…but grab another table, because the last royal feast will be full of new programming languages!



Functional Programming

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

Because of the success of my article on java closure, I have decided to write another article on functional programming.

In the last year functional programming is waving back to us, for a lot of reason. Let’s summarize the facts:

Functional programming is based on the core concept of pure function. The main advantages of functional programming is the lack of side-effects, at least at the syntax-level of the language.

This blog article explains very well the difference between imperative and functional “way of life”; we report a bunch of it:

Sophisticated type systems […] aid in program inference, which is the extent to which the computer (or the programmer with the aid of the computer) can infer the correct program from type information (think tab completion, only moreso). Program inference is currently an active area of research.

Type system is a very important key here. “tab completion” and type-based refactoring are more difficult or even impossible on dynamic languages. For this reason Java/C++/C# where winner and SmallTalk was a loser. And who is writing is a strong dynamic language lover, but languages with complex type semantics win easy on devel tool and compiler optimization. So a complex type system is a good thing. Erlang has a pattern-matching system, with a prolog-like symbol structure.

As a side-note a lot of OO folks are discovering the functional approach as a tool to aid in modular design. They call it “dependency injection”, “inversion of control”, “interpreter pattern” and the like.
Functional programming is a restriction that the programmer puts on his programs. Having a language with a compiler that will warn you if you’re breaking referential transparency is helpful, but not essential. I do functional programming in Java, for example, which most people consider an “imperative OO” language.


The lack of side effects is important because it free us to the need of heavy transaction semantic. If we have a huge set of process without shared resources, we can build simpler engine to run them in parallel. Locks are evil: the best way is to avoid evil, i.e. avoid the need of things like java synchronized keyword and so on.

Even in Java, in my ten years experience, Entity and Stateful EJB are avoided like fire by Senior Software Architect. The reason is simple: application server will have a lot of stuff to do to fulfill the contract of a Stateful EJB, and your app server will easily run out of resources or stop responding when the load grows.

On this side Erlang is more interesting than Lisp on my humble opinion, because it had an integrated process scheduler,and an intrinsic concurrent way of thinking. Erlang process send asynchronous messages, and the semantic is very easy: you send a message, they never return, they never fail, end of the story. If the process still is alive, it will receive it, process it and so on. If the process is dead, nothing will happen. Every process has a mailbox where messages arrive. Because all the data are static (do not mutate). Sending a message simply imply to “share” the message between the sender and the receiver.

Erlang process scheduler monitors every process mailbox, and if process A and B flood process C with messages, the Erlang scheduler can give more CPU time to process C to rebalance the situation.

Scala amis to Erlang-ize Java, and we will look to it in the next weeks. Keep reading us!

A Scala to .NET compiler has been released in a quite complete form:

Miguel Garcia, part of the Scala group at EPFL, has been striving to make the Scala productivity available to .Net developers too. In a project funded by Microsoft, he has now reached a major milestone in delivering that capability. In this interview Miguel tells you how you can now use Scala on .Net and gives an insight into the way this challenging project has been achieved and the future direction.

So, will be Scala a Cross-VM language, crossing the bridge no one think before?

Useful References

Erjang is a virtual machine for Erlang, which runs on Java. It seems faster then the ErlangVM

LambdaJ is a small Java library which aims to bring closure to Java.

Scala is a Java peak of functional programming: the Akka project is somewhat an  Erlang-equivalent written in Scala.