Your blog entry must explicitly answer the following questions about the class (mark the questions in bold in your post):
Regarding the class, I don’t feel I did anything particularly worth being proud of. But I did finish and submit project 1, so let’s go with that.
I used many of the abilities I have learned over my career, but perhaps the most useful was the ability to quickly recognize when I don’t know something and seek help. I asked Dr. Downing for clarification on several of the imported issues where I wasn’t sure what was being requested.
I don’t think what I did will have much lasting effect. There were some responses to my comments on the “paper” (the syllabus), so perhaps I provided some amusement.
I didn’t expect this choice for the first “paper”. I’d looked over the Papers page of the class web site, so I expected the paper to be something along the lines of an opinionated blog post. Initially I felt like being asked to comment on the syllabus was like being asked to comment on a bus schedule. There’s just not much to say. I had to work to come up with comments, and my comments all ended up being either typo call-outs or humorous asides.
Docker is an amazing tool and an amazing feat of engineering. Earlier today I pulled a Docker image to try out a C++ interpreter wrapped in a Jupyter notebook. It worked flawlessly. I didn’t notice until later that the image hadn’t been modified for five years! For much of my career, the idea that you could get such a complex system running effortlessly, in a completely different hardware and software environment than it was developed for, after half a decade, was just unthinkable.
Operator overloading is a mixed bag. There are cases where operator
overloads are justified. A good example is implementing +
to work on vector and matrix types. These overloads allow us to write a
program in a language closer to the problem domain than otherwise. So
operator overloading can make code easier to understand.
But it’s easy and tempting to abuse operator overloading, especially in C++, and here’s why: we (humans) don’t like programming expressions like
(print(print(print(print(cout, x), " + "), y), " = "), x + y); print
For native readers of left-to-write languages, it puts the operations
in the wrong order: the rightmost mention of print
is the
one that executes first. And we (humans) generally just don’t like deep
recursion in our languages. (Try to understand “The girl the boy the dog
bit hit cried.” I promise you it’s perfectly grammatical English.) So
all those nested parentheses make us uncomfortable. (Pipe down,
Lispers.)
We would much rather read this:
.print(x).print(" + ").print(y).print(" = ").print(x + y); cout
Ah, so easy to read! The order of execution matches the order of the code, and there’s not a nested parenthesis in sight.
But there’s a problem: in C++, you can’t add your own methods to a
class unless you can change the definition of the class—and you can’t
change the definition of ostream
, because it’s part of the
standard library. Maybe the standard library could put one
print
method on ostream
for each built-in
type, and one more taking anything that inherits some
std::printable
abstract class? Well, C++ needed an I/O API
before multiple inheritance was straightened out (it’s still kind of a
mess), so that wasn’t an option either.
So what is a young (35-year-old) language designer to do? Does he
extend his language to allow custom operators? Does he allow adding
methods to existing classes? Does he allow writing free functions infix
(like we can do in Haskell, say x
`mod`y
)?
Those would all be general-purpose features that would significantly
improve the ergonomics of the language. But no! He picks two operators
that look somewhat like arrows and have a precedence level not perfect
but not hopelessly wrong, and overloads them to double as I/O operators.
Fie, I say! Fie!
My daughter got perfect scores on her weekly Mandarin quiz.
Tom Preston-Werner’s “The Git Parable” is the best explanation of Git I have found. Reading it made me much, much better at using Git and at recovering when I messed up a repo or working tree.
See you next week!