Search code examples
javac++programming-languageslanguage-design

Do we need a Java++?


It seems to me that, in some ways, Java is where C was a while back. Both are fairly minimalist languages for their time, with relatively clean, simple cores to build on. (I'm referring to the core language here, not the libraries.) Both are/were extremely popular. Both are/were lingua francas, with tons of legacy code. Both are/were lacking several modern productivity features that programmers from other languages often miss. Both seem very inertia-dominated and slow to adapt to a changing world.

It seems to me like it would be reasonable to create a Java++ that's roughly a superset of of Java, as C++ is to C. Such a language would attempt to lift Java out of the relative stagnation it's undergone, break backwards compatibility only in a few minor ways only if absolutely necessary, add lots of modern features that plain old Java is missing, and worry about standardization later. Features that might be a good idea include:

  1. First class functions, delegates.
  2. Closures.
  3. Static type inference, similar to var in C# or auto in D.
  4. Operator overloading.
  5. Structs as value types distinct from classes, like C# and D.
  6. Properties.
  7. An option to ignore checked exceptions.
  8. The ability to declare more than one top-level public class in a file.
  9. More powerful builtin arrays that allow things like appending.
  10. Better generics/real templates.
  11. Something like the dynamic keyword for C# 4.0 that allows duck typing when necessary in a generally static language.
  12. Since Java is primarily a VM language, maybe some hardcore metaprogramming features like generating code on the fly for certain things.

Do you think there would be demand for such a language? Do you think such a thing would succeed?

Edit: I'm not talking about compatibility at the runtime/bytecode level, I'm talking about compatibility w/ Java at the source level. Also, yes, Java 7 could add some of these, but it seems like the "official" process for adding features to Java is extremely conservative. The real point is the idea of forking Java into a branch were the focus is on innovation more than stability/standardization.


Solution

  • Going to get downvoted by the Java fanboys for this but as someone who writes both Java and C# I'd say that C# is as close to Java ++ as you are going to get.

    C to C++ was a paradigm shift, from procedural to Object oriented, the only reason they retain the name is to woo C programmers into thinking that it was the same language which led to a load of really bad C code masquerading as C++.

    Java is constantly expanding and Sun are quickly incorporating more and more features, so it could well be that Java 7 or 8 is your Java ++