Thread overview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 20, 2020 Is there any language that native-compiles faster than D? | ||||
---|---|---|---|---|
| ||||
After having evaluated the compilation speed of D compared to other languages at https://github.com/nordlow/compiler-benchmark I wonder; is there any language that compiles to native code anywhere nearly as fast or faster than D, except C? If so it most likely needs to use a backend other than LLVM. I believe Jai is supposed to do that but it hasn't been released yet. |
August 20, 2020 Re: Is there any language that native-compiles faster than D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Thursday, 20 August 2020 at 20:50:25 UTC, Per Nordlöw wrote:
> After having evaluated the compilation speed of D compared to other languages at
>
> https://github.com/nordlow/compiler-benchmark
>
> I wonder; is there any language that compiles to native code anywhere nearly as fast or faster than D, except C?
>
> If so it most likely needs to use a backend other than LLVM.
>
> I believe Jai is supposed to do that but it hasn't been released yet.
Pardon me, but that code seems everything but remotely representative to me - no structs, no classes, no control flow, just a few integer additions and calls. It even seems to make D look worse than it is, simply because object.d is imported but totally unused. E.g., on my Win64 box with DMD 2.093, compiling this:
-----
int add_int_n0_h0(int x) { return x + 15440; }
int add_int_n0(int x) { return x + add_int_n0_h0(x) + 95485; }
int add_int_n1_h0(int x) { return x + 37523; }
int add_int_n1(int x) { return x + add_int_n1_h0(x) + 92492; }
int add_int_n2_h0(int x) { return x + 39239; }
int add_int_n2(int x) { return x + add_int_n2_h0(x) + 12248; }
int main()
{
int int_sum = 0;
int_sum += add_int_n0(0);
int_sum += add_int_n1(1);
int_sum += add_int_n2(2);
return int_sum;
}
-----
with `dmd -o- bla.d` takes about 37ms, while creating an empty object.d and compiling with `dmd -o- bla.d object.d` takes 24ms. There's no default includes for C, so this would make the comparison more fair.
Additionally, generics and templates are completely different concepts and can't be compared.
|
August 20, 2020 Re: Is there any language that native-compiles faster than D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Thursday, 20 August 2020 at 21:21:39 UTC, kinke wrote: > with `dmd -o- bla.d` takes about 37ms, while creating an empty object.d and compiling with `dmd -o- bla.d object.d` takes 24ms. There's no default includes for C, so this would make the comparison more fair. Thanks. But for really large files that won't make that big of difference. I'll add the generation of the object.d file aswell. > Additionally, generics and templates are completely different concepts and can't be compared. I'm aware of that. But I wanted to start somewhere and expand from there. |
August 20, 2020 Re: Is there any language that native-compiles faster than D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Thursday, 20 August 2020 at 21:34:54 UTC, Per Nordlöw wrote: > But for really large files that won't make that big of difference. Of course not, but your benchmark is as tiny as it gets. ;) > I'll add the generation of the object.d file aswell. For linking, a D main requires the _d_cmain template imported by object.d, so you'll have to make it extern(C) in that case. > I'm aware of that. But I wanted to start somewhere and expand from there. I don't think languages can be compared like that. One would probably need a reasonably-sized non-contrived project and port it to each language, exploiting the language features, but then runtime and standard libraries would play a significant role as well (object.d kinda already does). Another strong suit of D, its module system and compiling multiple modules at once, isn't reflected either. |
August 20, 2020 Re: Is there any language that native-compiles faster than D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | I've just seen that you use ldmd2, not ldc2 directly. This makes quite a difference for such tiny code, in my case (with -c, not -o-) something like 60ms vs. 42ms. |
August 20, 2020 Re: Is there any language that native-compiles faster than D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Thursday, 20 August 2020 at 21:49:16 UTC, kinke wrote:
> Of course not, but your benchmark is as tiny as it gets. ;)
Ah sry, just seen now that the table has been generated with `--function-count=200 --function-depth=450`.
|
August 20, 2020 Re: Is there any language that native-compiles faster than D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On 8/20/20 4:50 PM, Per Nordlöw wrote:
> After having evaluated the compilation speed of D compared to other languages at
>
> https://github.com/nordlow/compiler-benchmark
>
> I wonder; is there any language that compiles to native code anywhere nearly as fast or faster than D, except C?
>
> If so it most likely needs to use a backend other than LLVM.
>
> I believe Jai is supposed to do that but it hasn't been released yet.
I tried Python a while ago, the build-run cycle for a simple program was about the same. For Perl it was faster.
|
August 20, 2020 Re: Is there any language that native-compiles faster than D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Thursday, 20 August 2020 at 20:50:25 UTC, Per Nordlöw wrote:
> After having evaluated the compilation speed of D compared to other languages at
>
> https://github.com/nordlow/compiler-benchmark
>
> I wonder; is there any language that compiles to native code anywhere nearly as fast or faster than D, except C?
Object Pascal / Delphi has been very fast in the past, perhaps the existing Pascal compilers still are.
|
August 20, 2020 Re: Is there any language that native-compiles faster than D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Thursday, 20 August 2020 at 21:49:16 UTC, kinke wrote:
> For linking, a D main requires the _d_cmain template imported by object.d, so you'll have to make it extern(C) in that case.
Moreover, I just realized I should probably add a test case with `-betterC` aswell. Or maybe make it default until `-betterC` is not sufficient.
|
August 20, 2020 Re: Is there any language that native-compiles faster than D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Thursday, 20 August 2020 at 22:20:19 UTC, Andrei Alexandrescu wrote:
> I tried Python a while ago, the build-run cycle for a simple program was about the same. For Perl it was faster.
That same as what? D? That entirely depends on the complexity of the Python program. What kind of app/program where you testing?
|
Copyright © 1999-2021 by the D Language Foundation