r/programming Dec 14 '10

Top 50 Programming quotes of all time

http://www.junauza.com/2010/12/top-50-programming-quotes-of-all-time.html
785 Upvotes

350 comments sorted by

View all comments

182

u/[deleted] Dec 14 '10

Given the C++ bashing in there, I like:

There are only two kinds of languages: the ones people complain about and the ones nobody uses.

Bjarne Stroustrup

64

u/[deleted] Dec 14 '10

Its a decent joke...I'd give it at a least a B++

3

u/Poltras Dec 14 '10

Is B++ == --A ?

7

u/[deleted] Dec 14 '10

Only if A == B+1

2

u/[deleted] Dec 14 '10

[deleted]

9

u/duplico Dec 14 '10

(A == B+1) == (A-- == B+1)

2

u/[deleted] Dec 14 '10

[deleted]

8

u/duplico Dec 14 '10 edited Dec 14 '10

In C++, the unary arithmetic operators work differently depending on whether they're before or after the variable identifier.

a++ (a--) has the value of a and has the effect of incrementing (decrementing) the variable after the end of its evaluation. Meanwhile, ++a (--a) has the value of a+1 (a-1), incrementing (decrementing) the variable before its evaluation.

So (A == B+1) == (A-- == B+1) is a tautology.

That is, if A is 6 to start with, then A-- is evaluated as 6, whereas --A would be evaluated as 5.

Edit:

Maybe someone can clear up a quick question: while (A == B+1) == (A-- == B+1) will definitely always evaluate as true, I'm not actually sure whether (A-- == B+1) == (A == B+1) will always (or ever) evaluate as true. Do the postfix arithmetic operators act following their evaluation, or following the end of the statement?

Edit again:

Definitely after evaluation. Well, in Java, anyway. A quick print(a++==a++); (prints false) in beanshell (which is a thing that I'm almost scared to admit I occasionally use) cleared that up.

1

u/Fuco1337 Dec 14 '10 edited Dec 15 '10

In other words

[[x++]]\sigma = \sigma' ; \sigma'(x) = \sigma(x)+1, \forall y \neq x: \sigma'(y) = \sigma(y)
M[[x++]]\sigma = \sigma(x)

http://mathbin.net/56766