O'Reilly logo

Algorithms in a Nutshell by Gary Pollice, Stanley Selkow, George T. Heineman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Choosing a Programming Language

Throughout this book we use a variety of programming languages to illustrate the algorithms. No single language is the right one to use in all circumstances. Too often, a specific programming language is used simply because it was used on a similar project. Since you are interested in algorithms, it is likely that you also want to ensure that your implementations run as fast as possible. This level of fine-tuning or optimization is beyond the scope of this book, though we describe several instances where carefully designed code optimizations result in impressive performance benefits. Choosing a language often depends on a number of factors:

Garbage collection versus manual memory allocation

In the previous section we described low-level details about the way information is stored as a C program executes. Using the standard memory allocation packages available, most C programmers are used to allocating memory as needed, and freeing it when done. An alternative approach is to use a language such as Java or Scheme that provides built-in garbage collection to manage allocated memory. Garbage collection technology is increasingly efficient, and there are existing packages available to enable even C programs to integrate garbage collection with the default memory allocation schemes.

Bytecode interpretation versus compiled code

The common perception is that compiled code will outperform interpreted code every time. In Java, for example, the Java compiler ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required