Matt Campbell
unread,Mar 18, 2017, 9:39:14 AM3/18/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to j2objc-...@googlegroups.com
Hi Robert,
As a user of J2ObjC for about a year now, I believe your conclusion is
correct. And there are some other things that will make translated APIs
feel foreign to an Objective-C or Swift developer, even when the Java
code is thoroughly marked up with @ObjectiveCName annotations (as mine
is). First, the JRE emulation library is not marked up with those
annotations, so if you have to deal with Java collections or other JRE
APIs from platform-specific code, those APIs will feel very foreign. Of
course, the Java collections themselves (and related things like
iterators) feel foreign in Objective-C or Swift, where one normally
works with NSArray, NSDictionary, and the equivalent Swift types. And to
avoid compiler warnings, you'll need to use JNI types like jboolean and
jint in some places, rather than the usual BOOL and NSInteger. Not sure
how that impacts Swift.
I think the ideal solution for cross-platform code would be Kotlin, with
a Kotlin to ObjC translator similar to J2ObjC. In that case, I wouldn't
want a JRE emulation library, but instead, the subset of the Kotlin
standard library that's common to Kotlin's existing JVM and JS backends.
I certainly don't have time to work on such a thing, though.
So J2ObjC is the best that we have for writing cross-platform code that
can target the Apple platforms with minimal glue and minimal runtime
overhead, using the Apple compiler toolchain so we're not likely to be
impacted by any new requirements that Apple might add in the future (as
they have in the past with 64-bit and bitcode).
Matt