From: Lew on
Arne Vajhøj wrote:
>>>>>> BTW, isn't ++something a C++'ism?

Lew wrote:
>>>>> It's been around longer than that, since C.

Arne Vajhøj wrote:
>>>> I know, but the ++something is better than something++
>>>> because it is faster is rooted in C++ classes I believe.

Lew wrote:
>> I wouldn't know. This is a Java newsgroup. I'm not aware of any speed
>> differences between the two expressions in Java, and would be dubious of
>> any claims that there are.

Arne Vajhøj wrote:
> Neither am I.
>
> But I think the something++ notation is more readable and

I'm sure you agree that's entirely a matter of taste and style.

Two of us in this thread have expressed the opposite opinion, and both are
good programmers.

> the main reason why the ++something is used is the influence
> of C++ programmer micro optimization.

Neither of us who expressed a preference for the pre-increment version had
"C++ micro[-]optimization" as the reason. Both of us had readability as the
reason. Do you have any evidence for your assertion? It would need to be
statistical to justify the claim of "main reason".

--
Lew
From: Peter Duniho on
Lew wrote:
> [...]
> Neither of us who expressed a preference for the pre-increment version
> had "C++ micro[-]optimization" as the reason. Both of us had
> readability as the reason. Do you have any evidence for your
> assertion? It would need to be statistical to justify the claim of
> "main reason".

If "++something" is so much more readable than "something++", why isn't
the language named "++C"?

:p

Okay, I'm being facetious. And if you find "++something" more readable,
by all means use it. Readability is indeed a subjective matter, and
what matters most is who is going to be involved with the code the most.

That said, in my 20+ years of using the C language and derivatives, it's
been my experience that "something++" is far more common a construct.

And just as I find the spellings such as "Worcestershire" and "neighbor"
more readable than the more phonetically-obvious "Warstershyer" and
"nayber", I would expect most to find "something++" more readable,
simply because it's the form most commonly used.

That is, it's not more readable because it makes more logical sense.
It's more readable because humans have millions of years of
pattern-matching skills built into us, and those skills work best with
things we're more familiar with, such as the more commonly seen
"something++".

Pete
From: Arne Vajhøj on
On 15-02-2010 20:44, Lew wrote:
> Arne Vajhøj wrote:
>>>>>>> BTW, isn't ++something a C++'ism?
>
> Lew wrote:
>>>>>> It's been around longer than that, since C.
>
> Arne Vajhøj wrote:
>>>>> I know, but the ++something is better than something++
>>>>> because it is faster is rooted in C++ classes I believe.
>
> Lew wrote:
>>> I wouldn't know. This is a Java newsgroup. I'm not aware of any speed
>>> differences between the two expressions in Java, and would be dubious of
>>> any claims that there are.
>
> Arne Vajhøj wrote:
>> Neither am I.
>>
>> But I think the something++ notation is more readable and
>
> I'm sure you agree that's entirely a matter of taste and style.

Yes.
>> the main reason why the ++something is used is the influence
>> of C++ programmer micro optimization.
>
> Neither of us who expressed a preference for the pre-increment version
> had "C++ micro[-]optimization" as the reason. Both of us had readability
> as the reason.

Readability is not independent of experience.

And even though you may not consider yourself C++ programmers, then
I am pretty sure that you have read C++ programs before learning
Java and had Java teachers that used to do C++ programming.

> Do you have any evidence for your assertion? It would
> need to be statistical to justify the claim of "main reason".

The discussion is as classic in C++ as avoiding public fields in
Java.

I can (obviously) not produce statistics that show how much
C++ way of thinking has been inherited by Java programmers.

It is my belief that most Java programmer either did use
C++ before Java or learned Java by other that did use C++
before Java or have read plenty of Java books by people that
did use C++ before Java.

Arne

From: Arved Sandstrom on
Arne Vajhøj wrote:
[ SNIP ]

> It is my belief that most Java programmer either did use
> C++ before Java or learned Java by other that did use C++
> before Java or have read plenty of Java books by people that
> did use C++ before Java.
>
> Arne

I'll bet lots and lots of money that in 2010 that point #1 is no longer
the case. I'm not convinced that it was _ever_ the case. In 2010 point
#2 is also likely not the case, and although point #3 may be true, I'm
glad you used the word "use" and not "knew well".

AHS
From: RedGrittyBrick on
On 16/02/2010 10:17, Arved Sandstrom wrote:
> Arne Vajhøj wrote:
> [ SNIP ]
>
>> It is my belief that most Java programmer either did use
>> C++ before Java or learned Java by other that did use C++
>> before Java or have read plenty of Java books by people that
>> did use C++ before Java.
>>
>
> I'll bet lots and lots of money that in 2010 that point #1 is no longer
> the case. I'm not convinced that it was _ever_ the case. In 2010 point
> #2 is also likely not the case, and although point #3 may be true, I'm
> glad you used the word "use" and not "knew well".
>

Regardless, my programming language history went something like

A = A + 1
a := a + 1
a += 1
a++

So, to me, a++ is more natural than ++a.

--
RGB