Unless I am missing something, you can just use .length on a static array: int[5] a = [1,2,3,4,5]; writeln(a.length); // 5
Is that available at compile time, though?
Beautiful Binary Search in D
21–30 of 62 posts
Re: Beautiful Binary Search in D
#22Earlier quoted context omitted.
I'm not sure I follow Is this about D code that interops with C/C++? You have "extern (C++)" and @nogc for that
No, it's about pure D code. Some (many) people just don't want a GC in their program and that's why they use C++. If they switch to D, they'll have to put up with a GC if any of their dependencies needs one, and the probability of that being the case is... high.
The GC also doesn't run if you don't call it so mitigating it's downsides while keeping the good aspects isn't all that hard.
Re: Beautiful Binary Search in D
#23Earlier quoted context omitted.
Is your gcc plugin a personal project or something you built for a team ? I find the idea brilliant in itself but I wonder if other people felt the need, and uses / enjoy this kind of improvements. I want to add profile/coverage info in emacs now :) D is a strange point in PL landscape, it's been here for ages, never took off (for some value of taking off) even though it seems there's a lot to like.
D has suffered from lack of corporate sponsor, and there were a couple of reboots trying to chase the next big thing that would bring more people in, this allowed other language ecosystems to improve their shortcomings, thus reducing the distance in language features. From my point of view in systems programming, experience with Oberon back in the day and such, I would really like that we would be talking more about…
But Digital Mars is a company. D:
>From my point of view in systems programming, experience with Oberon back in the day and such, I would really like that we would be talking more about D and less about Rust and Go, but unfortunately it isn't how things went.
As someone who has no idea what Oberon is or does sorry and believes that using anything other than Rust is literally pouring blood on your hands and de facto proscribes you in the future inquisitions on digital harm through software, why?
Re: Beautiful Binary Search in D
#24Earlier quoted context omitted.
It was a small personal project, I posted about it here some months ago fwiw: https://news.ycombinator.com/item?id=34211482 D has no (FAANG) corporate sponsor and it does all things well/has no particular speciality, these two things make it hard to compete with marketing of other languages I think There's a small but dedicated and active community
> does all things well a great feature IMO, helps communication in large teams I believe (in the imaginary world where teams use D :) thanks for the link, have the best day
Re: Beautiful Binary Search in D
#25Earlier quoted context omitted.
No, it's about pure D code. Some (many) people just don't want a GC in their program and that's why they use C++. If they switch to D, they'll have to put up with a GC if any of their dependencies needs one, and the probability of that being the case is... high.
@nogc eliminates that risk. The GC also doesn't run if you don't call it so mitigating it's downsides while keeping the good aspects isn't all that hard.
Bear in mind you're simply not going to convince anti-GC folks that you can have the "good aspects" of a GC without the bad ones, and they're the folks you're trying to market to. To many C++ programmers the only good GC is one that is absent. You can tell them they're wrong all you want, but regardless of who's right, it's always been a losing battle.
Re: Beautiful Binary Search in D
#26Earlier quoted context omitted.
@nogc eliminates that risk. The GC also doesn't run if you don't call it so mitigating it's downsides while keeping the good aspects isn't all that hard.
You disable GC for the whole program? And what do you do when one of your dependencies relies on it? Just live with a memory leak? Bear in mind you're simply not going to convince anti-GC folks that you can have the "good aspects" of a GC without the bad ones, and they're the folks you're trying to market to. To many C++ programmers the only good GC is one that is absent. You can tell them they're wrong all you want,…
You can also make it so it will compile but won't collect unless you ask it to explicitly.
We don't exclusively market to C++ developers. D replaced PHP and Java for quite a few D users.
Re: Beautiful Binary Search in D
#27Re: Beautiful Binary Search in D
#28Earlier quoted context omitted.
@nogc eliminates that risk. The GC also doesn't run if you don't call it so mitigating it's downsides while keeping the good aspects isn't all that hard.
You disable GC for the whole program? And what do you do when one of your dependencies relies on it? Just live with a memory leak? Bear in mind you're simply not going to convince anti-GC folks that you can have the "good aspects" of a GC without the bad ones, and they're the folks you're trying to market to. To many C++ programmers the only good GC is one that is absent. You can tell them they're wrong all you want,…
There's even a mode of D that operates this way by default, "-betterC" meant to be a C replacement
The GC really is an entirety opt-in component.
I'd encourage you/other folks to give D an honest try, you might be surprised
Re: Beautiful Binary Search in D
#29Earlier quoted context omitted.
You disable GC for the whole program? And what do you do when one of your dependencies relies on it? Just live with a memory leak? Bear in mind you're simply not going to convince anti-GC folks that you can have the "good aspects" of a GC without the bad ones, and they're the folks you're trying to market to. To many C++ programmers the only good GC is one that is absent. You can tell them they're wrong all you want,…
It won't compile. You can also make it so it will compile but won't collect unless you ask it to explicitly. We don't exclusively market to C++ developers. D replaced PHP and Java for quite a few D users.
If you see PHP and Java replacement as taking off, that's awesome. I was addressing those who want to see it replace C++.
Re: Beautiful Binary Search in D
#30Earlier quoted context omitted.
You disable GC for the whole program? And what do you do when one of your dependencies relies on it? Just live with a memory leak? Bear in mind you're simply not going to convince anti-GC folks that you can have the "good aspects" of a GC without the bad ones, and they're the folks you're trying to market to. To many C++ programmers the only good GC is one that is absent. You can tell them they're wrong all you want,…
Aye, you can turn off GC entirely, for the whole program There's even a mode of D that operates this way by default, "-betterC" meant to be a C replacement The GC really is an entirety opt-in component. I'd encourage you/other folks to give D an honest try, you might be surprised