Live data from Hacker News

Beautiful Binary Search in D

muscar.eu

51–60 of 62 posts

Re: Beautiful Binary Search in D

#51
post #19
post #18

Earlier quoted context omitted.

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

> D was designed by Walter Bright (who played a large role in inflicting C++ on the world)

That's a rather unfair characterization. He wrote the Datalight/Zortech C++ compiler. He was never--that I recall--a big flag-waver for C++.

Re: Beautiful Binary Search in D

#52
post #10

Earlier quoted context omitted.

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…

> D has suffered from lack of corporate sponsor 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 lit…

Oberon is the language Niklaus Wirth designed after Pascal and Modula.

Re: Beautiful Binary Search in D

#53
post #14

Earlier quoted context omitted.

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

> This is the logic I personally used in deciding not to use D. Good call - I was unfortunate enough that I had to use it professionally for a few years. As comic book guy in the Simpsons would say "Worst language ever!".

I’m interested in hearing more. Also, I’m curious what language you use as a your daily driver?

Re: Beautiful Binary Search in D

#54
post #19

Earlier quoted context omitted.

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

> D was designed by Walter Bright (who played a large role in inflicting C++ on the world) That's a rather unfair characterization. He wrote the Datalight/Zortech C++ compiler. He was never--that I recall--a big flag-waver for C++.

His company originally was a C++ toolchain shop.

Anyway, I was joking — Walter did one of the first (if not the first?) "Proper" C++ compilers, so the idea of not learning from C++ is rather ironic.

Re: Beautiful Binary Search in D

#55

Earlier quoted context omitted.

Conveniences like closures depend on gc

C++ has had closures without a GC for over a decade now.

As syntactic sugar for how C++ functors used to be implemented, and they also bring their own set of issues when interoperating with co-routines.

Re: Beautiful Binary Search in D

#56
post #55

Earlier quoted context omitted.

C++ has had closures without a GC for over a decade now.

As syntactic sugar for how C++ functors used to be implemented, and they also bring their own set of issues when interoperating with co-routines.

If anything that's a statement about coroutines, not closures. And even then, not every coroutine has problems. I don't see a logical implication from that to a GC requirement.

Re: Beautiful Binary Search in D

#58

Earlier quoted context omitted.

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 mi…

Conveniences like closures depend on gc

That's not true

https://dlang.org/spec/function.html#function-pointers-deleg...

Re: Beautiful Binary Search in D

#59

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…

D isn't a good substitute for C due to its garbage collector.

Yes, people always chime in about how you can disable D's garbage collector, but then you're stuck with an awkward language that lacks support for basic things like exceptions, closures, strings, slices, and a host of other features not to mention pretty much any third party library.

If you are willing to accept a GC then D might be a good choice, if you find it fun then by all means go for it, but it's no longer so clear cut at that point given the wealth of GC'd programming languages available.

Re: Beautiful Binary Search in D

#60
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?

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

While we might disagree on a lot of semantical things on this, I'd argue that D very much learned from those mistakes. There's a strong argument for D's templates to be "templates done right" (which C++'s most certainly aren't).

So I encourage you to read more into this topic. To me, this question seems just about as uninformed as someone complaining about a LISP tutorial on macros, asking "did no one learn from the mistake that is the C preprocessor?".

If/where there are other models better suited for metaprogramming would be another (interesting) discussion (full of tradeoffs, I'm sure), but the notion of proper (hygienic?) templates not being adequate anywhere can certainly not be inferred from C++'s implementation alone.

Post reply on HN