[fpc-pascal] Re: making FPC more code optimized
ik
idokan at gmail.com
Sun Apr 29 12:13:31 CEST 2012
On Sun, Apr 29, 2012 at 12:58, Reinier Olislagers
<reinierolislagers at gmail.com> wrote:
> On 29-4-2012 11:40, ik wrote:
>> Hello,
>>
>> Here is something that I'm asking without really know anything about
>> the subject, so please bear with me.
>>
>> I'ved asked few places that works with Pascal (Delphi and FPC), why
>> does they use C as the infrastructure, and they all say that there is
>> not even one Pascal compiler that makes the code optimized and fast
>> running with low resources, while many C compilers does have such
>> features.
>> For them it's not the language, but the compilers that are problematic.
>>
>> I'm not talking about "killer feature" that never exists, but what
>> stops FPC and/or other Pascal compilers to be more optimized, with
>> lower footprint, and faster code like with C compilers for example ?
>> Is there anything that can be done to make them "there" as well ?
>
> Ido,
>
> I don't quite understand what you mean.... perhaps you could expand a bit...
>
> Are you saying:
> 1. FPC is using "C infrastructure" and you want to use something else.
> What do you mean by that? I don't understand.
> Oh, perhaps you mean that some companies/institutions are switching from
> FPC/Delphi to C?
Not at all.
> 2. FPC does not generate small, fast code?
> Are you describing some particular performance problems that might
> perhaps be addressed or is this a general comment?
> Are you talking about a specific embedded platform perhaps?
I'm working at the moment on a distributed service that I'm writing in OP.
If I need to control high availability, and process many requests,
then C will have much faster implementation for it (not only in how I
write it, but in the way that it is translated to machine code).
Let's take simple program:
---- pascal code ----
program hello;
begin
writeln('Hello World');
end.
----- pascal code ----
vs c code:
------ c code -----
#include <stdio.h>
int main(int argc, char ** argv) {
printf("Hello World\n");
return 0;
}
------ c code ------
The code executable will be not only smaller, but takes less memory to
run, and will be more optimized.
>
> Anyway, to me as a user on a desktop platform, FPC is plenty fast enough.
>
> With today's processors, having a compiler that works on Windows, OSX
> and Linux is a much bigger advantage than perhaps getting the last ounce
> of performance out of the compiler.... but I understand the needs of
> embedded developers can be different.
Desktop today is changing to "smart" phones, so it's more and more
embedded like development.
FPC with JVM is one of the smartest implementation of a compiler imho.
It makes you keep your language, but distribute your code in many
platforms.
Next can be also supporting the MS .NET runtime library, and making
Pascal as the only current programming language that can be used on
all the environments that really matters today.
But all of that is not important, if C code that does exactly what the
Pascal code, can do it with less resources.
>
> IIRC, e.g. on the "Size Matters" wiki FAQ page, some strategies for
> stripping FPC for embedded development are mentioned. Perhaps the people
> you are talking to are not aware of those methods?
They are aware of them, but still, both Linux and Windows (afaik),
loads the whole executable to memory. Smaller executable, and dynamic
executable are taking less memory.
But I'm talking about how the code is implemented when it is converted
into assembler.
The C code is more "efficient" and optimized when it is translated
into machine code at the end. It also has less memory footprint and
there-for, you can use the same machine to do more.
I'm looking to understand, what is required by the compiler to make it
create better outcome that will make it the same if not better then
the C code, making the choice in Pascal for people like myself and
others (that does willing to use it that is), to know that they can
create good infrastructures using Pascal.
I prefer Pascal to any other compiled language, without thinking
twice, as long as it answers my needs.
>
> Regards,
> Reinier
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Ido
More information about the fpc-pascal
mailing list