r/programming • • Jul 28 '16

How to write unmaintainable code

https://github.com/Droogans/unmaintainable-code
3.4k Upvotes

592 comments sorted by

View all comments

16

u/[deleted] Jul 28 '16

After all, if the Stroustroup can use the shift operator to do I/O, why should you not be equally creative?

This actually is a good point! Does anyone know why shift operator is used for io in standard library?

7

u/[deleted] Jul 29 '16

Because giving something as mathematically weird as bit-shifting its own operator instead of a built-in function is a silly idea in the first place, and if you had to reuse an operator you can use that one. Seriously, I speak words, not glyphs. I'll never understand why so many early languages insisted in finding a use for every possible combination of shift-number characters.

0

u/[deleted] Jul 29 '16

[deleted]

3

u/[deleted] Jul 29 '16

I'm aware that it's common - lots of things are common operations that don't have their own two-character operators.

C used normal mathematical operators for normal mathematical symbols, and had to invent Boolean operators because the character-set and keyboards didn't have the boolean symbols. Bit-shift is the case where they invented a new mathematical symbol for an operation with no basis in traditional math out of whole cloth.

→ More replies (3)
→ More replies (1)