Re: Looking for some thoughtful review of my first D program

2023-12-30 Thread Renato via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 11:08:26 UTC, Thomas Teixeira wrote: Hi, you all ! I've wanted to look at D for the last two years, being a C fanboy and not fond of C++. It seemed like a good alternative between some delightful extra new stuff and keeping C-like experience : performances and

Looking for some thoughtful review of my first D program

2023-12-27 Thread Thomas Teixeira via Digitalmars-d-learn
Hi, you all ! I've wanted to look at D for the last two years, being a C fanboy and not fond of C++. It seemed like a good alternative between some delightful extra new stuff and keeping C-like experience : performances and code style wise. I wrote my first CLI program this weekend and would

Re: my first D program (and benchmark against perl)

2015-11-12 Thread perlancar via Digitalmars-d-learn
On Thursday, 12 November 2015 at 12:49:55 UTC, Daniel Kozak wrote: dmd -O -release -inline -boundscheck=off asciitable.d real0m1.463s user0m1.453s sys 0m0.003s ldc2 -singleobj -release -O3 -boundscheck=off asciitable.d real0m0.945s user0m0.940s sys 0m0.000s gdc -O3 -

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 12 November 2015 at 12:49:55 UTC, Daniel Kozak wrote: On Thursday, 12 November 2015 at 12:25:08 UTC, Daniel Kozak wrote: ... auto res = appender(uninitializedArray!(char[])(total)); res.clear(); ... this is faster for DMD and ldc: auto res = appender!(string)(); res.

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 12 November 2015 at 12:25:08 UTC, Daniel Kozak wrote: V Thu, 12 Nov 2015 12:13:10 + perlancar via Digitalmars-d-learn napsáno: On Wednesday, 11 November 2015 at 14:20:51 UTC, Rikki Cattermole wrote: > I turned it into mostly using large allocations, instead of > small ones.

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 12 Nov 2015 12:13:10 + perlancar via Digitalmars-d-learn napsáno: > On Wednesday, 11 November 2015 at 14:20:51 UTC, Rikki Cattermole > wrote: > > I turned it into mostly using large allocations, instead of > > small ones. > > Although I'd recommend using Appender instead of my custom

Re: my first D program (and benchmark against perl)

2015-11-12 Thread perlancar via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 14:20:51 UTC, Rikki Cattermole wrote: I turned it into mostly using large allocations, instead of small ones. Although I'd recommend using Appender instead of my custom functions for this. Oh and for me, I got it at 2 secs, 513 ms, 397 μs, and 5 hnsecs. Unopt

Re: my first D program (and benchmark against perl)

2015-11-12 Thread perlancar via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 14:26:32 UTC, Andrea Fontana wrote: Did you try rdmd -O -noboundscheck -release yourscript.d ? I just did. It improves speed from 17.127s to 14.831s. Nice, but nowhere near gdc/ldc level. You should try using appender!string rather than concatenate (http://

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 12 Nov 2015 11:03:38 + Tobias Pankrath via Digitalmars-d-learn napsáno: > > or with ~ operator: > > > > import std.stdio; > > > > [...] > > Did anyone check that the last loop isn't optimized out? Yes, it is not optimized out > Could also be improved further if you make the functi

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Tobias Pankrath via Digitalmars-d-learn
or with ~ operator: import std.stdio; [...] Did anyone check that the last loop isn't optimized out? Could also be improved further if you make the function take an output range and reuse one appender for every call, but that might be to far off the original perl solution.

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 12 Nov 2015 09:12:32 + Daniel Kozak via Digitalmars-d-learn napsáno: > On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote: > > Here's my first non-hello-world D program, which is a direct > > translation from the Perl version. I was trying to get a feel > > about D's per

Re: my first D program (and benchmark against perl)

2015-11-12 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote: Here's my first non-hello-world D program, which is a direct translation from the Perl version. I was trying to get a feel about D's performance: ... While I am quite impressed with how easy I was able to write D, I am not so i

Re: my first D program (and benchmark against perl)

2015-11-11 Thread Rikki Cattermole via Digitalmars-d-learn
On 12/11/15 3:20 AM, Rikki Cattermole wrote: On 12/11/15 2:31 AM, perlancar wrote: Here's my first non-hello-world D program, which is a direct translation from the Perl version. I was trying to get a feel about D's performance: ---BEGIN asciitable.d--- import std.string; import std.stdio; str

Re: my first D program (and benchmark against perl)

2015-11-11 Thread cym13 via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 16:02:07 UTC, H. S. Teoh wrote: If performance is a problem, my first reaction would be to try GDC or LDC. While there have been recent improvements in DMD code generation quality, it still has a ways to go to catch with GDC/LDC's optimizer. T My computer

Re: my first D program (and benchmark against perl)

2015-11-11 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Nov 11, 2015 at 02:26:28PM +, Andrea Fontana via Digitalmars-d-learn wrote: > On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote: > >While I am quite impressed with how easy I was able to write D, I am > >not so impressed with the performance. Using rdmd (build 20151103),

Re: my first D program (and benchmark against perl)

2015-11-11 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote: While I am quite impressed with how easy I was able to write D, I am not so impressed with the performance. Using rdmd (build 20151103), the D program runs in 17.127s while the Perl version runs in 11.391s (so the D version is qui

Re: my first D program (and benchmark against perl)

2015-11-11 Thread Rikki Cattermole via Digitalmars-d-learn
On 12/11/15 2:31 AM, perlancar wrote: Here's my first non-hello-world D program, which is a direct translation from the Perl version. I was trying to get a feel about D's performance: ---BEGIN asciitable.d--- import std.string; import std.stdio; string fmttable(ref string[][] table) { stri

Re: my first D program (and benchmark against perl)

2015-11-11 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 13:32:00 UTC, perlancar wrote: for (int rownum=0; rownum < table.length; rownum++) { res ~= "|"; for (int colnum=0; colnum < table[rownum].length; colnum++) { res ~= leftJustify(table[rownum][colnum], widths[colnum]);

my first D program (and benchmark against perl)

2015-11-11 Thread perlancar via Digitalmars-d-learn
Here's my first non-hello-world D program, which is a direct translation from the Perl version. I was trying to get a feel about D's performance: ---BEGIN asciitable.d--- import std.string; import std.stdio; string fmttable(ref string[][] table) { string res = ""; // column widths

Re: My first D program

2013-05-30 Thread Shriramana Sharma
Thanks to all those who kindly replied. On Thu, May 30, 2013 at 9:57 PM, Regan Heath wrote: > > The D standard library is currently statically linked. This will change > shortly/eventually. Ah OK -- should have thought of that. So whatever is in libc.so or libstdc++.so doesn't get counted to th

Re: My first D program

2013-05-30 Thread bearophile
Shriramana Sharma: However I am somewhat taken aback to see the file size -- 335KiB for a simple Hello World? The equivalent C/C++ programs compiled with Clang without any -O options produce binaries of less than 10K! On Windows32 DMD produces binaries for small programs that are often half

Re: My first D program

2013-05-30 Thread Regan Heath
On Thu, 30 May 2013 12:13:19 +0100, Shriramana Sharma wrote: Hello. I am new to D and come from some intermediate C/C++ plus some Python programming background. I currently have DMD 2.062 installed on my Kubuntu Raring 64-bit system. 1. Too big binary output? OK so I wrote my first Hello Wo

My first D program

2013-05-30 Thread Shriramana Sharma
Hello. I am new to D and come from some intermediate C/C++ plus some Python programming background. I currently have DMD 2.062 installed on my Kubuntu Raring 64-bit system. 1. Too big binary output? OK so I wrote my first Hello World program: #! /usr/bin/rdmd import std.stdio ; void main() {