Metamorphing Machine I rather be this walking metamorphosis
than having that old formed opinion about everything!

18 things I wished someone had told me before I went into programming

1) A byte is eight bits, except when it ain't.
There are some DSP still in use today where a byte is 16 or even 24 bits.

2) A byte can hold numbers from 0 to 255, except when it won't.
Java's byte, for instance, is signed, so its range goes from -128 to 127.

3) It is an error to divide a number by zero. Or is it?
In PHP, it is not an error, but a warning.
In JavaScript, it's no error at all, you get Infinity as an answer.

4) Have you learned that "null propagate?" Well, not always.
In VB6, "Hello" & Null yields "Hello".
In JavaScript, 1 + null yields 1, while "1" + null yields "1null".

5) What can possibly go wrong when getting the rest of a division?
VB6: -7 Mod 4 = -3
Lua: -7 % 4 = 1

6) SQL is a standard. But each vendor has its own version. Any non-trivial query cannot be ported to other DBMSs without adapting it.

7) Convert a string to its upper case version or lower case version is easy. Nah, just kidding.
There are some languages (not programming languages, natural languages) that if you convert a string from upper case to lower, then back to upper, it renders a different string from the original one.

8) Memory management is fraking difficult.
In VB6 you have referenced-counted objects. In VB.NET (and C#, and Java, and Go), you have garbage collection. Both these schemes manage memory for you.
In Free Pascal, you're on your own. You must fiddle with Assigned, Getmem, Freemem, New, and Dispose functions.
In C you're on your own, too.

9) Text/strings are hard. Say, to convert a string by removing any accents from its letters is a kind of black magic.
One must understand ASCII, Code Pages, Unicode Character Sets, Glyphs, Codepoints, surrogate pairs, NFC, NFD, NFKC, NFKD (normalization), UTF-8, UTF-16, UTF-32 (encoding), and probably many more things that I forgot to mention.

10) Not all letters have an upper or lower case counterpart.

11) Did you know different computers store numbers in memory differently?
There's something called little-endian machines, that store the number 32,768 like this (bytes are inside square brackets, bits are represented from left to right): [00000000][00000001].
There's another something called big-endian machines that store the same number as this: [00000001][00000000].
As an example, numbers in Hindu-Arabic digits are big-endian. The first digits we find while reading from left to right (meaning from "low memory addresses" to "upper addresses") are the "big" ones.
Windows is little-endian, meaning if we could read the numbers directly from the memory, the first digits we would see would be the "small" ones.
This mostly will not hurt you, unless you're working on compilers.

12) Never trust user input.
While I was starting my career in software, I was tasked to build a form where, among other things, the user would input a date.
I happily coded a masked box (that's a textbox with a mask, like "_ _ /_ _ /_ _ _ _") that converted its content to date (using CDate function) on its lost focus event.
When presenting it to one of my bosses, they filled it with nines, like 99/99/9999, hit the tab key, and crashed the application.

13) Locales are real.
Dates can be written in some ways. A few examples of the same date: 04/07/2020, 2020-07-04, 07.04.20, Sat Jul 04 2020 00:00:00.
So can monetary values. A few more examples: 1,000.50; 1.000,50. I learned pretty fast that this can cause a slew of issues.

14) Different OSes cannot agree on what a line break is!
In Windows, it is a line-feed (character 10) followed by a carriage return (character 13.)
In *nix, it is a line feed.
In IBM mainframes, it is character 21.
Of course, Unicode has its own line breaks (NEL, or next line U+0085, and line separator U+2028) that nobody uses.

15) In my limited experience, Agile is anything but. I was part of a couple of teams where we started doing stand-up meetings, had sprints, and so on.
Both crumbled when deadlines were not met. Those meetings were left behind - we could not spend time with them anymore - and we began churning code like trained monkeys.

16) Even though our society is now deeply dependent on software, or as Marc Andreesen put it, "Software is eating the world", programmers are not respected.
There are a ton of bad managers, racial bias, sexism, and ageism.

17) Undefined behavior. There's not such a thing in VB6. If I increment &H7FFFFFFF& by one, I'll get a Run-time error 6, Overflow.
In C, for instance, anything can happen, including nothing.

18) And at last but not at least:
What we are? Users! What we want? We don't know! When do we want it? Now!
(From https://imgflip.com/memegenerator/What-Do-We-Want)

Next week, I'll talk about sexual harassment.

Andrej Biasic
2021-10-27