Freedom, economy and information technology.
Random header image... Refresh for more!

C– for cross compiler

In late 1994, when I need to write a programming language it was a pain. You must start with flex, lex and so on, and the way will be very long.

Then I found GCC was able to compile in a pseudo-machine language, already optimized. Then a set of backend was able to emit mc68000, 80×86, power pc code…

I am glad to see now there is a “stripped down” version of the C language to simplify this hard work….
By the way, Fortran has been the first compiled language, appeared near 1957.

“A new perspective on programming-language infrastructure”

Welcome to C–

Suppose you are writing a compiler; how will you get quality machine code? You might write your own code generator—but that’s a lot of work. You might use somebody else’s: perhaps VPO, MLRISC, or the gcc back end. But each of these impressive systems has a rich, complex, and ill-documented interface, and furthermore, to use MLRISC you must write your front end in ML, to use gcc you must write it in C, and so on. You might generate C, if you can live without multiple results in registers, proper tail calls, computed gotos, accurate garbage collection, and efficient exceptions.

You would be much happier with one portable assembly language that could be generated by a front end and implemented by any of several code generators. Such a language should serve as the interface between high-level compilers and retargetable, optimizing code generators. Authors of front ends and authors of code generators could cooperate easily. C– is that language.

What distinguishes C–

The following aspects of C– distinguish it from other compiler infrastructures:

* Other infrastructures focus on adding new optimizations; C– focuses on supporting multiple front ends for multiple languages.

* C– has a machine-level type system, so you don’t have to shoehorn your favorite high-level language into a high-level data model that doesn’t fit.

* C– provides a run-time interface, so you can implement garbage collection and exception handling using the techniques that are best suited to your language.

The run-time interface is the most novel and most distinguishing feature of C–.

via C– Home.

June 15, 2009   No Comments

Java HttpClient and Load Balancer bad interactions

Working for a very big customer, I found a very nasty interaction between Sun HttpClient (JDK 1.4) and Http  Load Balancers.

In a complex network environment, sometimes you can experience low level TCP/IP comunication errors, because sometimes HttpClient get confused and hangs.

The bad behavior of Sun HttpClient is well known: some guys suggested me to use the Axis Web Client. Anyway you can solve the issue adding these three parameters to the JVM launch line

-Dsun.net.client.defaultConnectTimeout=5000
-Dsun.net.client.defaultReadTimeout=5000
-Dhttp.keepAlive=false

The first two parameters set globally the socket timeout to 5 seconds.
The last parameter forces the JVM to avoid reusing http connections when doing http request.

To be honest, http.keepAlive=false is not always effective and could have huge performance impacts, so be very carful adopting it.

But if you stick on the two sun.net.client.default*  properties (doing some tests) you can solve the issue.

References

From Java Plug-in Control Panel:

[...]
Networking properties description:

sun.net.client.defaultConnectTimeout

sun.net.client.defaultReadTimeout

These properties specify, respectively, the default connect and read timeout values for the protocol handlers used by java.net.URLConnection. The default values set by the protocol handlers is -1, which means there is no timeout set.

sun.net.client.defaultConnectTimeout specifies the timeout (in milliseconds) to establish the connection to the host. For example, for http connections it is the timeout when establishing the connection to the http server. For ftp connections it is the timeout when establishing the connection to ftp servers.

sun.net.client.defaultReadTimeout specifies the timeout (in milliseconds) when reading from an input stream when a connection is established to a resource.

For the official description of these properties, see Networking Properties.

[...]

May 21, 2009   No Comments

Portal Software: LifeRay

I am not a big fan of portal software, because it is not cheap to delivery.

Portal specification is heavy to use and implement, and can have a reason only in very big corporate company.

SingleSignOn can be delivered in different and simpler way.

The big advanteg of the Portal is the ability to “deactivate” specific unstable feature on the fly, with also the ability to aggregate remote data (remote portlet is one of the key of the idea behind portal specification).

If you need to setup a fast demo, LifeRay is ready to use.

April 9, 2009   No Comments