9.2. Minor Contenders
Now, it's time to put on an asbestos suit and my +4 plate mail. I debated whether to
include any sections on Perl, Lisp, PHP, or Smalltalk. They're fantastic languages
in their own right. I just don't think they're next.
If you're deeply religious about any of these languages, you can just read these
one-sentence summaries, and skip to the next section: Perl's too loose and too
messy, PHP is too close to the HTML, Lisp is not accessible, and Smalltalk wasn't
Java.
If you already feel slighted and you must read onif you're a language cultist and
I've mentioned your pet language in also-rans, or worse, didn't mention your pet
language at allgo ahead and fire up your Gmail client and your thesaurus, and drop
me a nasty note. Ted Neward reviewed this book, so I can take a few more
euphemisms for the word sucks. Just keep this in mind: I'm not saying that your
language isn't good, or popular. I'm just saying 10 years from now, we probably
won't look back at any of these languages as the Java killer.
Steve Yegge: Perl, Lisp, PHP, and Smalltalk
Why won't
Perl replace
Java?
SY: Well, I'd say Perl was pretty darn successful,
and it's still one of the most popular languages
around. Perl had world-class marketing: Larry
Wall understands programmers, and he's funny
and articulate. Perl filled a desperate niche in the
Unix-scripting world, and another with CGI. Perl
was successful because it was executed superbly,
just as Java was.
I do think it's on the wane, though. Perl used to be
more productive than the alternatives, so you
could argue it was ugly all you wanted, but people
got their jobs done faster. But newer languages,
it's not in the same league as more powerful
languages like Ruby, Python, and Lisp.
Is Smalltalk
next?
SY: I doubt it. In the end, languages have to have
buzz and momentum, and I just don't see any
marketing for Smalltalk. The community got the
wind knocked out of it by Java, and it doesn't seem
to have ever recovered. 9.2.1. PHP
PHP is an open source scripting language that's been gathering momentum since
the early 2000s. It's a markup language that's designed to be embedded into
HTML. It's very easy to quickly develop simple web applications in PHP,
but those
applications typically have little back-end structure. For these reasons, it's not
really targeting the same niche as Java applications, though it's sometimes been
pressed into service in much the same way. Here is "Hello, World" in PHP:
<html>
<head>
<title>Hello, World</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>
Web programmers recognize this as an HTML scripting language. The code is
processed on the server side, so pure HTML can be sent down to the client. It
actually handles this kind of scripting pretty well, but it's purely a tag language.
readability or not. After all, programs that were hard to write should be hard to
read. Other Perl problems relate to the language itself. Perl's object orientation is
obviously bolted on, and Perl has a secret handshake of sorts, in the form of many
cryptic syntactic shortcuts that only the mother of Perl could love. A whole lot of
us at one time or another have had some sort of love/hate relationship with Perl. It's
interesting to talk about, but it's pretty much the antithesis of Java, and it's likely
not going to make a dent.
9.2.3. Smalltalk
Smalltalk is a beautiful language invented way before its time. Smalltalk and Lisp
are probably the two languages that share the most with Ruby. Smart developers
used Smalltalk to build successful object-oriented applications long before Java
was even a twinkle in Gossling's eye. And not-so-smart developers used Smalltalk
to build some of the ugliest object-
oriented code ever written. In truth, for the most
part, in the mid- and late 1970s, we just didn't have the wisdom or the processing
power for OOP yet, and we didn't have features like just-in-time compilers.
In Chapter 8, you saw the elegance of the Smalltalk language. It's object-oriented
through and through, and the syntax is remarkably consistent. Smalltalk's syntax
probably seemed strange to the masses of programmers who grew up coding
COBOL, BASIC, Pascal, C, or C++. Most of the businesses I know of that actually
tried Smalltalk were able to get their applications out in time, they just never were
able to integrate those applications with the rest of the world.
Smalltalk never was able to lure C and C++ developers away, because it was too
alien and had the perception of being too slow. As the small Smalltalk community
waited for objects to emerge, Java's founders aggressively grabbed the C++
community by the throat, forced it to come along with C++ syntax and usage
models, and offered solutions to solve the most pressing problems the C develo
pers
encountered. As we showed, Java was effectively a compromise between perfect
OO and the C++ community. Later, IBM made a move to buy OTI, a maker of
expose them to functional techniques.
Maybe all languages will once again return to Lisp, but I don't think that Lisp itself
is the ultimate answer. It's just too alien, and it takes too much time and effort to
learn.
9.2.5. Functional Languages
It's probably a bit too early to be talking about functional languages , because we
seem to be moving toward object-oriented languages instead. Still, functional
programming provides a higher abstraction and very good productivity. It's
possible that some functional language could explode, with the right killer app.
Haskell and Erlang are two of a family of programming languages called
functional languages. Functions are the focus of functional languages. I use the
word function in the pure mathematical sense:
Functions have no side effects. This oddity takes some getting used to for
most procedural programmers, but also has significant benefits.
Functions return values.
You can use the return value of a function anywhere you can use the
returned type.
You can do functional programming in languages like Ruby and Lisp, but for
research or purity, often it's better to use a purer language. Here's a Haskell
example, which computes the factorial of a number:
fact 0 = 1
fact n = n * fact (n - 1)
Then, as expected, you can compute the value like this:
fact 10
Here's a Fibonacci sequence (where each number is the sum of the previous two):
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
Functional languages let you work at a higher level of abstraction. Haskell has
good traction in research and academic communities, and seems to be gaining a