September 14, 2022
On Tuesday, 13 September 2022 at 21:04:51 UTC, Steven Schveighoffer wrote:
> Same thing with binary. It allows me to express *certain numbers* without thinking or figuring too hard. Like building a number that has n consecutive bits set (i.e. the poker example). Or if you have a register that has sets of odd-length bit patterns.
>

Exactly - or the bit pattern doesn't even mean a number, but the state of switches or buttons or something like that.
September 14, 2022
On Tuesday, 13 September 2022 at 20:12:10 UTC, Don Allen wrote:
> So you used 0b notation to come up with a justification for 0b notation :-)
>
> I do this sort of thing with an HP calculator.
>

No, he used binary notation because it's the best tool for the job. He didn't even need to reach for his calculator and that's the point.

I would also never do the bit shifting thing you showed earlier (for that purpose). It's way too much mental friction. You need to build in your mind what you'd see on screen with binary literals.
September 14, 2022
On Wednesday, 14 September 2022 at 00:35:04 UTC, Walter Bright wrote:
> On 9/13/2022 2:04 PM, Steven Schveighoffer wrote:
>>> Is it? How do you know it didn't overflow the int and create a long? How do you know you filled up the int?
>> 
>> How do you know the purpose is to fill up an int?
>
> Ok, I'll rephrase that. How do you know when to stop?
>
> There's a reason hex is so ubiquitous. It's compact. Binary literals beyond a few digits (8 max) are more or less unreadable. Yes, the _ can extend it to more digits before it becomes unreadable. (Even long hex numbers benefit from _, again, after 8 digits.)

As a digital electronics lover I wouldn't support Walter. But in the days when big data penetrated our bones, Walter was right. As the number of bits increases, grouping and counting becomes meaningless. The simplest example is the RGB color system. 16.7 million colors of 3 x 8 bits!

SDB@
September 14, 2022
On Wednesday, 14 September 2022 at 05:58:53 UTC, Walter Bright wrote:
> People often complain that D has too many features. What features would you say are not worth it?

ImportC, -betterC, @nogc, nothrow, @live. These things don't even *work* on their own terms, and they continue to have additional downstream effects over several parts of D and the ecosystem. Massive complication for little benefit.

To a lesser extent, @safe and dip1000 can go too.

September 14, 2022
On Wednesday, 14 September 2022 at 12:36:09 UTC, Ali Çehreli wrote:
> On 9/14/22 01:43, Patrick Schluter wrote:
>
> > `core.bitop.popcnt(check) == 4` would be simpler and most
> modern CPU's
> > have an instruction for that.
>
> That will give total number of bits set. Steve's function determines whether 5 neighboring bits are set consecutively, anywhere in the "register".

ok. My bad.

>
> And that 4 is a red herring that made me think I found a bug. No, the function finds 5 consecutive bits set by 4 shifts. :)
>



September 14, 2022

On 9/14/22 1:58 AM, Walter Bright wrote:

>

On 9/13/2022 7:56 PM, Steven Schveighoffer wrote:

>

But it doesn't disprove the fact that sometimes, hex digits aren't as clear.

Does sometimes justify a language feature, when there are other ways?

This isn't Go. We have comfort features that make code easier to read and write. binary literals cost nothing to have. There is no cost on the user, and no cost on the compiler (parsing a binary literal isn't any more taxing than parsing a hex literal).

If we were talking about adding binary literals, when it's possible to do it via a template, maybe you have a point. But we aren't. We are talking about removing a zero-cost feature.

Can you describe exactly what is gained by removing binary literals? If you think it's because the compiler gets simpler, think again. The only code that is removed is this:

https://github.com/dlang/dmd/blob/978cd5d766f22957e029754f43245e9d76830d70/compiler/src/dmd/lexer.d#L1979-L1985

Half of which is dealing with ImportC.

>

People often complain that D has too many features. What features would you say are not worth it?

There's a difference between "not worth adding" and "not worth keeping". Removing features needs a very high bar to make sense. Adding features also needs a high bar, considering that it's more difficult to remove later than it is to not add it.

That being said, if binary literals weren't in the language, I'd be fine adding them. They don't cost anything, and add a way to write code that is clearer in some cases.

If I had to pick at gunpoint an established language feature to remove, it would be betterC. But I can't see any features I'd want to remove. D's features are pretty nice.

-Steve

September 14, 2022

On 9/14/22 4:43 AM, Patrick Schluter wrote:

>

core.bitop.popcnt(check) == 4 would be simpler and most modern CPU's have an instruction for that.

I do use that for flushes! https://github.com/schveiguy/poker/blob/6f70cf7ca74e19e78b470f81640a3ce34a95d0d3/source/poker/hand.d#L376-L386

And a cool thing about that too, the "best" flush is simply the mask that is larger (because it has higher bits set, i.e. bigger rank cards).

Man, that was a fun little project ;)

-Steve

September 14, 2022
On Wednesday, 14 September 2022 at 05:58:53 UTC, Walter Bright wrote:
> On 9/13/2022 7:56 PM, Steven Schveighoffer wrote:
>> But it doesn't disprove the fact that *sometimes*, hex digits aren't as clear.
>
> Does sometimes justify a language feature, when there are other ways?
>
> People often complain that D has too many features. What features would you say are not worth it?

Template constraints. Horrible error messages (though better than they were) and confusing to work out which overload matches. They make documentation complicated. Just use static if and static assert instead to solve all these problems.
September 14, 2022
On Wednesday, 14 September 2022 at 05:58:53 UTC, Walter Bright wrote:
> On 9/13/2022 7:56 PM, Steven Schveighoffer wrote:
>> But it doesn't disprove the fact that *sometimes*, hex digits aren't as clear.
>
> Does sometimes justify a language feature, when there are other ways?

"Sometimes" justifies a lot of features. Hex literals are only sometimes useful for example.
September 14, 2022
On Wednesday, 14 September 2022 at 13:30:46 UTC, Adam D Ruppe wrote:
> On Wednesday, 14 September 2022 at 05:58:53 UTC, Walter Bright wrote:
>> People often complain that D has too many features. What features would you say are not worth it?
>
> ImportC, -betterC, @nogc, nothrow, @live. These things don't even *work* on their own terms, and they continue to have additional downstream effects over several parts of D and the ecosystem. Massive complication for little benefit.
>
> To a lesser extent, @safe and dip1000 can go too.

Because D is multiparadigm, everyone has their own list. I love and use all of those features. Currently I can only think of 1 feature I don't use, but others use it so it doesn't matter.