2

I read a really interesting article about how create cross-plateform app : http://www.skyscanner.net/blogs/developing-mobile-cross-platform-library-part-3-javascript

But I would prefer use Dart instead of Javascript, and I was wondering if it's possible to interact between Dart/Objc and Dart/Java (Android), in the exact same way that is showed in the article (run a Javascript VM to execute the javascript code).

Thanks

Alon Amir
  • 4,913
  • 9
  • 47
  • 86
Jean Lebrument
  • 5,079
  • 8
  • 33
  • 67

2 Answers2

1

You can code it in Dart and use dart2js to output JS code then put that JS code in PhoneGap or Cocoonjs to get it on Android/IOS.

The article seems to show how its done with JavaScript. I am sure its possible to code a Dart mobile cross-platform library but it hasnt been done yet.

GoogleFailedMe
  • 125
  • 1
  • 1
  • 7
  • The problem is that dart2js converts dart to not "plain js" but in a JS that the VM can interpret. So I don't know if it's possible using dart2js. – Jean Lebrument Jan 01 '15 at 22:28
  • 1
    yea its not the best process but its the only one atm. I can confirm Cocoonjs worked with my 2d dart game. You may get different results. – GoogleFailedMe Jan 01 '15 at 22:36
  • I'm hesitating between Typescript and Dart. Because the process to be able to call Javascript from Dart is quite long. – Jean Lebrument Jan 02 '15 at 01:52
  • 1
    Can you post an example for an quite long JS interop call? What do you mean by "not plain" JS. It might be not very readable but dart2js produces normal JS. – Günter Zöchbauer Jan 30 '15 at 13:16
  • For the JS interop call, take a look on the skyscanner article on my OP. http://pastebin.com/25P8ugnS As you can see on the pastbin, the Javascript code created by dart2js is optimized to be executed faster than "regular" JS. But I don't know if I can still have interaction between iOS/dart2js code and Android/dart2js code. – Jean Lebrument Jan 30 '15 at 19:08
1

iOS does not allow 3rd party VMs to be included with your app. The only VM you have access to is the JavaScript VM that is bundled standard with iOS. Even Google Chrome on iOS is crippled in this way (they cannot include v8 on iOS).

Lex Berezhny
  • 512
  • 3
  • 15
  • Dart can be compiled to JS. If it is possible with JS it usually is possible in Dart too. – Günter Zöchbauer Jan 30 '15 at 13:12
  • The OP says he wants to run Dart in Dart VM "the same way that JavaScript runs in JavaScript VM". – Lex Berezhny Jan 30 '15 at 13:15
  • I created a more complete post here: http://stackoverflow.com/questions/28223230/questions-about-web-languages-interoperability-in-a-cross-plateform-project/28225220?noredirect=1#comment44833999_28225220 I think we can close this one and continue on the new one. – Jean Lebrument Jan 30 '15 at 19:01