Live data from Hacker News

Beautiful Binary Search in D

muscar.eu

11–20 of 62 posts

Re: Beautiful Binary Search in D

#11
post #4

D is the systems language I enjoy writing the most out of C++, Rust, and Go. It feels a lot like a mix between C# and JS, but at the low level access of C++. It has a lot of unique features but the "killer feature" by far for me is Contract Programming and Invariants https://tour.dlang.org/tour/en/gems/contract-programming Invariants changed my life, so much so that I built a GCC plugin to add them to C++ It used to…

[deleted]

Re: Beautiful Binary Search in D

#12
post #4

D is the systems language I enjoy writing the most out of C++, Rust, and Go. It feels a lot like a mix between C# and JS, but at the low level access of C++. It has a lot of unique features but the "killer feature" by far for me is Contract Programming and Invariants https://tour.dlang.org/tour/en/gems/contract-programming Invariants changed my life, so much so that I built a GCC plugin to add them to C++ It used to…

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 never took off IMO because you can't abstract away a GC. The moment your callees rely on a GC, you have no choice but to have one in your program. The idea that you can avoid it in practice just because the language doesn't mandate it is therefore an illusion, and so it's not surprising at all that it isn't replacing C++.

Re: Beautiful Binary Search in D

#14

Earlier 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 never took off IMO because you can't abstract away a GC. The moment your callees rely on a GC, you have no choice but to have one in your program. The idea that you can avoid it in practice just because the language doesn't mandate it is therefore an illusion, and so it's not surprising at all that it isn't replacing C++.

This is the logic I personally used in deciding not to use D.

Re: Beautiful Binary Search in D

#15
post #14

Earlier quoted context omitted.

D never took off IMO because you can't abstract away a GC. The moment your callees rely on a GC, you have no choice but to have one in your program. The idea that you can avoid it in practice just because the language doesn't mandate it is therefore an illusion, and so it's not surprising at all that it isn't replacing C++.

This is the logic I personally used in deciding not to use D.

Yeah, I'm pretty sure it's the reason many C++ folks reject it. It's kind of ironic that having the "wrong" useful feature can hurt you, but that seems to be what's happening here. I feel like they might actually have a shot at solving it by literally dropping GC support, but it's hard to say at this point. I don't know if the standard library still has anything that needs a GC, but making sure that's not the case might be a good first step if they're ever interested in going in this direction.

Re: Beautiful Binary Search in D

#16

Earlier 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 never took off IMO because you can't abstract away a GC. The moment your callees rely on a GC, you have no choice but to have one in your program. The idea that you can avoid it in practice just because the language doesn't mandate it is therefore an illusion, and so it's not surprising at all that it isn't replacing C++.

I'm not sure I follow

Is this about D code that interops with C/C++?

You have "extern (C++)" and @nogc for that

Re: Beautiful Binary Search in D

#17
post #7

Earlier 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.

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

#18
post #8

Beauty is in the eye of the beholder. While clever, this is (IMO) far less understandable and more error-prone than say COBOL's positively ancient built-in SEARCH ALL binary search statement. Here's an example of a 3-key binary table search from IBM's COBOL documentation that includes options for found and not found conditions. SEARCH ALL TABLE-ENTRY AT END PERFORM NOENTRY WHEN KEY-1 (INDX-1) = VALUE-1 AND KEY-2 (IND…

Agree. This just screams of being too clever. It's OK to repeat things sometimes. If you DRY to the point that the code is not even readable, is that really an improvement?

Also I physically shuddered when I saw the word template. Did no one learn from C++ mistakes?

Re: Beautiful Binary Search in D

#19
post #18
post #8

Beauty is in the eye of the beholder. While clever, this is (IMO) far less understandable and more error-prone than say COBOL's positively ancient built-in SEARCH ALL binary search statement. Here's an example of a 3-key binary table search from IBM's COBOL documentation that includes options for found and not found conditions. SEARCH ALL TABLE-ENTRY AT END PERFORM NOENTRY WHEN KEY-1 (INDX-1) = VALUE-1 AND KEY-2 (IND…

Agree. This just screams of being too clever. It's OK to repeat things sometimes. If you DRY to the point that the code is not even readable, is that really an improvement? Also I physically shuddered when I saw the word template. Did no one learn from C++ mistakes?

> Did no one learn from C++ mistakes?

D was designed by Walter Bright (who played a large role in inflicting C++ on the world) and Andrei Alexandrescu so you could say that...

Re: Beautiful Binary Search in D

#20

Earlier quoted context omitted.

D never took off IMO because you can't abstract away a GC. The moment your callees rely on a GC, you have no choice but to have one in your program. The idea that you can avoid it in practice just because the language doesn't mandate it is therefore an illusion, and so it's not surprising at all that it isn't replacing C++.

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.
Post reply on HN