Re: D as a Better C

2017-08-29 Thread Parke via Digitalmars-d-announce
On Tue, Aug 29, 2017 at 7:19 PM, Michael V. Franklin via
Digitalmars-d-announce  wrote:
> For example, the following is the most minimal "Hello World" I can make with
> D that does not require the -betterC switch, and does not use the official D
> runtime.  Instead the runtime features required by this program are
> implemented in object.d.

Thank you for the very helpful example and explanation.

-Parke


Re: D as a Better C

2017-08-29 Thread Parke via Digitalmars-d-announce
> On Monday, 28 August 2017 at 22:45:01 UTC, Parke wrote:
>> When I write "hello world" in C, the executable is 8,519 bytes.
>>  When I write "hello world" in D, the executable is 100 times larger:
>> 865,179 bytes.


On Tue, Aug 29, 2017 at 8:26 AM, Kagamin via Digitalmars-d-announce
 wrote:
> You mean the examples from the blog post
> https://dlang.org/blog/2017/08/23/d-as-a-better-c/ give you 800kb
> executables?


No, I was talking about the below version of "hello world" that I
compiled several weeks prior to reading the blog post.

import std.stdio;
void main() { writeln("Hello, world!"); }

The above D code yields 865,179 bytes.


Below is the version from the blog post:

import core.stdc.stdio;
extern (C) int main( int argc, char** argv ) {
printf ( "hello world\n" );
return 0;
}

The above D code yields 445,244 bytes when compiled with -release.
The above D code yields 445,187 bytes when compiled with -release -betterC.
DMD64 D Compiler 2.075.0-b2 on Linux on x86-64.

Still 50 times larger than C.  Perhaps it would be smaller with a
newer version of DMD.

But my original question was about what you (Kagamin) called
"intermediate D".  I was trying to understand what "intermediate D"
is, and whether or not I could use "intermediate D" (whatever it is)
to produce small(er) executables.

-Parke


Re: D as a Better C

2017-08-28 Thread Parke via Digitalmars-d-announce
> On Friday, 25 August 2017 at 18:08:06 UTC, Parke wrote:
>> Is there any documentation on how to access and use the minimal runtime?

On Mon, Aug 28, 2017 at 5:22 AM, Kagamin via Digitalmars-d-announce
 wrote:
> Runtime implements language features like boundschecking, it's not used
> explicitly in the code.

I understand that.

On Wed, Aug 23, 2017 at 10:17 AM, Kagamin via Digitalmars-d-announce
> 7.5kb totext.exe (encodes stdin to base64 and writes to stdout) - wrote it
> to put images in xml for opensearch descriptions.
> 12.5kb retab.exe (retabifies source code with various features)
> 5.5kb keepower.exe (manages screen saver and power settings because of
> obnoxious domain policy)
> 14.5kb fsum.exe (computes various hash sums of a file)

Is the source code available for totext.exe, retab.exe keepower.exe,
and fsum.exe?

If the source code were available, I could try compiling them and see
if I could reproduce the nice, small executable sizes you list above.

When I write "hello world" in C, the executable is 8,519 bytes.  When
I write "hello world" in D, the executable is 100 times larger:
865,179 bytes.

Interestingly, "hello world" in C, compiled statically, yields 908,608
bytes.  And "hello world" in assembly yields 368 bytes.

Thanks,

Parke


Re: D as a Better C

2017-08-25 Thread Parke via Digitalmars-d-announce
> On Thursday, 24 August 2017 at 19:09:58 UTC, Parke wrote:
>> What is "intermediate D"?

On Fri, Aug 25, 2017 at 1:54 AM, Kagamin via Digitalmars-d-announce
 wrote:
> D with minimal runtime.

Is there any documentation on how to access and use the minimal runtime?

-Parke


Re: D as a Better C

2017-08-24 Thread Parke via Digitalmars-d-announce
On Wed, Aug 23, 2017 at 10:17 AM, Kagamin via Digitalmars-d-announce
 wrote:
> Not a better C, but intermediate D has small footprint for me too.

What is "intermediate D"?

-Parke

> 7.5kb totext.exe (encodes stdin to base64 and writes to stdout) - wrote it
> to put images in xml for opensearch descriptions.
> 12.5kb retab.exe (retabifies source code with various features)
> 5.5kb keepower.exe (manages screen saver and power settings because of
> obnoxious domain policy)
> 14.5kb fsum.exe (computes various hash sums of a file)
>
> Additional features: string switch, array cast. Also how assert failure
> works in C? Mine shows a nice formatted message.