Live data from Hacker News

Beautiful Binary Search in D

muscar.eu

31–40 of 62 posts

Re: Beautiful Binary Search in D

#31
post #7

Earlier 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

I mean to say it's sort of a solid general purpose language/jack of all trades, with no particular speciality or thing it's deficient at

Re: Beautiful Binary Search in D

#32
post #26

Earlier quoted context omitted.

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.

It won't compile, and... how is that a solution? You've basically told some users they can't use your language in that case. That's problem solved? If you see PHP and Java replacement as taking off, that's awesome. I was addressing those who want to see it replace C++.

The express purpose of the @nogc attribute is to enforce that code under it's influence doesn't use the GC.

There is lots of @nogc code available to depend upon

Re: Beautiful Binary Search in D

#33

Earlier quoted context omitted.

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

You're not understanding my point unfortunately. I never said you can't turn it off. I said if you do, and any of your dependencies expect it to be on, then you have a problem. (Yes, I have tried D. That's how I know this.)

If you actually turn it off (as in GC.disable()) they won't know either way, it's just a memory allocator to them.

Re: Beautiful Binary Search in D

#34

Earlier quoted context omitted.

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

You're not understanding my point unfortunately. I never said you can't turn it off. I said if you do, and any of your dependencies expect it to be on, then you have a problem. (Yes, I have tried D. That's how I know this.)

Ohhh, fair enough, yeah I see what you're saying.

Yeah you're boned in that case I think and that's a real problem that can pop up if you want full @nogc

EDIT: Maybe not based on Max's comment

D-Plug (Audio FX plugins) is one example of having to build up a dependency stack of @nogc compatible deps, a lot of that is in-house stuff.

Not impossible but it's a commitment, at which point you may as well use something else unless you REALLY want to use D, for sure.

Re: Beautiful Binary Search in D

#35
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…

That's right. The Cobol version has its own beauty because it's built into the language. Also, this is my TIL nugget of the day. Thanks :)

Re: Beautiful Binary Search in D

#37
post #32

Earlier quoted context omitted.

It won't compile, and... how is that a solution? You've basically told some users they can't use your language in that case. That's problem solved? If you see PHP and Java replacement as taking off, that's awesome. I was addressing those who want to see it replace C++.

The express purpose of the @nogc attribute is to enforce that code under it's influence doesn't use the GC. There is lots of @nogc code available to depend upon

> There is lots of @nogc code available to depend upon

That's not sufficient here. You can literally have a billion @nogc libraries, and even if there was one single GC-requiring library that many people want to use, the problem would be still there.

The only way to make this work is to ensure all of the libraries most people want to use work fine without a GC (or have @nogc alternatives that people would actually want to use). While not theoretically impossible, practically speaking, that's incredibly hard to pull off when you have a shiny GC sitting there.

Re: Beautiful Binary Search in D

#38

Earlier quoted context omitted.

You're not understanding my point unfortunately. I never said you can't turn it off. I said if you do, and any of your dependencies expect it to be on, then you have a problem. (Yes, I have tried D. That's how I know this.)

Ohhh, fair enough, yeah I see what you're saying. Yeah you're boned in that case I think and that's a real problem that can pop up if you want full @nogc EDIT: Maybe not based on Max's comment D-Plug (Audio FX plugins) is one example of having to build up a dependency stack of @nogc compatible deps, a lot of that is in-house stuff. Not impossible but it's a commitment, at which point you may as well use something els…

> a lot of that is in-house stuff.

That's exactly the issue. Having to reinvent every wheel you need just isn't a selling point.

Re: Beautiful Binary Search in D

#39
D is a refreshing language in the sea of "alternative to C languages", they didn't reinvent the syntax, so if you come from C, using D will feel very natural and at home! (and you'll be protected from most unsafe/ub quirks of C)

When it comes to metaprogramming, it's excellent, but it is a double edged sword, it can be useful, but if abused it'll tank your build speed, so one must find a proper balance to avoid pain later

One of the few languages that offers its own backend! (LLVM/GCC backends are also available)

I love this level of independence, a real labor of love, one of the best better C, i'd even say this is the evolution C needed

Re: Beautiful Binary Search in D

#40
post #32

Earlier quoted context omitted.

It won't compile, and... how is that a solution? You've basically told some users they can't use your language in that case. That's problem solved? If you see PHP and Java replacement as taking off, that's awesome. I was addressing those who want to see it replace C++.

The express purpose of the @nogc attribute is to enforce that code under it's influence doesn't use the GC. There is lots of @nogc code available to depend upon

In practice, "lots" isn't good enough. The whole ecosystem should work, not just lots.
Post reply on HN