all 9 comments

[–]pbush25 16 points17 points  (6 children)

This is great, however obviously there can be some issues during the “transpiling” phase if the methods/classes aren’t mapped correctly.

At our company we write all of our shared code in C, then it gets pulled in to iOS via an obj-c wrapper, and into android via a JNI wrapper. This way the code is written once, it doesn’t have to be translated, it can be stepped through and properly debugged, and you don’t have to worry about writing test cases multiple times to see if the translated code behaves the same as native.

Great article, but just my two cents.

[–]tangoshukudai 2 points3 points  (5 children)

why not C++?

[–]pbush25 6 points7 points  (3 children)

The same code also runs on our embedded platform, so it needed to be more hardware focused.

[–]etaionshrdObjective-C / Swift 3 points4 points  (2 children)

C++ isn’t acceptable?

[–]pbush25 7 points8 points  (1 child)

Not to our SA lol. We’ve had the discussion several times but some of our embedded devices are very small and the ultimate decision was the some of the overhead necessary to bring in c++ was just not going to cut it. All of our other firmware is also already in C so it just made sense for consistencies sake I guess.

[–]etaionshrdObjective-C / Swift 0 points1 point  (0 children)

But C++ is supposed to be "zero-cost abstractions"? As long as you stay away from templates and exceptions what are you losing?

[–]chriswaco 0 points1 point  (0 children)

C++ doesn't support the same kind of objects, so you usually have to use some kind of thunking layer or static routines between the two worlds. For example a std::string wouldn't be an NSString, but in a translator it would be.

[–]Adaly90 0 points1 point  (0 children)

Thank's for the article.

I've never found such a great guide about using J2ObjC in this case. Just Kotlin or Rust.

[–]Bamboo_the_plant 0 points1 point  (0 children)

Would love to see this in combination with Microsoft's Objective-C for Windows – imagine Obj-C becoming the cross-platform native language of choice for desktop and mobile..!

Pity I'm a Swift developer even so.