'. '

Bck2Brwsr 0.10

From APIDesign

(Difference between revisions)
Jump to: navigation, search
Current revision (17:29, 15 September 2014) (edit) (undo)
 
(5 intermediate revisions not shown.)
Line 1: Line 1:
-
Using Object.defineProperty to make sure the [[JavaScript]] Object has all the methods of {{JDK|java/lang|Object}}, while those methods do not show up during iteration
+
The ahead-of-time mode has support for [[JDK]]8's [[Closure|Lambdas]] (thanks to [[RetroLambda]] project). Following example properly returns "XXXXXXXXXX" in [[Bck2Brwsr 0.10]] when '''compound''' methods is called:
-
 
+
-
<source lang="javascript">
+
-
for (var p in anObject) {
+
-
console.log('A prop found ' + p);
+
-
}
+
-
</source>
+
-
 
+
-
The ahead-of-time mode has support for [[JDK]]8's [[Closure|Lambdas]] (thanks to [[RetroLambda]] project). Following example properly return "XXXXXXXXXX" in [[Bck2Brwsr 0.10]] when '''compound''' methods is called:
+
<source lang="java">
<source lang="java">
Line 23: Line 15:
</source>
</source>
-
My experience from implementing lambdas in [[Bck2Brwsr]] [[VM]] was so horrible that I had to express my hate of [[invokeDynamic]] in a [[InvokeDynamic|dedicated essay]]. Such instruction should have never be addeded in [[JVM]] specification!
+
My experience from implementing lambdas in [[Bck2Brwsr]] [[VM]] was so horrible that [[I]] had to express my hate of [[invokeDynamic]] in a [[InvokeDynamic|dedicated essay]]. Such instruction should have never be added into the [[JVM]] specification! See the ''Lambdas Go [[Bck2Brwsr]]'' video:
 +
 
 +
{{#ev:youtube|ATp7WgUCIbU}}
Support for [[JDK]]8 defender and interface static methods. In the following example the method '''defaultValue''' properly returns ''42'' in [[Bck2Brwsr 0.10]]:
Support for [[JDK]]8 defender and interface static methods. In the following example the method '''defaultValue''' properly returns ''42'' in [[Bck2Brwsr 0.10]]:
Line 42: Line 36:
}
}
</source>
</source>
 +
 +
The support for [[Closures|lamdas]] does not mean [[Bck2Brwsr 0.10]] supports [[JDK]]8 APIs. It does not. The libraries are still subset of [[JDK]]7 - one can use [[Closures|lamdas]] only in own code so far. Technically it should not be a problem to backport [[JDK]]8, libraries - it just has not been done yet.
 +
 +
Using Object.defineProperty to make sure the [[JavaScript]] Object has all the methods of {{JDK|java/lang|Object}}, while those methods do not show up during iteration
 +
 +
<source lang="javascript">
 +
for (var p in anObject) {
 +
console.log('A prop found ' + p);
 +
}
 +
</source>
 +
 +
 +
[[Category:Video]]

Current revision

The ahead-of-time mode has support for JDK8's Lambdas (thanks to RetroLambda project). Following example properly returns "XXXXXXXXXX" in Bck2Brwsr 0.10 when compound methods is called:

private static void fewTimes(Runnable r, int cnt) {
    while (cnt-- > 0) {
        r.run();
    }
}
 
public static String compound() {
    StringBuilder sb = new StringBuilder();
    fewTimes(() -> sb.append('X'), 10);
    return sb.toString();
}

My experience from implementing lambdas in Bck2Brwsr VM was so horrible that I had to express my hate of invokeDynamic in a dedicated essay. Such instruction should have never be added into the JVM specification! See the Lambdas Go Bck2Brwsr video:

Support for JDK8 defender and interface static methods. In the following example the method defaultValue properly returns 42 in Bck2Brwsr 0.10:

public interface Value {
    public static int staticValue(Value v) {
        return v.value();
    }
 
    public default int value() {
        return 42;
    }
 
    public static int defaultValue() {
        return staticValue(new Value() {});
    }
}

The support for lamdas does not mean Bck2Brwsr 0.10 supports JDK8 APIs. It does not. The libraries are still subset of JDK7 - one can use lamdas only in own code so far. Technically it should not be a problem to backport JDK8, libraries - it just has not been done yet.

Using Object.defineProperty to make sure the JavaScript Object has all the methods of Object, while those methods do not show up during iteration

for (var p in anObject) {
  console.log('A prop found ' + p);
}
Personal tools
buy