Java’s Broken Booleans

  • Thread starter Lawrence D'Oliveiro
  • Start date
J

Joshua Cranmer

In what way is it not exactly the same effect?

|| is a short-circuit operator.
Note that I didn’t directly call you an ad-hominem, I just mentioned a
situation that many others besides myself would agree is just plain stupid.
I only asked if you did it, I didn’t even try to claim you did. You could
have kept your mouth shut and not admitted to doing this sort of thing, but
no, you had to speak up and fall right into it.

As I said, I care more about readability of code than speed of
execution. If you think that is just plain stupid, then I would not want
to hire you for a project management team.
 
L

Lew

|| is a short-circuit operator.

Gods, "Lawrence", read the freaking tutorials at least!
As I said, I care more about readability of code than speed of execution. If
you think that is just plain stupid, then I would not want to hire you for a
project management team.

I wouldn't want to hire him to clean toilets.
 
D

Daniele Futtorovic

Well, Daniele, that's a really good idea. I'm surprised "Lawrence
D'Oliveiro" didn't think of it! (No, I'm not.)

These values would need keywords to identify them. Could we use, hm, oh,
I don't know, "Satan" and "G-D"? No? How about "true" and "false"
(respectively?), then?

We'd better make them incommensurate with 'int' though, or we're right
back to the problem we're trying to avoid.

Count me in! That way we could bitch and moan on Usenet about not being
able to use them as array indices any more (which is necessary because,
obviously, sometimes there's one part of an array that is true and one
part of it that is false)!

That'd be fucking awesome!
 
A

Andreas Leitgeb

Daniele Futtorovic said:
Count me in! That way we could bitch and moan on Usenet about not being
able to use them as array indices any more (which is necessary because,
obviously, sometimes there's one part of an array that is true and one
part of it that is false)!

I hope you all enjoy your laughs, for there wouldn't be any other point
for it, otherwise. Especially, if the intention was to to make fun of
Lawrence supposedly wanting the status-quo, then that was an obvious
utter failure, of course.
 
A

Arne Vajhøj

But Mr Duniho claims that Java does “just as I wishâ€, while you are saying
what I wish is wrong. Who is right?

Both.

Peter is saying that Java supports the functionality that you wish
while I am saying that you are using the wrong syntax for it.

Arne
 
A

Arne Vajhøj

|| is a short-circuit operator.


As I said, I care more about readability of code than speed of
execution. If you think that is just plain stupid, then I would not want
to hire you for a project management team.

s/project management//w

Arne
 
A

Arne Vajhøj

Afaict, the name of that variable isn't changed. Setting it to
false doesn't change it to a variable "unmodified" holding "true". :)

So, depending on the value, the fixed claim "it is modified" is
either meant to be true or wrong. A wrong claim of being modified
can of course be seen as a claim of being "unmodified", but
that is just interpretation, not the original data.

I don't consider the variable name to indicate a claim
to be true.

A boolean indicates whether something is true or false.

There are no implication that true is to be expected
or be more normal.

Arne
 
A

Arne Vajhøj

Well, guess what, they all do—except Java.

Given that some languages does not have ordering
of booleans and that other languages has the opposite
order, then I think the only thing we can conclude is that
you know too few programming languages.

Arne
 
A

Arne Vajhøj

That seems to be characteristic of the responses here when I point out
deficiencies and mistakes in Java or its specification.

The problem is that you have not found deficiencies and midtakes.

Just shown that you don't know Java or programming languages
in general.
It’s like Java is
all you know, you have no standard of comparison with other languages, even
other common ones—no sense of perspective on how things should be done
versus how your favourite language does them.

As has been proven by your false claim of Java being the only
language having true > false (which is false because Java does
have that via Boolean and because there are several languages
without it), then we know lots of languages - you don't know
many languages and not really Java either.

Arne
 
A

Arne Vajhøj

Try doing this with an if statement:

public class ExampleSub extends Example {
ExampleSub() {
super((System.currentTimeMillis()&1)==0?"Even":"Odd");
}
}

class Example {
String s;
Example(String t) {
s = t;
}
}

A static method or a static factory might be preferable, but this is an
example where ?: cannot easily be transformed into an if statement.

A static method with an if statement!

:)

Arne
 
L

Lew

I don't consider the variable name to indicate a claim
to be true.

A boolean indicates whether something is true or false.

There are no implication that true is to be expected
or be more normal.

Gödel's incompleteness theorem proves that no sufficiently powerful logic
system is complete. That means there will always be truth, under an
interpretation, that can be neither proven nor disproven (the two being equal
in predicate logic).

It's a tautology that "p is false" means "not p is true". "false" and "true"
are just two sides of the same coin, and have no precedence any more than
"heads" or "tails" do for that coin.
 
A

Arved Sandstrom

Non the less it proves that your claim was false.

Arne

VB 6 still did it that way, i.e. true is -1. I believe VB.NET switched
over to true being 1. In fact I think that for numeric conversion
purposes and to be backward compatible with VB code, VB.NET has anything
other than 0 being true. But don't quote me on VB.NET.

And FWIW it wasn't what I'd call stupid that VB used 0 for false and -1
for true; no more stupid than C's interpretation. Every concrete
representation has its warts. VB actually had its reasons, starting with
a definition of true as "not false" and false being 0, and the fact that
a signed 16-bit was used for booleans (Integers from VB1 through VB4,
and actual Booleans for VB4 through VB6).

The only thing stupid is for Larry to require a specific numerical
representation of what should remain symbolic truth values.

AHS
 
A

Arne Vajhøj

VB 6 still did it that way, i.e. true is -1. I believe VB.NET switched
over to true being 1. In fact I think that for numeric conversion
purposes and to be backward compatible with VB code, VB.NET has anything
other than 0 being true. But don't quote me on VB.NET.

And FWIW it wasn't what I'd call stupid that VB used 0 for false and -1
for true; no more stupid than C's interpretation. Every concrete
representation has its warts. VB actually had its reasons, starting with
a definition of true as "not false" and false being 0, and the fact that
a signed 16-bit was used for booleans (Integers from VB1 through VB4,
and actual Booleans for VB4 through VB6).

The only thing stupid is for Larry to require a specific numerical
representation of what should remain symbolic truth values.

I completely agree.

I am pretty sure that all of this is mainly because K&R
decided not to have a bool in C.

A lot of people learned to use int for true/false.

Arne
 
D

Daniele Futtorovic

I hope you all enjoy your laughs, for there wouldn't be any other
point for it, otherwise.
Good.

Especially, if the intention was to to make fun of Lawrence
supposedly wanting the status-quo,

Not quite, my dear Watson. The intent was to highlight a situation which
strongly suggested that D'Oliveiro will take any position and put forth
anything as long as it serves to stir up or protract these pointless
fuckfests of threads we've been seeing lately.
 
A

Andreas Leitgeb

Arne Vajhøj said:
I don't consider the variable name to indicate a claim
to be true.

Typically, boolean things are named like "hasNext()" or
"isEmpty()", "contains(...)", that is: some part of a sentence
which together with a subject and eventual further parameters
reads as an English sentence expressing a claim. And if it
doesn't include a verb, then "is" is taken as the default.

If I were to implement a modification state property and anticipated
the "modified" state to be more often checked for falseness
(i.e.: if I expected "if (!modified) ..." to be the typical use)
then I'd rather call the property something like "unmodified", instead -
or some synonym of it, that doesn't contain the negation in the name
but still conveys the inverse meaning of "modified" - e.g. "clean" ;)

Mathematical booleans are strictly symmetric, but natural ones much
less so. - In my private world's variant of "natural", anyways.
 
A

Andreas Leitgeb

Daniele Futtorovic said:
Not quite, my dear Watson. The intent was to highlight a situation which
strongly suggested that D'Oliveiro will ...

Strongly suggested? To whom? (Apart from those, who
actively "feed", what *they* claim to be a troll)
 
J

Joshua Cranmer

It’s a stupid thing to do.

It is well-known that xor'ing a bit with 1 is equivalent to flipping it,
i.e. a = not a. Since 0 is false, if you xor each bit with 1, you get
not 0 for every bit, so 0 xor "all 1s" = 0 xor -1 = -1.
 
A

Arved Sandstrom

Typically, boolean things are named like "hasNext()" or
"isEmpty()", "contains(...)", that is: some part of a sentence
which together with a subject and eventual further parameters
reads as an English sentence expressing a claim. And if it
doesn't include a verb, then "is" is taken as the default.

If I were to implement a modification state property and anticipated
the "modified" state to be more often checked for falseness
(i.e.: if I expected "if (!modified) ..." to be the typical use)
then I'd rather call the property something like "unmodified", instead -
or some synonym of it, that doesn't contain the negation in the name
but still conveys the inverse meaning of "modified" - e.g. "clean" ;)

Mathematical booleans are strictly symmetric, but natural ones much
less so. - In my private world's variant of "natural", anyways.
Point well taken. I see poor choices here often happen in JSF, with EL
tests for "rendered" and "disabled". It's irritating and somewhat
error-prone to always have to do things like

disabled="#{not bean.fooEnabled}"

although to some extent I blame HTML for having chosen "disabled" as an
attribute; "rendered" in JSF at least has a positive sense.

AHS
 
L

Lawrence D'Oliveiro

I am pretty sure that all of this is mainly because K&R
decided not to have a bool in C.

A lot of people learned to use int for true/false.

No, I first came across it in Pascal, as I explained in my original posting.
To me, that remains the benchmark for judging other interpretations of the
Boolean type.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top