- Modules
-
Without modules, one can't have short function names, making the library
harder to use. The name conflicts are hard to solve.
Languages badly missing modules: C, PHP4
- Garbage Collector
-
Without a garbage collector, you have to decide who is allocating and -even
worse- who is deallocating the objects.
Languages badly missing garbage collection: C, C++
- Generics / Templates / Parametric Polymophism
-
Without generics, you can't have statically typed containers. The typical
example is Java's list: you need to downcast back to the object's real type
when taking something out of it:
ArrayList result = new ArrayList();
result.add("foo");
String s = (String) result.get(0);
(note the "(String)" cast)
Languages badly missing generics: C, Java, C#
- Overloaded functions
-
Without function overloading, part of the problems of the absence of modules
are still there. For example in OCaml "length" is either "Array.length" or
"List.length" or "String.length" ; you have to choose which one you want.
Languages badly missing overloaded functions: OCaml
- Overloaded operators
-
This is a special syntactical issue. Some people tend to dislike overloaded
operators. But if you want things like numbers or strings to be handled in a
library, you don't have much choice. Without overloaded operators, you need
special cases in the language for handling things like equality or
array-indexing.
Languages badly missing overloaded operators: Java (this may change), Delphi-Kylix
- Anonymous Functions
-
Without anonymous functions, having simple things like "finding an element in
a list" or "a custom sort" is tedious. For example Java doesn't even have a
"find" method, acknowledging the difficulty to use "find" without anonymous
functions.
Languages badly missing anonymous functions: C, C#, C++, Java (but anonymous inner classes)
- Exceptions
-
Without exceptions error reporting is hard. You usually have to resort to
returning "special" values like -1, which is hard to remember/use, and is
dangerous (unchecked errors in C cause many problems including security
issues)
Languages badly missing exceptions: C
- Exceptions in Function Prototypes
-
Java is the first language I know forcing people to declare the exceptions
thrown by a function. This has the nice advantage of documenting the API, and
forcing this documentation to be up to date.
Exception inference a la ML type inference would be quite easy.
Languages missing exceptions declaration in function prototypes: C, C++, C#, OCaml
- Subtyping
-
(for ints, floats...)
- Compile-time checks of sub-languages (printf, regexps...)
-
printf is a typical example where compile-time type-checking is useful and
needed. Most languages use an ad'hoc solution in the compiler to handle this
(eg: C, OCaml). Another example is regexps which could return a tuple instead
of a list of matches. Some other examples: pack/unpack (created in Perl for
accessing structs).
Pliant and Cayenne can achieve this.
C++ may be able to achieve this using templates?
Maybe also camlp4?
Release: $Id: libraries-need-features.html,v 1.4 2002/05/17 15:22:56 pixel_ Exp $