Re: Cleaned up C++

2015-04-27 Thread ketmar via Digitalmars-d
On Mon, 27 Apr 2015 08:23:26 +, ponce wrote: Bringing D in the workplace often bring incredible resistance and arguments. I've heard it all over the years: - D is like C#, why use it? - D can't be scripted (yes it can) - D isn't fast enough - D isn't much used and is 10 years old,

Re: Cleaned up C++

2015-04-27 Thread Laeeth Isharc via Digitalmars-d
On Sunday, 26 April 2015 at 19:13:33 UTC, ponce wrote: On Sunday, 26 April 2015 at 14:28:11 UTC, Baz wrote: On Sunday, 26 April 2015 at 12:04:20 UTC, Laeeth Isharc wrote: On Sunday, 26 April 2015 at 09:26:11 UTC, ponce wrote: On Wednesday, 22 April 2015 at 19:51:23 UTC, ponce wrote: I

Re: Cleaned up C++

2015-04-27 Thread ponce via Digitalmars-d
On Monday, 27 April 2015 at 07:45:30 UTC, Laeeth Isharc wrote: On Sunday, 26 April 2015 at 19:13:33 UTC, ponce wrote: Lesson taken: should have put a less aggressive title. Not necessarily. The people who complain loudly constitute a tiny subset of those who are ultimately influenced. One

Re: Cleaned up C++

2015-04-26 Thread ponce via Digitalmars-d
On Wednesday, 22 April 2015 at 19:51:23 UTC, ponce wrote: I should put in in a d-idioms anyway. http://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17?

Re: Cleaned up C++

2015-04-26 Thread Baz via Digitalmars-d
On Sunday, 26 April 2015 at 12:04:20 UTC, Laeeth Isharc wrote: On Sunday, 26 April 2015 at 09:26:11 UTC, ponce wrote: On Wednesday, 22 April 2015 at 19:51:23 UTC, ponce wrote: I should put in in a d-idioms anyway. http://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17? excellent.

Re: Cleaned up C++

2015-04-26 Thread Laeeth Isharc via Digitalmars-d
On Sunday, 26 April 2015 at 09:26:11 UTC, ponce wrote: On Wednesday, 22 April 2015 at 19:51:23 UTC, ponce wrote: I should put in in a d-idioms anyway. http://p0nce.github.io/d-idioms/#How-does-D-improve-on-C++17? excellent. I linked it here: http://wiki.dlang.org/Coming_From

Re: Cleaned up C++

2015-04-26 Thread ponce via Digitalmars-d
On Sunday, 26 April 2015 at 14:28:11 UTC, Baz wrote: On Sunday, 26 April 2015 at 12:04:20 UTC, Laeeth Isharc wrote: On Sunday, 26 April 2015 at 09:26:11 UTC, ponce wrote: On Wednesday, 22 April 2015 at 19:51:23 UTC, ponce wrote: I should put in in a d-idioms anyway.

Re: Cleaned up C++

2015-04-25 Thread Walter Bright via Digitalmars-d
On 4/24/2015 11:51 PM, Iain Buclaw via Digitalmars-d wrote: I wonder just how large... IIRC I think the limit on ubyte arrays is 1M? A large enough value can not just case stack overflow, but can cause the stack pointer to be anywhere in the address space. I don't know of a limit on ubyte

Re: Cleaned up C++

2015-04-25 Thread Andrei Alexandrescu via Digitalmars-d
On 4/22/15 1:36 PM, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they are dead and elide them and 3) Doing the initialisation has a significant performance impact? The boring example

Re: Cleaned up C++

2015-04-25 Thread John Colvin via Digitalmars-d
On Saturday, 25 April 2015 at 21:26:25 UTC, Andrei Alexandrescu wrote: On 4/22/15 1:36 PM, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they are dead and elide them and 3) Doing the

Re: Cleaned up C++

2015-04-25 Thread Andrei Alexandrescu via Digitalmars-d
On 4/25/15 3:23 PM, John Colvin wrote: On Saturday, 25 April 2015 at 21:26:25 UTC, Andrei Alexandrescu wrote: On 4/22/15 1:36 PM, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they

Re: Cleaned up C++

2015-04-25 Thread Iain Buclaw via Digitalmars-d
On 25 Apr 2015 01:25, Walter Bright via Digitalmars-d digitalmars-d@puremagic.com wrote: On 4/24/2015 5:59 AM, John Colvin wrote: one reason why it might be faster is that e.g. gcc can produce code like this: #includealloca.h void bar(char* a); void foo(unsigned int n) { char *a =

Re: Cleaned up C++

2015-04-24 Thread Daniel Murphy via Digitalmars-d
Walter Bright wrote in message news:mhc7am$942$1...@digitalmars.com... Everyone hated it :-) but me. And by that Walter means the interface was highly unsafe and he didn't want to change it.

Re: Cleaned up C++

2015-04-24 Thread Walter Bright via Digitalmars-d
On 4/24/2015 12:23 AM, John Colvin wrote: Except of course that alloca is a lot cheaper than malloc/free. That's not necessarily true. But in any case, go ahead and use it if you like. Just prepare to benchmark and be disappointed :-)

Re: Cleaned up C++

2015-04-24 Thread ponce via Digitalmars-d
On Friday, 24 April 2015 at 08:16:40 UTC, Walter Bright wrote: On 4/24/2015 12:23 AM, John Colvin wrote: Except of course that alloca is a lot cheaper than malloc/free. That's not necessarily true. But in any case, go ahead and use it if you like. Just prepare to benchmark and be

Re: Cleaned up C++

2015-04-24 Thread John Colvin via Digitalmars-d
On Friday, 24 April 2015 at 12:34:19 UTC, ponce wrote: On Friday, 24 April 2015 at 08:16:40 UTC, Walter Bright wrote: On 4/24/2015 12:23 AM, John Colvin wrote: Except of course that alloca is a lot cheaper than malloc/free. That's not necessarily true. But in any case, go ahead and use it

Re: Cleaned up C++

2015-04-24 Thread deadalnix via Digitalmars-d
On Friday, 24 April 2015 at 08:16:40 UTC, Walter Bright wrote: On 4/24/2015 12:23 AM, John Colvin wrote: Except of course that alloca is a lot cheaper than malloc/free. That's not necessarily true. But in any case, go ahead and use it if you like. Just prepare to benchmark and be

Re: Cleaned up C++

2015-04-24 Thread Walter Bright via Digitalmars-d
On 4/24/2015 10:27 AM, deadalnix wrote: On Friday, 24 April 2015 at 08:16:40 UTC, Walter Bright wrote: On 4/24/2015 12:23 AM, John Colvin wrote: Except of course that alloca is a lot cheaper than malloc/free. That's not necessarily true. But in any case, go ahead and use it if you like. Just

Re: Cleaned up C++

2015-04-24 Thread Walter Bright via Digitalmars-d
On 4/24/2015 5:59 AM, John Colvin wrote: one reason why it might be faster is that e.g. gcc can produce code like this: #includealloca.h void bar(char* a); void foo(unsigned int n) { char *a = (char*)alloca(n); bar(a); } foo: movl%edi, %eax pushq%rbp addq$46,

Re: Cleaned up C++

2015-04-24 Thread John Colvin via Digitalmars-d
On Friday, 24 April 2015 at 01:54:11 UTC, Walter Bright wrote: On 4/23/2015 3:11 PM, deadalnix wrote: For arbitrary large, you can always do something like : Item* itemPtr = (arbitrarylarge thresold) ? alloca(arbitrarylarge) : GC.alloc(arbitrarylarge); One extra check compared to a heap

Re: Cleaned up C++

2015-04-23 Thread via Digitalmars-d
On Wednesday, 22 April 2015 at 22:26:45 UTC, John Colvin wrote: On Wednesday, 22 April 2015 at 21:59:48 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 22 April 2015 at 20:36:12 UTC, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are

Re: Cleaned up C++

2015-04-23 Thread Iain Buclaw via Digitalmars-d
On 23 April 2015 at 16:28, via Digitalmars-d digitalmars-d@puremagic.com wrote: On Wednesday, 22 April 2015 at 22:26:45 UTC, John Colvin wrote: On Wednesday, 22 April 2015 at 21:59:48 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 22 April 2015 at 20:36:12 UTC, John Colvin wrote: Is it even

Re: Cleaned up C++

2015-04-23 Thread John Colvin via Digitalmars-d
On Thursday, 23 April 2015 at 14:29:01 UTC, Ola Fosheim Grøstad wrote: Can you give a specific example where all 3 points are satisfied? Not sure why you would need it, plenty of cases where compilers will fail. E.g. queues between threads (like real time threads) where you allocate in one

Re: Cleaned up C++

2015-04-23 Thread via Digitalmars-d
On Thursday, 23 April 2015 at 14:50:26 UTC, John Colvin wrote: There are cases where you might really need to grab an extra 1-5%, at which point you are hand optimising and = void is a reasonable tool. Well, it can be a lot more than 1-5% in special situations if you hand over a small header

Re: Cleaned up C++

2015-04-23 Thread via Digitalmars-d
On Thursday, 23 April 2015 at 14:55:42 UTC, Iain Buclaw wrote: There are two states each local variable can be assigned. 1. Used 2. Read int a = 1; // a = Used return a; // a = Read printf(%d\n, a); // a = Read int b = a; // b = Used, a = Read int c = void; // c = Unused If a variable is

Re: Cleaned up C++

2015-04-23 Thread Walter Bright via Digitalmars-d
On 4/23/2015 1:10 AM, bearophile wrote: Walter Bright: On 4/22/2015 2:58 PM, bearophile wrote: D is less stack-friendly than Ada (and probably Rust too), ?? In Ada standard library you have safe fixed-size stack-allocated associative arrays. In D you can't even allocate safely a

Re: Cleaned up C++

2015-04-23 Thread John Colvin via Digitalmars-d
On Thursday, 23 April 2015 at 18:37:47 UTC, Walter Bright wrote: On 4/23/2015 1:10 AM, bearophile wrote: Walter Bright: On 4/22/2015 2:58 PM, bearophile wrote: D is less stack-friendly than Ada (and probably Rust too), ?? In Ada standard library you have safe fixed-size stack-allocated

Re: Cleaned up C++

2015-04-23 Thread weaselcat via Digitalmars-d
On Thursday, 23 April 2015 at 18:37:47 UTC, Walter Bright wrote: On 4/23/2015 1:10 AM, bearophile wrote: Walter Bright: On 4/22/2015 2:58 PM, bearophile wrote: D is less stack-friendly than Ada (and probably Rust too), ?? In Ada standard library you have safe fixed-size stack-allocated

Re: Cleaned up C++

2015-04-23 Thread via Digitalmars-d
On Thursday, 23 April 2015 at 20:40:36 UTC, John Colvin wrote: scopeBuffer), but in practice it's not a big win over just stack allocating the maximum size all the time (again, like scopeBuffer). If you have a random distribution of sizes then allocating the maximum will use twice as much

Re: Cleaned up C++

2015-04-23 Thread deadalnix via Digitalmars-d
On Thursday, 23 April 2015 at 18:37:47 UTC, Walter Bright wrote: On 4/23/2015 1:10 AM, bearophile wrote: Walter Bright: On 4/22/2015 2:58 PM, bearophile wrote: D is less stack-friendly than Ada (and probably Rust too), ?? In Ada standard library you have safe fixed-size stack-allocated

Re: Cleaned up C++

2015-04-23 Thread John Colvin via Digitalmars-d
On Thursday, 23 April 2015 at 01:45:14 UTC, deadalnix wrote: On Wednesday, 22 April 2015 at 20:36:12 UTC, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they are dead and elide them and

Re: Cleaned up C++

2015-04-23 Thread Iain Buclaw via Digitalmars-d
On Wednesday, 22 April 2015 at 20:29:49 UTC, Walter Bright wrote: On 4/22/2015 12:51 PM, ponce wrote: I didn't appreciate how important default initialization was before having to fix a non-deterministic, release-only, time-dependent bug in a video encoder some months ago. Just because of

Re: Cleaned up C++

2015-04-23 Thread bearophile via Digitalmars-d
Walter Bright: On 4/22/2015 2:58 PM, bearophile wrote: D is less stack-friendly than Ada (and probably Rust too), ?? In Ada standard library you have safe fixed-size stack-allocated associative arrays. In D you can't even allocate safely a dynamically-sized 1D array on the stack, and

Re: Cleaned up C++

2015-04-23 Thread Walter Bright via Digitalmars-d
On 4/23/2015 2:54 PM, weaselcat wrote: Is there a reason scopebuffer isn't part of the documentation? Everyone hated it :-) but me.

Re: Cleaned up C++

2015-04-23 Thread Walter Bright via Digitalmars-d
On 4/23/2015 3:11 PM, deadalnix wrote: For arbitrary large, you can always do something like : Item* itemPtr = (arbitrarylarge thresold) ? alloca(arbitrarylarge) : GC.alloc(arbitrarylarge); One extra check compared to a heap allocation is not going to make things terrible, and it is

Cleaned up C++

2015-04-22 Thread Walter Bright via Digitalmars-d
I'd missed this post on reddit: http://www.reddit.com/r/programming/comments/30wj8g/managing_cs_complexity_or_learning_to_enjoy_c/cpx41ix

Re: Cleaned up C++

2015-04-22 Thread weaselcat via Digitalmars-d
On Wednesday, 22 April 2015 at 19:29:08 UTC, Walter Bright wrote: D is just another of those “Let's put everything on the heap”-languages that do then of course need GC. what's up with people constantly equating garbage collection to being the same as java?

Re: Cleaned up C++

2015-04-22 Thread ponce via Digitalmars-d
On Wednesday, 22 April 2015 at 19:29:08 UTC, Walter Bright wrote: I'd missed this post on reddit: http://www.reddit.com/r/programming/comments/30wj8g/managing_cs_complexity_or_learning_to_enjoy_c/cpx41ix Thanks for the mention. I must have forgotten some. I should put in in a d-idioms

Re: Cleaned up C++

2015-04-22 Thread deadalnix via Digitalmars-d
On Wednesday, 22 April 2015 at 20:36:12 UTC, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they are dead and elide them and 3) Doing the initialisation has a significant performance

Re: Cleaned up C++

2015-04-22 Thread John Colvin via Digitalmars-d
On Wednesday, 22 April 2015 at 20:29:49 UTC, Walter Bright wrote: On 4/22/2015 12:51 PM, ponce wrote: I didn't appreciate how important default initialization was before having to fix a non-deterministic, release-only, time-dependent bug in a video encoder some months ago. Just because of 2

Re: Cleaned up C++

2015-04-22 Thread ketmar via Digitalmars-d
On Wed, 22 Apr 2015 19:32:46 +, weaselcat wrote: On Wednesday, 22 April 2015 at 19:29:08 UTC, Walter Bright wrote: D is just another of those “Let's put everything on the heap”-languages that do then of course need GC. what's up with people constantly equating garbage collection to

Re: Cleaned up C++

2015-04-22 Thread John Colvin via Digitalmars-d
On Wednesday, 22 April 2015 at 21:59:48 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 22 April 2015 at 20:36:12 UTC, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they are dead and

Re: Cleaned up C++

2015-04-22 Thread bearophile via Digitalmars-d
weaselcat: On Wednesday, 22 April 2015 at 19:29:08 UTC, Walter Bright wrote: D is just another of those “Let's put everything on the heap”-languages that do then of course need GC. what's up with people constantly equating garbage collection to being the same as java? In D you don't put

Re: Cleaned up C++

2015-04-22 Thread via Digitalmars-d
On Wednesday, 22 April 2015 at 20:36:12 UTC, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they are dead and elide them and 3) Doing the initialisation has a significant performance

Re: Cleaned up C++

2015-04-22 Thread Walter Bright via Digitalmars-d
On 4/22/2015 1:36 PM, John Colvin wrote: Is it even possible to contrive a case where 1) The default initialisation stores are technically dead and 2) Modern compilers can't tell they are dead and elide them and 3) Doing the initialisation has a significant performance impact? And you can

Re: Cleaned up C++

2015-04-22 Thread Walter Bright via Digitalmars-d
On 4/22/2015 2:58 PM, bearophile wrote: D is less stack-friendly than Ada (and probably Rust too), ??

Re: Cleaned up C++

2015-04-22 Thread Walter Bright via Digitalmars-d
On 4/22/2015 12:51 PM, ponce wrote: I didn't appreciate how important default initialization was before having to fix a non-deterministic, release-only, time-dependent bug in a video encoder some months ago. Just because of 2 uninitialized variables (C++ doesn't require member initialization in

Re: Cleaned up C++

2015-04-22 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 22 April 2015 at 22:41:33 UTC, Walter Bright wrote: And you can still initialize with '= void'. This was my tip of the week two TWID's ago! http://arsdnet.net/this-week-in-d/apr-12.html

Re: Cleaned up C++

2015-04-22 Thread Walter Bright via Digitalmars-d
On 4/22/2015 3:52 PM, Adam D. Ruppe wrote: On Wednesday, 22 April 2015 at 22:41:33 UTC, Walter Bright wrote: And you can still initialize with '= void'. This was my tip of the week two TWID's ago! http://arsdnet.net/this-week-in-d/apr-12.html Yup!