I just thought of a good CS idea! - Journal of Omnifarious
Mar. 19th, 2004
06:28 pm - I just thought of a good CS idea!
I demand one main feature out of any new programming language I evaluate. The language must make it easy for programs to build programs, either at compile time, or at run time.
Java, last I looked carefully, couldn't do that. It has a static type system, so you can't combine objects together into new programs like you can in Python, Ruby, or even *shudder* perl. You can create new classes on the fly by using introspection, hand building byte code and feeding it to the class loader, but that's like pounding in a nail with a screwdriver. And it doesn't have C++'s sophisticated templating mechanism, so you can't build new programs at compile time. Now, it recently added generics, but I have a strong suspicion that generics will turn out to not be powerful enough to do what C++ templates can do. But that's just a guess.
As an example of what I mean....
Python has three functions, filter, map, and reduce. They are built in functions. They work easily and simply on any type. In more recent versions of Python, they even work well on any abstraction at all of a sequence.
I can build template functions that do the same thing, and are just as type agnostic (and preserving) in C++.
I doubt, even with generics, that I can build anything even remotely similar for Java. Note that the lambda expression (or object) passed in must have a method that takes objects of the type the sequence holds. It must not be required to take things of type Object.