CSC/ECE 517 Fall 2011/ch1 1b tj: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 17: Line 17:


= STL vs JCF =
= STL vs JCF =
The Java collections framework was first introduced with Java 2 platform, Standard edition. version 1.2. Before collections framework was introduced, grouping of objects in Java was through the use of arrays, Vector and HashTable. The arrays, vectors and HashTable had different syntaxes for accessing members. For example, the arrays uses square bracket symbol [ ], the HashTable uses 'get and put' method and as for Vectors, it is the elementAt method. This caused a lot of inconsistency meaning programmers were using different methods to implement their own collections. Prior to Java 2, the classes lacked a central and unifying theme. There are many advantages of Java Collections framework  compared to frameworks such as those in C++( standard template library). The STL (Standard Template Library) which became a part of the ANSI/ISO standard definition of the C++ language in 1994 is organized around three fundamental components namely containers - to hold objects, algorithms ( perform manipulation of elements in containers) and iterators. In addition, supporting them there are three additional components: allocators, adaptors and function objects.  The JCF was introduced in 1998 and the primary difference between STL and JCF is that JCF has a singular focus - It focuses mainly on containers rather than on combination of containers and algorithms ( as STL does). 
The Quality of Implementation of the C++ compiler has a large impact on usability of STL. First, the error messages involving templates are very long and hard to interpret. Then, if used without proper care, STL templates can lead to code bloat. The Java Collections Framework make programming easy by providing many useful data structures and algorithms so that the programmer does not have to write them. The performance of a program is increased considerably because of the implementation of these data structures and algorithms because the various implementations of each interface can be interchanged. Collections have much better performance compared to Vectors and HashTable in the old version. The entire standard collections framework is designed around a set of standard interfaces and several standard implementations such a LinkedList, HashSet and TreeSet  are provided in these interfaces so the programmers can use them or also create their own.
= Ruby vs Java CF =
= Ruby vs Java CF =

Revision as of 20:53, 6 September 2011

Collections Framework


Introduction

In this wiki, we are going to talk about collections frameworks : their history, the advantages of standard collections frameworks (like Java), compared to that of C++, the advantages of collections built into languages like Ruby compared to those having collections as class libraries. We will illustrate the advantages and compare the differences with some examples.

What is a collections framework?

A collection is a group of objects, and is essentially a container that groups multiple elements into a single unit. Since a collection is just a group of objects, some examples of a collection are : a stack of books, a dictionary, a list of names, a telephone directory. A collections framework is a system to represent and manipulate these collections.

Need for a collections framework

The need for a collections framework is to address the need for reusable collection data structures. This led to the development of many collections frameworks.

History

As mentioned before, to address the need for reusable collection data structures, several independent frameworks were developed. Doug Lea's collections package (released in 1995) was the first widely used collection. In 1996, a company called Object Space developed and released the Java Generic Library ,JGL, with the main goal of being consistent with C++ Standard Template Library.

STL vs JCF

The Java collections framework was first introduced with Java 2 platform, Standard edition. version 1.2. Before collections framework was introduced, grouping of objects in Java was through the use of arrays, Vector and HashTable. The arrays, vectors and HashTable had different syntaxes for accessing members. For example, the arrays uses square bracket symbol [ ], the HashTable uses 'get and put' method and as for Vectors, it is the elementAt method. This caused a lot of inconsistency meaning programmers were using different methods to implement their own collections. Prior to Java 2, the classes lacked a central and unifying theme. There are many advantages of Java Collections framework compared to frameworks such as those in C++( standard template library). The STL (Standard Template Library) which became a part of the ANSI/ISO standard definition of the C++ language in 1994 is organized around three fundamental components namely containers - to hold objects, algorithms ( perform manipulation of elements in containers) and iterators. In addition, supporting them there are three additional components: allocators, adaptors and function objects. The JCF was introduced in 1998 and the primary difference between STL and JCF is that JCF has a singular focus - It focuses mainly on containers rather than on combination of containers and algorithms ( as STL does).

The Quality of Implementation of the C++ compiler has a large impact on usability of STL. First, the error messages involving templates are very long and hard to interpret. Then, if used without proper care, STL templates can lead to code bloat. The Java Collections Framework make programming easy by providing many useful data structures and algorithms so that the programmer does not have to write them. The performance of a program is increased considerably because of the implementation of these data structures and algorithms because the various implementations of each interface can be interchanged. Collections have much better performance compared to Vectors and HashTable in the old version. The entire standard collections framework is designed around a set of standard interfaces and several standard implementations such a LinkedList, HashSet and TreeSet are provided in these interfaces so the programmers can use them or also create their own.

Ruby vs Java CF