I am passionate about teaching people to program. I feel that the more people will know programming, the better off the world will be. Therefore, it makes me sad that programming is inherently hard. Here is an easy example to show something that is inherently hard, no matter what solution you find.
You choose to teach new people language X. What features should X have? Ideally, X should not be a language fit for only new programmers — otherwise, there will never be good support for X. You want people who work on X implementations to be using X for their day-to-day jobs, at least partially.
Now, for the next question: what should be the result of “1/2”?
Here are some possible answers:
- 0 (C, Java) — seriously guys? seriously? people learned in school something about 1/2, but that ain’t even close
- Raise exception (nothing I know) — that would not work *at all* for real programmers
- 1/2 (ABC, some Schemes) — Rational numbers. Except after real calculations, these tend to explode space-wise, and teach the new programmers about the wonders of OutOfMemoryException
- 0.5 (Perl) — floating point numbers. The misnamed floating point numbers. If you take the inverse of 303743984349384034343743945., and multiply it by 303743984349384034343743945., you do not get 1. You get 0.99999999999999989 (on my Mac’s floating point HW) I must have forgotten that lesson in math class, that sometimes x/x is just really close to 1…
I could not think of any others. Now, this is fairly basic. You have to have numbers like 1 and 2 to appeal to, well, anyone. If you have 1,2 and division, you already screwed yourself up — you’re going to explain to someone new to programming why they this is 0 (“why? and how do I represent freakin’ one-half? the point does WHAT?”), why they occasionally need to apply .compress(max_error) (“space? I’m on earth.”) or why x/x is really really close to 1 (“oh, that’s what those pentium jokes mean — programmers are insane”)
[You think this only hurts you if you’re doing super-complicated science stuff? I once had floating point approximation bugs in a Perl program designed to calculate the size of generated images. I actually had to use a rational-number module.]