Jump to page: 1 26  
Page
Thread overview
The problem that took him 5 years to fix in C++, I solved in a minute with D
Mar 10, 2022
matheus
Mar 10, 2022
rikki cattermole
Mar 10, 2022
Paulo Pinto
Mar 10, 2022
FeepingCreature
Mar 10, 2022
Mike Parker
Mar 10, 2022
Mike Parker
Mar 10, 2022
matheus
Mar 10, 2022
matheus
Mar 10, 2022
bachmeier
Mar 10, 2022
bachmeier
Mar 10, 2022
IGotD-
Mar 10, 2022
Paulo Pinto
Mar 11, 2022
Nicholas Wilson
Mar 11, 2022
Paulo Pinto
Mar 11, 2022
Bruce Carneal
Mar 14, 2022
Paulo Pinto
Mar 14, 2022
Bruce Carneal
Mar 11, 2022
Nicholas Wilson
Mar 14, 2022
Guillaume Piolat
Mar 20, 2022
Guillaume Piolat
Mar 20, 2022
Guillaume Piolat
Mar 10, 2022
Guillaume Piolat
Mar 10, 2022
Walter Bright
Mar 10, 2022
zjh
Mar 10, 2022
zjh
Mar 10, 2022
zjh
Mar 10, 2022
Paul Backus
Mar 10, 2022
zjh
Mar 10, 2022
zjh
Mar 10, 2022
zjh
Mar 10, 2022
Basile B.
Mar 10, 2022
zjh
Mar 10, 2022
Paul Backus
Mar 11, 2022
Timon Gehr
Mar 10, 2022
matheus
Mar 10, 2022
Ali Çehreli
Mar 10, 2022
David Gileadi
Mar 10, 2022
H. S. Teoh
Mar 11, 2022
zjh
Mar 11, 2022
H. S. Teoh
Mar 10, 2022
Basile B.
Mar 10, 2022
IGotD-
Mar 10, 2022
Paulo Pinto
Mar 10, 2022
IGotD-
March 10, 2022
Hi,

Today someone sent me this video: https://www.youtube.com/embed/ABg4_EV5L3w
(C++ Weekly - Ep 313 - The `constexpr` Problem That Took Me 5 Years To Fix!).

It's a 26 minute long video of a guy trying to generate a concatenated string during CT in C++.

I was flabbergasted by the problems this poor guy had in front of him for a thing that shouldn't seem so complex (In my opinion of course). And more yet that he has being struggling with this for 5 years.

So I decided to try the same with D, it was 14 lines[1] of code written in less than a minute and it just worked on the first try. Then I looked the Assembly code:

.L.str:
        .asciz  "hello world, hello world, hello world, "

After that I even asked over the D IRC channel if it was just this? And a user confirmed that my string was being generated through CT as the Assembly indicated.

Again incredible. My first programming language was C, then in 2000-ish I had my first contact with C++ and I just hated and went back to C and then while looking for alternatives I stumbled on D which I use till this day as a "super C".

But now after so many years I couldn't believe the C++ is still struggling even to this day with this type of thing.

I'd like to quote this comment from the video:

> meowsqueak:
> "Well done solving this puzzle, but I’m left in shock. The need to employ a template, static constexpr variables, a lambda function, and four utility functions just to compile-time generate a static string in C++ is an embarrassment."[2]

And indeed it is an embarrassment. Well D may have it flaws but I always found it lot time better or less restrictive language compared to others, especially C++.

Finally I'd like to take this moment and thank for all the effort.

Matheus.

[1] - Here is the snippet I wrote: https://godbolt.org/z/MsT36Prx4
[2] - Youtube comment: https://www.youtube.com/watch?v=ABg4_EV5L3w&lc=Ugzb7kTLS8GNS9bK07F4AaABAg

PS: I'm a ESL, sorry for any English mistakes.
March 10, 2022
We can shorten that even further!

```d
import std.range : repeat, join;

pragma(msg, "hello world, ".repeat(3).join);
```
March 09, 2022

On 3/9/22 9:01 PM, matheus wrote:

>

Hi,

Today someone sent me this video: https://www.youtube.com/embed/ABg4_EV5L3w
(C++ Weekly - Ep 313 - The constexpr Problem That Took Me 5 Years To Fix!).

It's a 26 minute long video of a guy trying to generate a concatenated string during CT in C++.

I was flabbergasted by the problems this poor guy had in front of him for a thing that shouldn't seem so complex (In my opinion of course). And more yet that he has being struggling with this for 5 years.

So I decided to try the same with D, it was 14 lines[1] of code written in less than a minute and it just worked on the first try.

Watched a bunch of this video, and one thing that has stuck out to me -- the compiler is complaining about destructors.

One of the "side effects" of D having a builtin GC is that it perfectly fits the requirements of memory allocation at compile time as well. The heap is abstracted behind a different set of primitives, and apparently C++ cannot figure this out because they need to worry about destruction/free!

Am I reading this wrong?

-Steve

March 10, 2022
On Thursday, 10 March 2022 at 02:01:01 UTC, matheus wrote:
> Hi,
>
> Today someone sent me this video: https://www.youtube.com/embed/ABg4_EV5L3w
> (C++ Weekly - Ep 313 - The `constexpr` Problem That Took Me 5 Years To Fix!).
>
> It's a 26 minute long video of a guy trying to generate a concatenated string during CT in C++.
>
> I was flabbergasted by the problems this poor guy had in front of him for a thing that shouldn't seem so complex (In my opinion of course). And more yet that he has being struggling with this for 5 years.
>
> So I decided to try the same with D, it was 14 lines[1] of code written in less than a minute and it just worked on the first try. Then I looked the Assembly code:
>
> .L.str:
>         .asciz  "hello world, hello world, hello world, "
>
> After that I even asked over the D IRC channel if it was just this? And a user confirmed that my string was being generated through CT as the Assembly indicated.
>
> Again incredible. My first programming language was C, then in 2000-ish I had my first contact with C++ and I just hated and went back to C and then while looking for alternatives I stumbled on D which I use till this day as a "super C".
>
> But now after so many years I couldn't believe the C++ is still struggling even to this day with this type of thing.
>
> I'd like to quote this comment from the video:
>
>> meowsqueak:
>> "Well done solving this puzzle, but I’m left in shock. The need to employ a template, static constexpr variables, a lambda function, and four utility functions just to compile-time generate a static string in C++ is an embarrassment."[2]
>
> And indeed it is an embarrassment. Well D may have it flaws but I always found it lot time better or less restrictive language compared to others, especially C++.
>
> Finally I'd like to take this moment and thank for all the effort.
>
> Matheus.
>
> [1] - Here is the snippet I wrote: https://godbolt.org/z/MsT36Prx4
> [2] - Youtube comment: https://www.youtube.com/watch?v=ABg4_EV5L3w&lc=Ugzb7kTLS8GNS9bK07F4AaABAg
>
> PS: I'm a ESL, sorry for any English mistakes.

Well, a language alone doesn't make ecosystems, D is a good language, but after 10 years doesn't hold a candle to CUDA, Metal, Unreal, SYSCL, AUTOSAR/MISRA certifications, iOS/Android/Windows SDK, High Energy Physics research, PyTorch/Tensorflow, LLVM/GCC, ....

Before bashing C++'s design, which does indeed have plenty of flaws with several books describing them, what about finishing all those previews that are already 5 years and longer in the making and finally decide what domain D is good at?

The way I see it, C# 10 and C++ 20 have mostly catched up in where D was 10 years ago, Rust and Go have found out a way to push them into devs regardless of what they think about them, thanks all those Cloud Native Foundation projects, Khronos is slowly adopting Rust alongside C++ on some of their ongoing standard discussions.

Creating such ecosystems is what D should worry about, not how great a bare bones compiler is against the competition.
March 10, 2022
This would make a great post on HackerNews or Reddit! Please do so.

P.S. I sent you email about this, but your email address doesn't work.
March 10, 2022

On Thursday, 10 March 2022 at 06:44:47 UTC, Paulo Pinto wrote:

>

The way I see it, C# 10 and C++ 20 have mostly catched up in where D was 10 years ago, Rust and Go have found out a way to push them into devs regardless of what they think about them, thanks all those Cloud Native Foundation projects, Khronos is slowly adopting Rust alongside C++ on some of their ongoing standard discussions.

It was probably a good move for Rust and Go to go their own way, rather than copying others too much, in the sense that they stand out with one significant feature that is rare.

>

Creating such ecosystems is what D should worry about, not how great a bare bones compiler is against the competition.

D should start with fixing basic problems such as not being able to unify types with alias. C++ is currently ahead in meta-programming utility IMHO. Template composition is foundational for meta-programming, without proper aliases it is just not very practical.

After that the whole memory management and "shared" topic should be settled in a way that bring the language some unique advantages.

Until that is in place there is really no use in pointing to minor features like string concatenation, which basically has no measurable impact on true system level programming or advanced (non-macroish) meta programming for that matter.

March 10, 2022

On Thursday, 10 March 2022 at 02:01:01 UTC, matheus wrote:

>

Hi,

I hope to see the official priority list of D.

March 10, 2022
On Thursday, 10 March 2022 at 06:44:47 UTC, Paulo Pinto wrote:
> Before bashing C++'s design, which does indeed have plenty of flaws with several books describing them, what about finishing all those previews that are already 5 years and longer in the making and finally decide what domain D is good at?
>

Why? D being flawed does not take away one whit from C++'s issues. The C++ people are free to bash us right back. I don't follow this logic of "nobody is allowed to complain unless their own record is spotless." Nobody is ever spotless. Every language has warts. But of course you can complain about other languages' warts at any time you want! If I couldn't complain about the inadequacy of the tools that the profession considers adequate, I would certainly go crazy.
March 10, 2022

Hope to see D's vision(or position), roadmap and continue changing progress bar on the home page from time to time.
D should have a dynamic priority list of features/todo. and letting users known. and it should put on the dlang homepage.
Then new and old users can intuitively feel the progress . Otherwise,plain users don't know the power of d.
Just like C++ now has no user defined attributes, which is very uncomfortable.
We should show our strengths on the home page.
In addition, we should dig into the good posts of skilled users of d Forum and classify them and, reward them for their excellent answers. Then, we can avoid answering the same questions repeatedly by just providing a link.

March 10, 2022

On Thursday, 10 March 2022 at 11:32:07 UTC, FeepingCreature wrote:

>

On Thursday, 10 March 2022 at 06:44:47 UTC, Paulo Pinto wrote:

>

Before bashing C++'s design, which does indeed have plenty of flaws with several books describing them, what about finishing all those previews that are already 5 years and longer in the making and finally decide what domain D is good at?

Why?

Because negative advertising doesn't work, it is negative and will be perceived as whining.

Demonstrate what you are good at, but show your own merits.

Demonstrating feature parity with C++ would be good of course, so go for it when you are ready, but bragging about string concatenation won't win over any C++ programmer that needs what C++ is good for. It isn't something most C++ programmers care about.

« First   ‹ Prev
1 2 3 4 5 6