Jocelyn Paine

Dr. Dobb's Bloggers

Plain Language

This morning, I
was berating my brain. If I were supple enough,
I'd have given it a good kick. Because it couldn't
remember how to open and print to a Unicode file in Java.
(You
create a new File...

This morning, I
was berating my brain. If I were supple enough,
I'd have given it a good kick. Because it couldn't
remember how to open and print to a Unicode file in Java.
(You
create a new FileOutputStream pointing
at the file, then
create an OutputStreamWriter from the
FileOutputStream
and the name of your encoding, and then create
a PrintWriter from the OutputStreamWriter. While
doing this, you have to keep in mind the
difference between the "write" methods, which
most output streams can execute, and the "print"
methods, which fewer can. I don't know why.)

But then I decided that it isn't my brain that's
at fault; it's Java. Because look how Java makes you define
an associative table:

Which is ludicrous, insane, crazy, preposterous, risible, ridiculous,
farcical and absurd, as well as every other
synonym you can think of. An associative table is a mapping, and a mapping is
a function, and function is the most fundamental notion in mathematics. Also
the simplest. Functions are sets of ordered
pairs, so any decent language would let you write them using a notation
whose primitives represent the primitive parts of a set of ordered pairs, clearly
arrangeable to describe the whole.

It's analogous, or should be, to the control knobs on
my cooker. The layout of the knobs is a scaled-down picture of the layout
of the hotplates, and the set of possible rotations of each knob is a
curved picture of the set of its hotplate's possible temperatures. The
parts of the controls match the parts of what they control, and the
arrangement of these controls matches the arrangement of the things they
control. Except if I program in Java, when
my cooker controls would look like this:

Moreover — returning to the associative table
— why must I tell Java that 80 is an
integer? Does it know an 80 that isn't?
Why must I tell it that TRUE is a Boolean?
Does it know TRUEs that aren't? Perhaps
they're TRUES used by
visitors from another universe whose
logic is different from ours, so that when they
come here, they have to switch. Like
an internationalisation-resource-bundle, except that
you carry with you not your time-zone and alphabet,
but your universe's truth values.

I copied the associative-table code from a
video called "Public
Static Void". This was one of the
keynote
speeches at OSCON 2010, the
O'Reilly Open Source Convention, and
is by
Rob
Pike, co-designer of
Google's
Go programming language.
Pike doesn't like the verbosity of Java and C++, and
gives examples that demonstrate it, as well as ridiculing
the spurious packaging around
80 and TRUE.
At the beginning of the video, he quotes
Lisp expert Dick Gabriel:

I'm always delighted by the light touch and
stillness of early programming languages. Not
much text; a lot gets done. Old programs read
like quiet conversations between a well-spoken
research worker and a well-studied mechanical
colleague, not as a debate with a compiler.
Who'd have guessed sophistication bought such noise?

I'm sure Gabriel was thinking of Lisp.
And maybe also of APL, Algol 60, BCPL, Comit, Simula 67, Snobol,
and even Fortran. But then, perhaps somewhere in the years that began with
Pascal and Modula and Clu, and ended with C++ and Java, something went awry.
What? And why?

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task.
However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Video

This month's Dr. Dobb's Journal

This month,
Dr. Dobb's Journal is devoted to mobile programming. We introduce you to Apple's new Swift programming language, discuss the perils of being the third-most-popular mobile platform, revisit SQLite on Android
, and much more!