[fpc-devel] Pascal to Java compiler

Daniël Mantione daniel.mantione at freepascal.org
Thu Nov 27 22:59:57 CET 2008



Op Thu, 27 Nov 2008, schreef Felipe Monteiro de Carvalho:

> On Thu, Nov 27, 2008 at 1:17 PM, Marco van de Voort <marcov at stack.nl> wrote:
>> Besides the pure language problem, there is also the library problem. Java
>> and .NET are more than just a bytecode specification, there are also vast
>> standard libraries, and the VCL-alike standard libraries of FPC (classes
>> unit etc) are not designed to work on top of Java or .NET classes.
>
> My initial experience was that this is no problem. The Java libraries
> are just an API just like any other. Just call the appropriate
> routines and you can build your implementation for anything in the FPC
> library.
>
> I managed to write a simple ReadLn using base Java routines. It turns
> out they don't have one ready (horrible!), so I just got a routine
> that reads byte per byte and read until a new line comes. Parsed the
> ASCII into a number, processed the signal, etc.

One time, during a programming contest, the jury had written their 
solution to a problem in Java. A 10MB output file had to be written. 
Their implementation took about 15 minutes and took about 60 MB of memory.

During the contest, I was the first one to solve the problem and my 
program, of course coded with FPC, took something like 0,15s while using 
200k of memory. When the contest was over, the jury expressed their 
surprise, and when I talked to them afterwards, they told there was a 
complete amazement in the jury room when my submission came in and was 
correct in every sense of the word.

We analyzed this, and it was nothing smart on my side, it was a simple 
Pascal text I/O versus Java text I/O issue. Not only is Java's text I/O 
terribly hard to use, it is also terribly inefficient. Our text I/O, on 
the other hand, is very well optimized.

Daniël


More information about the fpc-devel mailing list