First of all, if you want to create a new language, don't create a
language for a paradigm that's becoming mature, create one for a new
paradigm the for which best precepts are not yet so settled.
OO programming is far from being mature.
C++ is a mess (sorry, it just is, like any other pseudo-OO language,
e.g. PHP supports objects, but you can't really see PHP as an OO
language), Smalltalk is not useful for current application development
out of various reasons (it's rather rapid high level programming like a
macro in MS Word) and has a very programmer unfriendly syntax (compared
to BASIC, Pascal and C) and Java... well...
<RANT>
- Java is too slow! Java is a fast language, it certainly scores in the
top 10 of 100 languages and I guess it has the fastest VM of all
languages that are VM based and not statically compiled; but it could do
much faster most of the time, the CPUs offer more power than Java really
utilizes.
- Java wastes memory like hell! Re-code your Java code in another
language and save up to 90% memory. There is no logical reason why an OO
language must wastes so much more memory compared to non-OO languages.
- Java has no clean design! Everything is an object, except a
primitives. This leads to many problems of inconsistency throughout the
language and the Java API.
- The Java API offers code for almost everything you can think of... and
most of the time you don't need 90% of it! It's plain overkill and
wastes resources. It makes JVM downloads huge to receive unnecessary
code. Also there are strange relationships between packages (java.lang
needs classes from java.security, which needs classes form java.util and
so on; so you can't simply remove uneeded packages).
- The Bytecode language is inflexible! It has many unecessary opcodes
(256 are too many, Java could easily do with less than half of these)
and important opcodes are missing (to make use of raw CPU power). But
it's not easily possible to alter it, to replace it or to extend it.
- The native interface (JNI) sucks! It's slow, poor and there must be a
better way to connect a VM based language to the rest of the world.
Being able to easily access library functions, for example, of libraries
written in C is very important in some cases (even though it's not cross
platform compatbile, but see below). With JNI, you must write a C
library wrapper yourself, you can't just call functions of a library
directly from within Java.
- Java is not really platform independent! "Write once, run everywhere"
is a dream, an illusion. It doesn't work. Java code written for my
mobile phone won't run on my PC in a normal JVM. Why not? There is no
reason why it shouldn't! All this stupid editions stuff like J2SE, J2ME,
J2EE is completely unnecessary and all this stupid profile stuff, like
Set-Top-Box profiles and so on are a lot of talking about nothing. A
single VM could handle everything with an API that covers all devices
and situations, however no device has to support all of the API and not
the full API has to be present.
I do understand that nearly all of these limitations have nothing to do
with Java itself, they come from the JVM, not from the language. But so
far nobody has made an attempt to write a better JVM without all these
limitations. Especially the fact that they all try to be compatible to
Sun's JVM prevent that there is some real progress on these issues.
</RANT>
Everyone says "Can you do it any better?". Yes, I honestly think I can.
I think you can as well. Probably 10% of all regular posters in this
group could do it better. But there is no point in touching a running
system! Java works. It does its job (good or bad). Java left its traces
all over the place (not just in the real world, but also in the mind of
people). So I see no point in trying to improve Java (that's Sun's
task), Java wouldn't be Java anymore if I'd be trying to change it. Java
will survive, everything I criticized above will become better over the
years, one way or another, and my dream language may never even get
written in the first place.
E.g., look into aspect-oriented programming.
I did already. It's a lot of BLAH and very little behind it. Everything
AspectJ can do for example (aspect extension to Java) could be done in
Java directly, if Java would be designed more intelligent.
It shounds like you've got some sort of dogmatic notion of
object-oriented "purity."
Because it makes everything easier. It means the language has less
opcodes (that means less keywords or structures that programmers have to
memorize), the language is more flexible and can easily get extended on
the lowest (bytecode!) level.
That is particularly backwards. Programming languages must serve the
needs of programmers (at least if humans are going to write programs
in this putative language).
And that's what my language would do. It would offer programmers
possebilities unthinkable in Java. There is no need for a programmer to
look behind the scenes.
You still write:
int a = 10;
int b = 20;
int c = ((a + b) * (a | b)) >> 3;
That this will be all objects and methods after running through the
bytecode compiler is nothing you as programmer had to worry about! And
it won't slow down execution speed either, as the JNI compiler can
easily transform it back to native (NON-OO) machine code (so after JIT
no objects are involved anymore).
It sounds like your language cannot be grounded in a real machine if
it cannot make use of object state.
Sorry, I don't understand what you are trying to say here.
It also sounds like you're conflating the compiler with the virtual
machine for which the compiler will generate code.
I'm currently designing the VM, not the language. The workflow is:
Source-Code ==Bytecode-Compiler==> Bytecode ==Compiler==> Machine-Code
I only define the Bytecode and how classes, methods and so on are stored
and referenced right now. Later on I will define certain classes and how
the compiler makes machine code out of them. The bytecode compiler can
stay undefined, because what language is actually used to write the
source-code doesn't matter to the VM.
Here is how it could look:
Source-Code:
int a = 10;
int b = 20;
int c = a + b;
Bytecode:
load_const 10
new Integer
pop_object 1
load_const 20
new Integer
store_object 2
push_object 1
call_method add(Integer, Integer)
push_object 3
Machine code:
mov ax, [dx + 4]
mov 10, [ax]
mov bx, [dx + 8]
mov 20, [bx]
add cx, [ax]
add cx, [bx]
mov cx, [dx + 12]
Since the Compiler knows that Integer is just a wrapper Object for an
"int" value (which does not exist, as there are only objects, no
primitives) and because it knows how to express every method of Integer
directly in assembler, it an switch back from OO and eliminate all
object creation/cleanup and method calls.
Integer (as in java.lang.Integer) is not a part of the Java language
per se, it's a part of the Java standard libraries.
And that's how my language will work.
Per default, the language can't do any more than creating objects,
calling methods and accessing variables. All functionality comes only
from the standard classes "known" to the compiler.
Different companies could all use the same language, teach their native
compiler other classes and that way add whatever "functionality" to the
language they would like to have. I would just define some standard sets
of behaviors, which implement everything Java "knows" (as you wrote).
This is how to handle numbers, arrays (which are objects, too) and so
on.
Again, it sounds like you confuse what a virtual machine's role is in
the definition of a language vis. a vis. the roles of compilers and
libraries.
No, I don't. I just break the classic concepts of these. For me, the
language is the Bytecode assembler, not the source code transformed into
the bytecode assembler.
Java and its virtual machine are designed for real, stack-based,
register transfer architectures we use today.
1st) Java is all stack based, which is exactly how CPUs don't work, they
are register based. JIT has to transfer between both worlds.
2nd) Look at Smalltalk! You may learn something new.
Modern CPUs provide
direct abstractions in their programming models for integers,
characters and floating point numbers.
Fine for them. But the Bytecode language doesn't have to. After all CPUs
don't run bytecode directly, there's still a layer of abstraction that
can transform objects into primitve types. See my example code above.