Aredridel wrote:
I’ve been thinking about the Sapir-Whorf hypothesis as relates to
programming languages for quite some time. I think that the weak
version of the hypothesis holds true:
Language influences the way we think, and influences what we
think of.
In reality, I think languages and their speakers influence each other in
a feedback loop. Since I’m not a linguist, I won’t venture to trace the
evolution of Japanese honorifics, or the loss of Germanic verb forms in
English … I’ll just throw them out there as potential examples.
I find myself thinking quite differently after learning Ruby, after
learning perl, and mostly after learning PHP. Not all were good
changes, either.
[…]
Ruby is still changing how I think. This is my first foray into true OO
programming, and while I’ve read lots of theory, this is the first I’ve
come to practical experience.
Objective-C was my first foray into object-oriented languages, and it
took a couple of years before it truly sank in. My preliminary forays
into Ruby, however, have opened up extra options for programming:
BLOCKS
I never used Smalltalk, and only used Lisp briefly, so I never
understood the full impact of passing chunks of code to methods. Yes,
you can iterate over data structures, but a Python-style |for … in
…| can do the same, but now
File.open(filename) do |file|
# do stuff
end
seems like a far better way to handle file access than the old-school
begin
file = File.new(filename)
#do stuff
ensure
file.close
end
REGULAR EXPRESSIONS
I could never wrap my head around Perl, so I never realized how useful
ubiquitous regular expressions could be until Ruby. It even allows
RegExps in case statements, which makes parsing a line-by-line
mini-language almost trivial. By contrast, C, Python and Java provide
regexes using library calls, not expressions, which becomes cumbersome
quickly.
ACCESSORS
Ruby takes Eiffel’s Principle of Uniform Reference (no syntatic
difference between field access and method invocation), and adds a
built-in pattern for mutators that resembles setting a field.
Furthermore, the Object class adds a method to generate default
implementations from a simple method call. This is a huge time-saver.
Writing accessors in Java is a pain, and Python requires either accessor
routines a la Java or meta-object interception of field access to insert
additional behavior. (I even had a brief e-mail conversation on this
with Guido van Rossum, who didn’t see the point of Ruby’s abilities for
Python.)
Maybe accessors should be far less common – see
http://www.pragmaticprogrammer.com/ppllc/papers/1998_05.html – but
either way why type out six lines of code when two words will do?
Anyway, sorry to go on so long.
Is the hypothesis true? I have no idea. I surmise that is is
unprovable, but that does not make it any less useful than Newton’s
physics equations, which are provably false.
Technically, Newtonian mechanics is incomplete, in that it only covers
non-relativistic velocities, behavior of large masses close together, or
other cosmic events. F=ma works just fine for most terrestrial
purposes.
···
–
Frank Mitchell (frankm each bayarea period net)
Please avoid sending me Word or PowerPoint attachments.
See We Can Put an End to Word Attachments - GNU Project - Free Software Foundation