Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New bitwise operators are not obvious in what they do #2983

Open
cymplecy opened this issue Feb 8, 2022 · 8 comments
Open

New bitwise operators are not obvious in what they do #2983

cymplecy opened this issue Feb 8, 2022 · 8 comments

Comments

@cymplecy
Copy link
Contributor

cymplecy commented Feb 8, 2022

image

I don't think these symbols will mean much to many people

For instance, I haven't a clue what the 1st one is for at all! :)

Can they be changed to use words?

I'm assuming 2nd one is AND?
Which means 3rd one is OR?
And last one XOR????

Just guessing :)

@cymplecy
Copy link
Contributor Author

cymplecy commented Feb 8, 2022

Realised that 1st one is probably NOT???

But that is just by process of elimination :)

@cymplecy
Copy link
Contributor Author

cymplecy commented Feb 8, 2022

Or use JS bitwise symbols instead of words?
image

@cymplecy
Copy link
Contributor Author

cymplecy commented Feb 9, 2022

Microblocks uses
image

C uses the same
image

Python
image

I rest my case :)

@brianharvey
Copy link
Collaborator

Those aren't block languages. In those languages, a string of letters is a variable/procedure name, unless it's a reserved word, and they try to avoid having many of them. So their users have to learn to make sense of things like *++p*=2. Also, in those languages, if you name something exclusive or, users have to type all 12 characters every time they use it.

We're a block language. There are a few disadvantages of that, such as the amount of screen real estate a complicated expression takes up. But there are also advantages, one of which is that we can name things in ways ordinary people can read. So we don't have to decide between the mathematician's arcane ¬ and the C programmer's arcane !; we can call that function untitled script pic and any three-year-old will know what it means.

In situations in which the underlying function is hard to understand, such as the bitwise operators, we can't make them easy regardless of notation, but at least we can clue them in that they don't already understand it by using a word they don't know, such as "bitwise," in the name.

Programming is generally thought to be harder to learn than it really is, partly because heretofore novice programmers have had to memorize which of & and && is which. If you call them and and bitwise and that part, at least, becomes easy.

@brianharvey
Copy link
Collaborator

(P.S. Yes I do know that & is the bitwise one; the point is that K&R chose to make the simpler notation, the one you'd naturally pronounce "and," represent the more obscure function. Just to make it even harder to learn I guess.)

@cymplecy
Copy link
Contributor Author

cymplecy commented Feb 10, 2022

Well Microblocks is a block programming language and John chose to use the common computer symbols :)

But of course

bitwise not
bitwise and
bitwise or
bitwise xor

all work for me :)

Not sure about what words to use for

<<
>>
>>>

@programmeruser2
Copy link

Not sure about what words to use for

<<
>>
>>>

Left shift, right shift, and unsigned right shift?

@brianharvey
Copy link
Collaborator

The traditional names are left shift, arithmetic right shift, and logical right shift.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants