I've implemented new, constructor call (super/this), function call,
method call, assignation, return, print and
boolean, integer, double and String constants.
So helloword works !
to run it:
java -jar jdartc.jar foo.dart
generates a jar file foo.jar that can be run like this:
java -jar foo.jar
I will be please to give the commiter role to anyone that want to contribute
(don't forget that my brother is a psychopath).
R�mi
PS: jdart.jar is very big 7 megs because it also contains the Dart to JS
compiler,
I haven't taken the time to separate it from the Dart frontend.
I'm please to announce that Dart (a small subset in fact) run on the JVM.
https://code.google.com/p/jdart
I've implemented new, constructor call (super/this), function call,
method call, assignation, return, print and
boolean, integer, double and String constants.
So helloword works !
to run it:
java -jar jdartc.jar foo.dart
generates a jar file foo.jar that can be run like this:
java -jar foo.jar
I will be please to give the commiter role to anyone that want to contribute
(don't forget that my brother is a psychopath).
Rémi
PS: jdart.jar is very big 7 megs because it also contains the Dart to JS compiler,
I haven't taken the time to separate it from the Dart frontend.
Impressive. I assume invokedynamic came in handy?
Cheers,
Chanwit
On Tue, Oct 18, 2011 at 03:44, Rémi Forax <fo...@univ-mlv.fr> wrote:
> I'm please to announce that Dart (a small subset in fact) run on the JVM.
> https://code.google.com/p/jdart
>
> I've implemented new, constructor call (super/this), function call,
> method call, assignation, return, print and
> boolean, integer, double and String constants.
> So helloword works !
>
> to run it:
> java -jar jdartc.jar foo.dart
> generates a jar file foo.jar that can be run like this:
> java -jar foo.jar
>
> I will be please to give the commiter role to anyone that want to contribute
> (don't forget that my brother is a psychopath).
>
> Rémi
I'm please to announce that Dart (a small subset in fact) run on the JVM.
https://code.google.com/p/jdart
I've implemented new, constructor call (super/this), function call,
method call, assignation, return, print and
boolean, integer, double and String constants.
So helloword works !
to run it:
java -jar jdartc.jar foo.dart
generates a jar file foo.jar that can be run like this:
java -jar foo.jar
I will be please to give the commiter role to anyone that want to contribute
(don't forget that my brother is a psychopath).
Rémi
PS: jdart.jar is very big 7 megs because it also contains the Dart to JS compiler,
I haven't taken the time to separate it from the Dart frontend.
I knew it wouldn't take long :) Over the weekend perhaps?
Awesome work Remi...maybe more people will start to realize what power we have in invokedynamic.
- Charlie (mobile)
I'm please to announce that Dart (a small subset in fact) run on the JVM.
https://code.google.com/p/jdart
I've implemented new, constructor call (super/this), function call,
method call, assignation, return, print and
boolean, integer, double and String constants.
So helloword works !
to run it:
java -jar jdartc.jar foo.dart
generates a jar file foo.jar that can be run like this:
java -jar foo.jar
I will be please to give the commiter role to anyone that want to contribute
(don't forget that my brother is a psychopath).
Rémi
PS: jdart.jar is very big 7 megs because it also contains the Dart to JS compiler,
I haven't taken the time to separate it from the Dart frontend.
--
You received this message because you are subscribed to the Google Groups "JVM Languages" group.
To post to this group, send email to jvm-la...@googlegroups.com.
To unsubscribe from this group, send email to jvm-languages+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en.
Friday night and Sunday night indeed.
> Awesome work Remi...maybe more people will start to realize what power
> we have in invokedynamic.
>
shh, I prefer to think I'm awesome :)
invokedynamic() => merge(swiss_knife, ligth_saber);
> - Charlie (mobile)
>
R�mi
Rémi
--
You received this message because you are subscribed to the Google Groups "JVM Languages" group.
To post to this group, send email to jvm-la...@googlegroups.com.
To unsubscribe from this group, send email to jvm-languages+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en.
Rémi,
I like your nullable choice. Are you planning to take that discussion forward?
Cheers,
James
For the same reason, I really think it's a bad idea(tm) to let the integer
to overflow to some kind of bigint like python or ruby does.
To answer to your question, "should implementation ease drive the language ?",
I think that for Dart the answer is yes, beacuse if Dart is not faster that JS, there is no point to use Dart.
The current incarnations of the scripting languages are slow,
we know that a lot of developers will never use them at work just because they are slow.
[...]Better to answer latter than never :)
Rémi,
I like your nullable choice. Are you planning to take that discussion forward?
Cheers,
James
I think that int and double should be not nullable by default
just because the JIT can emit a simple iadd/dadd in case where you know
that both arguments are int/double.
It's important in my opinion because a fully typed Dart application
should be as fast as if it was written in Java.
For the same reason, I really think it's a bad idea(tm) to let the integer
to overflow to some kind of bigint like python or ruby does.
In practice, it never appears (JRuby guys has done some stats showing that
it only happens in their regression tests :) but you add a runtime cost for each operations.
Rémi
It just falls apart when you use generics.class A<T> {T x = null;...}If T is a number type your class would not work. With all other types it works.
The biggest example is List. new List<int>(10) would be illegal, since a new List<int> initializes its elements with 'null'.
--
John A. Tamplin
Software Engineer (GWT), Google
I'm not sure I understand how you plan to generate JVM byte codes in
jdart. How would the byte codes for this look:
int add(int i, int j) => i + j;
Cheers,
Peter
I suppose add is a lambda and sorry by advance, it will be a little
technical :)
A lambda is represented at runtime by a java.lang.invoke.MethodHandle,
when a lambda is created, I use invokedynamic to intern it
if it's possible (if it doesn't capture scope variables).
The lambda is desugared as a static method that will
be loaded by the runtime (using MethodHandles.Lookup.findStatic())
when invokedynamic loadConst is called
(you can specify bytecode constants as parameters of the bootstrap method
of invokedynamic, I also plan to use the same mechanism for const object).
static int $lambda1(int i, int j) {
iload 0
iload 1
iadd
ireturn
}
...
invokedynamic loadConst() Ljava/lang/invoke/MethodHandle; [$lambda(int,int)]
astore add // with add the slot of add
and when a lambda is call, I use invokedynamic to do the runtime
signature adaptation
(so specific for a callsite) and delegate to MethodHandle.invokeExact
after the adaptation
so var foo = add(2, 2.3) is compiled to something like this:
aload add
iconst_2
ldc 2.3
invokedynamic lambdaCall (ID)Ljava/lang/Object;
astore foo
>
> Cheers,
> Peter
cheers,
Rémi
Well, it could just as well be top-level method. My example above is a
complete Dart program (except there is no main method).
> A lambda is represented at runtime by a java.lang.invoke.MethodHandle,
> when a lambda is created, I use invokedynamic to intern it
> if it's possible (if it doesn't capture scope variables).
> The lambda is desugared as a static method that will
> be loaded by the runtime (using MethodHandles.Lookup.findStatic())
> when invokedynamic loadConst is called
> (you can specify bytecode constants as parameters of the bootstrap method
> of invokedynamic, I also plan to use the same mechanism for const object).
>
> static int $lambda1(int i, int j) {
> iload 0
> iload 1
> iadd
> ireturn
> }
> ...
That is what I thought you are doing. Now, what happens if I write:
main() {
print(add(3, 4));
print(add("3", "4"));
print(add(null, 4));
}
For reference, here is what should happen: http://try.dartlang.org/s/tvAc
Cheers,
Peter
add(3, 4) -> 7 // ok
add("3", "4") -> WrongMethodTypeException
because the compiler find that add is add(String, String) and
there is no conversion between String and int.
This exception should be mapped to TypeError.
add(null, 4) -> WrongMethodTypeException
because null is represened by a special type, here the compiler
find that add is add(type of null, int) and there is no conversion
between type of null and int.
var v = null;
add(v, 3) -> NPE
because add is typed add(Object, int), there is a conversion
from Object to int (Object -> Integer -> int) and during Integer -> int,
intValue is called on null.
Also this error should be mapped to TypeError
> Cheers,
> Peter
cheers,
Rémi
Not if you're implementing the Dart programming language.
> add(null, 4) -> WrongMethodTypeException
> because null is represened by a special type, here the compiler
> find that add is add(type of null, int) and there is no conversion
> between type of null and int.
>
> var v = null;
> add(v, 3) -> NPE
> because add is typed add(Object, int), there is a conversion
> from Object to int (Object -> Integer -> int) and during Integer -> int,
> intValue is called on null.
> Also this error should be mapped to TypeError
Not in the Dart programming language.
Cheers,
Peter
>
>> Cheers,
>> Peter
>
> cheers,
> Rémi
>
>
yes, I look for contributors.
and yes being able to run the jdart from Eclipse is a nice idea.
In fact, jdart is just another backend of the dart-to-JavaScript compiler,
it reuse the same frontend and just add one pass to convert Dart type to
Java one
and a bytecode generator powered by ASM.
So I don't expect the integration to the already existing eclipse Dart
plugin to be hard.
I will add this to the TODO list to the project.
If anyone is interested to contribute to jdart, just send me an email
with your google id, and I will add you as commiter.
R�mi
Correct me if I'm wrong, it does depend on the execution mode.
My plan is just to add the developer mode because I strongly believe
that the runtime cost of the check is not awful. I may be wrong.
> add(null, 4) -> WrongMethodTypeException
> because null is represened by a special type, here the compiler
> find that add is add(type of null, int) and there is no conversion
> between type of null and int.
>
> var v = null;
> add(v, 3) -> NPE
> because add is typed add(Object, int), there is a conversion
> from Object to int (Object -> Integer -> int) and during Integer -> int,
> intValue is called on null.
> Also this error should be mapped to TypeError
> Not in the Dart programming language.
What should be the result in developer mode ?
>
> Cheers,
> Peter
cheers,
Rémi
add(3, 4) -> 7 // okOn 10/22/2011 01:17 PM, Peter Ahé wrote:
On Sat, Oct 22, 2011 at 13:06, Rémi Forax<fo...@univ-mlv.fr> wrote:
On 10/22/2011 12:38 PM, Peter Ahé wrote:what happens if I write:
main() {
print(add(3, 4));
print(add("3", "4"));
print(add(null, 4));
}
For reference, here is what should happen: http://try.dartlang.org/s/tvAc
add("3", "4") -> WrongMethodTypeException
because the compiler find that add is add(String, String) and
there is no conversion between String and int.
This exception should be mapped to TypeError.
add(null, 4) -> WrongMethodTypeException
because null is represened by a special type, here the compiler
find that add is add(type of null, int) and there is no conversion
between type of null and int.
var v = null;
add(v, 3) -> NPE
because add is typed add(Object, int),
there is a conversion
from Object to int (Object -> Integer -> int) and during Integer -> int,
intValue is called on null.
Also this error should be mapped to TypeError
Remi,
As you can clearly see from Peter's example, you aren't implementing Dart.
Even in checked mode the behavior you describe does not match the spec. One should not be thinking in terms of a traditional mandatory typed language like Java.
On Sat, Oct 22, 2011 at 5:29 AM, Rémi Forax <fo...@univ-mlv.fr> wrote:
add(3, 4) -> 7 // okOn 10/22/2011 01:17 PM, Peter Ahé wrote:
On Sat, Oct 22, 2011 at 13:06, Rémi Forax<fo...@univ-mlv.fr> wrote:
On 10/22/2011 12:38 PM, Peter Ahé wrote:what happens if I write:
main() {
print(add(3, 4));
print(add("3", "4"));
print(add(null, 4));
}
For reference, here is what should happen: http://try.dartlang.org/s/tvAc
add("3", "4") -> WrongMethodTypeException
34. Type annotations don't change behavior except in checked mode. You need to support both checked mode and production mode.
In checked mode, ths would lead to a dynamic type error (though not for the reasons you describe).
because the compiler find that add is add(String, String) and
there is no conversion between String and int.
This exception should be mapped to TypeError.
add(null, 4) -> WrongMethodTypeException
NPE, in both modes.
because null is represened by a special type, here the compiler
find that add is add(type of null, int) and there is no conversion
between type of null and int.
var v = null;
add(v, 3) -> NPE
True, but not for the reasons you describe.
because add is typed add(Object, int),
The type Object doesn't come into play here at all. Dyanmic is not Object.
there is a conversion
from Object to int (Object -> Integer -> int) and during Integer -> int,
intValue is called on null.
Also this error should be mapped to TypeError
The point is, the type annotations don't have any effect except in checked mode. The static type of the incoming value has no effect even in checked mode - it is its dynamic type that matters.
--
Cheers, Gilad
The point is, the type annotations don't have any effect except in checked mode. The static type of the incoming value has no effect even in checked mode - it is its dynamic type that matters.
You would be assuming wrong. The exception is specifically for
generating JavaScript code.
If you want to run Java programs on a JVM, we recommend that you write
your programs in the Java programming languages. It is well-suited for
that particular task.
Cheers,
Peter
On Sat, Oct 22, 2011 at 8:49 AM, Gilad Bracha <gbr...@google.com> wrote:
The point is, the type annotations don't have any effect except in checked mode. The static type of the incoming value has no effect even in checked mode - it is its dynamic type that matters.Just like the Dart->JS compiler makes use of type information to produce efficient code and the code will be fail if the type annotations are wrong, I would assume a Dart->JVM compiler would be free to make the same assumptions (clearly if there are no types you have to generate the slow but correct code).
In JS, we don't want to turn x+y into a method call for efficiency reasons, so if you declare x and y are of type num and they are really something else, then you will get the wrong result as it will just use the JS + operator rathar than x.operator$ADD.
int vs bigint will be an even bigger problem when compiling to the JVM than to JS -- if you really have to implement everything as BigInteger, performance will be tremendously slower. I strongly feel that the answer here is to define bigint as int is currently defined, and leave the definition of int loose enough so that it can use the fastest option the target platform -- it could be implemented on top of bigint in the vm, Number in JS, or a 32-bit int in the JVM. Since the actual need for arbitrary precision is rare, you shouldn't pay the cost for all the simple for loops that will never need it, and you shouldn't have silently incorrect behavior at runtime for the cases that actually do require arbitrary precision.
--
John A. Tamplin
Software Engineer (GWT), Google
Javascript has no bigint, it does int to double overflow at some point depending on the implementation.int vs bigint will be an even bigger problem when compiling to the JVM than to JS -- if you really have to implement everything as BigInteger, performance will be tremendously slower. I strongly feel that the answer here is to define bigint as int is currently defined, and leave the definition of int loose enough so that it can use the fastest option the target platform -- it could be implemented on top of bigint in the vm, Number in JS, or a 32-bit int in the JVM. Since the actual need for arbitrary precision is rare, you shouldn't pay the cost for all the simple for loops that will never need it, and you shouldn't have silently incorrect behavior at runtime for the cases that actually do require arbitrary precision.
I can implement exactly the same thing in the JVM for Dart.
It's just I think it doesn't worth it. The spec should be changed to say that int can be mapped
to a fixed number of bits (>= 32) that will overflow (and not null by default).
Also it's better to have a bigint.dart in core library exactly like you can find bigint.js on the web
because there will be no surprise.
--
John A. Tamplin
Software Engineer (GWT), Google
And it's not because there is a bigint.dart that the VM doesn't replace it+1 for having a type bigint.
by a built-in type at runtime.
On Sat, Oct 22, 2011 at 12:54 PM, Rémi Forax <fo...@univ-mlv.fr> wrote:
And it's not because there is a bigint.dart that the VM doesn't replace it+1 for having a type bigint.
by a built-in type at runtime.That makes it a little harder, plus num can't be extended by user classes so you would still have to treat it specially there anyway -- must better to just define bigint as a type in the language like int.
--
John A. Tamplin
Software Engineer (GWT), Google
Just like the Dart->JS compiler makes use of type information to produce efficient code and the code will be fail if the type annotations are wrong, I would assume a Dart->JVM compiler would be free to make the same assumptions (clearly if there are no types you have to generate the slow but correct code).On Sat, Oct 22, 2011 at 8:49 AM, Gilad Bracha <gbr...@google.com> wrote:The point is, the type annotations don't have any effect except in checked mode. The static type of the incoming value has no effect even in checked mode - it is its dynamic type that matters.
In JS, we don't want to turn x+y into a method call for efficiency reasons, so if you declare x and y are of type num and they are really something else, then you will get the wrong result as it will just use the JS + operator rathar than x.operator$ADD.int vs bigint will be an even bigger problem when compiling to the JVM than to JS -- if you really have to implement everything as BigInteger, performance will be tremendously slower. I strongly feel that the answer here is to define bigint as int is currently defined, and leave the definition of int loose enough so that it can use the fastest option the target platform -- it could be implemented on top of bigint in the vm, Number in JS, or a 32-bit int in the JVM. Since the actual need for arbitrary precision is rare, you shouldn't pay the cost for all the simple for loops that will never need it, and you shouldn't have silently incorrect behavior at runtime for the cases that actually do require arbitrary precision.
--
John A. Tamplin
Software Engineer (GWT), Google
I completely agree. However the Dart->JS compiler is not spec-compliant, and the Dart->JVM compiler wouldn't be either. It would be still nice to have a decent subset of Dart working on the JVM.
int vs bigint will be an even bigger problem when compiling to the JVM than to JS -- if you really have to implement everything as BigInteger, performance will be tremendously slower. I strongly feel that the answer here is to define bigint as int is currently defined, and leave the definition of int loose enough so that it can use the fastest option the target platform -- it could be implemented on top of bigint in the vm, Number in JS, or a 32-bit int in the JVM. Since the actual need for arbitrary precision is rare, you shouldn't pay the cost for all the simple for loops that will never need it, and you shouldn't have silently incorrect behavior at runtime for the cases that actually do require arbitrary precision.
And again this would not be Dart. A close variant, but not Dart.