Contrary to popular belief, object orientation is not the One True Paradigm--there isn't one, each programming style has its own claim to fame, and one is not necessarily better than another. So, even more important than being proficient in multiple languages is the addition of multiple paradigms to your development arsenal.
Lee Copeland, managing technical editor of Better Software magazine , recently wrote of the Whorfian Hypothesis, which, according to Wikipedia.org, "argues that the nature of a particular language influences the habitual thought of its speakers." As early as 1957, Kenneth Iverson, inventor of APL, prefaced his presentation of that interesting language with the phrase "Language is a tool of thought." His goal was to efficiently process large arrays of data in multiple dimensions, so APL sports numerous operators, all very succinct and mutually orthogonal. When it's time to cut code, the programming language we're using tends to govern our thoughts. A C programmer will conjure up appropriate functions; a Java programmer will see nothing but objects; a developer using Haskell will traffic in lists and higher-order functions.
Each programming style, or paradigm, has its claim to fame, and one is not necessarily better than another. A message that needs to get out nowadays, both in industry and academia, is that object orientation is just another paradigm . It has its place and has certainly helped us write better-organized code for large projects, but it is not the One True Paradigm-because there isn't one.
So, should developers be proficient in multiple languages? Certainly, but it is even more important to master multiple paradigms, which is not necessarily the same thing: A language may or may not force a particular paradigm upon you. Java pretty much forces you to do objects, so you'll hurt yourself if you use it to write simple procedural code or to program in the functional style, à la Lisp. Likewise, you can do objects in C, but you have to build up so much scaffolding to support it that you end up feeling like you're rubbing a cat backward. However, languages like C++, Python, Ruby, D, and CLOS support multiple paradigms naturally.
An Invitation to Functional Programming
The most commonly used programming styles nowadays are imperative (aka, procedural), object oriented, and functional, but many others exist (e.g., declarative, logic, constraint). Imperative languages closely mirror computer internals-they implement instructions that change machine state. The object oriented (OO) style of programming is mostly imperative programming extended with the ability to package data and related functionality as classes. Most programmers seem to live in the imperative/OO world.
Functional programming, first made accessible through Lisp, is another powerful programming paradigm that is older than you might think. Lisp wasn't really usable until about 1960, but it is based on Alonzo Church's lambda calculus, which came almost thirty years earlier, so the functional paradigm was fairly mature before it was realized on a computer. Functional languages treat functions like they treat built-in types-they can be passed and returned as values to and from other functions, and can even be created at runtime. Some very powerful constructs come to life this way.
Since lists are so central in functional programming, you can easily create them by placing expressions inside brackets in Haskell and Python, as shown in listing 1.
The definition of morenums illustrates a list comprehension , whereby a list is created through a complex formula. As shown in listing 2, list comprehensions can traverse multiple sequences just like nested loops do and can filter out what isn't wanted. Several support functions are important in functional programming.
The map function applies a function to each element of a list and returns the resulting list:
>>> map(len,["a", "fine", "mess"])
[1, 4, 4]
The map function also accommodates functions whose arity matches the number of subsequent lists:
>>> map(operator.add, [1,2,3],[4,5,6])
[5, 7, 9]
The reduce function is used to summarize a list, usually reducing
| Attachment | Size |
|---|---|
| 370.9 KB |







