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…
Beautiful Binary Search in D
11–20 of 62 posts
Re: Beautiful Binary Search in D
#12D 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.
Re: Beautiful Binary Search in D
#13Unless 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
Re: Beautiful Binary Search in D
#14Earlier 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++.
Re: Beautiful Binary Search in D
#15Earlier 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.
Re: Beautiful Binary Search in D
#16Earlier 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++.
Is this about D code that interops with C/C++?
You have "extern (C++)" and @nogc for that
Re: Beautiful Binary Search in D
#17Earlier 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
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
#18Beauty 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…
Also I physically shuddered when I saw the word template. Did no one learn from C++ mistakes?
Re: Beautiful Binary Search in D
#19Beauty 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?
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
#20Earlier 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